summaryrefslogtreecommitdiffstats
path: root/chromeos/network/network_device_handler_unittest.cc
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-04 20:39:00 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-04 20:39:00 +0000
commit88471ffea5fcdfab97e07975c670ebe9ff4fec4a (patch)
tree417037c9615a97e109d0fb74ee7503576e2931f2 /chromeos/network/network_device_handler_unittest.cc
parent787a090dea46d71ec7cc48d145215e975564db59 (diff)
downloadchromium_src-88471ffea5fcdfab97e07975c670ebe9ff4fec4a.zip
chromium_src-88471ffea5fcdfab97e07975c670ebe9ff4fec4a.tar.gz
chromium_src-88471ffea5fcdfab97e07975c670ebe9ff4fec4a.tar.bz2
Enable NetworkStateHandler always
This CL should have no affect on Chrome's behavior. It does the following: * Removes --enable-new-network-handlers and always enables them * Adds --ash-enable-new-network-status-area and uses that to control whether or not to use the new status area code * Adds --enable-new-network-change-notifier and uses that to control whether or not to use the new NetworkStateHandler based network change notifier * Deletes the unused NetworkDeviceHandler (this was added thinking that it was needed for Geolocation, but it turned out that the code had changed between Flimflam and Shill so it wasn't necessary) BUG=161869 For chrome/browser/ui/webui/chromeos, ash/ash_switches: TBR=xiyuan@chromium.org,sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/12095106 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/network/network_device_handler_unittest.cc')
-rw-r--r--chromeos/network/network_device_handler_unittest.cc136
1 files changed, 0 insertions, 136 deletions
diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc
deleted file mode 100644
index 589b97a..0000000
--- a/chromeos/network/network_device_handler_unittest.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromeos/network/network_device_handler.h"
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "base/values.h"
-#include "chromeos/dbus/dbus_thread_manager.h"
-#include "chromeos/dbus/shill_device_client.h"
-#include "chromeos/dbus/shill_manager_client.h"
-#include "dbus/object_path.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
-
-namespace chromeos {
-
-namespace {
-
-class TestObserver : public NetworkDeviceHandler::Observer {
- public:
- TestObserver() : device_updates_(0) {}
-
- virtual void NetworkDevicesUpdated(const DeviceMap& devices) {
- ++device_updates_;
- devices_ = devices;
- }
-
- int device_updates() { return device_updates_; }
- const DeviceMap& devices() { return devices_; }
-
- private:
- int device_updates_;
- DeviceMap devices_;
-};
-
-} // namespace
-
-class NetworkDeviceHandlerTest : public testing::Test {
- public:
- NetworkDeviceHandlerTest()
- : manager_test_(NULL),
- device_test_(NULL) {
- }
- virtual ~NetworkDeviceHandlerTest() {
- }
-
- virtual void SetUp() OVERRIDE {
- // Initialize DBusThreadManager with a stub implementation.
- DBusThreadManager::InitializeWithStub();
- // Get the test interface for manager / device.
- manager_test_ =
- DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface();
- ASSERT_TRUE(manager_test_);
- device_test_ =
- DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface();
- ASSERT_TRUE(device_test_);
- }
-
- virtual void TearDown() OVERRIDE {
- device_handler_->RemoveObserver(observer_.get());
- observer_.reset();
- device_handler_.reset();
- DBusThreadManager::Shutdown();
- }
-
- void AddDevice(const std::string& type, const std::string& id) {
- manager_test_->AddDevice(id);
- device_test_->AddDevice(id, type, std::string("/device/" + id));
- }
-
- void RemoveDevice(const std::string& id) {
- manager_test_->RemoveDevice(id);
- device_test_->RemoveDevice(id);
- }
-
- // Call this after any initial Shill client setup
- void SetupNetworkDeviceHandler() {
- device_handler_.reset(new NetworkDeviceHandler());
- device_handler_->Init();
- observer_.reset(new TestObserver());
- device_handler_->AddObserver(observer_.get());
- }
-
- protected:
- MessageLoopForUI message_loop_;
- scoped_ptr<TestObserver> observer_;
- scoped_ptr<NetworkDeviceHandler> device_handler_;
- ShillManagerClient::TestInterface* manager_test_;
- ShillDeviceClient::TestInterface* device_test_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerTest);
-};
-
-TEST_F(NetworkDeviceHandlerTest, NetworkDeviceHandlerStub) {
- SetupNetworkDeviceHandler();
- EXPECT_FALSE(device_handler_->devices_ready());
-
- message_loop_.RunUntilIdle();
- EXPECT_EQ(1, observer_->device_updates());
- EXPECT_TRUE(device_handler_->devices_ready());
- // ShillManagerClient default stub entries are in shill_manager_client.cc.
- // TODO(stevenjb): Eliminate default stub entries and add them explicitly.
- const size_t kNumShillManagerClientStubImplDevices = 2;
- EXPECT_EQ(kNumShillManagerClientStubImplDevices,
- device_handler_->devices().size());
-}
-
-TEST_F(NetworkDeviceHandlerTest, NetworkDeviceHandlerPropertyChanged) {
- // This relies on the stub dbus implementations for ShillManagerClient,
- SetupNetworkDeviceHandler();
-
- message_loop_.RunUntilIdle();
- EXPECT_EQ(1, observer_->device_updates());
- const size_t kNumShillManagerClientStubImplDevices = 2;
- EXPECT_EQ(kNumShillManagerClientStubImplDevices, observer_->devices().size());
-
- // Add a device.
- const std::string kTestDevicePath("test_wifi_device1");
- AddDevice(flimflam::kTypeWifi, kTestDevicePath);
- message_loop_.RunUntilIdle();
- EXPECT_EQ(2, observer_->device_updates());
- EXPECT_EQ(kNumShillManagerClientStubImplDevices + 1,
- observer_->devices().size());
-
- // Remove a device
- RemoveDevice(kTestDevicePath);
- message_loop_.RunUntilIdle();
- EXPECT_EQ(3, observer_->device_updates());
- EXPECT_EQ(kNumShillManagerClientStubImplDevices, observer_->devices().size());
-}
-
-} // namespace chromeos