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

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@ and hansberry@ 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, "" /* name */, "" /* carrier */,
Kyle Horimoto 2017/04/28 22:07:29 nit: Pass a name like "tetherNetworkName1" instead
lesliewatkins 2017/04/29 00:57:54 Done.
131 100 /* full battery */, 100 /* full signal strength */);
132
133 network_state_handler()->AddTetherNetworkState(
134 kTetherNetworkGuid2, "" /* name */, "" /* carrier */,
135 100 /* full battery */, 100 /* full signal strength */);
136
123 wifi_hotspot_connector_ = base::WrapUnique(new WifiHotspotConnector( 137 wifi_hotspot_connector_ = base::WrapUnique(new WifiHotspotConnector(
124 network_state_handler(), test_network_connect_.get())); 138 network_state_handler(), test_network_connect_.get()));
125 139
126 mock_timer_ = new base::MockTimer(true /* retain_user_task */, 140 mock_timer_ = new base::MockTimer(true /* retain_user_task */,
127 false /* is_repeating */); 141 false /* is_repeating */);
128 wifi_hotspot_connector_->SetTimerForTest(base::WrapUnique(mock_timer_)); 142 wifi_hotspot_connector_->SetTimerForTest(base::WrapUnique(mock_timer_));
129 } 143 }
130 144
131 void SetUpShillState() { 145 void SetUpShillState() {
132 // Add a Wi-Fi service unrelated to the one under test. In some tests, a 146 // 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)); 208 last_configuration->GetString(shill::kPassphraseProperty, &password));
195 EXPECT_EQ(expected_password, password); 209 EXPECT_EQ(expected_password, password);
196 } 210 }
197 211
198 std::string wifi_guid; 212 std::string wifi_guid;
199 EXPECT_TRUE( 213 EXPECT_TRUE(
200 last_configuration->GetString(shill::kGuidProperty, &wifi_guid)); 214 last_configuration->GetString(shill::kGuidProperty, &wifi_guid));
201 return wifi_guid; 215 return wifi_guid;
202 } 216 }
203 217
218 void VerifyTetherAndWifiNetworkAssociation(const std::string& wifi_guid,
219 const std::string& tether_guid) {
220 const NetworkState* wifi_network_state =
221 network_state_handler()->GetNetworkStateFromGuid(wifi_guid);
222 ASSERT_TRUE(wifi_network_state);
223 EXPECT_EQ(tether_guid, wifi_network_state->tether_guid());
224
225 const NetworkState* tether_network_state =
226 network_state_handler()->GetNetworkStateFromGuid(tether_guid);
227 ASSERT_TRUE(tether_network_state);
228 EXPECT_EQ(wifi_guid, tether_network_state->tether_guid());
229 }
230
231 void VerifyWifiNetworkNotAssociated(const std::string& wifi_guid) {
232 const NetworkState* wifi_network_state =
233 network_state_handler()->GetNetworkStateFromGuid(wifi_guid);
234 ASSERT_TRUE(wifi_network_state);
235 EXPECT_TRUE(wifi_network_state->tether_guid().empty());
236 }
237
204 void WifiConnectionCallback(const std::string& wifi_guid) { 238 void WifiConnectionCallback(const std::string& wifi_guid) {
205 connection_callback_responses_.push_back(wifi_guid); 239 connection_callback_responses_.push_back(wifi_guid);
206 } 240 }
207 241
208 base::test::ScopedTaskEnvironment scoped_task_environment_; 242 base::test::ScopedTaskEnvironment scoped_task_environment_;
209 243
210 std::string other_wifi_service_path_; 244 std::string other_wifi_service_path_;
211 std::vector<std::string> connection_callback_responses_; 245 std::vector<std::string> connection_callback_responses_;
212 246
213 base::MockTimer* mock_timer_; 247 base::MockTimer* mock_timer_;
214 std::unique_ptr<TestNetworkConnect> test_network_connect_; 248 std::unique_ptr<TestNetworkConnect> test_network_connect_;
215 249
216 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; 250 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_;
217 251
218 private: 252 private:
219 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest); 253 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest);
220 }; 254 };
221 255
222 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) { 256 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) {
223 wifi_hotspot_connector_->ConnectToWifiHotspot( 257 wifi_hotspot_connector_->ConnectToWifiHotspot(
224 std::string(kSsid), std::string(kPassword), 258 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
225 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 259 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
226 base::Unretained(this))); 260 base::Unretained(this)));
227 261
228 std::string wifi_guid = 262 std::string wifi_guid =
229 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 263 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
230 EXPECT_FALSE(wifi_guid.empty()); 264 EXPECT_FALSE(wifi_guid.empty());
231 265
232 // Network does not become connectable. 266 // Network does not become connectable.
233 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 267 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
234 268
235 // Timeout timer fires. 269 // Timeout timer fires.
236 EXPECT_EQ(0u, connection_callback_responses_.size()); 270 EXPECT_EQ(0u, connection_callback_responses_.size());
237 InvokeTimerTask(); 271 InvokeTimerTask();
238 EXPECT_EQ(1u, connection_callback_responses_.size()); 272 EXPECT_EQ(1u, connection_callback_responses_.size());
239 EXPECT_EQ("", connection_callback_responses_[0]); 273 EXPECT_EQ("", connection_callback_responses_[0]);
240 } 274 }
241 275
242 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) { 276 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) {
243 wifi_hotspot_connector_->ConnectToWifiHotspot( 277 wifi_hotspot_connector_->ConnectToWifiHotspot(
244 std::string(kSsid), std::string(kPassword), 278 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
245 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 279 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
246 base::Unretained(this))); 280 base::Unretained(this)));
247 281
248 std::string wifi_guid = 282 std::string wifi_guid =
249 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 283 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
250 EXPECT_FALSE(wifi_guid.empty()); 284 EXPECT_FALSE(wifi_guid.empty());
251 285
252 // Another network becomes connectable. This should not cause the connection 286 // Another network becomes connectable. This should not cause the connection
253 // to start. 287 // to start.
254 NotifyConnectable(other_wifi_service_path_); 288 NotifyConnectable(other_wifi_service_path_);
289 VerifyWifiNetworkNotAssociated(wifi_guid);
290 std::string other_wifi_guid = network_state_handler()
291 ->GetNetworkState(other_wifi_service_path_)
292 ->guid();
293 VerifyWifiNetworkNotAssociated(other_wifi_guid);
255 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 294 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
256 295
257 // Timeout timer fires. 296 // Timeout timer fires.
258 EXPECT_EQ(0u, connection_callback_responses_.size()); 297 EXPECT_EQ(0u, connection_callback_responses_.size());
259 InvokeTimerTask(); 298 InvokeTimerTask();
260 EXPECT_EQ(1u, connection_callback_responses_.size()); 299 EXPECT_EQ(1u, connection_callback_responses_.size());
261 EXPECT_EQ("", connection_callback_responses_[0]); 300 EXPECT_EQ("", connection_callback_responses_[0]);
262 } 301 }
263 302
264 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) { 303 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) {
265 wifi_hotspot_connector_->ConnectToWifiHotspot( 304 wifi_hotspot_connector_->ConnectToWifiHotspot(
266 std::string(kSsid), std::string(kPassword), 305 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
267 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 306 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
268 base::Unretained(this))); 307 base::Unretained(this)));
269 308
270 std::string wifi_guid = 309 std::string wifi_guid =
271 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 310 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
272 EXPECT_FALSE(wifi_guid.empty()); 311 EXPECT_FALSE(wifi_guid.empty());
273 312
274 // Network becomes connectable. 313 // Network becomes connectable.
275 NotifyConnectable(test_network_connect_->last_service_path_created()); 314 NotifyConnectable(test_network_connect_->last_service_path_created());
315 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
276 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 316 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
277 317
278 // Network connection does not occur. 318 // Network connection does not occur.
279 EXPECT_EQ(0u, connection_callback_responses_.size()); 319 EXPECT_EQ(0u, connection_callback_responses_.size());
280 320
281 // Timeout timer fires. 321 // Timeout timer fires.
282 InvokeTimerTask(); 322 InvokeTimerTask();
283 EXPECT_EQ(1u, connection_callback_responses_.size()); 323 EXPECT_EQ(1u, connection_callback_responses_.size());
284 EXPECT_EQ("", connection_callback_responses_[0]); 324 EXPECT_EQ("", connection_callback_responses_[0]);
285 } 325 }
286 326
287 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) { 327 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) {
288 wifi_hotspot_connector_->ConnectToWifiHotspot( 328 wifi_hotspot_connector_->ConnectToWifiHotspot(
289 std::string(kSsid), std::string(kPassword), 329 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
290 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 330 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
291 base::Unretained(this))); 331 base::Unretained(this)));
292 332
293 std::string wifi_guid = 333 std::string wifi_guid =
294 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 334 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
295 EXPECT_FALSE(wifi_guid.empty()); 335 EXPECT_FALSE(wifi_guid.empty());
296 336
297 // Network becomes connectable. 337 // Network becomes connectable.
298 NotifyConnectable(test_network_connect_->last_service_path_created()); 338 NotifyConnectable(test_network_connect_->last_service_path_created());
339 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
299 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 340 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
300 EXPECT_EQ(0u, connection_callback_responses_.size()); 341 EXPECT_EQ(0u, connection_callback_responses_.size());
301 342
302 // Connection to network successful. 343 // Connection to network successful.
303 NotifyConnected(test_network_connect_->last_service_path_created()); 344 NotifyConnected(test_network_connect_->last_service_path_created());
304 EXPECT_EQ(1u, connection_callback_responses_.size()); 345 EXPECT_EQ(1u, connection_callback_responses_.size());
305 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 346 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
306 VerifyTimerStopped(); 347 VerifyTimerStopped();
307 } 348 }
308 349
309 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) { 350 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) {
310 wifi_hotspot_connector_->ConnectToWifiHotspot( 351 wifi_hotspot_connector_->ConnectToWifiHotspot(
311 std::string(kSsid), "", 352 std::string(kSsid), "", kTetherNetworkGuid,
Kyle Horimoto 2017/04/28 22:07:29 nit: Add /* password */ after "".
lesliewatkins 2017/04/29 00:57:54 Done.
312 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 353 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
313 base::Unretained(this))); 354 base::Unretained(this)));
314 355
315 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), ""); 356 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), "");
316 EXPECT_FALSE(wifi_guid.empty()); 357 EXPECT_FALSE(wifi_guid.empty());
317 358
318 // Network becomes connectable. 359 // Network becomes connectable.
319 NotifyConnectable(test_network_connect_->last_service_path_created()); 360 NotifyConnectable(test_network_connect_->last_service_path_created());
361 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
320 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 362 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
321 EXPECT_EQ(0u, connection_callback_responses_.size()); 363 EXPECT_EQ(0u, connection_callback_responses_.size());
322 364
323 // Connection to network successful. 365 // Connection to network successful.
324 NotifyConnected(test_network_connect_->last_service_path_created()); 366 NotifyConnected(test_network_connect_->last_service_path_created());
325 EXPECT_EQ(1u, connection_callback_responses_.size()); 367 EXPECT_EQ(1u, connection_callback_responses_.size());
326 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 368 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
327 VerifyTimerStopped(); 369 VerifyTimerStopped();
328 } 370 }
329 371
330 TEST_F(WifiHotspotConnectorTest, 372 TEST_F(WifiHotspotConnectorTest,
331 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) { 373 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) {
332 wifi_hotspot_connector_->ConnectToWifiHotspot( 374 wifi_hotspot_connector_->ConnectToWifiHotspot(
333 "ssid1", "password1", 375 "ssid1", "password1", "tetherNetworkGuid1",
334 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 376 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
335 base::Unretained(this))); 377 base::Unretained(this)));
336 378
337 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1"); 379 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
338 EXPECT_FALSE(wifi_guid1.empty()); 380 EXPECT_FALSE(wifi_guid1.empty());
339 std::string service_path1 = 381 std::string service_path1 =
340 test_network_connect_->last_service_path_created(); 382 test_network_connect_->last_service_path_created();
341 EXPECT_FALSE(service_path1.empty()); 383 EXPECT_FALSE(service_path1.empty());
342 384
343 // Before network becomes connectable, start the new connection. 385 // Before network becomes connectable, start the new connection.
344 EXPECT_EQ(0u, connection_callback_responses_.size()); 386 EXPECT_EQ(0u, connection_callback_responses_.size());
345 wifi_hotspot_connector_->ConnectToWifiHotspot( 387 wifi_hotspot_connector_->ConnectToWifiHotspot(
346 "ssid2", "password2", 388 "ssid2", "password2", kTetherNetworkGuid2,
347 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 389 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
348 base::Unretained(this))); 390 base::Unretained(this)));
349 391
350 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2"); 392 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
351 EXPECT_FALSE(wifi_guid2.empty()); 393 EXPECT_FALSE(wifi_guid2.empty());
352 std::string service_path2 = 394 std::string service_path2 =
353 test_network_connect_->last_service_path_created(); 395 test_network_connect_->last_service_path_created();
354 EXPECT_FALSE(service_path2.empty()); 396 EXPECT_FALSE(service_path2.empty());
355 397
356 EXPECT_NE(service_path1, service_path2); 398 EXPECT_NE(service_path1, service_path2);
357 399
358 // The original connection attempt should have gotten a "" response. 400 // The original connection attempt should have gotten a "" response.
359 EXPECT_EQ(1u, connection_callback_responses_.size()); 401 EXPECT_EQ(1u, connection_callback_responses_.size());
360 EXPECT_EQ("", connection_callback_responses_[0]); 402 EXPECT_EQ("", connection_callback_responses_[0]);
361 403
362 // First network becomes connectable. 404 // First network becomes connectable.
363 NotifyConnectable(service_path1); 405 NotifyConnectable(service_path1);
406 VerifyWifiNetworkNotAssociated(wifi_guid1);
364 407
365 // A connection should not have started to that GUID. 408 // A connection should not have started to that GUID.
366 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 409 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
367 EXPECT_EQ(1u, connection_callback_responses_.size()); 410 EXPECT_EQ(1u, connection_callback_responses_.size());
368 411
369 // Second network becomes connectable. 412 // Second network becomes connectable.
370 NotifyConnectable(service_path2); 413 NotifyConnectable(service_path2);
414 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
371 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect()); 415 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
372 EXPECT_EQ(1u, connection_callback_responses_.size()); 416 EXPECT_EQ(1u, connection_callback_responses_.size());
373 417
374 // Connection to network successful. 418 // Connection to network successful.
375 NotifyConnected(service_path2); 419 NotifyConnected(service_path2);
376 EXPECT_EQ(2u, connection_callback_responses_.size()); 420 EXPECT_EQ(2u, connection_callback_responses_.size());
421 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
422 VerifyTimerStopped();
423 }
424
425 TEST_F(WifiHotspotConnectorTest,
426 TestConnect_SecondConnectionWhileWaitingForFirstToConnect) {
427 wifi_hotspot_connector_->ConnectToWifiHotspot(
428 "ssid1", "password1", kTetherNetworkGuid,
429 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
430 base::Unretained(this)));
431
432 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
433 EXPECT_FALSE(wifi_guid1.empty());
434 std::string service_path1 =
435 test_network_connect_->last_service_path_created();
436 EXPECT_FALSE(service_path1.empty());
437
438 // First network becomes connectable.
439 NotifyConnectable(service_path1);
440 VerifyTetherAndWifiNetworkAssociation(wifi_guid1, kTetherNetworkGuid);
441
442 // After network becomes connectable, request a connection to second network.
443 wifi_hotspot_connector_->ConnectToWifiHotspot(
444 "ssid2", "password2", kTetherNetworkGuid2,
445 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
446 base::Unretained(this)));
447
448 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
449 EXPECT_FALSE(wifi_guid2.empty());
450 std::string service_path2 =
451 test_network_connect_->last_service_path_created();
452 EXPECT_FALSE(service_path2.empty());
453
454 EXPECT_NE(service_path1, service_path2);
455
456 // Second network becomes connectable.
457 NotifyConnectable(service_path2);
458 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
459 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
460 EXPECT_EQ(1u, connection_callback_responses_.size());
461
462 // The original connection attempt should have gotten a "" response.
Kyle Horimoto 2017/04/28 22:07:29 Move this up to right after the second ConnectToWi
lesliewatkins 2017/04/29 00:57:54 Done.
463 EXPECT_EQ(1u, connection_callback_responses_.size());
464 EXPECT_EQ("", connection_callback_responses_[0]);
465
466 // Connection to network successful.
467 NotifyConnected(service_path2);
468 EXPECT_EQ(2u, connection_callback_responses_.size());
377 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]); 469 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
378 VerifyTimerStopped(); 470 VerifyTimerStopped();
379 } 471 }
380 472
381 } // namespace tether 473 } // namespace tether
382 474
383 } // namespace chromeos 475 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698