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

Side by Side Diff: chrome/browser/chromeos/tether/tether_service_unittest.cc

Issue 2883283004: Merged Tether and cellular network types in System Tray. (Closed)
Patch Set: 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 "chrome/browser/chromeos/tether/tether_service.h" 5 #include "chrome/browser/chromeos/tether/tether_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 void SetTetherTechnologyStateEnabled(bool enabled) { 164 void SetTetherTechnologyStateEnabled(bool enabled) {
165 network_state_handler()->SetTetherTechnologyState( 165 network_state_handler()->SetTetherTechnologyState(
166 enabled 166 enabled
167 ? chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED 167 ? chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED
168 : chromeos::NetworkStateHandler::TechnologyState:: 168 : chromeos::NetworkStateHandler::TechnologyState::
169 TECHNOLOGY_AVAILABLE); 169 TECHNOLOGY_AVAILABLE);
170 } 170 }
171 171
172 void SetCellularTechnologyStateEnabled(bool enabled) {
173 network_state_handler()->SetTechnologyEnabled(
174 chromeos::NetworkTypePattern::Cellular(), enabled,
175 chromeos::network_handler::ErrorCallback());
176 base::RunLoop().RunUntilIdle();
177 }
178
172 content::TestBrowserThreadBundle thread_bundle_; 179 content::TestBrowserThreadBundle thread_bundle_;
173 180
174 std::unique_ptr<TestingProfile> profile_; 181 std::unique_ptr<TestingProfile> profile_;
175 std::unique_ptr<chromeos::FakePowerManagerClient> fake_power_manager_client_; 182 std::unique_ptr<chromeos::FakePowerManagerClient> fake_power_manager_client_;
176 std::unique_ptr<ExtendedFakeSessionManagerClient> 183 std::unique_ptr<ExtendedFakeSessionManagerClient>
177 fake_session_manager_client_; 184 fake_session_manager_client_;
178 std::unique_ptr<TestingPrefServiceSimple> test_pref_service_; 185 std::unique_ptr<TestingPrefServiceSimple> test_pref_service_;
179 std::unique_ptr<NiceMock<MockCryptAuthDeviceManager>> 186 std::unique_ptr<NiceMock<MockCryptAuthDeviceManager>>
180 mock_cryptauth_device_manager_; 187 mock_cryptauth_device_manager_;
181 std::unique_ptr<cryptauth::FakeCryptAuthService> fake_cryptauth_service_; 188 std::unique_ptr<cryptauth::FakeCryptAuthService> fake_cryptauth_service_;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ON_CALL(*mock_adapter_, IsPowered()).WillByDefault(Return(false)); 278 ON_CALL(*mock_adapter_, IsPowered()).WillByDefault(Return(false));
272 279
273 CreateTetherService(); 280 CreateTetherService();
274 281
275 EXPECT_EQ( 282 EXPECT_EQ(
276 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED, 283 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
277 network_state_handler()->GetTechnologyState( 284 network_state_handler()->GetTechnologyState(
278 chromeos::NetworkTypePattern::Tether())); 285 chromeos::NetworkTypePattern::Tether()));
279 } 286 }
280 287
288 TEST_F(TetherServiceTest, TestCellularIsUnavailable) {
289 test_manager_client()->RemoveTechnology(shill::kTypeCellular);
290 ASSERT_EQ(
291 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
292 network_state_handler()->GetTechnologyState(
293 chromeos::NetworkTypePattern::Cellular()));
294
295 CreateTetherService();
296
297 SetTetherTechnologyStateEnabled(false);
298 EXPECT_EQ(
299 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
300 network_state_handler()->GetTechnologyState(
301 chromeos::NetworkTypePattern::Tether()));
302
303 SetTetherTechnologyStateEnabled(true);
304 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
305 network_state_handler()->GetTechnologyState(
306 chromeos::NetworkTypePattern::Tether()));
307 }
308
309 TEST_F(TetherServiceTest, TestCellularIsAvailable) {
310 // TODO (lesliewatkins): Investigate why cellular needs to be removed and
311 // re-added for NetworkStateHandler to return the correct TechnologyState.
312 test_manager_client()->RemoveTechnology(shill::kTypeCellular);
313 test_manager_client()->AddTechnology(shill::kTypeCellular, false);
314
315 CreateTetherService();
316
317 // Cellular disabled
318 SetCellularTechnologyStateEnabled(false);
319 ASSERT_EQ(
320 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
321 network_state_handler()->GetTechnologyState(
322 chromeos::NetworkTypePattern::Cellular()));
323
324 SetTetherTechnologyStateEnabled(false);
325 EXPECT_EQ(
326 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
327 network_state_handler()->GetTechnologyState(
328 chromeos::NetworkTypePattern::Tether()));
329
330 SetTetherTechnologyStateEnabled(true);
331 EXPECT_EQ(
332 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNINITIALIZED,
333 network_state_handler()->GetTechnologyState(
334 chromeos::NetworkTypePattern::Tether()));
335
336 // Cellular enabled
337 SetCellularTechnologyStateEnabled(true);
338 ASSERT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
339 network_state_handler()->GetTechnologyState(
340 chromeos::NetworkTypePattern::Cellular()));
341
342 SetTetherTechnologyStateEnabled(false);
343 EXPECT_EQ(
344 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
345 network_state_handler()->GetTechnologyState(
346 chromeos::NetworkTypePattern::Tether()));
347
348 SetTetherTechnologyStateEnabled(true);
349 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
350 network_state_handler()->GetTechnologyState(
351 chromeos::NetworkTypePattern::Tether()));
352 }
353
281 TEST_F(TetherServiceTest, TestEnabled) { 354 TEST_F(TetherServiceTest, TestEnabled) {
282 CreateTetherService(); 355 CreateTetherService();
283 356
284 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED, 357 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
285 network_state_handler()->GetTechnologyState( 358 network_state_handler()->GetTechnologyState(
286 chromeos::NetworkTypePattern::Tether())); 359 chromeos::NetworkTypePattern::Tether()));
287 360
288 SetTetherTechnologyStateEnabled(false); 361 SetTetherTechnologyStateEnabled(false);
289 EXPECT_EQ( 362 EXPECT_EQ(
290 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE, 363 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_AVAILABLE,
(...skipping 24 matching lines...) Expand all
315 SetTetherTechnologyStateEnabled(false); 388 SetTetherTechnologyStateEnabled(false);
316 389
317 EXPECT_EQ(1, tether_service_->updated_technology_state_count()); 390 EXPECT_EQ(1, tether_service_->updated_technology_state_count());
318 391
319 SetTetherTechnologyStateEnabled(true); 392 SetTetherTechnologyStateEnabled(true);
320 SetTetherTechnologyStateEnabled(true); 393 SetTetherTechnologyStateEnabled(true);
321 SetTetherTechnologyStateEnabled(true); 394 SetTetherTechnologyStateEnabled(true);
322 395
323 EXPECT_EQ(2, tether_service_->updated_technology_state_count()); 396 EXPECT_EQ(2, tether_service_->updated_technology_state_count());
324 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698