| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 void DictionaryValueCallback(const std::string& expected_id, | 59 void DictionaryValueCallback(const std::string& expected_id, |
| 60 const std::string& expected_json, | 60 const std::string& expected_json, |
| 61 const std::string& service_path, | 61 const std::string& service_path, |
| 62 const base::DictionaryValue& dictionary) { | 62 const base::DictionaryValue& dictionary) { |
| 63 std::string dict_str = PrettyJson(dictionary); | 63 std::string dict_str = PrettyJson(dictionary); |
| 64 EXPECT_EQ(expected_json, dict_str); | 64 EXPECT_EQ(expected_json, dict_str); |
| 65 EXPECT_EQ(expected_id, service_path); | 65 EXPECT_EQ(expected_id, service_path); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ErrorCallback(bool error_expected, | 68 void ErrorCallback(const std::string& error_name, |
| 69 const std::string& expected_id, | |
| 70 const std::string& error_name, | |
| 71 std::unique_ptr<base::DictionaryValue> error_data) { | 69 std::unique_ptr<base::DictionaryValue> error_data) { |
| 72 EXPECT_TRUE(error_expected) << "Unexpected error: " << error_name | 70 ADD_FAILURE() << "Unexpected error: " << error_name |
| 73 << " with associated data: \n" | 71 << " with associated data: \n" |
| 74 << PrettyJson(*error_data); | 72 << PrettyJson(*error_data); |
| 73 } |
| 74 |
| 75 void RecordError(std::string* error_name_ptr, |
| 76 const std::string& error_name, |
| 77 std::unique_ptr<base::DictionaryValue> error_data) { |
| 78 *error_name_ptr = error_name; |
| 75 } | 79 } |
| 76 | 80 |
| 77 void ServiceResultCallback(const std::string& expected_result, | 81 void ServiceResultCallback(const std::string& expected_result, |
| 78 const std::string& service_path, | 82 const std::string& service_path, |
| 79 const std::string& guid) { | 83 const std::string& guid) { |
| 80 EXPECT_EQ(expected_result, service_path); | 84 EXPECT_EQ(expected_result, service_path); |
| 81 } | 85 } |
| 82 | 86 |
| 83 void DBusErrorCallback(const std::string& error_name, | 87 void DBusErrorCallback(const std::string& error_name, |
| 84 const std::string& error_message) { | 88 const std::string& error_message) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 mock_profile_client_ = new MockShillProfileClient(); | 191 mock_profile_client_ = new MockShillProfileClient(); |
| 188 mock_service_client_ = new MockShillServiceClient(); | 192 mock_service_client_ = new MockShillServiceClient(); |
| 189 dbus_setter->SetShillManagerClient( | 193 dbus_setter->SetShillManagerClient( |
| 190 std::unique_ptr<ShillManagerClient>(mock_manager_client_)); | 194 std::unique_ptr<ShillManagerClient>(mock_manager_client_)); |
| 191 dbus_setter->SetShillProfileClient( | 195 dbus_setter->SetShillProfileClient( |
| 192 std::unique_ptr<ShillProfileClient>(mock_profile_client_)); | 196 std::unique_ptr<ShillProfileClient>(mock_profile_client_)); |
| 193 dbus_setter->SetShillServiceClient( | 197 dbus_setter->SetShillServiceClient( |
| 194 std::unique_ptr<ShillServiceClient>(mock_service_client_)); | 198 std::unique_ptr<ShillServiceClient>(mock_service_client_)); |
| 195 | 199 |
| 196 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)).Times(AnyNumber()); | 200 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)).Times(AnyNumber()); |
| 201 EXPECT_CALL(*mock_service_client_, AddPropertyChangedObserver(_, _)) |
| 202 .Times(AnyNumber()); |
| 203 EXPECT_CALL(*mock_service_client_, RemovePropertyChangedObserver(_, _)) |
| 204 .Times(AnyNumber()); |
| 197 EXPECT_CALL(*mock_manager_client_, GetProperties(_)).Times(AnyNumber()); | 205 EXPECT_CALL(*mock_manager_client_, GetProperties(_)).Times(AnyNumber()); |
| 198 EXPECT_CALL(*mock_manager_client_, AddPropertyChangedObserver(_)) | 206 EXPECT_CALL(*mock_manager_client_, AddPropertyChangedObserver(_)) |
| 199 .Times(AnyNumber()); | 207 .WillRepeatedly(Invoke( |
| 208 this, |
| 209 &NetworkConfigurationHandlerTest::AddPropertyChangedObserver)); |
| 200 EXPECT_CALL(*mock_manager_client_, RemovePropertyChangedObserver(_)) | 210 EXPECT_CALL(*mock_manager_client_, RemovePropertyChangedObserver(_)) |
| 201 .Times(AnyNumber()); | 211 .WillRepeatedly(Invoke( |
| 212 this, |
| 213 &NetworkConfigurationHandlerTest::RemovePropertyChangedObserver)); |
| 202 | 214 |
| 203 network_state_handler_ = NetworkStateHandler::InitializeForTest(); | 215 network_state_handler_ = NetworkStateHandler::InitializeForTest(); |
| 204 network_configuration_handler_.reset(new NetworkConfigurationHandler()); | 216 network_configuration_handler_.reset(new NetworkConfigurationHandler()); |
| 205 network_configuration_handler_->Init(network_state_handler_.get(), | 217 network_configuration_handler_->Init(network_state_handler_.get(), |
| 206 NULL /* network_device_handler */); | 218 NULL /* network_device_handler */); |
| 207 base::RunLoop().RunUntilIdle(); | 219 base::RunLoop().RunUntilIdle(); |
| 208 } | 220 } |
| 209 | 221 |
| 210 void TearDown() override { | 222 void TearDown() override { |
| 211 network_state_handler_->Shutdown(); | 223 network_state_handler_->Shutdown(); |
| 212 network_configuration_handler_.reset(); | 224 network_configuration_handler_.reset(); |
| 213 network_state_handler_.reset(); | 225 network_state_handler_.reset(); |
| 214 DBusThreadManager::Shutdown(); | 226 DBusThreadManager::Shutdown(); |
| 215 } | 227 } |
| 216 | 228 |
| 229 void AddPropertyChangedObserver(ShillPropertyChangedObserver* observer) { |
| 230 property_changed_observers_.AddObserver(observer); |
| 231 } |
| 232 |
| 233 void RemovePropertyChangedObserver(ShillPropertyChangedObserver* observer) { |
| 234 property_changed_observers_.RemoveObserver(observer); |
| 235 } |
| 236 |
| 217 // Handles responses for GetProperties method calls. | 237 // Handles responses for GetProperties method calls. |
| 218 void OnGetProperties( | 238 void OnGetProperties( |
| 219 const dbus::ObjectPath& path, | 239 const dbus::ObjectPath& path, |
| 220 const ShillClientHelper::DictionaryValueCallback& callback) { | 240 const ShillClientHelper::DictionaryValueCallback& callback) { |
| 221 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); | 241 callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); |
| 222 } | 242 } |
| 223 | 243 |
| 224 // Handles responses for SetProperties method calls. | 244 // Handles responses for SetProperties method calls. |
| 225 void OnSetProperties(const dbus::ObjectPath& service_path, | 245 void OnSetProperties(const dbus::ObjectPath& service_path, |
| 226 const base::DictionaryValue& properties, | 246 const base::DictionaryValue& properties, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 251 result.AppendBoolean(false); | 271 result.AppendBoolean(false); |
| 252 callback.Run(result); | 272 callback.Run(result); |
| 253 } | 273 } |
| 254 | 274 |
| 255 void OnConfigureService( | 275 void OnConfigureService( |
| 256 const dbus::ObjectPath& profile_path, | 276 const dbus::ObjectPath& profile_path, |
| 257 const base::DictionaryValue& properties, | 277 const base::DictionaryValue& properties, |
| 258 const ObjectPathCallback& callback, | 278 const ObjectPathCallback& callback, |
| 259 const ShillClientHelper::ErrorCallback& error_callback) { | 279 const ShillClientHelper::ErrorCallback& error_callback) { |
| 260 callback.Run(dbus::ObjectPath("/service/2")); | 280 callback.Run(dbus::ObjectPath("/service/2")); |
| 281 |
| 282 // Notify property changed observer that service list was changed - the |
| 283 // goal is to have network state handler update it's network state list. |
| 284 base::ListValue value; |
| 285 value.AppendString("/service/1"); |
| 286 value.AppendString("/service/2"); |
| 287 for (auto& observer : property_changed_observers_) { |
| 288 observer.OnPropertyChanged("ServiceCompleteList", value); |
| 289 } |
| 261 } | 290 } |
| 262 | 291 |
| 263 void OnGetLoadableProfileEntries( | 292 void OnGetLoadableProfileEntries( |
| 264 const dbus::ObjectPath& service_path, | 293 const dbus::ObjectPath& service_path, |
| 265 const ShillClientHelper::DictionaryValueCallback& callback) { | 294 const ShillClientHelper::DictionaryValueCallback& callback) { |
| 266 base::DictionaryValue entries; | 295 base::DictionaryValue entries; |
| 267 entries.SetString("profile1", "entry1"); | 296 entries.SetString("profile1", "entry1"); |
| 268 entries.SetString("profile2", "entry2"); | 297 entries.SetString("profile2", "entry2"); |
| 269 callback.Run(DBUS_METHOD_CALL_SUCCESS, entries); | 298 callback.Run(DBUS_METHOD_CALL_SUCCESS, entries); |
| 270 } | 299 } |
| 271 | 300 |
| 272 void OnDeleteEntry(const dbus::ObjectPath& profile_path, | 301 void OnDeleteEntry(const dbus::ObjectPath& profile_path, |
| 273 const std::string& entry_path, | 302 const std::string& entry_path, |
| 274 const base::Closure& callback, | 303 const base::Closure& callback, |
| 275 const ShillClientHelper::ErrorCallback& error_callback) { | 304 const ShillClientHelper::ErrorCallback& error_callback) { |
| 276 // Don't run the callback immediately to emulate actual behavior. | 305 // Don't run the callback immediately to emulate actual behavior. |
| 277 message_loop_.task_runner()->PostTask(FROM_HERE, callback); | 306 message_loop_.task_runner()->PostTask(FROM_HERE, callback); |
| 278 } | 307 } |
| 279 | 308 |
| 280 bool PendingProfileEntryDeleterForTest(const std::string& service_path) { | 309 bool PendingProfileEntryDeleterForTest(const std::string& service_path) { |
| 281 return network_configuration_handler_->PendingProfileEntryDeleterForTest( | 310 return network_configuration_handler_->PendingProfileEntryDeleterForTest( |
| 282 service_path); | 311 service_path); |
| 283 } | 312 } |
| 284 | 313 |
| 285 void CreateConfiguration(const std::string& service_path, | 314 void CreateConfiguration(const std::string& service_path, |
| 286 const base::DictionaryValue& properties) { | 315 const base::DictionaryValue& properties) { |
| 287 network_configuration_handler_->CreateShillConfiguration( | 316 network_configuration_handler_->CreateShillConfiguration( |
| 288 properties, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 317 properties, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 289 base::Bind(&ServiceResultCallback, service_path), | 318 base::Bind(&ServiceResultCallback, service_path), |
| 290 base::Bind(&ErrorCallback, false, std::string())); | 319 base::Bind(&ErrorCallback)); |
| 291 } | 320 } |
| 292 | 321 |
| 293 protected: | 322 protected: |
| 294 MockShillManagerClient* mock_manager_client_; | 323 MockShillManagerClient* mock_manager_client_; |
| 295 MockShillProfileClient* mock_profile_client_; | 324 MockShillProfileClient* mock_profile_client_; |
| 296 MockShillServiceClient* mock_service_client_; | 325 MockShillServiceClient* mock_service_client_; |
| 297 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 326 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
| 298 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; | 327 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; |
| 299 base::MessageLoopForUI message_loop_; | 328 base::MessageLoopForUI message_loop_; |
| 300 base::DictionaryValue* dictionary_value_result_; | 329 base::DictionaryValue* dictionary_value_result_; |
| 330 |
| 331 base::ObserverList<ShillPropertyChangedObserver, true> |
| 332 property_changed_observers_; |
| 301 }; | 333 }; |
| 302 | 334 |
| 303 TEST_F(NetworkConfigurationHandlerTest, GetProperties) { | 335 TEST_F(NetworkConfigurationHandlerTest, GetProperties) { |
| 304 std::string service_path = "/service/1"; | 336 std::string service_path = "/service/1"; |
| 305 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; | 337 std::string expected_json = "{\n \"SSID\": \"MyNetwork\"\n}\n"; |
| 306 std::string networkName = "MyNetwork"; | 338 std::string networkName = "MyNetwork"; |
| 307 std::string key = "SSID"; | 339 std::string key = "SSID"; |
| 308 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); | 340 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); |
| 309 | 341 |
| 310 base::DictionaryValue value; | 342 base::DictionaryValue value; |
| 311 value.Set(key, new base::Value(networkName)); | 343 value.Set(key, new base::Value(networkName)); |
| 312 dictionary_value_result_ = &value; | 344 dictionary_value_result_ = &value; |
| 313 EXPECT_CALL(*mock_service_client_, | 345 EXPECT_CALL(*mock_service_client_, |
| 314 SetProperty(dbus::ObjectPath(service_path), key, | 346 SetProperty(dbus::ObjectPath(service_path), key, |
| 315 IsEqualTo(networkNameValue.get()), _, _)).Times(1); | 347 IsEqualTo(networkNameValue.get()), _, _)).Times(1); |
| 316 mock_service_client_->SetProperty( | 348 mock_service_client_->SetProperty( |
| 317 dbus::ObjectPath(service_path), key, *networkNameValue, | 349 dbus::ObjectPath(service_path), key, *networkNameValue, |
| 318 base::Bind(&base::DoNothing), base::Bind(&DBusErrorCallback)); | 350 base::Bind(&base::DoNothing), base::Bind(&DBusErrorCallback)); |
| 319 base::RunLoop().RunUntilIdle(); | 351 base::RunLoop().RunUntilIdle(); |
| 320 | 352 |
| 321 ShillServiceClient::DictionaryValueCallback get_properties_callback; | 353 ShillServiceClient::DictionaryValueCallback get_properties_callback; |
| 322 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) | 354 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) |
| 323 .WillOnce( | 355 .WillOnce( |
| 324 Invoke(this, &NetworkConfigurationHandlerTest::OnGetProperties)); | 356 Invoke(this, &NetworkConfigurationHandlerTest::OnGetProperties)); |
| 325 network_configuration_handler_->GetShillProperties( | 357 network_configuration_handler_->GetShillProperties( |
| 326 service_path, | 358 service_path, |
| 327 base::Bind(&DictionaryValueCallback, service_path, expected_json), | 359 base::Bind(&DictionaryValueCallback, service_path, expected_json), |
| 328 base::Bind(&ErrorCallback, false, service_path)); | 360 base::Bind(&ErrorCallback)); |
| 329 base::RunLoop().RunUntilIdle(); | 361 base::RunLoop().RunUntilIdle(); |
| 330 } | 362 } |
| 331 | 363 |
| 332 TEST_F(NetworkConfigurationHandlerTest, SetProperties) { | 364 TEST_F(NetworkConfigurationHandlerTest, SetProperties) { |
| 333 std::string service_path = "/service/1"; | 365 std::string service_path = "/service/1"; |
| 334 std::string networkName = "MyNetwork"; | 366 std::string networkName = "MyNetwork"; |
| 335 std::string key = "SSID"; | 367 std::string key = "SSID"; |
| 336 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); | 368 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); |
| 337 | 369 |
| 338 base::DictionaryValue value; | 370 base::DictionaryValue value; |
| 339 value.Set(key, new base::Value(networkName)); | 371 value.Set(key, new base::Value(networkName)); |
| 340 dictionary_value_result_ = &value; | 372 dictionary_value_result_ = &value; |
| 341 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) | 373 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) |
| 342 .WillOnce( | 374 .WillOnce( |
| 343 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); | 375 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); |
| 344 network_configuration_handler_->SetShillProperties( | 376 network_configuration_handler_->SetShillProperties( |
| 345 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 377 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 346 base::Bind(&base::DoNothing), | 378 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 347 base::Bind(&ErrorCallback, false, service_path)); | |
| 348 base::RunLoop().RunUntilIdle(); | 379 base::RunLoop().RunUntilIdle(); |
| 349 } | 380 } |
| 350 | 381 |
| 351 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) { | 382 TEST_F(NetworkConfigurationHandlerTest, ClearProperties) { |
| 352 std::string service_path = "/service/1"; | 383 std::string service_path = "/service/1"; |
| 353 std::string networkName = "MyNetwork"; | 384 std::string networkName = "MyNetwork"; |
| 354 std::string key = "SSID"; | 385 std::string key = "SSID"; |
| 355 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); | 386 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); |
| 356 | 387 |
| 357 // First set up a value to clear. | 388 // First set up a value to clear. |
| 358 base::DictionaryValue value; | 389 base::DictionaryValue value; |
| 359 value.Set(key, new base::Value(networkName)); | 390 value.Set(key, new base::Value(networkName)); |
| 360 dictionary_value_result_ = &value; | 391 dictionary_value_result_ = &value; |
| 361 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) | 392 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) |
| 362 .WillOnce( | 393 .WillOnce( |
| 363 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); | 394 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); |
| 364 network_configuration_handler_->SetShillProperties( | 395 network_configuration_handler_->SetShillProperties( |
| 365 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 396 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 366 base::Bind(&base::DoNothing), | 397 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 367 base::Bind(&ErrorCallback, false, service_path)); | |
| 368 base::RunLoop().RunUntilIdle(); | 398 base::RunLoop().RunUntilIdle(); |
| 369 | 399 |
| 370 // Now clear it. | 400 // Now clear it. |
| 371 std::vector<std::string> values_to_clear; | 401 std::vector<std::string> values_to_clear; |
| 372 values_to_clear.push_back(key); | 402 values_to_clear.push_back(key); |
| 373 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _)) | 403 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _)) |
| 374 .WillOnce( | 404 .WillOnce( |
| 375 Invoke(this, &NetworkConfigurationHandlerTest::OnClearProperties)); | 405 Invoke(this, &NetworkConfigurationHandlerTest::OnClearProperties)); |
| 376 network_configuration_handler_->ClearShillProperties( | 406 network_configuration_handler_->ClearShillProperties( |
| 377 service_path, values_to_clear, base::Bind(&base::DoNothing), | 407 service_path, values_to_clear, base::Bind(&base::DoNothing), |
| 378 base::Bind(&ErrorCallback, false, service_path)); | 408 base::Bind(&ErrorCallback)); |
| 379 base::RunLoop().RunUntilIdle(); | 409 base::RunLoop().RunUntilIdle(); |
| 380 } | 410 } |
| 381 | 411 |
| 382 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { | 412 TEST_F(NetworkConfigurationHandlerTest, ClearPropertiesError) { |
| 383 std::string service_path = "/service/1"; | 413 std::string service_path = "/service/1"; |
| 384 std::string networkName = "MyNetwork"; | 414 std::string networkName = "MyNetwork"; |
| 385 std::string key = "SSID"; | 415 std::string key = "SSID"; |
| 386 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); | 416 std::unique_ptr<base::Value> networkNameValue(new base::Value(networkName)); |
| 387 | 417 |
| 388 // First set up a value to clear. | 418 // First set up a value to clear. |
| 389 base::DictionaryValue value; | 419 base::DictionaryValue value; |
| 390 value.Set(key, new base::Value(networkName)); | 420 value.Set(key, new base::Value(networkName)); |
| 391 dictionary_value_result_ = &value; | 421 dictionary_value_result_ = &value; |
| 392 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) | 422 EXPECT_CALL(*mock_service_client_, SetProperties(_, _, _, _)) |
| 393 .WillOnce( | 423 .WillOnce( |
| 394 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); | 424 Invoke(this, &NetworkConfigurationHandlerTest::OnSetProperties)); |
| 395 network_configuration_handler_->SetShillProperties( | 425 network_configuration_handler_->SetShillProperties( |
| 396 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 426 service_path, value, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 397 base::Bind(&base::DoNothing), | 427 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 398 base::Bind(&ErrorCallback, false, service_path)); | |
| 399 base::RunLoop().RunUntilIdle(); | 428 base::RunLoop().RunUntilIdle(); |
| 400 | 429 |
| 401 // Now clear it. | 430 // Now clear it. |
| 402 std::vector<std::string> values_to_clear; | 431 std::vector<std::string> values_to_clear; |
| 403 values_to_clear.push_back(key); | 432 values_to_clear.push_back(key); |
| 404 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _)) | 433 EXPECT_CALL(*mock_service_client_, ClearProperties(_, _, _, _)) |
| 405 .WillOnce(Invoke( | 434 .WillOnce(Invoke( |
| 406 this, &NetworkConfigurationHandlerTest::OnClearPropertiesError)); | 435 this, &NetworkConfigurationHandlerTest::OnClearPropertiesError)); |
| 436 |
| 437 std::string error; |
| 407 network_configuration_handler_->ClearShillProperties( | 438 network_configuration_handler_->ClearShillProperties( |
| 408 service_path, values_to_clear, base::Bind(&base::DoNothing), | 439 service_path, values_to_clear, base::Bind(&base::DoNothing), |
| 409 base::Bind(&ErrorCallback, true, service_path)); | 440 base::Bind(&ErrorCallback)); |
| 410 base::RunLoop().RunUntilIdle(); | 441 base::RunLoop().RunUntilIdle(); |
| 411 } | 442 } |
| 412 | 443 |
| 413 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { | 444 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { |
| 414 std::string networkName = "MyNetwork"; | 445 std::string networkName = "MyNetwork"; |
| 415 std::string key = "SSID"; | 446 std::string key = "SSID"; |
| 416 std::string type = "wifi"; | 447 std::string type = "wifi"; |
| 417 std::string profile = "profile path"; | 448 std::string profile = "profile path"; |
| 418 base::DictionaryValue value; | 449 base::DictionaryValue value; |
| 419 shill_property_util::SetSSID(networkName, &value); | 450 shill_property_util::SetSSID(networkName, &value); |
| 420 value.SetWithoutPathExpansion(shill::kTypeProperty, new base::Value(type)); | 451 value.SetWithoutPathExpansion(shill::kTypeProperty, new base::Value(type)); |
| 421 value.SetWithoutPathExpansion(shill::kProfileProperty, | 452 value.SetWithoutPathExpansion(shill::kProfileProperty, |
| 422 new base::Value(profile)); | 453 new base::Value(profile)); |
| 423 | 454 |
| 424 EXPECT_CALL(*mock_manager_client_, | 455 EXPECT_CALL(*mock_manager_client_, |
| 425 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) | 456 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) |
| 426 .WillOnce( | 457 .WillOnce( |
| 427 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); | 458 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); |
| 428 CreateConfiguration("/service/2", value); | 459 CreateConfiguration("/service/2", value); |
| 429 base::RunLoop().RunUntilIdle(); | 460 base::RunLoop().RunUntilIdle(); |
| 430 } | 461 } |
| 431 | 462 |
| 432 TEST_F(NetworkConfigurationHandlerTest, RemoveConfiguration) { | 463 TEST_F(NetworkConfigurationHandlerTest, RemoveConfiguration) { |
| 433 std::string service_path = "/service/1"; | 464 std::string service_path = "/service/2"; |
| 465 |
| 466 // Set up network configuration so the associated network service has the |
| 467 // profile path set to |profile|. |
| 468 std::string key = "SSID"; |
| 469 std::string type = "wifi"; |
| 470 base::DictionaryValue value; |
| 471 shill_property_util::SetSSID("Service", &value); |
| 472 value.SetWithoutPathExpansion(shill::kTypeProperty, new base::Value(type)); |
| 473 value.SetWithoutPathExpansion(shill::kProfileProperty, |
| 474 new base::Value("profile2")); |
| 475 EXPECT_CALL(*mock_manager_client_, |
| 476 ConfigureServiceForProfile(dbus::ObjectPath("profile2"), _, _, _)) |
| 477 .WillOnce( |
| 478 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); |
| 479 |
| 480 dictionary_value_result_ = &value; |
| 481 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) |
| 482 .WillRepeatedly( |
| 483 Invoke(this, &NetworkConfigurationHandlerTest::OnGetProperties)); |
| 484 |
| 485 CreateConfiguration(service_path, value); |
| 486 base::RunLoop().RunUntilIdle(); |
| 487 |
| 488 // Set Up mock flor GetLoadableProfileEntries - it returns |
| 489 // [(profile1, entry1), (profile2, entry2)] profile-entry pairs. |
| 490 EXPECT_CALL(*mock_service_client_, |
| 491 GetLoadableProfileEntries(dbus::ObjectPath(service_path), _)) |
| 492 .WillOnce(Invoke( |
| 493 this, &NetworkConfigurationHandlerTest::OnGetLoadableProfileEntries)); |
| 494 |
| 495 // Expectations for entries deleted during the test. |
| 496 EXPECT_CALL(*mock_profile_client_, |
| 497 DeleteEntry(dbus::ObjectPath("profile1"), "entry1", _, _)) |
| 498 .WillOnce(Invoke(this, &NetworkConfigurationHandlerTest::OnDeleteEntry)); |
| 499 EXPECT_CALL(*mock_profile_client_, |
| 500 DeleteEntry(dbus::ObjectPath("profile2"), "entry2", _, _)) |
| 501 .WillOnce(Invoke(this, &NetworkConfigurationHandlerTest::OnDeleteEntry)); |
| 434 | 502 |
| 435 TestCallback test_callback; | 503 TestCallback test_callback; |
| 436 EXPECT_CALL(*mock_service_client_, GetLoadableProfileEntries(_, _)) | |
| 437 .WillOnce(Invoke( | |
| 438 this, &NetworkConfigurationHandlerTest::OnGetLoadableProfileEntries)); | |
| 439 EXPECT_CALL(*mock_profile_client_, DeleteEntry(_, _, _, _)) | |
| 440 .WillRepeatedly( | |
| 441 Invoke(this, &NetworkConfigurationHandlerTest::OnDeleteEntry)); | |
| 442 | |
| 443 network_configuration_handler_->RemoveConfiguration( | 504 network_configuration_handler_->RemoveConfiguration( |
| 444 service_path, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 505 service_path, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 445 base::Bind(&TestCallback::Run, base::Unretained(&test_callback)), | 506 base::Bind(&TestCallback::Run, base::Unretained(&test_callback)), |
| 446 base::Bind(&ErrorCallback, false, service_path)); | 507 base::Bind(&ErrorCallback)); |
| 508 |
| 447 base::RunLoop().RunUntilIdle(); | 509 base::RunLoop().RunUntilIdle(); |
| 448 EXPECT_EQ(1, test_callback.run_count()); | 510 EXPECT_EQ(1, test_callback.run_count()); |
| 449 EXPECT_FALSE(PendingProfileEntryDeleterForTest(service_path)); | 511 EXPECT_FALSE(PendingProfileEntryDeleterForTest(service_path)); |
| 450 } | 512 } |
| 451 | 513 |
| 514 TEST_F(NetworkConfigurationHandlerTest, RemoveConfigurationFromCurrentProfile) { |
| 515 std::string service_path = "/service/2"; |
| 516 |
| 517 // Set up network configuration so the associated network service has the |
| 518 // profile path set to |profile|. |
| 519 std::string key = "SSID"; |
| 520 std::string type = "wifi"; |
| 521 base::DictionaryValue value; |
| 522 shill_property_util::SetSSID("Service", &value); |
| 523 value.SetWithoutPathExpansion(shill::kTypeProperty, new base::Value(type)); |
| 524 value.SetWithoutPathExpansion(shill::kProfileProperty, |
| 525 new base::Value("profile2")); |
| 526 EXPECT_CALL(*mock_manager_client_, |
| 527 ConfigureServiceForProfile(dbus::ObjectPath("profile2"), _, _, _)) |
| 528 .WillOnce( |
| 529 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); |
| 530 |
| 531 dictionary_value_result_ = &value; |
| 532 EXPECT_CALL(*mock_service_client_, GetProperties(_, _)) |
| 533 .WillRepeatedly( |
| 534 Invoke(this, &NetworkConfigurationHandlerTest::OnGetProperties)); |
| 535 |
| 536 CreateConfiguration(service_path, value); |
| 537 base::RunLoop().RunUntilIdle(); |
| 538 |
| 539 // Set Up mock flor GetLoadableProfileEntries - it returns |
| 540 // [(profile1, entry1), (profile2, entry2)] profile-entry pairs. |
| 541 EXPECT_CALL(*mock_service_client_, |
| 542 GetLoadableProfileEntries(dbus::ObjectPath(service_path), _)) |
| 543 .WillOnce(Invoke( |
| 544 this, &NetworkConfigurationHandlerTest::OnGetLoadableProfileEntries)); |
| 545 |
| 546 // Expectations for entries deleted during the test. |
| 547 EXPECT_CALL(*mock_profile_client_, |
| 548 DeleteEntry(dbus::ObjectPath("profile2"), "entry2", _, _)) |
| 549 .WillOnce(Invoke(this, &NetworkConfigurationHandlerTest::OnDeleteEntry)); |
| 550 EXPECT_CALL(*mock_profile_client_, |
| 551 DeleteEntry(dbus::ObjectPath("profile1"), "entry1", _, _)) |
| 552 .Times(0); |
| 553 |
| 554 TestCallback test_callback; |
| 555 network_configuration_handler_->RemoveConfigurationFromCurrentProfile( |
| 556 service_path, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 557 base::Bind(&TestCallback::Run, base::Unretained(&test_callback)), |
| 558 base::Bind(&ErrorCallback)); |
| 559 |
| 560 base::RunLoop().RunUntilIdle(); |
| 561 EXPECT_EQ(1, test_callback.run_count()); |
| 562 EXPECT_FALSE(PendingProfileEntryDeleterForTest(service_path)); |
| 563 } |
| 564 |
| 565 TEST_F(NetworkConfigurationHandlerTest, |
| 566 RemoveNonExistentConfigurationFromCurrentProfile) { |
| 567 // Set Up mock flor GetLoadableProfileEntries - it returns |
| 568 // [(profile1, entry1), (profile2, entry2)] profile-entry pairs. |
| 569 EXPECT_CALL(*mock_service_client_, |
| 570 GetLoadableProfileEntries(dbus::ObjectPath("/service/3"), _)) |
| 571 .WillRepeatedly(Invoke( |
| 572 this, &NetworkConfigurationHandlerTest::OnGetLoadableProfileEntries)); |
| 573 |
| 574 // Expectations for entries deleted during the test. |
| 575 EXPECT_CALL(*mock_profile_client_, |
| 576 DeleteEntry(dbus::ObjectPath("profile2"), "entry2", _, _)) |
| 577 .Times(0); |
| 578 EXPECT_CALL(*mock_profile_client_, |
| 579 DeleteEntry(dbus::ObjectPath("profile1"), "entry1", _, _)) |
| 580 .Times(0); |
| 581 |
| 582 TestCallback test_callback; |
| 583 std::string error; |
| 584 network_configuration_handler_->RemoveConfigurationFromCurrentProfile( |
| 585 "/service/3", NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 586 base::Bind(&TestCallback::Run, base::Unretained(&test_callback)), |
| 587 base::Bind(&RecordError, base::Unretained(&error))); |
| 588 EXPECT_EQ("NetworkNotConfigured", error); |
| 589 |
| 590 base::RunLoop().RunUntilIdle(); |
| 591 EXPECT_EQ(0, test_callback.run_count()); |
| 592 EXPECT_FALSE(PendingProfileEntryDeleterForTest("/service/3")); |
| 593 } |
| 594 |
| 452 //////////////////////////////////////////////////////////////////////////////// | 595 //////////////////////////////////////////////////////////////////////////////// |
| 453 // Stub based tests | 596 // Stub based tests |
| 454 | 597 |
| 455 namespace { | 598 namespace { |
| 456 | 599 |
| 457 class TestObserver : public chromeos::NetworkStateHandlerObserver { | 600 class TestObserver : public chromeos::NetworkStateHandlerObserver { |
| 458 public: | 601 public: |
| 459 TestObserver() : network_list_changed_count_(0) {} | 602 TestObserver() : network_list_changed_count_(0) {} |
| 460 ~TestObserver() override {} | 603 ~TestObserver() override {} |
| 461 | 604 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 properties.SetStringWithoutPathExpansion(shill::kStateProperty, | 681 properties.SetStringWithoutPathExpansion(shill::kStateProperty, |
| 539 shill::kStateIdle); | 682 shill::kStateIdle); |
| 540 properties.SetStringWithoutPathExpansion( | 683 properties.SetStringWithoutPathExpansion( |
| 541 shill::kProfileProperty, NetworkProfileHandler::GetSharedProfilePath()); | 684 shill::kProfileProperty, NetworkProfileHandler::GetSharedProfilePath()); |
| 542 | 685 |
| 543 network_configuration_handler_->CreateShillConfiguration( | 686 network_configuration_handler_->CreateShillConfiguration( |
| 544 properties, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 687 properties, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 545 base::Bind( | 688 base::Bind( |
| 546 &NetworkConfigurationHandlerStubTest::CreateConfigurationCallback, | 689 &NetworkConfigurationHandlerStubTest::CreateConfigurationCallback, |
| 547 base::Unretained(this)), | 690 base::Unretained(this)), |
| 548 base::Bind(&ErrorCallback, false, service_path)); | 691 base::Bind(&ErrorCallback)); |
| 549 base::RunLoop().RunUntilIdle(); | 692 base::RunLoop().RunUntilIdle(); |
| 550 } | 693 } |
| 551 | 694 |
| 552 protected: | 695 protected: |
| 553 bool GetServiceStringProperty(const std::string& service_path, | 696 bool GetServiceStringProperty(const std::string& service_path, |
| 554 const std::string& key, | 697 const std::string& key, |
| 555 std::string* result) { | 698 std::string* result) { |
| 556 ShillServiceClient::TestInterface* service_test = | 699 ShillServiceClient::TestInterface* service_test = |
| 557 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 700 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 558 const base::DictionaryValue* properties = | 701 const base::DictionaryValue* properties = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 base::DictionaryValue properties_to_set; | 736 base::DictionaryValue properties_to_set; |
| 594 properties_to_set.SetStringWithoutPathExpansion(shill::kIdentityProperty, | 737 properties_to_set.SetStringWithoutPathExpansion(shill::kIdentityProperty, |
| 595 test_identity); | 738 test_identity); |
| 596 properties_to_set.SetStringWithoutPathExpansion(shill::kPassphraseProperty, | 739 properties_to_set.SetStringWithoutPathExpansion(shill::kPassphraseProperty, |
| 597 test_passphrase); | 740 test_passphrase); |
| 598 network_configuration_handler_->SetShillProperties( | 741 network_configuration_handler_->SetShillProperties( |
| 599 service_path, properties_to_set, | 742 service_path, properties_to_set, |
| 600 NetworkConfigurationObserver::SOURCE_USER_ACTION, | 743 NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 601 base::Bind(&NetworkConfigurationHandlerStubTest::SuccessCallback, | 744 base::Bind(&NetworkConfigurationHandlerStubTest::SuccessCallback, |
| 602 base::Unretained(this), "SetProperties"), | 745 base::Unretained(this), "SetProperties"), |
| 603 base::Bind(&ErrorCallback, false, service_path)); | 746 base::Bind(&ErrorCallback)); |
| 604 base::RunLoop().RunUntilIdle(); | 747 base::RunLoop().RunUntilIdle(); |
| 605 | 748 |
| 606 EXPECT_EQ("SetProperties", success_callback_name_); | 749 EXPECT_EQ("SetProperties", success_callback_name_); |
| 607 std::string identity, passphrase; | 750 std::string identity, passphrase; |
| 608 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kIdentityProperty, | 751 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kIdentityProperty, |
| 609 &identity)); | 752 &identity)); |
| 610 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kPassphraseProperty, | 753 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kPassphraseProperty, |
| 611 &passphrase)); | 754 &passphrase)); |
| 612 EXPECT_EQ(test_identity, identity); | 755 EXPECT_EQ(test_identity, identity); |
| 613 EXPECT_EQ(test_passphrase, passphrase); | 756 EXPECT_EQ(test_passphrase, passphrase); |
| 614 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(service_path)); | 757 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(service_path)); |
| 615 | 758 |
| 616 // Clear Properties | 759 // Clear Properties |
| 617 std::vector<std::string> properties_to_clear; | 760 std::vector<std::string> properties_to_clear; |
| 618 properties_to_clear.push_back(shill::kIdentityProperty); | 761 properties_to_clear.push_back(shill::kIdentityProperty); |
| 619 properties_to_clear.push_back(shill::kPassphraseProperty); | 762 properties_to_clear.push_back(shill::kPassphraseProperty); |
| 620 network_configuration_handler_->ClearShillProperties( | 763 network_configuration_handler_->ClearShillProperties( |
| 621 service_path, properties_to_clear, | 764 service_path, properties_to_clear, |
| 622 base::Bind(&NetworkConfigurationHandlerStubTest::SuccessCallback, | 765 base::Bind(&NetworkConfigurationHandlerStubTest::SuccessCallback, |
| 623 base::Unretained(this), "ClearProperties"), | 766 base::Unretained(this), "ClearProperties"), |
| 624 base::Bind(&ErrorCallback, false, service_path)); | 767 base::Bind(&ErrorCallback)); |
| 625 base::RunLoop().RunUntilIdle(); | 768 base::RunLoop().RunUntilIdle(); |
| 626 | 769 |
| 627 EXPECT_EQ("ClearProperties", success_callback_name_); | 770 EXPECT_EQ("ClearProperties", success_callback_name_); |
| 628 EXPECT_FALSE(GetServiceStringProperty(service_path, shill::kIdentityProperty, | 771 EXPECT_FALSE(GetServiceStringProperty(service_path, shill::kIdentityProperty, |
| 629 &identity)); | 772 &identity)); |
| 630 EXPECT_FALSE(GetServiceStringProperty(service_path, shill::kIdentityProperty, | 773 EXPECT_FALSE(GetServiceStringProperty(service_path, shill::kIdentityProperty, |
| 631 &passphrase)); | 774 &passphrase)); |
| 632 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(service_path)); | 775 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(service_path)); |
| 633 } | 776 } |
| 634 | 777 |
| 635 TEST_F(NetworkConfigurationHandlerStubTest, StubGetNameFromWifiHex) { | 778 TEST_F(NetworkConfigurationHandlerStubTest, StubGetNameFromWifiHex) { |
| 636 // TODO(stevenjb): Remove dependency on default Stub service. | 779 // TODO(stevenjb): Remove dependency on default Stub service. |
| 637 const std::string service_path("/service/wifi1"); | 780 const std::string service_path("/service/wifi1"); |
| 638 std::string wifi_hex = "5468697320697320484558205353494421"; | 781 std::string wifi_hex = "5468697320697320484558205353494421"; |
| 639 std::string expected_name = "This is HEX SSID!"; | 782 std::string expected_name = "This is HEX SSID!"; |
| 640 | 783 |
| 641 // Set Properties | 784 // Set Properties |
| 642 base::DictionaryValue properties_to_set; | 785 base::DictionaryValue properties_to_set; |
| 643 properties_to_set.SetStringWithoutPathExpansion(shill::kWifiHexSsid, | 786 properties_to_set.SetStringWithoutPathExpansion(shill::kWifiHexSsid, |
| 644 wifi_hex); | 787 wifi_hex); |
| 645 network_configuration_handler_->SetShillProperties( | 788 network_configuration_handler_->SetShillProperties( |
| 646 service_path, properties_to_set, | 789 service_path, properties_to_set, |
| 647 NetworkConfigurationObserver::SOURCE_USER_ACTION, | 790 NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 648 base::Bind(&base::DoNothing), | 791 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 649 base::Bind(&ErrorCallback, false, service_path)); | |
| 650 base::RunLoop().RunUntilIdle(); | 792 base::RunLoop().RunUntilIdle(); |
| 651 std::string wifi_hex_result; | 793 std::string wifi_hex_result; |
| 652 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kWifiHexSsid, | 794 EXPECT_TRUE(GetServiceStringProperty(service_path, shill::kWifiHexSsid, |
| 653 &wifi_hex_result)); | 795 &wifi_hex_result)); |
| 654 EXPECT_EQ(wifi_hex, wifi_hex_result); | 796 EXPECT_EQ(wifi_hex, wifi_hex_result); |
| 655 | 797 |
| 656 // Get Properties | 798 // Get Properties |
| 657 network_configuration_handler_->GetShillProperties( | 799 network_configuration_handler_->GetShillProperties( |
| 658 service_path, | 800 service_path, |
| 659 base::Bind(&NetworkConfigurationHandlerStubTest::GetPropertiesCallback, | 801 base::Bind(&NetworkConfigurationHandlerStubTest::GetPropertiesCallback, |
| 660 base::Unretained(this)), | 802 base::Unretained(this)), |
| 661 base::Bind(&ErrorCallback, false, service_path)); | 803 base::Bind(&ErrorCallback)); |
| 662 base::RunLoop().RunUntilIdle(); | 804 base::RunLoop().RunUntilIdle(); |
| 663 | 805 |
| 664 EXPECT_EQ(service_path, get_properties_path_); | 806 EXPECT_EQ(service_path, get_properties_path_); |
| 665 std::string name_result; | 807 std::string name_result; |
| 666 EXPECT_TRUE(GetReceivedStringProperty(service_path, shill::kNameProperty, | 808 EXPECT_TRUE(GetReceivedStringProperty(service_path, shill::kNameProperty, |
| 667 &name_result)); | 809 &name_result)); |
| 668 EXPECT_EQ(expected_name, name_result); | 810 EXPECT_EQ(expected_name, name_result); |
| 669 } | 811 } |
| 670 | 812 |
| 671 TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { | 813 TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 699 service_path, NetworkProfileHandler::GetSharedProfilePath())); | 841 service_path, NetworkProfileHandler::GetSharedProfilePath())); |
| 700 EXPECT_EQ(shill::kTypeWifi, test_observer->GetStringProperty( | 842 EXPECT_EQ(shill::kTypeWifi, test_observer->GetStringProperty( |
| 701 service_path, shill::kTypeProperty)); | 843 service_path, shill::kTypeProperty)); |
| 702 | 844 |
| 703 base::DictionaryValue properties_to_set; | 845 base::DictionaryValue properties_to_set; |
| 704 properties_to_set.SetStringWithoutPathExpansion(shill::kPassphraseProperty, | 846 properties_to_set.SetStringWithoutPathExpansion(shill::kPassphraseProperty, |
| 705 test_passphrase); | 847 test_passphrase); |
| 706 network_configuration_handler_->SetShillProperties( | 848 network_configuration_handler_->SetShillProperties( |
| 707 service_path, properties_to_set, | 849 service_path, properties_to_set, |
| 708 NetworkConfigurationObserver::SOURCE_USER_ACTION, | 850 NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 709 base::Bind(&base::DoNothing), | 851 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 710 base::Bind(&ErrorCallback, false, service_path)); | |
| 711 base::RunLoop().RunUntilIdle(); | 852 base::RunLoop().RunUntilIdle(); |
| 712 EXPECT_EQ(test_passphrase, test_observer->GetStringProperty( | 853 EXPECT_EQ(test_passphrase, test_observer->GetStringProperty( |
| 713 service_path, shill::kPassphraseProperty)); | 854 service_path, shill::kPassphraseProperty)); |
| 714 | 855 |
| 715 std::string user_profile = "/profiles/user1"; | 856 std::string user_profile = "/profiles/user1"; |
| 716 std::string userhash = "user1"; | 857 std::string userhash = "user1"; |
| 717 DBusThreadManager::Get() | 858 DBusThreadManager::Get() |
| 718 ->GetShillProfileClient() | 859 ->GetShillProfileClient() |
| 719 ->GetTestInterface() | 860 ->GetTestInterface() |
| 720 ->AddProfile(user_profile, userhash); | 861 ->AddProfile(user_profile, userhash); |
| 721 | 862 |
| 722 network_configuration_handler_->SetNetworkProfile( | 863 network_configuration_handler_->SetNetworkProfile( |
| 723 service_path, user_profile, | 864 service_path, user_profile, |
| 724 NetworkConfigurationObserver::SOURCE_USER_ACTION, | 865 NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 725 base::Bind(&base::DoNothing), | 866 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 726 base::Bind(&ErrorCallback, false, service_path)); | |
| 727 base::RunLoop().RunUntilIdle(); | 867 base::RunLoop().RunUntilIdle(); |
| 728 EXPECT_TRUE(test_observer->HasConfiguration(service_path)); | 868 EXPECT_TRUE(test_observer->HasConfiguration(service_path)); |
| 729 EXPECT_FALSE(test_observer->HasConfigurationInProfile( | 869 EXPECT_FALSE(test_observer->HasConfigurationInProfile( |
| 730 service_path, NetworkProfileHandler::GetSharedProfilePath())); | 870 service_path, NetworkProfileHandler::GetSharedProfilePath())); |
| 731 EXPECT_TRUE( | 871 EXPECT_TRUE( |
| 732 test_observer->HasConfigurationInProfile(service_path, user_profile)); | 872 test_observer->HasConfigurationInProfile(service_path, user_profile)); |
| 733 | 873 |
| 734 network_configuration_handler_->RemoveConfiguration( | 874 network_configuration_handler_->RemoveConfiguration( |
| 735 service_path, NetworkConfigurationObserver::SOURCE_USER_ACTION, | 875 service_path, NetworkConfigurationObserver::SOURCE_USER_ACTION, |
| 736 base::Bind(&base::DoNothing), | 876 base::Bind(&base::DoNothing), base::Bind(&ErrorCallback)); |
| 737 base::Bind(&ErrorCallback, false, service_path)); | |
| 738 base::RunLoop().RunUntilIdle(); | 877 base::RunLoop().RunUntilIdle(); |
| 739 | 878 |
| 740 EXPECT_FALSE(test_observer->HasConfiguration(service_path)); | 879 EXPECT_FALSE(test_observer->HasConfiguration(service_path)); |
| 741 EXPECT_FALSE(test_observer->HasConfigurationInProfile( | 880 EXPECT_FALSE(test_observer->HasConfigurationInProfile( |
| 742 service_path, NetworkProfileHandler::GetSharedProfilePath())); | 881 service_path, NetworkProfileHandler::GetSharedProfilePath())); |
| 743 EXPECT_FALSE( | 882 EXPECT_FALSE( |
| 744 test_observer->HasConfigurationInProfile(service_path, user_profile)); | 883 test_observer->HasConfigurationInProfile(service_path, user_profile)); |
| 745 | 884 |
| 746 network_configuration_handler_->RemoveObserver(test_observer.get()); | 885 network_configuration_handler_->RemoveObserver(test_observer.get()); |
| 747 } | 886 } |
| 748 | 887 |
| 749 } // namespace chromeos | 888 } // namespace chromeos |
| OLD | NEW |