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

Side by Side Diff: chromeos/network/network_connection_handler_unittest.cc

Issue 2850993002: [CrOS Tether] Add the HasConnectedToHost network field to NetworkStateHandler. (Closed)
Patch Set: stevenjb@ 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network/network_connection_handler.h" 5 #include "chromeos/network/network_connection_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 EXPECT_FALSE(ConfigureService(kConfigConnectable).empty()); 481 EXPECT_FALSE(ConfigureService(kConfigConnectable).empty());
482 Disconnect(kWifi0); 482 Disconnect(kWifi0);
483 EXPECT_EQ(NetworkConnectionHandler::kErrorNotConnected, GetResultAndReset()); 483 EXPECT_EQ(NetworkConnectionHandler::kErrorNotConnected, GetResultAndReset());
484 } 484 }
485 485
486 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_Success) { 486 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_Success) {
487 network_state_handler()->SetTetherTechnologyState( 487 network_state_handler()->SetTetherTechnologyState(
488 NetworkStateHandler::TECHNOLOGY_ENABLED); 488 NetworkStateHandler::TECHNOLOGY_ENABLED);
489 network_state_handler()->AddTetherNetworkState( 489 network_state_handler()->AddTetherNetworkState(
490 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, 490 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */,
491 100 /* signal_strength */); 491 100 /* signal_strength */, true /* has_connected_to_host */);
492 network_connection_handler_->SetTetherDelegate(fake_tether_delegate_.get()); 492 network_connection_handler_->SetTetherDelegate(fake_tether_delegate_.get());
493 493
494 Connect(kTetherGuid /* service_path */); 494 Connect(kTetherGuid /* service_path */);
495 495
496 EXPECT_EQ(kTetherGuid, fake_tether_delegate_->last_service_path()); 496 EXPECT_EQ(kTetherGuid, fake_tether_delegate_->last_service_path());
497 fake_tether_delegate_->last_success_callback().Run(); 497 fake_tether_delegate_->last_success_callback().Run();
498 EXPECT_EQ(kSuccessResult, GetResultAndReset()); 498 EXPECT_EQ(kSuccessResult, GetResultAndReset());
499 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid)); 499 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid));
500 EXPECT_EQ(kSuccessResult, 500 EXPECT_EQ(kSuccessResult,
501 network_connection_observer_->GetResult(kTetherGuid)); 501 network_connection_observer_->GetResult(kTetherGuid));
502 } 502 }
503 503
504 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_Failure) { 504 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_Failure) {
505 network_state_handler()->SetTetherTechnologyState( 505 network_state_handler()->SetTetherTechnologyState(
506 NetworkStateHandler::TECHNOLOGY_ENABLED); 506 NetworkStateHandler::TECHNOLOGY_ENABLED);
507 network_state_handler()->AddTetherNetworkState( 507 network_state_handler()->AddTetherNetworkState(
508 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, 508 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */,
509 100 /* signal_strength */); 509 100 /* signal_strength */, true /* has_connected_to_host */);
510 network_connection_handler_->SetTetherDelegate(fake_tether_delegate_.get()); 510 network_connection_handler_->SetTetherDelegate(fake_tether_delegate_.get());
511 511
512 Connect(kTetherGuid /* service_path */); 512 Connect(kTetherGuid /* service_path */);
513 513
514 EXPECT_EQ(kTetherGuid, fake_tether_delegate_->last_service_path()); 514 EXPECT_EQ(kTetherGuid, fake_tether_delegate_->last_service_path());
515 fake_tether_delegate_->last_error_callback().Run( 515 fake_tether_delegate_->last_error_callback().Run(
516 NetworkConnectionHandler::kErrorConnectFailed); 516 NetworkConnectionHandler::kErrorConnectFailed);
517 EXPECT_EQ(NetworkConnectionHandler::kErrorConnectFailed, GetResultAndReset()); 517 EXPECT_EQ(NetworkConnectionHandler::kErrorConnectFailed, GetResultAndReset());
518 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid)); 518 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid));
519 EXPECT_EQ(NetworkConnectionHandler::kErrorConnectFailed, 519 EXPECT_EQ(NetworkConnectionHandler::kErrorConnectFailed,
520 network_connection_observer_->GetResult(kTetherGuid)); 520 network_connection_observer_->GetResult(kTetherGuid));
521 } 521 }
522 522
523 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_NoTetherDelegate) { 523 TEST_F(NetworkConnectionHandlerTest, ConnectToTetherNetwork_NoTetherDelegate) {
524 network_state_handler()->SetTetherTechnologyState( 524 network_state_handler()->SetTetherTechnologyState(
525 NetworkStateHandler::TECHNOLOGY_ENABLED); 525 NetworkStateHandler::TECHNOLOGY_ENABLED);
526 network_state_handler()->AddTetherNetworkState( 526 network_state_handler()->AddTetherNetworkState(
527 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, 527 kTetherGuid, "TetherNetwork", "Carrier", 100 /* battery_percentage */,
528 100 /* signal_strength */); 528 100 /* signal_strength */, true /* has_connected_to_host */);
529 529
530 // Do not set a tether delegate. 530 // Do not set a tether delegate.
531 531
532 Connect(kTetherGuid /* service_path */); 532 Connect(kTetherGuid /* service_path */);
533 533
534 EXPECT_EQ( 534 EXPECT_EQ(
535 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate, 535 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate,
536 GetResultAndReset()); 536 GetResultAndReset());
537 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid)); 537 EXPECT_TRUE(network_connection_observer_->GetRequested(kTetherGuid));
538 EXPECT_EQ( 538 EXPECT_EQ(
539 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate, 539 NetworkConnectionHandler::kErrorTetherConnectionAttemptWithNoDelegate,
540 network_connection_observer_->GetResult(kTetherGuid)); 540 network_connection_observer_->GetResult(kTetherGuid));
541 } 541 }
542 542
543 } // namespace chromeos 543 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_configuration_handler_unittest.cc ('k') | chromeos/network/network_state_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698