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

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: Fixed small typo preventing unit tests from building. 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());
238 }
239
204 void WifiConnectionCallback(const std::string& wifi_guid) { 240 void WifiConnectionCallback(const std::string& wifi_guid) {
205 connection_callback_responses_.push_back(wifi_guid); 241 connection_callback_responses_.push_back(wifi_guid);
206 } 242 }
207 243
208 base::test::ScopedTaskEnvironment scoped_task_environment_; 244 base::test::ScopedTaskEnvironment scoped_task_environment_;
209 245
210 std::string other_wifi_service_path_; 246 std::string other_wifi_service_path_;
211 std::vector<std::string> connection_callback_responses_; 247 std::vector<std::string> connection_callback_responses_;
212 248
213 base::MockTimer* mock_timer_; 249 base::MockTimer* mock_timer_;
214 std::unique_ptr<TestNetworkConnect> test_network_connect_; 250 std::unique_ptr<TestNetworkConnect> test_network_connect_;
215 251
216 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; 252 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_;
217 253
218 private: 254 private:
219 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest); 255 DISALLOW_COPY_AND_ASSIGN(WifiHotspotConnectorTest);
220 }; 256 };
221 257
222 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) { 258 TEST_F(WifiHotspotConnectorTest, TestConnect_NetworkDoesNotBecomeConnectable) {
223 wifi_hotspot_connector_->ConnectToWifiHotspot( 259 wifi_hotspot_connector_->ConnectToWifiHotspot(
224 std::string(kSsid), std::string(kPassword), 260 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
225 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 261 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
226 base::Unretained(this))); 262 base::Unretained(this)));
227 263
228 std::string wifi_guid = 264 std::string wifi_guid =
229 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 265 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
230 EXPECT_FALSE(wifi_guid.empty()); 266 EXPECT_FALSE(wifi_guid.empty());
231 267
232 // Network does not become connectable. 268 // Network does not become connectable.
233 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 269 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
234 270
235 // Timeout timer fires. 271 // Timeout timer fires.
236 EXPECT_EQ(0u, connection_callback_responses_.size()); 272 EXPECT_EQ(0u, connection_callback_responses_.size());
237 InvokeTimerTask(); 273 InvokeTimerTask();
238 EXPECT_EQ(1u, connection_callback_responses_.size()); 274 EXPECT_EQ(1u, connection_callback_responses_.size());
239 EXPECT_EQ("", connection_callback_responses_[0]); 275 EXPECT_EQ("", connection_callback_responses_[0]);
240 } 276 }
241 277
242 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) { 278 TEST_F(WifiHotspotConnectorTest, TestConnect_AnotherNetworkBecomesConnectable) {
243 wifi_hotspot_connector_->ConnectToWifiHotspot( 279 wifi_hotspot_connector_->ConnectToWifiHotspot(
244 std::string(kSsid), std::string(kPassword), 280 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
245 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 281 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
246 base::Unretained(this))); 282 base::Unretained(this)));
247 283
248 std::string wifi_guid = 284 std::string wifi_guid =
249 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 285 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
250 EXPECT_FALSE(wifi_guid.empty()); 286 EXPECT_FALSE(wifi_guid.empty());
251 287
252 // Another network becomes connectable. This should not cause the connection 288 // Another network becomes connectable. This should not cause the connection
253 // to start. 289 // to start.
254 NotifyConnectable(other_wifi_service_path_); 290 NotifyConnectable(other_wifi_service_path_);
291 VerifyNetworkNotAssociated(wifi_guid);
292 std::string other_wifi_guid = network_state_handler()
293 ->GetNetworkState(other_wifi_service_path_)
294 ->guid();
295 VerifyNetworkNotAssociated(other_wifi_guid);
255 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 296 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
256 297
257 // Timeout timer fires. 298 // Timeout timer fires.
258 EXPECT_EQ(0u, connection_callback_responses_.size()); 299 EXPECT_EQ(0u, connection_callback_responses_.size());
259 InvokeTimerTask(); 300 InvokeTimerTask();
260 EXPECT_EQ(1u, connection_callback_responses_.size()); 301 EXPECT_EQ(1u, connection_callback_responses_.size());
261 EXPECT_EQ("", connection_callback_responses_[0]); 302 EXPECT_EQ("", connection_callback_responses_[0]);
262 } 303 }
263 304
264 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) { 305 TEST_F(WifiHotspotConnectorTest, TestConnect_CannotConnectToNetwork) {
265 wifi_hotspot_connector_->ConnectToWifiHotspot( 306 wifi_hotspot_connector_->ConnectToWifiHotspot(
266 std::string(kSsid), std::string(kPassword), 307 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
267 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 308 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
268 base::Unretained(this))); 309 base::Unretained(this)));
269 310
270 std::string wifi_guid = 311 std::string wifi_guid =
271 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 312 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
272 EXPECT_FALSE(wifi_guid.empty()); 313 EXPECT_FALSE(wifi_guid.empty());
273 314
274 // Network becomes connectable. 315 // Network becomes connectable.
275 NotifyConnectable(test_network_connect_->last_service_path_created()); 316 NotifyConnectable(test_network_connect_->last_service_path_created());
317 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
276 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 318 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
277 319
278 // Network connection does not occur. 320 // Network connection does not occur.
279 EXPECT_EQ(0u, connection_callback_responses_.size()); 321 EXPECT_EQ(0u, connection_callback_responses_.size());
280 322
281 // Timeout timer fires. 323 // Timeout timer fires.
282 InvokeTimerTask(); 324 InvokeTimerTask();
283 EXPECT_EQ(1u, connection_callback_responses_.size()); 325 EXPECT_EQ(1u, connection_callback_responses_.size());
284 EXPECT_EQ("", connection_callback_responses_[0]); 326 EXPECT_EQ("", connection_callback_responses_[0]);
285 } 327 }
286 328
287 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) { 329 TEST_F(WifiHotspotConnectorTest, TestConnect_Success) {
288 wifi_hotspot_connector_->ConnectToWifiHotspot( 330 wifi_hotspot_connector_->ConnectToWifiHotspot(
289 std::string(kSsid), std::string(kPassword), 331 std::string(kSsid), std::string(kPassword), kTetherNetworkGuid,
290 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 332 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
291 base::Unretained(this))); 333 base::Unretained(this)));
292 334
293 std::string wifi_guid = 335 std::string wifi_guid =
294 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword)); 336 VerifyLastConfiguration(std::string(kSsid), std::string(kPassword));
295 EXPECT_FALSE(wifi_guid.empty()); 337 EXPECT_FALSE(wifi_guid.empty());
296 338
297 // Network becomes connectable. 339 // Network becomes connectable.
298 NotifyConnectable(test_network_connect_->last_service_path_created()); 340 NotifyConnectable(test_network_connect_->last_service_path_created());
341 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
299 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 342 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
300 EXPECT_EQ(0u, connection_callback_responses_.size()); 343 EXPECT_EQ(0u, connection_callback_responses_.size());
301 344
302 // Connection to network successful. 345 // Connection to network successful.
303 NotifyConnected(test_network_connect_->last_service_path_created()); 346 NotifyConnected(test_network_connect_->last_service_path_created());
304 EXPECT_EQ(1u, connection_callback_responses_.size()); 347 EXPECT_EQ(1u, connection_callback_responses_.size());
305 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 348 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
306 VerifyTimerStopped(); 349 VerifyTimerStopped();
307 } 350 }
308 351
309 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) { 352 TEST_F(WifiHotspotConnectorTest, TestConnect_Success_EmptyPassword) {
310 wifi_hotspot_connector_->ConnectToWifiHotspot( 353 wifi_hotspot_connector_->ConnectToWifiHotspot(
311 std::string(kSsid), "", 354 std::string(kSsid), "" /* password */, kTetherNetworkGuid,
312 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 355 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
313 base::Unretained(this))); 356 base::Unretained(this)));
314 357
315 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), ""); 358 std::string wifi_guid = VerifyLastConfiguration(std::string(kSsid), "");
316 EXPECT_FALSE(wifi_guid.empty()); 359 EXPECT_FALSE(wifi_guid.empty());
317 360
318 // Network becomes connectable. 361 // Network becomes connectable.
319 NotifyConnectable(test_network_connect_->last_service_path_created()); 362 NotifyConnectable(test_network_connect_->last_service_path_created());
363 VerifyTetherAndWifiNetworkAssociation(wifi_guid, kTetherNetworkGuid);
320 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect()); 364 EXPECT_EQ(wifi_guid, test_network_connect_->network_id_to_connect());
321 EXPECT_EQ(0u, connection_callback_responses_.size()); 365 EXPECT_EQ(0u, connection_callback_responses_.size());
322 366
323 // Connection to network successful. 367 // Connection to network successful.
324 NotifyConnected(test_network_connect_->last_service_path_created()); 368 NotifyConnected(test_network_connect_->last_service_path_created());
325 EXPECT_EQ(1u, connection_callback_responses_.size()); 369 EXPECT_EQ(1u, connection_callback_responses_.size());
326 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]); 370 EXPECT_EQ(wifi_guid, connection_callback_responses_[0]);
327 VerifyTimerStopped(); 371 VerifyTimerStopped();
328 } 372 }
329 373
330 TEST_F(WifiHotspotConnectorTest, 374 TEST_F(WifiHotspotConnectorTest,
331 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) { 375 TestConnect_SecondConnectionWhileWaitingForFirstToBecomeConnectable) {
332 wifi_hotspot_connector_->ConnectToWifiHotspot( 376 wifi_hotspot_connector_->ConnectToWifiHotspot(
333 "ssid1", "password1", 377 "ssid1", "password1", "tetherNetworkGuid1",
334 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 378 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
335 base::Unretained(this))); 379 base::Unretained(this)));
336 380
337 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1"); 381 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
338 EXPECT_FALSE(wifi_guid1.empty()); 382 EXPECT_FALSE(wifi_guid1.empty());
339 std::string service_path1 = 383 std::string service_path1 =
340 test_network_connect_->last_service_path_created(); 384 test_network_connect_->last_service_path_created();
341 EXPECT_FALSE(service_path1.empty()); 385 EXPECT_FALSE(service_path1.empty());
342 386
343 // Before network becomes connectable, start the new connection. 387 // Before network becomes connectable, start the new connection.
344 EXPECT_EQ(0u, connection_callback_responses_.size()); 388 EXPECT_EQ(0u, connection_callback_responses_.size());
345 wifi_hotspot_connector_->ConnectToWifiHotspot( 389 wifi_hotspot_connector_->ConnectToWifiHotspot(
346 "ssid2", "password2", 390 "ssid2", "password2", kTetherNetworkGuid2,
347 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback, 391 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
348 base::Unretained(this))); 392 base::Unretained(this)));
349 393
350 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2"); 394 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
351 EXPECT_FALSE(wifi_guid2.empty()); 395 EXPECT_FALSE(wifi_guid2.empty());
352 std::string service_path2 = 396 std::string service_path2 =
353 test_network_connect_->last_service_path_created(); 397 test_network_connect_->last_service_path_created();
354 EXPECT_FALSE(service_path2.empty()); 398 EXPECT_FALSE(service_path2.empty());
399 VerifyNetworkNotAssociated(wifi_guid1);
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);
364 409
365 // A connection should not have started to that GUID. 410 // A connection should not have started to that GUID.
366 EXPECT_EQ("", test_network_connect_->network_id_to_connect()); 411 EXPECT_EQ("", test_network_connect_->network_id_to_connect());
367 EXPECT_EQ(1u, connection_callback_responses_.size()); 412 EXPECT_EQ(1u, connection_callback_responses_.size());
368 413
369 // Second network becomes connectable. 414 // Second network becomes connectable.
370 NotifyConnectable(service_path2); 415 NotifyConnectable(service_path2);
416 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
371 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect()); 417 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
372 EXPECT_EQ(1u, connection_callback_responses_.size()); 418 EXPECT_EQ(1u, connection_callback_responses_.size());
373 419
420 // Connection to network successful.
421 NotifyConnected(service_path2);
422 EXPECT_EQ(2u, connection_callback_responses_.size());
423 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
424 VerifyTimerStopped();
425 }
426
427 TEST_F(WifiHotspotConnectorTest,
428 TestConnect_SecondConnectionWhileWaitingForFirstToConnect) {
429 wifi_hotspot_connector_->ConnectToWifiHotspot(
430 "ssid1", "password1", kTetherNetworkGuid,
431 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
432 base::Unretained(this)));
433
434 std::string wifi_guid1 = VerifyLastConfiguration("ssid1", "password1");
435 EXPECT_FALSE(wifi_guid1.empty());
436 std::string service_path1 =
437 test_network_connect_->last_service_path_created();
438 EXPECT_FALSE(service_path1.empty());
439
440 // First network becomes connectable.
441 NotifyConnectable(service_path1);
442 VerifyTetherAndWifiNetworkAssociation(wifi_guid1, kTetherNetworkGuid);
443
444 // After network becomes connectable, request a connection to second network.
445 wifi_hotspot_connector_->ConnectToWifiHotspot(
446 "ssid2", "password2", kTetherNetworkGuid2,
447 base::Bind(&WifiHotspotConnectorTest::WifiConnectionCallback,
448 base::Unretained(this)));
449
450 // The first Tether and Wi-Fi networks should no longer be associated.
451 VerifyNetworkNotAssociated(kTetherNetworkGuid);
452 VerifyNetworkNotAssociated(wifi_guid1);
453
454 // The original connection attempt should have gotten a "" response.
455 EXPECT_EQ(1u, connection_callback_responses_.size());
456 EXPECT_EQ("", connection_callback_responses_[0]);
457
458 std::string wifi_guid2 = VerifyLastConfiguration("ssid2", "password2");
459 EXPECT_FALSE(wifi_guid2.empty());
460 std::string service_path2 =
461 test_network_connect_->last_service_path_created();
462 EXPECT_FALSE(service_path2.empty());
463
464 EXPECT_NE(service_path1, service_path2);
465
466 // Second network becomes connectable.
467 NotifyConnectable(service_path2);
468 VerifyTetherAndWifiNetworkAssociation(wifi_guid2, kTetherNetworkGuid2);
469 EXPECT_EQ(wifi_guid2, test_network_connect_->network_id_to_connect());
470 EXPECT_EQ(1u, connection_callback_responses_.size());
471
374 // Connection to network successful. 472 // Connection to network successful.
375 NotifyConnected(service_path2); 473 NotifyConnected(service_path2);
376 EXPECT_EQ(2u, connection_callback_responses_.size()); 474 EXPECT_EQ(2u, connection_callback_responses_.size());
377 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]); 475 EXPECT_EQ(wifi_guid2, connection_callback_responses_[1]);
378 VerifyTimerStopped(); 476 VerifyTimerStopped();
379 } 477 }
380 478
381 } // namespace tether 479 } // namespace tether
382 480
383 } // namespace chromeos 481 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698