Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: chromeos/network/network_state_handler_unittest.cc

Issue 275543005: Use GUID instead of ServicePath in networkingPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {
+ // 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 =
+ DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
+ EXPECT_TRUE(profile_test->AddService("/profile/default", wifi_path));
+ UpdateManagerProperties();
+ // Verify that a FavoriteState existis with a valid GUID.
+ const FavoriteState* favorite =
+ network_state_handler_->GetFavoriteState(wifi_path);
+ ASSERT_TRUE(favorite);
+ std::string wifi_guid = favorite->guid();
+ EXPECT_FALSE(wifi_guid.empty());
+ // Verify that a NetworkState existis with the same GUID.
+ 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);
+ 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

Powered by Google App Engine
This is Rietveld 408576698