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

Unified Diff: chrome/browser/chromeos/tether/tether_service_unittest.cc

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: Merged Tether and cellular network types in System Tray. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/tether/tether_service_unittest.cc
diff --git a/chrome/browser/chromeos/tether/tether_service_unittest.cc b/chrome/browser/chromeos/tether/tether_service_unittest.cc
index 00752a106e0b54f05486bbce80b39d17765d4acc..b27910fbfa1bca59985069e85b78a197a787e246 100644
--- a/chrome/browser/chromeos/tether/tether_service_unittest.cc
+++ b/chrome/browser/chromeos/tether/tether_service_unittest.cc
@@ -274,12 +274,85 @@ TEST_F(TetherServiceTest, TestBluetoothIsNotPowered) {
CreateTetherService();
+ base::RunLoop().RunUntilIdle();
Ryan Hansberry 2017/05/23 01:14:29 Is this necessary?
stevenjb 2017/05/23 22:11:07 Maybe add a comment. The NetworkHandler code is la
lesliewatkins 2017/05/26 23:49:32 This one isn't-- it got added by accident!
+
EXPECT_EQ(
chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
network_state_handler()->GetTechnologyState(
chromeos::NetworkTypePattern::Tether()));
}
+TEST_F(TetherServiceTest, TestCellularIsUnavailable) {
+ test_manager_client()->RemoveTechnology(shill::kTypeCellular);
+ ASSERT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Cellular()));
+
+ CreateTetherService();
+
+ SetTetherTechnologyStateEnabled(false);
+ EXPECT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+
+ SetTetherTechnologyStateEnabled(true);
+ EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+}
+
+TEST_F(TetherServiceTest, TestCellularIsAvailable) {
+ // TODO (lesliewatkins): Investigate why cellular needs to be removed and
+ // re-added for NetworkStateHandler to return the correct TechnologyState.
+ test_manager_client()->RemoveTechnology(shill::kTypeCellular);
+ test_manager_client()->AddTechnology(shill::kTypeCellular, false);
+
+ CreateTetherService();
+
+ network_state_handler()->SetTechnologyEnabled(
+ chromeos::NetworkTypePattern::Cellular(), false,
+ chromeos::network_handler::ErrorCallback());
+
+ base::RunLoop().RunUntilIdle();
+ ASSERT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Cellular()));
+
+ SetTetherTechnologyStateEnabled(false);
+ EXPECT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+
+ SetTetherTechnologyStateEnabled(true);
+ EXPECT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+
+ network_state_handler()->SetTechnologyEnabled(
Ryan Hansberry 2017/05/23 01:14:29 Please break out these repeated SetTechnologyEnabl
lesliewatkins 2017/05/26 23:49:32 Done.
+ chromeos::NetworkTypePattern::Cellular(), true,
+ chromeos::network_handler::ErrorCallback());
+ base::RunLoop().RunUntilIdle();
Ryan Hansberry 2017/05/23 01:14:29 Are these RunLoop calls after calling on NetworkSt
stevenjb 2017/05/23 22:11:07 Se comment above. A SetTechnologyEnabled() wrapper
lesliewatkins 2017/05/26 23:49:32 Yes, these are, because the call is still asynchro
+ ASSERT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Cellular()));
+
+ SetTetherTechnologyStateEnabled(false);
+ EXPECT_EQ(
+ chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+
+ SetTetherTechnologyStateEnabled(true);
+ EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
+ network_state_handler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::Tether()));
+}
+
TEST_F(TetherServiceTest, TestEnabled) {
CreateTetherService();

Powered by Google App Engine
This is Rietveld 408576698