Chromium Code Reviews| Index: chromeos/network/network_state_handler_unittest.cc |
| diff --git a/chromeos/network/network_state_handler_unittest.cc b/chromeos/network/network_state_handler_unittest.cc |
| index c0d63259d1a56f2861cf6b9dfb097ff1d516fb6d..849baef1bf360c31bd8d0f29c9491ee0993b98df 100644 |
| --- a/chromeos/network/network_state_handler_unittest.cc |
| +++ b/chromeos/network/network_state_handler_unittest.cc |
| @@ -17,6 +17,7 @@ |
| #include "chromeos/dbus/shill_manager_client.h" |
| #include "chromeos/dbus/shill_profile_client.h" |
| #include "chromeos/dbus/shill_service_client.h" |
| +#include "chromeos/network/favorite_state.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler_observer.h" |
| #include "chromeos/network/shill_property_util.h" |
| @@ -213,6 +214,12 @@ class NetworkStateHandlerTest : public testing::Test { |
| add_to_watchlist); |
| } |
| + void UpdateManagerProperties() { |
| + message_loop_.RunUntilIdle(); |
| + network_state_handler_->UpdateManagerProperties(); |
| + message_loop_.RunUntilIdle(); |
| + } |
| + |
| base::MessageLoopForUI message_loop_; |
| scoped_ptr<NetworkStateHandler> network_state_handler_; |
| scoped_ptr<TestObserver> test_observer_; |
| @@ -349,9 +356,7 @@ TEST_F(NetworkStateHandlerTest, FavoriteState) { |
| ShillProfileClient::TestInterface* profile_test = |
| DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
| EXPECT_TRUE(profile_test->AddService("/profile/default", wifi1)); |
| - message_loop_.RunUntilIdle(); |
| - network_state_handler_->UpdateManagerProperties(); |
| - message_loop_.RunUntilIdle(); |
| + UpdateManagerProperties(); |
| EXPECT_EQ(1u, test_observer_->favorite_count()); |
| } |
| @@ -478,4 +483,39 @@ TEST_F(NetworkStateHandlerTest, RequestUpdate) { |
| kShillManagerClientStubDefaultWireless)); |
| } |
| +TEST_F(NetworkStateHandlerTest, NetworkGuid) { |
|
pneubeck (no reviews)
2014/05/12 13:37:07
you need a second test that does more or less the
stevenjb
2014/05/13 01:19:00
Good point. I added the second test. The "InProfil
|
| + // And a Favorite, ensure it has a GUID. |
| + const std::string wifi_path = "wifi_with_guid"; |
| + service_test_->AddService( |
| + wifi_path, wifi_path, shill::kTypeWifi, shill::kStateOnline, |
| + true /* add_to_visible */, true /* add_to_watchlist */); |
| + ShillProfileClient::TestInterface* profile_test = |
|
pneubeck (no reviews)
2014/05/12 13:37:07
nit: better move this to the test class to make th
stevenjb
2014/05/13 01:19:00
Done.
|
| + DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
| + EXPECT_TRUE(profile_test->AddService("/profile/default", wifi_path)); |
| + UpdateManagerProperties(); |
| + // Verify that a FavoriteState existis with a valid GUID. |
|
pneubeck (no reviews)
2014/05/12 13:37:07
existis -> exists
stevenjb
2014/05/13 01:19:00
Done.
|
| + const FavoriteState* favorite = |
| + network_state_handler_->GetFavoriteState(wifi_path); |
|
pneubeck (no reviews)
2014/05/12 13:37:07
you could also test GetFavoriteStateFromGuid() her
stevenjb
2014/05/13 01:19:00
Added a GetState test
|
| + ASSERT_TRUE(favorite); |
| + std::string wifi_guid = favorite->guid(); |
| + EXPECT_FALSE(wifi_guid.empty()); |
| + // Verify that a NetworkState existis with the same GUID. |
|
pneubeck (no reviews)
2014/05/12 13:37:07
existis -> exists
stevenjb
2014/05/13 01:19:00
Done.
|
| + const NetworkState* network = |
| + network_state_handler_->GetNetworkState(wifi_path); |
| + ASSERT_TRUE(network); |
| + EXPECT_EQ(wifi_guid, network->guid()); |
| + // Remove the service, verify that there is no longer a NetworkState for it. |
| + service_test_->RemoveService(wifi_path); |
|
pneubeck (no reviews)
2014/05/12 13:37:07
I think you're not testing the right thing anymore
stevenjb
2014/05/13 01:19:00
ServiceClientTest::RemoveService does *NOT* remove
pneubeck (no reviews)
2014/05/13 08:43:54
In that case and if the profile isn't removed, sho
stevenjb
2014/05/13 18:25:07
Well, the Fake clients are just an approximation.
pneubeck (no reviews)
2014/05/14 08:46:06
so why the misleading 'out-of-range' comment that
|
| + UpdateManagerProperties(); |
| + EXPECT_FALSE(network_state_handler_->GetNetworkState(wifi_path)); |
| + // Add the service and verify that a NetworkState exists with the same guid. |
| + service_test_->AddService( |
| + wifi_path, wifi_path, shill::kTypeWifi, shill::kStateOnline, |
| + true /* add_to_visible */, true /* add_to_watchlist */); |
| + UpdateManagerProperties(); |
| + network = network_state_handler_->GetNetworkState(wifi_path); |
| + ASSERT_TRUE(network); |
| + EXPECT_EQ(wifi_guid, network->guid()); |
| +} |
| + |
| } // namespace chromeos |