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 "chromeos/network/network_state_handler.h" | 5 #include "chromeos/network/network_state_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 EXPECT_EQ( | 486 EXPECT_EQ( |
487 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, | 487 NetworkStateHandler::TECHNOLOGY_UNAVAILABLE, |
488 network_state_handler_->GetTechnologyState(NetworkTypePattern::Wimax())); | 488 network_state_handler_->GetTechnologyState(NetworkTypePattern::Wimax())); |
489 } | 489 } |
490 | 490 |
491 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { | 491 TEST_F(NetworkStateHandlerTest, ServicePropertyChanged) { |
492 // Set a service property. | 492 // Set a service property. |
493 const std::string eth1 = kShillManagerClientStubDefaultService; | 493 const std::string eth1 = kShillManagerClientStubDefaultService; |
494 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1); | 494 const NetworkState* ethernet = network_state_handler_->GetNetworkState(eth1); |
495 ASSERT_TRUE(ethernet); | 495 ASSERT_TRUE(ethernet); |
496 EXPECT_EQ("", ethernet->security()); | 496 EXPECT_EQ("", ethernet->security_class()); |
497 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1)); | 497 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService(eth1)); |
498 base::StringValue security_value("TestSecurity"); | 498 base::StringValue security_class_value("TestSecurityClass"); |
499 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 499 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
500 dbus::ObjectPath(eth1), | 500 dbus::ObjectPath(eth1), |
501 shill::kSecurityProperty, security_value, | 501 shill::kSecurityClassProperty, security_class_value, |
502 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 502 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
503 message_loop_.RunUntilIdle(); | 503 message_loop_.RunUntilIdle(); |
504 ethernet = network_state_handler_->GetNetworkState(eth1); | 504 ethernet = network_state_handler_->GetNetworkState(eth1); |
505 EXPECT_EQ("TestSecurity", ethernet->security()); | 505 EXPECT_EQ("TestSecurityClass", ethernet->security_class()); |
506 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth1)); | 506 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth1)); |
507 | 507 |
508 // Changing a service to the existing value should not trigger an update. | 508 // Changing a service to the existing value should not trigger an update. |
509 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 509 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
510 dbus::ObjectPath(eth1), | 510 dbus::ObjectPath(eth1), |
511 shill::kSecurityProperty, security_value, | 511 shill::kSecurityClassProperty, security_class_value, |
512 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 512 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
513 message_loop_.RunUntilIdle(); | 513 message_loop_.RunUntilIdle(); |
514 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth1)); | 514 EXPECT_EQ(2, test_observer_->PropertyUpdatesForService(eth1)); |
515 } | 515 } |
516 | 516 |
517 TEST_F(NetworkStateHandlerTest, GetState) { | 517 TEST_F(NetworkStateHandlerTest, GetState) { |
518 const std::string profile = "/profile/profile1"; | 518 const std::string profile = "/profile/profile1"; |
519 const std::string wifi_path = kShillManagerClientStubDefaultWifi; | 519 const std::string wifi_path = kShillManagerClientStubDefaultWifi; |
520 | 520 |
521 // Add a wifi service to a Profile. | 521 // Add a wifi service to a Profile. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 message_loop_.RunUntilIdle(); | 632 message_loop_.RunUntilIdle(); |
633 EXPECT_EQ(shill::kStateReady, | 633 EXPECT_EQ(shill::kStateReady, |
634 test_observer_->default_network_connection_state()); | 634 test_observer_->default_network_connection_state()); |
635 EXPECT_EQ(1u, test_observer_->default_network_change_count()); | 635 EXPECT_EQ(1u, test_observer_->default_network_change_count()); |
636 | 636 |
637 // Updating a property on the default network should trigger | 637 // Updating a property on the default network should trigger |
638 // a default network change. | 638 // a default network change. |
639 test_observer_->reset_change_counts(); | 639 test_observer_->reset_change_counts(); |
640 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 640 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
641 dbus::ObjectPath(wifi1), | 641 dbus::ObjectPath(wifi1), |
642 shill::kSecurityProperty, base::StringValue("TestSecurity"), | 642 shill::kSecurityClassProperty, base::StringValue("TestSecurityClass"), |
643 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 643 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
644 message_loop_.RunUntilIdle(); | 644 message_loop_.RunUntilIdle(); |
645 EXPECT_EQ(1u, test_observer_->default_network_change_count()); | 645 EXPECT_EQ(1u, test_observer_->default_network_change_count()); |
646 | 646 |
647 // No default network updates for signal strength changes. | 647 // No default network updates for signal strength changes. |
648 test_observer_->reset_change_counts(); | 648 test_observer_->reset_change_counts(); |
649 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( | 649 DBusThreadManager::Get()->GetShillServiceClient()->SetProperty( |
650 dbus::ObjectPath(wifi1), | 650 dbus::ObjectPath(wifi1), |
651 shill::kSignalStrengthProperty, base::FundamentalValue(32), | 651 shill::kSignalStrengthProperty, base::FundamentalValue(32), |
652 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); | 652 base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, | 774 kShillManagerClientStubDefaultWifi, shill::kIPConfigProperty, |
775 base::StringValue(kIPConfigPath)); | 775 base::StringValue(kIPConfigPath)); |
776 UpdateManagerProperties(); | 776 UpdateManagerProperties(); |
777 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( | 777 EXPECT_EQ(1, test_observer_->PropertyUpdatesForDevice( |
778 kShillManagerClientStubWifiDevice)); | 778 kShillManagerClientStubWifiDevice)); |
779 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( | 779 EXPECT_EQ(1, test_observer_->PropertyUpdatesForService( |
780 kShillManagerClientStubDefaultWifi)); | 780 kShillManagerClientStubDefaultWifi)); |
781 } | 781 } |
782 | 782 |
783 } // namespace chromeos | 783 } // namespace chromeos |
OLD | NEW |