Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
| 12 #include "chromeos/dbus/fake_shill_device_client.h" | 13 #include "chromeos/dbus/fake_shill_device_client.h" |
| 13 #include "chromeos/dbus/fake_shill_manager_client.h" | 14 #include "chromeos/dbus/fake_shill_manager_client.h" |
| 14 #include "chromeos/network/network_device_handler_impl.h" | 15 #include "chromeos/network/network_device_handler_impl.h" |
| 15 #include "chromeos/network/network_state_handler.h" | 16 #include "chromeos/network/network_state_handler.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 | 19 |
| 19 namespace chromeos { | 20 namespace chromeos { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 fake_device_client_->GetTestInterface(); | 60 fake_device_client_->GetTestInterface(); |
| 60 device_test->AddDevice( | 61 device_test->AddDevice( |
| 61 kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1"); | 62 kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1"); |
| 62 device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1"); | 63 device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1"); |
| 63 | 64 |
| 64 base::ListValue test_ip_configs; | 65 base::ListValue test_ip_configs; |
| 65 test_ip_configs.AppendString("ip_config1"); | 66 test_ip_configs.AppendString("ip_config1"); |
| 66 device_test->SetDeviceProperty( | 67 device_test->SetDeviceProperty( |
| 67 kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs); | 68 kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs); |
| 68 | 69 |
| 69 message_loop_.RunUntilIdle(); | 70 base::RunLoop().RunUntilIdle(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void TearDown() override { | 73 void TearDown() override { |
| 73 network_device_handler_.reset(); | 74 network_device_handler_.reset(); |
| 74 network_state_handler_.reset(); | 75 network_state_handler_.reset(); |
| 75 DBusThreadManager::Shutdown(); | 76 DBusThreadManager::Shutdown(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void ErrorCallback(const std::string& error_name, | 79 void ErrorCallback(const std::string& error_name, |
| 79 std::unique_ptr<base::DictionaryValue> error_data) { | 80 std::unique_ptr<base::DictionaryValue> error_data) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 95 VLOG(1) << "StringSuccessCallback: " << result; | 96 VLOG(1) << "StringSuccessCallback: " << result; |
| 96 result_ = result; | 97 result_ = result; |
| 97 } | 98 } |
| 98 | 99 |
| 99 protected: | 100 protected: |
| 100 std::string result_; | 101 std::string result_; |
| 101 | 102 |
| 102 FakeShillDeviceClient* fake_device_client_; | 103 FakeShillDeviceClient* fake_device_client_; |
| 103 std::unique_ptr<NetworkDeviceHandler> network_device_handler_; | 104 std::unique_ptr<NetworkDeviceHandler> network_device_handler_; |
| 104 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 105 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
| 105 base::MessageLoopForUI message_loop_; | 106 base::MessageLoopForUI message_loop_; |
|
armansito
2016/09/06 22:04:32
ditto
| |
| 106 base::Closure success_callback_; | 107 base::Closure success_callback_; |
| 107 network_handler::DictionaryResultCallback properties_success_callback_; | 108 network_handler::DictionaryResultCallback properties_success_callback_; |
| 108 network_handler::StringResultCallback string_success_callback_; | 109 network_handler::StringResultCallback string_success_callback_; |
| 109 network_handler::ErrorCallback error_callback_; | 110 network_handler::ErrorCallback error_callback_; |
| 110 std::unique_ptr<base::DictionaryValue> properties_; | 111 std::unique_ptr<base::DictionaryValue> properties_; |
| 111 | 112 |
| 112 private: | 113 private: |
| 113 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerTest); | 114 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerTest); |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 TEST_F(NetworkDeviceHandlerTest, GetDeviceProperties) { | 117 TEST_F(NetworkDeviceHandlerTest, GetDeviceProperties) { |
| 117 network_device_handler_->GetDeviceProperties( | 118 network_device_handler_->GetDeviceProperties( |
| 118 kDefaultWifiDevicePath, properties_success_callback_, error_callback_); | 119 kDefaultWifiDevicePath, properties_success_callback_, error_callback_); |
| 119 message_loop_.RunUntilIdle(); | 120 base::RunLoop().RunUntilIdle(); |
| 120 EXPECT_EQ(kResultSuccess, result_); | 121 EXPECT_EQ(kResultSuccess, result_); |
| 121 std::string type; | 122 std::string type; |
| 122 properties_->GetString(shill::kTypeProperty, &type); | 123 properties_->GetString(shill::kTypeProperty, &type); |
| 123 EXPECT_EQ(shill::kTypeWifi, type); | 124 EXPECT_EQ(shill::kTypeWifi, type); |
| 124 } | 125 } |
| 125 | 126 |
| 126 TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) { | 127 TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) { |
| 127 // Set the shill::kScanIntervalProperty to true. The call | 128 // Set the shill::kScanIntervalProperty to true. The call |
| 128 // should succeed and the value should be set. | 129 // should succeed and the value should be set. |
| 129 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, | 130 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, |
| 130 shill::kScanIntervalProperty, | 131 shill::kScanIntervalProperty, |
| 131 base::FundamentalValue(1), | 132 base::FundamentalValue(1), |
| 132 success_callback_, | 133 success_callback_, |
| 133 error_callback_); | 134 error_callback_); |
| 134 message_loop_.RunUntilIdle(); | 135 base::RunLoop().RunUntilIdle(); |
| 135 EXPECT_EQ(kResultSuccess, result_); | 136 EXPECT_EQ(kResultSuccess, result_); |
| 136 | 137 |
| 137 // GetDeviceProperties should return the value set by SetDeviceProperty. | 138 // GetDeviceProperties should return the value set by SetDeviceProperty. |
| 138 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, | 139 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, |
| 139 properties_success_callback_, | 140 properties_success_callback_, |
| 140 error_callback_); | 141 error_callback_); |
| 141 message_loop_.RunUntilIdle(); | 142 base::RunLoop().RunUntilIdle(); |
| 142 EXPECT_EQ(kResultSuccess, result_); | 143 EXPECT_EQ(kResultSuccess, result_); |
| 143 int interval = 0; | 144 int interval = 0; |
| 144 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( | 145 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( |
| 145 shill::kScanIntervalProperty, &interval)); | 146 shill::kScanIntervalProperty, &interval)); |
| 146 EXPECT_EQ(1, interval); | 147 EXPECT_EQ(1, interval); |
| 147 | 148 |
| 148 // Repeat the same with value false. | 149 // Repeat the same with value false. |
| 149 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, | 150 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, |
| 150 shill::kScanIntervalProperty, | 151 shill::kScanIntervalProperty, |
| 151 base::FundamentalValue(2), | 152 base::FundamentalValue(2), |
| 152 success_callback_, | 153 success_callback_, |
| 153 error_callback_); | 154 error_callback_); |
| 154 message_loop_.RunUntilIdle(); | 155 base::RunLoop().RunUntilIdle(); |
| 155 EXPECT_EQ(kResultSuccess, result_); | 156 EXPECT_EQ(kResultSuccess, result_); |
| 156 | 157 |
| 157 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, | 158 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, |
| 158 properties_success_callback_, | 159 properties_success_callback_, |
| 159 error_callback_); | 160 error_callback_); |
| 160 message_loop_.RunUntilIdle(); | 161 base::RunLoop().RunUntilIdle(); |
| 161 EXPECT_EQ(kResultSuccess, result_); | 162 EXPECT_EQ(kResultSuccess, result_); |
| 162 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( | 163 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( |
| 163 shill::kScanIntervalProperty, &interval)); | 164 shill::kScanIntervalProperty, &interval)); |
| 164 EXPECT_EQ(2, interval); | 165 EXPECT_EQ(2, interval); |
| 165 | 166 |
| 166 // Set property on an invalid path. | 167 // Set property on an invalid path. |
| 167 network_device_handler_->SetDeviceProperty(kUnknownCellularDevicePath, | 168 network_device_handler_->SetDeviceProperty(kUnknownCellularDevicePath, |
| 168 shill::kScanIntervalProperty, | 169 shill::kScanIntervalProperty, |
| 169 base::FundamentalValue(1), | 170 base::FundamentalValue(1), |
| 170 success_callback_, | 171 success_callback_, |
| 171 error_callback_); | 172 error_callback_); |
| 172 message_loop_.RunUntilIdle(); | 173 base::RunLoop().RunUntilIdle(); |
| 173 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 174 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 174 | 175 |
| 175 // Setting a owner-protected device property through SetDeviceProperty must | 176 // Setting a owner-protected device property through SetDeviceProperty must |
| 176 // fail. | 177 // fail. |
| 177 network_device_handler_->SetDeviceProperty( | 178 network_device_handler_->SetDeviceProperty( |
| 178 kDefaultCellularDevicePath, | 179 kDefaultCellularDevicePath, |
| 179 shill::kCellularAllowRoamingProperty, | 180 shill::kCellularAllowRoamingProperty, |
| 180 base::FundamentalValue(true), | 181 base::FundamentalValue(true), |
| 181 success_callback_, | 182 success_callback_, |
| 182 error_callback_); | 183 error_callback_); |
| 183 message_loop_.RunUntilIdle(); | 184 base::RunLoop().RunUntilIdle(); |
| 184 EXPECT_NE(kResultSuccess, result_); | 185 EXPECT_NE(kResultSuccess, result_); |
| 185 | 186 |
| 186 } | 187 } |
| 187 | 188 |
| 188 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) { | 189 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) { |
| 189 // Start with disabled data roaming. | 190 // Start with disabled data roaming. |
| 190 ShillDeviceClient::TestInterface* device_test = | 191 ShillDeviceClient::TestInterface* device_test = |
| 191 fake_device_client_->GetTestInterface(); | 192 fake_device_client_->GetTestInterface(); |
| 192 device_test->SetDeviceProperty(kDefaultCellularDevicePath, | 193 device_test->SetDeviceProperty(kDefaultCellularDevicePath, |
| 193 shill::kCellularAllowRoamingProperty, | 194 shill::kCellularAllowRoamingProperty, |
| 194 base::FundamentalValue(false)); | 195 base::FundamentalValue(false)); |
| 195 | 196 |
| 196 network_device_handler_->SetCellularAllowRoaming(true); | 197 network_device_handler_->SetCellularAllowRoaming(true); |
| 197 message_loop_.RunUntilIdle(); | 198 base::RunLoop().RunUntilIdle(); |
| 198 | 199 |
| 199 // Roaming should be enabled now. | 200 // Roaming should be enabled now. |
| 200 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, | 201 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, |
| 201 properties_success_callback_, | 202 properties_success_callback_, |
| 202 error_callback_); | 203 error_callback_); |
| 203 message_loop_.RunUntilIdle(); | 204 base::RunLoop().RunUntilIdle(); |
| 204 EXPECT_EQ(kResultSuccess, result_); | 205 EXPECT_EQ(kResultSuccess, result_); |
| 205 bool allow_roaming; | 206 bool allow_roaming; |
| 206 EXPECT_TRUE(properties_->GetBooleanWithoutPathExpansion( | 207 EXPECT_TRUE(properties_->GetBooleanWithoutPathExpansion( |
| 207 shill::kCellularAllowRoamingProperty, &allow_roaming)); | 208 shill::kCellularAllowRoamingProperty, &allow_roaming)); |
| 208 EXPECT_TRUE(allow_roaming); | 209 EXPECT_TRUE(allow_roaming); |
| 209 | 210 |
| 210 network_device_handler_->SetCellularAllowRoaming(false); | 211 network_device_handler_->SetCellularAllowRoaming(false); |
| 211 message_loop_.RunUntilIdle(); | 212 base::RunLoop().RunUntilIdle(); |
| 212 | 213 |
| 213 // Roaming should be disable again. | 214 // Roaming should be disable again. |
| 214 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, | 215 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, |
| 215 properties_success_callback_, | 216 properties_success_callback_, |
| 216 error_callback_); | 217 error_callback_); |
| 217 message_loop_.RunUntilIdle(); | 218 base::RunLoop().RunUntilIdle(); |
| 218 EXPECT_EQ(kResultSuccess, result_); | 219 EXPECT_EQ(kResultSuccess, result_); |
| 219 EXPECT_TRUE(properties_->GetBooleanWithoutPathExpansion( | 220 EXPECT_TRUE(properties_->GetBooleanWithoutPathExpansion( |
| 220 shill::kCellularAllowRoamingProperty, &allow_roaming)); | 221 shill::kCellularAllowRoamingProperty, &allow_roaming)); |
| 221 EXPECT_FALSE(allow_roaming); | 222 EXPECT_FALSE(allow_roaming); |
| 222 } | 223 } |
| 223 | 224 |
| 224 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabled) { | 225 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabled) { |
| 225 // We add a wifi device by default, initial call should succeed. | 226 // We add a wifi device by default, initial call should succeed. |
| 226 fake_device_client_->GetTestInterface()->SetTDLSState( | 227 fake_device_client_->GetTestInterface()->SetTDLSState( |
| 227 shill::kTDLSConnectedState); | 228 shill::kTDLSConnectedState); |
| 228 network_device_handler_->SetWifiTDLSEnabled( | 229 network_device_handler_->SetWifiTDLSEnabled( |
| 229 "fake_ip_address", true, string_success_callback_, error_callback_); | 230 "fake_ip_address", true, string_success_callback_, error_callback_); |
| 230 message_loop_.RunUntilIdle(); | 231 base::RunLoop().RunUntilIdle(); |
| 231 EXPECT_EQ(shill::kTDLSConnectedState, result_); | 232 EXPECT_EQ(shill::kTDLSConnectedState, result_); |
| 232 } | 233 } |
| 233 | 234 |
| 234 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledNonexistent) { | 235 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledNonexistent) { |
| 235 // Set the TDLS state to 'Nonexistant'. Call should fail with 'Nonexistant' | 236 // Set the TDLS state to 'Nonexistant'. Call should fail with 'Nonexistant' |
| 236 // result. | 237 // result. |
| 237 fake_device_client_->GetTestInterface()->SetTDLSState( | 238 fake_device_client_->GetTestInterface()->SetTDLSState( |
| 238 shill::kTDLSNonexistentState); | 239 shill::kTDLSNonexistentState); |
| 239 network_device_handler_->SetWifiTDLSEnabled( | 240 network_device_handler_->SetWifiTDLSEnabled( |
| 240 "fake_ip_address", true, string_success_callback_, error_callback_); | 241 "fake_ip_address", true, string_success_callback_, error_callback_); |
| 241 message_loop_.RunUntilIdle(); | 242 base::RunLoop().RunUntilIdle(); |
| 242 EXPECT_EQ(shill::kTDLSNonexistentState, result_); | 243 EXPECT_EQ(shill::kTDLSNonexistentState, result_); |
| 243 } | 244 } |
| 244 | 245 |
| 245 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledMissing) { | 246 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledMissing) { |
| 246 // Remove the wifi device. Call should fail with "device missing" error. | 247 // Remove the wifi device. Call should fail with "device missing" error. |
| 247 fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath); | 248 fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath); |
| 248 message_loop_.RunUntilIdle(); | 249 base::RunLoop().RunUntilIdle(); |
| 249 network_device_handler_->SetWifiTDLSEnabled( | 250 network_device_handler_->SetWifiTDLSEnabled( |
| 250 "fake_ip_address", true, string_success_callback_, error_callback_); | 251 "fake_ip_address", true, string_success_callback_, error_callback_); |
| 251 message_loop_.RunUntilIdle(); | 252 base::RunLoop().RunUntilIdle(); |
| 252 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 253 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 253 } | 254 } |
| 254 | 255 |
| 255 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledBusy) { | 256 TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledBusy) { |
| 256 // Set the busy count, call should succeed after repeat attempt. | 257 // Set the busy count, call should succeed after repeat attempt. |
| 257 fake_device_client_->GetTestInterface()->SetTDLSState( | 258 fake_device_client_->GetTestInterface()->SetTDLSState( |
| 258 shill::kTDLSConnectedState); | 259 shill::kTDLSConnectedState); |
| 259 fake_device_client_->GetTestInterface()->SetTDLSBusyCount(1); | 260 fake_device_client_->GetTestInterface()->SetTDLSBusyCount(1); |
| 260 network_device_handler_->SetWifiTDLSEnabled( | 261 network_device_handler_->SetWifiTDLSEnabled( |
| 261 "fake_ip_address", true, string_success_callback_, error_callback_); | 262 "fake_ip_address", true, string_success_callback_, error_callback_); |
| 262 message_loop_.RunUntilIdle(); | 263 base::RunLoop().RunUntilIdle(); |
| 263 EXPECT_EQ(shill::kTDLSConnectedState, result_); | 264 EXPECT_EQ(shill::kTDLSConnectedState, result_); |
| 264 | 265 |
| 265 // Set the busy count to a large number, call should fail after max number | 266 // Set the busy count to a large number, call should fail after max number |
| 266 // of repeat attempt. | 267 // of repeat attempt. |
| 267 fake_device_client_->GetTestInterface()->SetTDLSBusyCount(100000); | 268 fake_device_client_->GetTestInterface()->SetTDLSBusyCount(100000); |
| 268 network_device_handler_->SetWifiTDLSEnabled( | 269 network_device_handler_->SetWifiTDLSEnabled( |
| 269 "fake_ip_address", true, string_success_callback_, error_callback_); | 270 "fake_ip_address", true, string_success_callback_, error_callback_); |
| 270 message_loop_.RunUntilIdle(); | 271 base::RunLoop().RunUntilIdle(); |
| 271 EXPECT_EQ(NetworkDeviceHandler::kErrorTimeout, result_); | 272 EXPECT_EQ(NetworkDeviceHandler::kErrorTimeout, result_); |
| 272 } | 273 } |
| 273 | 274 |
| 274 TEST_F(NetworkDeviceHandlerTest, GetWifiTDLSStatus) { | 275 TEST_F(NetworkDeviceHandlerTest, GetWifiTDLSStatus) { |
| 275 // We add a wifi device by default, initial call should succeed. | 276 // We add a wifi device by default, initial call should succeed. |
| 276 fake_device_client_->GetTestInterface()->SetTDLSState( | 277 fake_device_client_->GetTestInterface()->SetTDLSState( |
| 277 shill::kTDLSConnectedState); | 278 shill::kTDLSConnectedState); |
| 278 network_device_handler_->GetWifiTDLSStatus( | 279 network_device_handler_->GetWifiTDLSStatus( |
| 279 "fake_ip_address", string_success_callback_, error_callback_); | 280 "fake_ip_address", string_success_callback_, error_callback_); |
| 280 message_loop_.RunUntilIdle(); | 281 base::RunLoop().RunUntilIdle(); |
| 281 EXPECT_EQ(shill::kTDLSConnectedState, result_); | 282 EXPECT_EQ(shill::kTDLSConnectedState, result_); |
| 282 | 283 |
| 283 // Remove the wifi device. Call should fail with "device missing" error. | 284 // Remove the wifi device. Call should fail with "device missing" error. |
| 284 fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath); | 285 fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath); |
| 285 message_loop_.RunUntilIdle(); | 286 base::RunLoop().RunUntilIdle(); |
| 286 network_device_handler_->GetWifiTDLSStatus( | 287 network_device_handler_->GetWifiTDLSStatus( |
| 287 "fake_ip_address", string_success_callback_, error_callback_); | 288 "fake_ip_address", string_success_callback_, error_callback_); |
| 288 message_loop_.RunUntilIdle(); | 289 base::RunLoop().RunUntilIdle(); |
| 289 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 290 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 290 } | 291 } |
| 291 | 292 |
| 292 TEST_F(NetworkDeviceHandlerTest, RequestRefreshIPConfigs) { | 293 TEST_F(NetworkDeviceHandlerTest, RequestRefreshIPConfigs) { |
| 293 network_device_handler_->RequestRefreshIPConfigs( | 294 network_device_handler_->RequestRefreshIPConfigs( |
| 294 kDefaultWifiDevicePath, success_callback_, error_callback_); | 295 kDefaultWifiDevicePath, success_callback_, error_callback_); |
| 295 message_loop_.RunUntilIdle(); | 296 base::RunLoop().RunUntilIdle(); |
| 296 EXPECT_EQ(kResultSuccess, result_); | 297 EXPECT_EQ(kResultSuccess, result_); |
| 297 // TODO(stevenjb): Add test interface to ShillIPConfigClient and test | 298 // TODO(stevenjb): Add test interface to ShillIPConfigClient and test |
| 298 // refresh calls. | 299 // refresh calls. |
| 299 } | 300 } |
| 300 | 301 |
| 301 TEST_F(NetworkDeviceHandlerTest, SetCarrier) { | 302 TEST_F(NetworkDeviceHandlerTest, SetCarrier) { |
| 302 const char kCarrier[] = "carrier"; | 303 const char kCarrier[] = "carrier"; |
| 303 | 304 |
| 304 // Test that the success callback gets called. | 305 // Test that the success callback gets called. |
| 305 network_device_handler_->SetCarrier( | 306 network_device_handler_->SetCarrier( |
| 306 kDefaultCellularDevicePath, kCarrier, success_callback_, error_callback_); | 307 kDefaultCellularDevicePath, kCarrier, success_callback_, error_callback_); |
| 307 message_loop_.RunUntilIdle(); | 308 base::RunLoop().RunUntilIdle(); |
| 308 EXPECT_EQ(kResultSuccess, result_); | 309 EXPECT_EQ(kResultSuccess, result_); |
| 309 | 310 |
| 310 // Test that the shill error propagates to the error callback. | 311 // Test that the shill error propagates to the error callback. |
| 311 network_device_handler_->SetCarrier( | 312 network_device_handler_->SetCarrier( |
| 312 kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_); | 313 kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_); |
| 313 message_loop_.RunUntilIdle(); | 314 base::RunLoop().RunUntilIdle(); |
| 314 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 315 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 315 } | 316 } |
| 316 | 317 |
| 317 TEST_F(NetworkDeviceHandlerTest, RequirePin) { | 318 TEST_F(NetworkDeviceHandlerTest, RequirePin) { |
| 318 // Test that the success callback gets called. | 319 // Test that the success callback gets called. |
| 319 network_device_handler_->RequirePin(kDefaultCellularDevicePath, | 320 network_device_handler_->RequirePin(kDefaultCellularDevicePath, |
| 320 true, | 321 true, |
| 321 kDefaultPin, | 322 kDefaultPin, |
| 322 success_callback_, | 323 success_callback_, |
| 323 error_callback_); | 324 error_callback_); |
| 324 message_loop_.RunUntilIdle(); | 325 base::RunLoop().RunUntilIdle(); |
| 325 EXPECT_EQ(kResultSuccess, result_); | 326 EXPECT_EQ(kResultSuccess, result_); |
| 326 | 327 |
| 327 // Test that the shill error propagates to the error callback. | 328 // Test that the shill error propagates to the error callback. |
| 328 network_device_handler_->RequirePin(kUnknownCellularDevicePath, | 329 network_device_handler_->RequirePin(kUnknownCellularDevicePath, |
| 329 true, | 330 true, |
| 330 kDefaultPin, | 331 kDefaultPin, |
| 331 success_callback_, | 332 success_callback_, |
| 332 error_callback_); | 333 error_callback_); |
| 333 message_loop_.RunUntilIdle(); | 334 base::RunLoop().RunUntilIdle(); |
| 334 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 335 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 335 } | 336 } |
| 336 | 337 |
| 337 TEST_F(NetworkDeviceHandlerTest, EnterPin) { | 338 TEST_F(NetworkDeviceHandlerTest, EnterPin) { |
| 338 // Test that the success callback gets called. | 339 // Test that the success callback gets called. |
| 339 network_device_handler_->EnterPin(kDefaultCellularDevicePath, | 340 network_device_handler_->EnterPin(kDefaultCellularDevicePath, |
| 340 kDefaultPin, | 341 kDefaultPin, |
| 341 success_callback_, | 342 success_callback_, |
| 342 error_callback_); | 343 error_callback_); |
| 343 message_loop_.RunUntilIdle(); | 344 base::RunLoop().RunUntilIdle(); |
| 344 EXPECT_EQ(kResultSuccess, result_); | 345 EXPECT_EQ(kResultSuccess, result_); |
| 345 | 346 |
| 346 // Test that the shill error propagates to the error callback. | 347 // Test that the shill error propagates to the error callback. |
| 347 network_device_handler_->EnterPin(kUnknownCellularDevicePath, | 348 network_device_handler_->EnterPin(kUnknownCellularDevicePath, |
| 348 kDefaultPin, | 349 kDefaultPin, |
| 349 success_callback_, | 350 success_callback_, |
| 350 error_callback_); | 351 error_callback_); |
| 351 message_loop_.RunUntilIdle(); | 352 base::RunLoop().RunUntilIdle(); |
| 352 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 353 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 353 } | 354 } |
| 354 | 355 |
| 355 TEST_F(NetworkDeviceHandlerTest, UnblockPin) { | 356 TEST_F(NetworkDeviceHandlerTest, UnblockPin) { |
| 356 const char kPuk[] = "12345678"; | 357 const char kPuk[] = "12345678"; |
| 357 const char kPin[] = "1234"; | 358 const char kPin[] = "1234"; |
| 358 | 359 |
| 359 // Test that the success callback gets called. | 360 // Test that the success callback gets called. |
| 360 network_device_handler_->UnblockPin(kDefaultCellularDevicePath, | 361 network_device_handler_->UnblockPin(kDefaultCellularDevicePath, |
| 361 kPin, | 362 kPin, |
| 362 kPuk, | 363 kPuk, |
| 363 success_callback_, | 364 success_callback_, |
| 364 error_callback_); | 365 error_callback_); |
| 365 message_loop_.RunUntilIdle(); | 366 base::RunLoop().RunUntilIdle(); |
| 366 EXPECT_EQ(kResultSuccess, result_); | 367 EXPECT_EQ(kResultSuccess, result_); |
| 367 | 368 |
| 368 // Test that the shill error propagates to the error callback. | 369 // Test that the shill error propagates to the error callback. |
| 369 network_device_handler_->UnblockPin(kUnknownCellularDevicePath, | 370 network_device_handler_->UnblockPin(kUnknownCellularDevicePath, |
| 370 kPin, | 371 kPin, |
| 371 kPuk, | 372 kPuk, |
| 372 success_callback_, | 373 success_callback_, |
| 373 error_callback_); | 374 error_callback_); |
| 374 message_loop_.RunUntilIdle(); | 375 base::RunLoop().RunUntilIdle(); |
| 375 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 376 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
| 376 } | 377 } |
| 377 | 378 |
| 378 TEST_F(NetworkDeviceHandlerTest, ChangePin) { | 379 TEST_F(NetworkDeviceHandlerTest, ChangePin) { |
| 379 const char kNewPin[] = "1234"; | 380 const char kNewPin[] = "1234"; |
| 380 const char kIncorrectPin[] = "9999"; | 381 const char kIncorrectPin[] = "9999"; |
| 381 | 382 |
| 382 fake_device_client_->SetSimLocked(kDefaultCellularDevicePath, true); | 383 fake_device_client_->SetSimLocked(kDefaultCellularDevicePath, true); |
| 383 | 384 |
| 384 // Test that the success callback gets called. | 385 // Test that the success callback gets called. |
| 385 network_device_handler_->ChangePin( | 386 network_device_handler_->ChangePin( |
| 386 kDefaultCellularDevicePath, FakeShillDeviceClient::kDefaultSimPin, | 387 kDefaultCellularDevicePath, FakeShillDeviceClient::kDefaultSimPin, |
| 387 kNewPin, success_callback_, error_callback_); | 388 kNewPin, success_callback_, error_callback_); |
| 388 message_loop_.RunUntilIdle(); | 389 base::RunLoop().RunUntilIdle(); |
| 389 EXPECT_EQ(kResultSuccess, result_); | 390 EXPECT_EQ(kResultSuccess, result_); |
| 390 | 391 |
| 391 // Test that the shill error propagates to the error callback. | 392 // Test that the shill error propagates to the error callback. |
| 392 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, | 393 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, |
| 393 kNewPin, success_callback_, | 394 kNewPin, success_callback_, |
| 394 error_callback_); | 395 error_callback_); |
| 395 message_loop_.RunUntilIdle(); | 396 base::RunLoop().RunUntilIdle(); |
| 396 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); | 397 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); |
| 397 } | 398 } |
| 398 | 399 |
| 399 } // namespace chromeos | 400 } // namespace chromeos |
| OLD | NEW |