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

Unified Diff: chromeos/components/tether/wifi_hotspot_connector_unittest.cc

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: Created 3 years, 8 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/components/tether/wifi_hotspot_connector_unittest.cc
diff --git a/chromeos/components/tether/wifi_hotspot_connector_unittest.cc b/chromeos/components/tether/wifi_hotspot_connector_unittest.cc
index 9fe074a744ca43ebded6a9ed43f055c5d60588fa..12dc00404eb33064918589d6602b331f921c7e1f 100644
--- a/chromeos/components/tether/wifi_hotspot_connector_unittest.cc
+++ b/chromeos/components/tether/wifi_hotspot_connector_unittest.cc
@@ -13,6 +13,7 @@
#include "base/test/scoped_task_environment.h"
#include "base/timer/mock_timer.h"
#include "base/values.h"
+#include "chromeos/components/tether/fake_active_host.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_service_client.h"
@@ -36,6 +37,8 @@ const char kPassword[] = "password";
const char kOtherWifiServiceGuid[] = "otherWifiServiceGuid";
+const char kDeviceId[] = "deviceId";
+
std::string CreateConfigurationJsonString(const std::string& guid) {
std::stringstream ss;
ss << "{"
@@ -120,9 +123,15 @@ class WifiHotspotConnectorTest : public NetworkStateTest {
SetUpShillState();
test_network_connect_ = base::WrapUnique(new TestNetworkConnect(this));
+ fake_active_host_ = base::WrapUnique(new FakeActiveHost());
Kyle Horimoto 2017/04/17 19:50:04 nit: Use base::MakeUnique<FakeActiveHost>().
lesliewatkins 2017/04/27 00:33:53 Done.
+
+ network_state_handler()->AddTetherNetworkState(kDeviceId, "");
Kyle Horimoto 2017/04/17 19:50:04 You should be passing a tether network GUID, not a
lesliewatkins 2017/04/27 00:33:54 Done.
+
+ fake_active_host_->SetActiveHostConnecting(kDeviceId, kDeviceId);
Kyle Horimoto 2017/04/17 19:50:04 Also pass the GUID here as well. Don't use the sam
lesliewatkins 2017/04/27 00:33:54 Done.
wifi_hotspot_connector_ = base::WrapUnique(new WifiHotspotConnector(
- network_state_handler(), test_network_connect_.get()));
+ network_state_handler(), test_network_connect_.get(),
+ fake_active_host_.get()));
mock_timer_ = new base::MockTimer(true /* retain_user_task */,
false /* is_repeating */);
@@ -202,6 +211,34 @@ class WifiHotspotConnectorTest : public NetworkStateTest {
return wifi_guid;
}
+ void VerifyTetherAndWifiNetworkAssociation(const std::string& wifi_guid) {
+ const NetworkState* wifi_network_state =
+ network_state_handler()->GetNetworkStateFromGuid(wifi_guid);
+ EXPECT_TRUE(wifi_network_state);
+ EXPECT_EQ(fake_active_host_->GetTetherNetworkGuid(),
+ wifi_network_state->tether_guid());
+
+ const NetworkState* tether_network_state =
+ network_state_handler()->GetNetworkStateFromGuid(
+ fake_active_host_->GetTetherNetworkGuid());
+ EXPECT_TRUE(tether_network_state);
+ EXPECT_EQ(wifi_guid, tether_network_state->tether_guid());
+ }
+
+ void VerifyTetherAndWifiNetworkDisassociation(const std::string& wifi_guid) {
Kyle Horimoto 2017/04/17 19:50:04 nit: Rename this to VerifyTetherAndWifiNetworkNotA
lesliewatkins 2017/04/27 00:33:53 Done.
+ const NetworkState* wifi_network_state =
+ network_state_handler()->GetNetworkStateFromGuid(wifi_guid);
+ EXPECT_TRUE(wifi_network_state);
+ EXPECT_NE(fake_active_host_->GetTetherNetworkGuid(),
Kyle Horimoto 2017/04/17 19:50:04 Here, the tether GUID should be "". Assert that th
lesliewatkins 2017/04/27 00:33:53 Done.
lesliewatkins 2017/04/27 00:33:53 Done.
+ wifi_network_state->tether_guid());
+
+ const NetworkState* tether_network_state =
+ network_state_handler()->GetNetworkStateFromGuid(
+ fake_active_host_->GetTetherNetworkGuid());
+ EXPECT_TRUE(tether_network_state);
+ EXPECT_NE(wifi_guid, tether_network_state->tether_guid());
+ }
+
void WifiConnectionCallback(const std::string& wifi_guid) {
connection_callback_responses_.push_back(wifi_guid);
}
@@ -217,6 +254,8 @@ class WifiHotspotConnectorTest : public NetworkStateTest {
std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_;
private:
+ std::unique_ptr<FakeActiveHost> fake_active_host_;
Kyle Horimoto 2017/04/17 19:50:04 Move this up to the protected section underneath t
lesliewatkins 2017/04/27 00:33:53 Done.
+
DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest);
};
@@ -253,6 +292,7 @@ TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) {
// Another network becomes connectable. This should not cause the connection
// to start.
NotifyConnectable(other_wifi_service_path_);
+ VerifyTetherAndWifiNetworkDisassociation(wifi_guid);
EXPECT_EQ("", test_network_connect_->network_id_to_connect());
// Timeout timer fires.
@@ -274,6 +314,7 @@ TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) {
// Network becomes connectable.
NotifyConnectable(test_network_connect_->last_service_path_created());
+ VerifyTetherAndWifiNetworkAssociation(wifi_guid);
EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
// Network connection does not occur.
@@ -297,6 +338,7 @@ TEST_F(WifiHotspotConnectorTest, TestConnect_Success) {
// Network becomes connectable.
NotifyConnectable(test_network_connect_->last_service_path_created());
+ VerifyTetherAndWifiNetworkAssociation(wifi_guid);
EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
EXPECT_EQ(0u, connection_callback_responses_.size());
@@ -318,6 +360,7 @@ TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) {
// Network becomes connectable.
NotifyConnectable(test_network_connect_->last_service_path_created());
+ VerifyTetherAndWifiNetworkAssociation(wifi_guid);
EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
EXPECT_EQ(0u, connection_callback_responses_.size());
@@ -362,6 +405,7 @@ TEST_F(WifiHotspotConnectorTest,
// First network becomes connectable.
NotifyConnectable(service_path1);
+ VerifyTetherAndWifiNetworkDisassociation(wifi_guid1);
// A connection should not have started to that GUID.
EXPECT_EQ("", test_network_connect_->network_id_to_connect());
@@ -369,6 +413,7 @@ TEST_F(WifiHotspotConnectorTest,
// Second network becomes connectable.
NotifyConnectable(service_path2);
+ VerifyTetherAndWifiNetworkAssociation(wifi_guid2);
EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
EXPECT_EQ(1u, connection_callback_responses_.size());

Powered by Google App Engine
This is Rietveld 408576698