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

Side by Side Diff: chromeos/components/tether/wifi_hotspot_connector_unittest.cc

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: khorimoto@ comments Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/components/tether/wifi_hotspot_connector.h" 5 #include "chromeos/components/tether/wifi_hotspot_connector.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 18 matching lines...) Expand all
29 29
30 namespace tether { 30 namespace tether {
31 31
32 namespace { 32 namespace {
33 33
34 const char kSsid[] = "ssid"; 34 const char kSsid[] = "ssid";
35 const char kPassword[] = "password"; 35 const char kPassword[] = "password";
36 36
37 const char kOtherWifiServiceGuid[] = "otherWifiServiceGuid"; 37 const char kOtherWifiServiceGuid[] = "otherWifiServiceGuid";
38 38
39 const char kTetherNetworkGuid[] = "tetherNetworkGuid";
40 const char kTetherNetworkGuid2[] = "tetherNetworkGuid2";
41
39 std::string CreateConfigurationJsonString(const std::string& guid) { 42 std::string CreateConfigurationJsonString(const std::string& guid) {
40 std::stringstream ss; 43 std::stringstream ss;
41 ss << "{" 44 ss << "{"
42 << " \"GUID\": \"" << guid << "\"," 45 << " \"GUID\": \"" << guid << "\","
43 << " \"Type\": \"" << shill::kTypeWifi << "\"," 46 << " \"Type\": \"" << shill::kTypeWifi << "\","
44 << " \"State\": \"" << shill::kStateIdle << "\"" 47 << " \"State\": \"" << shill::kStateIdle << "\""
45 << "}"; 48 << "}";
46 return ss.str(); 49 return ss.str();
47 } 50 }
48 51
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 112
110 WifiHotspotConnectorTest() {} 113 WifiHotspotConnectorTest() {}
111 ~WifiHotspotConnectorTest() override {} 114 ~WifiHotspotConnectorTest() override {}
112 115
113 void SetUp() override { 116 void SetUp() override {
114 other_wifi_service_path_.clear(); 117 other_wifi_service_path_.clear();
115 connection_callback_responses_.clear(); 118 connection_callback_responses_.clear();
116 119
117 DBusThreadManager::Initialize(); 120 DBusThreadManager::Initialize();
118 NetworkStateTest::SetUp(); 121 NetworkStateTest::SetUp();
122 network_state_handler()->SetTetherTechnologyState(
123 NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED);
124
119 SetUpShillState(); 125 SetUpShillState();
120 126
121 test_network_connect_ = base::WrapUnique(new TestNetworkConnect(this)); 127 test_network_connect_ = base::WrapUnique(new TestNetworkConnect(this));
122 128
129 network_state_handler()->AddTetherNetworkState(
130 kTetherNetworkGuid, "tetherNetworkName" /* name */,
131 "tetherNetworkCarrier" /* carrier */, 100 /* full battery */,
132 100 /* full signal strength */, false /* has_connected_to_host */);
133
134 network_state_handler()->AddTetherNetworkState(
135 kTetherNetworkGuid2, "tetherNetworkName2" /* name */,
136 "tetherNetworkCarrier2" /* carrier */, 100 /* full battery */,
137 100 /* full signal strength */, false /* has_connected_to_host */);
138
123 wifi_hotspot_connector_ = base::WrapUnique(new WifiHotspotConnector( 139 wifi_hotspot_connector_ = base::WrapUnique(new WifiHotspotConnector(
124 network_state_handler(), test_network_connect_.get())); 140 network_state_handler(), test_network_connect_.get()));
125 141
126 mock_timer_ = new base::MockTimer(true /* retain_user_task */, 142 mock_timer_ = new base::MockTimer(true /* retain_user_task */,
127 false /* is_repeating */); 143 false /* is_repeating */);
128 wifi_hotspot_connector_->SetTimerForTest(base::WrapUnique(mock_timer_)); 144 wifi_hotspot_connector_->SetTimerForTest(base::WrapUnique(mock_timer_));
129 } 145 }
130 146
131 void SetUpShillState() { 147 void SetUpShillState() {
132 // Add a Wi-Fi service unrelated to the one under test. In some tests, a 148 // Add a Wi-Fi service unrelated to the one under test. In some tests, a
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 last_configuration->GetString(shill::kPassphraseProperty, &password)); 210 last_configuration->GetString(shill::kPassphraseProperty, &password));
195 EXPECT_EQ(expected_password, password); 211 EXPECT_EQ(expected_password, password);
196 } 212 }
197 213
198 std::string wifi_guid; 214 std::string wifi_guid;
199 EXPECT_TRUE( 215 EXPECT_TRUE(
200 last_configuration->GetString(shill::kGuidProperty, &wifi_guid)); 216 last_configuration->GetString(shill::kGuidProperty, &wifi_guid));
201 return wifi_guid; 217 return wifi_guid;
202 } 218 }
203 219
220 void VerifyTetherAndWifiNetworkAssociation(const std::string& wifi_guid,
221 const std::string& tether_guid) {
222 const NetworkState* wifi_network_state =
223 network_state_handler()->GetNetworkStateFromGuid(wifi_guid);
224 ASSERT_TRUE(wifi_network_state);
225 EXPECT_EQ(tether_guid, wifi_network_state->tether_guid());
226
227 const NetworkState* tether_network_state =
228 network_state_handler()->GetNetworkStateFromGuid(tether_guid);
229 ASSERT_TRUE(tether_network_state);
230 EXPECT_EQ(wifi_guid, tether_network_state->tether_guid());
231 }
232
233 void VerifyNetworkNotAssociated(const std::string& guid) {
234 const NetworkState* network_state =
235 network_state_handler()->GetNetworkStateFromGuid(guid);
236 ASSERT_TRUE(network_state);
237 // EXPECT_TRUE(network_state->tether_guid().empty());
Kyle Horimoto 2017/05/03 01:53:34 Use this, delete the line below.
lesliewatkins 2017/05/03 22:00:24 Done.
238 EXPECT_EQ(network_state->tether_guid(), std::string());
239 }
240
204 void WifiConnectionCallback(const std::string& wifi_guid) { 241 void WifiConnectionCallback(const std::string& wifi_guid) {
205 connection_callback_responses_.push_back(wifi_guid); 242 connection_callback_responses_.push_back(wifi_guid);
206 } 243 }
207 244
208 base::test::ScopedTaskEnvironment scoped_task_environment_; 245 base::test::ScopedTaskEnvironment scoped_task_environment_;
209 246
210 std::string other_wifi_service_path_; 247 std::string other_wifi_service_path_;
211 std::vector<std::string> connection_callback_responses_; 248 std::vector<std::string> connection_callback_responses_;
212 249
213 base::MockTimer* mock_timer_; 250 base::MockTimer* mock_timer_;
214 std::unique_ptr<TestNetworkConnect> test_network_connect_; 251 std::unique_ptr<TestNetworkConnect> test_network_connect_;
215 252
216 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; 253 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_;
217 254
218 private: 255 private:
219 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest); 256 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest);
220 }; 257 };
221 258
222 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) { 259 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) {
223 wifi_hotspot_connector_->ConnectToWifiHotspot( 260 wifi_hotspot_connector_->ConnectToWifiHotspot(
224 std::string(kSsid), std::string(kPassword), 261 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
225 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 262 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
226 base::Unretained(this))); 263 base::Unretained(this)));
227 264
228 std::string wifi_guid = 265 std::string wifi_guid =
229 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 266 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
230 EXPECT_FALSE(wifi_guid.empty()); 267 EXPECT_FALSE(wifi_guid.empty());
231 268
232 // Network does not become connectable. 269 // Network does not become connectable.
233 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 270 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
234 271
235 // Timeout timer fires. 272 // Timeout timer fires.
236 EXPECT_EQ(0u, connection_callback_responses_.size()); 273 EXPECT_EQ(0u, connection_callback_responses_.size());
237 InvokeTimerTask(); 274 InvokeTimerTask();
238 EXPECT_EQ(1u, connection_callback_responses_.size()); 275 EXPECT_EQ(1u, connection_callback_responses_.size());
239 EXPECT_EQ("", connection_callback_responses_[0]); 276 EXPECT_EQ("", connection_callback_responses_[0]);
240 } 277 }
241 278
242 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) { 279 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) {
243 wifi_hotspot_connector_->ConnectToWifiHotspot( 280 wifi_hotspot_connector_->ConnectToWifiHotspot(
244 std::string(kSsid), std::string(kPassword), 281 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
245 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 282 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
246 base::Unretained(this))); 283 base::Unretained(this)));
247 284
248 std::string wifi_guid = 285 std::string wifi_guid =
249 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 286 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
250 EXPECT_FALSE(wifi_guid.empty()); 287 EXPECT_FALSE(wifi_guid.empty());
251 288
252 // Another network becomes connectable. This should not cause the connection 289 // Another network becomes connectable. This should not cause the connection
253 // to start. 290 // to start.
254 NotifyConnectable(other_wifi_service_path_); 291 NotifyConnectable(other_wifi_service_path_);
292 VerifyNetworkNotAssociated(wifi_guid);
293 std::string other_wifi_guid = network_state_handler()
294 ->GetNetworkState(other_wifi_service_path_)
295 ->guid();
296 VerifyNetworkNotAssociated(other_wifi_guid);
255 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 297 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
256 298
257 // Timeout timer fires. 299 // Timeout timer fires.
258 EXPECT_EQ(0u, connection_callback_responses_.size()); 300 EXPECT_EQ(0u, connection_callback_responses_.size());
259 InvokeTimerTask(); 301 InvokeTimerTask();
260 EXPECT_EQ(1u, connection_callback_responses_.size()); 302 EXPECT_EQ(1u, connection_callback_responses_.size());
261 EXPECT_EQ("", connection_callback_responses_[0]); 303 EXPECT_EQ("", connection_callback_responses_[0]);
262 } 304 }
263 305
264 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) { 306 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) {
265 wifi_hotspot_connector_->ConnectToWifiHotspot( 307 wifi_hotspot_connector_->ConnectToWifiHotspot(
266 std::string(kSsid), std::string(kPassword), 308 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
267 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 309 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
268 base::Unretained(this))); 310 base::Unretained(this)));
269 311
270 std::string wifi_guid = 312 std::string wifi_guid =
271 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 313 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
272 EXPECT_FALSE(wifi_guid.empty()); 314 EXPECT_FALSE(wifi_guid.empty());
273 315
274 // Network becomes connectable. 316 // Network becomes connectable.
275 NotifyConnectable(test_network_connect_->last_service_path_created()); 317 NotifyConnectable(test_network_connect_->last_service_path_created());
318 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
276 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 319 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
277 320
278 // Network connection does not occur. 321 // Network connection does not occur.
279 EXPECT_EQ(0u, connection_callback_responses_.size()); 322 EXPECT_EQ(0u, connection_callback_responses_.size());
280 323
281 // Timeout timer fires. 324 // Timeout timer fires.
282 InvokeTimerTask(); 325 InvokeTimerTask();
283 EXPECT_EQ(1u, connection_callback_responses_.size()); 326 EXPECT_EQ(1u, connection_callback_responses_.size());
284 EXPECT_EQ("", connection_callback_responses_[0]); 327 EXPECT_EQ("", connection_callback_responses_[0]);
285 } 328 }
286 329
287 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) { 330 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) {
288 wifi_hotspot_connector_->ConnectToWifiHotspot( 331 wifi_hotspot_connector_->ConnectToWifiHotspot(
289 std::string(kSsid), std::string(kPassword), 332 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
290 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 333 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
291 base::Unretained(this))); 334 base::Unretained(this)));
292 335
293 std::string wifi_guid = 336 std::string wifi_guid =
294 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 337 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
295 EXPECT_FALSE(wifi_guid.empty()); 338 EXPECT_FALSE(wifi_guid.empty());
296 339
297 // Network becomes connectable. 340 // Network becomes connectable.
298 NotifyConnectable(test_network_connect_->last_service_path_created()); 341 NotifyConnectable(test_network_connect_->last_service_path_created());
342 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
299 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 343 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
300 EXPECT_EQ(0u, connection_callback_responses_.size()); 344 EXPECT_EQ(0u, connection_callback_responses_.size());
301 345
302 // Connection to network successful. 346 // Connection to network successful.
303 NotifyConnected(test_network_connect_->last_service_path_created()); 347 NotifyConnected(test_network_connect_->last_service_path_created());
304 EXPECT_EQ(1u, connection_callback_responses_.size()); 348 EXPECT_EQ(1u, connection_callback_responses_.size());
305 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 349 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
306 VerifyTimerStopped(); 350 VerifyTimerStopped();
307 } 351 }
308 352
309 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) { 353 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) {
310 wifi_hotspot_connector_->ConnectToWifiHotspot( 354 wifi_hotspot_connector_->ConnectToWifiHotspot(
311 std::string(kSsid), "", 355 std::string(kSsid), "" /* password */, kTetherNetworkGuid,
312 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 356 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
313 base::Unretained(this))); 357 base::Unretained(this)));
314 358
315 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), ""); 359 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), "");
316 EXPECT_FALSE(wifi_guid.empty()); 360 EXPECT_FALSE(wifi_guid.empty());
317 361
318 // Network becomes connectable. 362 // Network becomes connectable.
319 NotifyConnectable(test_network_connect_->last_service_path_created()); 363 NotifyConnectable(test_network_connect_->last_service_path_created());
364 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
320 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 365 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
321 EXPECT_EQ(0u, connection_callback_responses_.size()); 366 EXPECT_EQ(0u, connection_callback_responses_.size());
322 367
323 // Connection to network successful. 368 // Connection to network successful.
324 NotifyConnected(test_network_connect_->last_service_path_created()); 369 NotifyConnected(test_network_connect_->last_service_path_created());
325 EXPECT_EQ(1u, connection_callback_responses_.size()); 370 EXPECT_EQ(1u, connection_callback_responses_.size());
326 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 371 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
327 VerifyTimerStopped(); 372 VerifyTimerStopped();
328 } 373 }
329 374
330 TEST_F(WifiHotspotConnectorTest, 375 TEST_F(WifiHotspotConnectorTest,
331 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) { 376 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) {
332 wifi_hotspot_connector_->ConnectToWifiHotspot( 377 wifi_hotspot_connector_->ConnectToWifiHotspot(
333 "ssid1", "password1", 378 "ssid1", "password1", "tetherNetworkGuid1",
334 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 379 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
335 base::Unretained(this))); 380 base::Unretained(this)));
336 381
337 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1"); 382 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
338 EXPECT_FALSE(wifi_guid1.empty()); 383 EXPECT_FALSE(wifi_guid1.empty());
339 std::string service_path1 = 384 std::string service_path1 =
340 test_network_connect_->last_service_path_created(); 385 test_network_connect_->last_service_path_created();
341 EXPECT_FALSE(service_path1.empty()); 386 EXPECT_FALSE(service_path1.empty());
342 387
343 // Before network becomes connectable, start the new connection. 388 // Before network becomes connectable, start the new connection.
344 EXPECT_EQ(0u, connection_callback_responses_.size()); 389 EXPECT_EQ(0u, connection_callback_responses_.size());
345 wifi_hotspot_connector_->ConnectToWifiHotspot( 390 wifi_hotspot_connector_->ConnectToWifiHotspot(
346 "ssid2", "password2", 391 "ssid2", "password2", kTetherNetworkGuid2,
347 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 392 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
348 base::Unretained(this))); 393 base::Unretained(this)));
349 394
350 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2"); 395 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
351 EXPECT_FALSE(wifi_guid2.empty()); 396 EXPECT_FALSE(wifi_guid2.empty());
352 std::string service_path2 = 397 std::string service_path2 =
353 test_network_connect_->last_service_path_created(); 398 test_network_connect_->last_service_path_created();
354 EXPECT_FALSE(service_path2.empty()); 399 EXPECT_FALSE(service_path2.empty());
355 400
356 EXPECT_NE(service_path1, service_path2); 401 EXPECT_NE(service_path1, service_path2);
357 402
358 // The original connection attempt should have gotten a "" response. 403 // The original connection attempt should have gotten a "" response.
359 EXPECT_EQ(1u, connection_callback_responses_.size()); 404 EXPECT_EQ(1u, connection_callback_responses_.size());
360 EXPECT_EQ("", connection_callback_responses_[0]); 405 EXPECT_EQ("", connection_callback_responses_[0]);
361 406
362 // First network becomes connectable. 407 // First network becomes connectable.
363 NotifyConnectable(service_path1); 408 NotifyConnectable(service_path1);
409 VerifyNetworkNotAssociated(wifi_guid1);
Kyle Horimoto 2017/05/03 01:53:33 You can move this to just below the "EXPECT_FALSE(
lesliewatkins 2017/05/03 22:00:24 Done.
364 410
365 // A connection should not have started to that GUID. 411 // A connection should not have started to that GUID.
366 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 412 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
367 EXPECT_EQ(1u, connection_callback_responses_.size()); 413 EXPECT_EQ(1u, connection_callback_responses_.size());
368 414
369 // Second network becomes connectable. 415 // Second network becomes connectable.
370 NotifyConnectable(service_path2); 416 NotifyConnectable(service_path2);
417 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
371 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect()); 418 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
372 EXPECT_EQ(1u, connection_callback_responses_.size()); 419 EXPECT_EQ(1u, connection_callback_responses_.size());
373 420
421 // Connection to network successful.
422 NotifyConnected(service_path2);
423 EXPECT_EQ(2u, connection_callback_responses_.size());
424 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
425 VerifyTimerStopped();
426 }
427
428 TEST_F(WifiHotspotConnectorTest,
429 TestConnect_SecondConnectionWhileWaitingForFirstToConnect) {
430 wifi_hotspot_connector_->ConnectToWifiHotspot(
431 "ssid1", "password1", kTetherNetworkGuid,
432 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
433 base::Unretained(this)));
434
435 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
436 EXPECT_FALSE(wifi_guid1.empty());
437 std::string service_path1 =
438 test_network_connect_->last_service_path_created();
439 EXPECT_FALSE(service_path1.empty());
440
441 // First network becomes connectable.
442 NotifyConnectable(service_path1);
443 VerifyTetherAndWifiNetworkAssociation(wifi_guid1, kTetherNetworkGuid);
444
445 // After network becomes connectable, request a connection to second network.
446 wifi_hotspot_connector_->ConnectToWifiHotspot(
447 "ssid2", "password2", kTetherNetworkGuid2,
448 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
449 base::Unretained(this)));
450
451 // Disassocciate first network from Tether network.
Kyle Horimoto 2017/05/03 01:53:33 nit: The way you word this makes it seem like the
lesliewatkins 2017/05/03 22:00:24 Done.
452 VerifyNetworkNotAssociated(kTetherNetworkGuid);
453 VerifyNetworkNotAssociated(wifi_guid1);
454
455 // The original connection attempt should have gotten a "" response.
456 EXPECT_EQ(1u, connection_callback_responses_.size());
457 EXPECT_EQ("", connection_callback_responses_[0]);
458
459 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
460 EXPECT_FALSE(wifi_guid2.empty());
461 std::string service_path2 =
462 test_network_connect_->last_service_path_created();
463 EXPECT_FALSE(service_path2.empty());
464
465 EXPECT_NE(service_path1, service_path2);
466
467 // Second network becomes connectable.
468 NotifyConnectable(service_path2);
469 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
470 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
471 EXPECT_EQ(1u, connection_callback_responses_.size());
472
374 // Connection to network successful. 473 // Connection to network successful.
375 NotifyConnected(service_path2); 474 NotifyConnected(service_path2);
376 EXPECT_EQ(2u, connection_callback_responses_.size()); 475 EXPECT_EQ(2u, connection_callback_responses_.size());
377 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]); 476 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
378 VerifyTimerStopped(); 477 VerifyTimerStopped();
379 } 478 }
380 479
381 } // namespace tether 480 } // namespace tether
382 481
383 } // namespace chromeos 482 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698