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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
11 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 11 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 message_loop_.RunUntilIdle(); | 329 message_loop_.RunUntilIdle(); |
330 } | 330 } |
331 | 331 |
332 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { | 332 TEST_F(NetworkConfigurationHandlerTest, CreateConfiguration) { |
333 std::string networkName = "MyNetwork"; | 333 std::string networkName = "MyNetwork"; |
334 std::string key = "SSID"; | 334 std::string key = "SSID"; |
335 std::string profile = "profile path"; | 335 std::string profile = "profile path"; |
336 scoped_ptr<base::StringValue> networkNameValue( | 336 scoped_ptr<base::StringValue> networkNameValue( |
337 base::Value::CreateStringValue(networkName)); | 337 base::Value::CreateStringValue(networkName)); |
338 base::DictionaryValue value; | 338 base::DictionaryValue value; |
339 value.SetWithoutPathExpansion(flimflam::kSSIDProperty, | 339 value.SetWithoutPathExpansion(shill::kSSIDProperty, |
340 base::Value::CreateStringValue(networkName)); | 340 base::Value::CreateStringValue(networkName)); |
341 value.SetWithoutPathExpansion(flimflam::kProfileProperty, | 341 value.SetWithoutPathExpansion(shill::kProfileProperty, |
342 base::Value::CreateStringValue(profile)); | 342 base::Value::CreateStringValue(profile)); |
343 | 343 |
344 EXPECT_CALL(*mock_manager_client_, | 344 EXPECT_CALL(*mock_manager_client_, |
345 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) | 345 ConfigureServiceForProfile(dbus::ObjectPath(profile), _, _, _)) |
346 .WillOnce( | 346 .WillOnce( |
347 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); | 347 Invoke(this, &NetworkConfigurationHandlerTest::OnConfigureService)); |
348 network_configuration_handler_->CreateConfiguration( | 348 network_configuration_handler_->CreateConfiguration( |
349 value, | 349 value, |
350 base::Bind(&StringResultCallback, std::string("/service/2")), | 350 base::Bind(&StringResultCallback, std::string("/service/2")), |
351 base::Bind(&ErrorCallback, false, std::string(""))); | 351 base::Bind(&ErrorCallback, false, std::string(""))); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 TEST_F(NetworkConfigurationHandlerStubTest, StubSetAndClearProperties) { | 493 TEST_F(NetworkConfigurationHandlerStubTest, StubSetAndClearProperties) { |
494 // TODO(stevenjb): Remove dependency on default Stub service. | 494 // TODO(stevenjb): Remove dependency on default Stub service. |
495 const std::string service_path("wifi1"); | 495 const std::string service_path("wifi1"); |
496 const std::string test_identity("test_identity"); | 496 const std::string test_identity("test_identity"); |
497 const std::string test_passphrase("test_passphrase"); | 497 const std::string test_passphrase("test_passphrase"); |
498 | 498 |
499 // Set Properties | 499 // Set Properties |
500 base::DictionaryValue properties_to_set; | 500 base::DictionaryValue properties_to_set; |
501 properties_to_set.SetStringWithoutPathExpansion( | 501 properties_to_set.SetStringWithoutPathExpansion( |
502 flimflam::kIdentityProperty, test_identity); | 502 shill::kIdentityProperty, test_identity); |
503 properties_to_set.SetStringWithoutPathExpansion( | 503 properties_to_set.SetStringWithoutPathExpansion( |
504 flimflam::kPassphraseProperty, test_passphrase); | 504 shill::kPassphraseProperty, test_passphrase); |
505 network_configuration_handler_->SetProperties( | 505 network_configuration_handler_->SetProperties( |
506 service_path, | 506 service_path, |
507 properties_to_set, | 507 properties_to_set, |
508 base::Bind( | 508 base::Bind( |
509 &NetworkConfigurationHandlerStubTest::SuccessCallback, | 509 &NetworkConfigurationHandlerStubTest::SuccessCallback, |
510 base::Unretained(this), "SetProperties"), | 510 base::Unretained(this), "SetProperties"), |
511 base::Bind(&ErrorCallback, false, service_path)); | 511 base::Bind(&ErrorCallback, false, service_path)); |
512 message_loop_.RunUntilIdle(); | 512 message_loop_.RunUntilIdle(); |
513 | 513 |
514 EXPECT_EQ("SetProperties", success_callback_name_); | 514 EXPECT_EQ("SetProperties", success_callback_name_); |
515 std::string identity, passphrase; | 515 std::string identity, passphrase; |
516 EXPECT_TRUE(GetServiceStringProperty( | 516 EXPECT_TRUE(GetServiceStringProperty( |
517 service_path, flimflam::kIdentityProperty, &identity)); | 517 service_path, shill::kIdentityProperty, &identity)); |
518 EXPECT_TRUE(GetServiceStringProperty( | 518 EXPECT_TRUE(GetServiceStringProperty( |
519 service_path, flimflam::kPassphraseProperty, &passphrase)); | 519 service_path, shill::kPassphraseProperty, &passphrase)); |
520 EXPECT_EQ(test_identity, identity); | 520 EXPECT_EQ(test_identity, identity); |
521 EXPECT_EQ(test_passphrase, passphrase); | 521 EXPECT_EQ(test_passphrase, passphrase); |
522 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(service_path)); | 522 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(service_path)); |
523 | 523 |
524 // Clear Properties | 524 // Clear Properties |
525 std::vector<std::string> properties_to_clear; | 525 std::vector<std::string> properties_to_clear; |
526 properties_to_clear.push_back(flimflam::kIdentityProperty); | 526 properties_to_clear.push_back(shill::kIdentityProperty); |
527 properties_to_clear.push_back(flimflam::kPassphraseProperty); | 527 properties_to_clear.push_back(shill::kPassphraseProperty); |
528 network_configuration_handler_->ClearProperties( | 528 network_configuration_handler_->ClearProperties( |
529 service_path, | 529 service_path, |
530 properties_to_clear, | 530 properties_to_clear, |
531 base::Bind( | 531 base::Bind( |
532 &NetworkConfigurationHandlerStubTest::SuccessCallback, | 532 &NetworkConfigurationHandlerStubTest::SuccessCallback, |
533 base::Unretained(this), "ClearProperties"), | 533 base::Unretained(this), "ClearProperties"), |
534 base::Bind(&ErrorCallback, false, service_path)); | 534 base::Bind(&ErrorCallback, false, service_path)); |
535 message_loop_.RunUntilIdle(); | 535 message_loop_.RunUntilIdle(); |
536 | 536 |
537 EXPECT_EQ("ClearProperties", success_callback_name_); | 537 EXPECT_EQ("ClearProperties", success_callback_name_); |
538 EXPECT_FALSE(GetServiceStringProperty( | 538 EXPECT_FALSE(GetServiceStringProperty( |
539 service_path, flimflam::kIdentityProperty, &identity)); | 539 service_path, shill::kIdentityProperty, &identity)); |
540 EXPECT_FALSE(GetServiceStringProperty( | 540 EXPECT_FALSE(GetServiceStringProperty( |
541 service_path, flimflam::kIdentityProperty, &passphrase)); | 541 service_path, shill::kIdentityProperty, &passphrase)); |
542 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(service_path)); | 542 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(service_path)); |
543 } | 543 } |
544 | 544 |
545 TEST_F(NetworkConfigurationHandlerStubTest, StubGetNameFromWifiHex) { | 545 TEST_F(NetworkConfigurationHandlerStubTest, StubGetNameFromWifiHex) { |
546 // TODO(stevenjb): Remove dependency on default Stub service. | 546 // TODO(stevenjb): Remove dependency on default Stub service. |
547 const std::string service_path("wifi1"); | 547 const std::string service_path("wifi1"); |
548 std::string wifi_hex = "5468697320697320484558205353494421"; | 548 std::string wifi_hex = "5468697320697320484558205353494421"; |
549 std::string expected_name = "This is HEX SSID!"; | 549 std::string expected_name = "This is HEX SSID!"; |
550 | 550 |
551 // Set Properties | 551 // Set Properties |
552 base::DictionaryValue properties_to_set; | 552 base::DictionaryValue properties_to_set; |
553 properties_to_set.SetStringWithoutPathExpansion( | 553 properties_to_set.SetStringWithoutPathExpansion( |
554 flimflam::kWifiHexSsid, wifi_hex); | 554 shill::kWifiHexSsid, wifi_hex); |
555 network_configuration_handler_->SetProperties( | 555 network_configuration_handler_->SetProperties( |
556 service_path, | 556 service_path, |
557 properties_to_set, | 557 properties_to_set, |
558 base::Bind(&base::DoNothing), | 558 base::Bind(&base::DoNothing), |
559 base::Bind(&ErrorCallback, false, service_path)); | 559 base::Bind(&ErrorCallback, false, service_path)); |
560 message_loop_.RunUntilIdle(); | 560 message_loop_.RunUntilIdle(); |
561 std::string wifi_hex_result; | 561 std::string wifi_hex_result; |
562 EXPECT_TRUE(GetServiceStringProperty( | 562 EXPECT_TRUE(GetServiceStringProperty( |
563 service_path, flimflam::kWifiHexSsid, &wifi_hex_result)); | 563 service_path, shill::kWifiHexSsid, &wifi_hex_result)); |
564 EXPECT_EQ(wifi_hex, wifi_hex_result); | 564 EXPECT_EQ(wifi_hex, wifi_hex_result); |
565 | 565 |
566 // Get Properties | 566 // Get Properties |
567 network_configuration_handler_->GetProperties( | 567 network_configuration_handler_->GetProperties( |
568 service_path, | 568 service_path, |
569 base::Bind(&NetworkConfigurationHandlerStubTest::GetPropertiesCallback, | 569 base::Bind(&NetworkConfigurationHandlerStubTest::GetPropertiesCallback, |
570 base::Unretained(this)), | 570 base::Unretained(this)), |
571 base::Bind(&ErrorCallback, false, service_path)); | 571 base::Bind(&ErrorCallback, false, service_path)); |
572 message_loop_.RunUntilIdle(); | 572 message_loop_.RunUntilIdle(); |
573 | 573 |
574 EXPECT_EQ(service_path, get_properties_path_); | 574 EXPECT_EQ(service_path, get_properties_path_); |
575 std::string name_result; | 575 std::string name_result; |
576 EXPECT_TRUE(GetReceivedStringProperty( | 576 EXPECT_TRUE(GetReceivedStringProperty( |
577 service_path, flimflam::kNameProperty, &name_result)); | 577 service_path, shill::kNameProperty, &name_result)); |
578 EXPECT_EQ(expected_name, name_result); | 578 EXPECT_EQ(expected_name, name_result); |
579 } | 579 } |
580 | 580 |
581 TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { | 581 TEST_F(NetworkConfigurationHandlerStubTest, StubCreateConfiguration) { |
582 const std::string service_path("test_wifi"); | 582 const std::string service_path("test_wifi"); |
583 base::DictionaryValue properties; | 583 base::DictionaryValue properties; |
| 584 properties.SetStringWithoutPathExpansion(shill::kSSIDProperty, service_path); |
| 585 properties.SetStringWithoutPathExpansion(shill::kNameProperty, service_path); |
| 586 properties.SetStringWithoutPathExpansion(shill::kGuidProperty, service_path); |
584 properties.SetStringWithoutPathExpansion( | 587 properties.SetStringWithoutPathExpansion( |
585 flimflam::kSSIDProperty, service_path); | 588 shill::kTypeProperty, shill::kTypeWifi); |
586 properties.SetStringWithoutPathExpansion( | 589 properties.SetStringWithoutPathExpansion( |
587 flimflam::kNameProperty, service_path); | 590 shill::kStateProperty, shill::kStateIdle); |
588 properties.SetStringWithoutPathExpansion( | 591 properties.SetStringWithoutPathExpansion( |
589 flimflam::kGuidProperty, service_path); | 592 shill::kProfileProperty, shill_stub_helper::kSharedProfilePath); |
590 properties.SetStringWithoutPathExpansion( | |
591 flimflam::kTypeProperty, flimflam::kTypeWifi); | |
592 properties.SetStringWithoutPathExpansion( | |
593 flimflam::kStateProperty, flimflam::kStateIdle); | |
594 properties.SetStringWithoutPathExpansion( | |
595 flimflam::kProfileProperty, shill_stub_helper::kSharedProfilePath); | |
596 | 593 |
597 network_configuration_handler_->CreateConfiguration( | 594 network_configuration_handler_->CreateConfiguration( |
598 properties, | 595 properties, |
599 base::Bind( | 596 base::Bind( |
600 &NetworkConfigurationHandlerStubTest::CreateConfigurationCallback, | 597 &NetworkConfigurationHandlerStubTest::CreateConfigurationCallback, |
601 base::Unretained(this)), | 598 base::Unretained(this)), |
602 base::Bind(&ErrorCallback, false, service_path)); | 599 base::Bind(&ErrorCallback, false, service_path)); |
603 message_loop_.RunUntilIdle(); | 600 message_loop_.RunUntilIdle(); |
604 | 601 |
605 EXPECT_FALSE(create_service_path_.empty()); | 602 EXPECT_FALSE(create_service_path_.empty()); |
606 | 603 |
607 std::string ssid; | 604 std::string ssid; |
608 EXPECT_TRUE(GetServiceStringProperty( | 605 EXPECT_TRUE(GetServiceStringProperty( |
609 create_service_path_, flimflam::kSSIDProperty, &ssid)); | 606 create_service_path_, shill::kSSIDProperty, &ssid)); |
610 std::string actual_profile; | 607 std::string actual_profile; |
611 EXPECT_EQ(service_path, ssid); | 608 EXPECT_EQ(service_path, ssid); |
612 | 609 |
613 EXPECT_TRUE(GetServiceStringProperty( | 610 EXPECT_TRUE(GetServiceStringProperty( |
614 create_service_path_, flimflam::kProfileProperty, &actual_profile)); | 611 create_service_path_, shill::kProfileProperty, &actual_profile)); |
615 EXPECT_EQ(shill_stub_helper::kSharedProfilePath, actual_profile); | 612 EXPECT_EQ(shill_stub_helper::kSharedProfilePath, actual_profile); |
616 } | 613 } |
617 | 614 |
618 } // namespace chromeos | 615 } // namespace chromeos |
OLD | NEW |