| Index: chromeos/network/network_device_handler_unittest.cc
|
| diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc
|
| index 60a264bc6e9a34dbfd84ae38e3abf38bd60d21f4..1c3fd46249b59f1a674f3a5f19f2f5ffdae86d5b 100644
|
| --- a/chromeos/network/network_device_handler_unittest.cc
|
| +++ b/chromeos/network/network_device_handler_unittest.cc
|
| @@ -39,22 +39,14 @@ class NetworkDeviceHandlerTest : public testing::Test {
|
| scoped_ptr<ShillDeviceClient>(fake_device_client_));
|
| DBusThreadManager::InitializeForTesting(dbus_manager);
|
|
|
| - ShillDeviceClient::TestInterface* device_test =
|
| - fake_device_client_->GetTestInterface();
|
| - device_test->AddDevice(
|
| - kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1");
|
| - device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1");
|
| -
|
| - base::ListValue test_ip_configs;
|
| - test_ip_configs.AppendString("ip_config1");
|
| - device_test->SetDeviceProperty(
|
| - kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs);
|
| -
|
| success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback,
|
| base::Unretained(this));
|
| properties_success_callback_ =
|
| base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback,
|
| base::Unretained(this));
|
| + string_success_callback_ =
|
| + base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback,
|
| + base::Unretained(this));
|
| error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback,
|
| base::Unretained(this));
|
|
|
| @@ -62,6 +54,20 @@ class NetworkDeviceHandlerTest : public testing::Test {
|
| NetworkDeviceHandlerImpl* device_handler = new NetworkDeviceHandlerImpl;
|
| device_handler->Init(network_state_handler_.get());
|
| network_device_handler_.reset(device_handler);
|
| +
|
| + // Add devices after handlers have been initialized.
|
| + ShillDeviceClient::TestInterface* device_test =
|
| + fake_device_client_->GetTestInterface();
|
| + device_test->AddDevice(
|
| + kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1");
|
| + device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1");
|
| +
|
| + base::ListValue test_ip_configs;
|
| + test_ip_configs.AppendString("ip_config1");
|
| + device_test->SetDeviceProperty(
|
| + kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs);
|
| +
|
| + message_loop_.RunUntilIdle();
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -85,6 +91,10 @@ class NetworkDeviceHandlerTest : public testing::Test {
|
| properties_.reset(properties.DeepCopy());
|
| }
|
|
|
| + void StringSuccessCallback(const std::string& result) {
|
| + result_ = kResultSuccess;
|
| + }
|
| +
|
| protected:
|
| std::string result_;
|
|
|
| @@ -94,6 +104,7 @@ class NetworkDeviceHandlerTest : public testing::Test {
|
| base::MessageLoopForUI message_loop_;
|
| base::Closure success_callback_;
|
| network_handler::DictionaryResultCallback properties_success_callback_;
|
| + network_handler::StringResultCallback string_success_callback_;
|
| network_handler::ErrorCallback error_callback_;
|
| scoped_ptr<base::DictionaryValue> properties_;
|
|
|
| @@ -209,6 +220,22 @@ TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) {
|
| EXPECT_FALSE(allow_roaming);
|
| }
|
|
|
| +TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabled) {
|
| + // We add a wifi device by default, initial call should succed.
|
| + network_device_handler_->SetWifiTDLSEnabled(
|
| + "fake_ip_address", true, string_success_callback_, error_callback_);
|
| + message_loop_.RunUntilIdle();
|
| + EXPECT_EQ(kResultSuccess, result_);
|
| +
|
| + // Remove the wifi device. Call should fail with "device missing" error.
|
| + fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath);
|
| + message_loop_.RunUntilIdle();
|
| + network_device_handler_->SetWifiTDLSEnabled(
|
| + "fake_ip_address", true, string_success_callback_, error_callback_);
|
| + message_loop_.RunUntilIdle();
|
| + EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
|
| +}
|
| +
|
| TEST_F(NetworkDeviceHandlerTest, RequestRefreshIPConfigs) {
|
| network_device_handler_->RequestRefreshIPConfigs(
|
| kDefaultWifiDevicePath, success_callback_, error_callback_);
|
|
|