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

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

Issue 2900903002: Create a FakeTetherService, which stubs out TetherService for development. (Closed)
Patch Set: Fix TetherService tests. 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
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service_factory.cc ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ~TetherServiceTest() override {} 95 ~TetherServiceTest() override {}
96 96
97 void SetUp() override { 97 void SetUp() override {
98 chromeos::DBusThreadManager::Initialize(); 98 chromeos::DBusThreadManager::Initialize();
99 chromeos::NetworkStateTest::SetUp(); 99 chromeos::NetworkStateTest::SetUp();
100 100
101 message_center::MessageCenter::Initialize(); 101 message_center::MessageCenter::Initialize();
102 chromeos::NetworkConnect::Initialize(nullptr); 102 chromeos::NetworkConnect::Initialize(nullptr);
103 chromeos::NetworkHandler::Initialize(); 103 chromeos::NetworkHandler::Initialize();
104 104
105 base::CommandLine::ForCurrentProcess()->AppendSwitch(
106 chromeos::switches::kEnableTether);
107
108 TestingProfile::Builder builder; 105 TestingProfile::Builder builder;
109 profile_ = builder.Build(); 106 profile_ = builder.Build();
110 107
111 fake_power_manager_client_ = 108 fake_power_manager_client_ =
112 base::MakeUnique<chromeos::FakePowerManagerClient>(); 109 base::MakeUnique<chromeos::FakePowerManagerClient>();
113 fake_session_manager_client_ = 110 fake_session_manager_client_ =
114 base::MakeUnique<ExtendedFakeSessionManagerClient>(); 111 base::MakeUnique<ExtendedFakeSessionManagerClient>();
115 112
116 std::vector<cryptauth::ExternalDeviceInfo> test_device_infos; 113 std::vector<cryptauth::ExternalDeviceInfo> test_device_infos;
117 test_device_infos.push_back(cryptauth::ExternalDeviceInfo()); 114 test_device_infos.push_back(cryptauth::ExternalDeviceInfo());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 network_state_handler()->GetTechnologyState( 224 network_state_handler()->GetTechnologyState(
228 chromeos::NetworkTypePattern::Tether())); 225 chromeos::NetworkTypePattern::Tether()));
229 226
230 SetIsScreenLocked(false); 227 SetIsScreenLocked(false);
231 228
232 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED, 229 EXPECT_EQ(chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_ENABLED,
233 network_state_handler()->GetTechnologyState( 230 network_state_handler()->GetTechnologyState(
234 chromeos::NetworkTypePattern::Tether())); 231 chromeos::NetworkTypePattern::Tether()));
235 } 232 }
236 233
237 TEST_F(TetherServiceTest, TestFeatureFlag) { 234 TEST_F(TetherServiceTest, TestFeatureFlagDisabled) {
238 base::CommandLine::Reset(); 235 EXPECT_FALSE(TetherService::Get(profile_.get()));
239 base::CommandLine::Init(0, nullptr); 236 }
240 237
241 CreateTetherService(); 238 TEST_F(TetherServiceTest, TestFeatureFlagEnabled) {
239 base::CommandLine::ForCurrentProcess()->AppendSwitch(
240 chromeos::switches::kEnableTether);
242 241
243 EXPECT_EQ( 242 TetherService* tether_service = TetherService::Get(profile_.get());
244 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE, 243 EXPECT_TRUE(tether_service);
245 network_state_handler()->GetTechnologyState( 244 tether_service->Shutdown();
246 chromeos::NetworkTypePattern::Tether()));
247 } 245 }
248 246
249 TEST_F(TetherServiceTest, TestNoTetherHosts) { 247 TEST_F(TetherServiceTest, TestNoTetherHosts) {
250 ON_CALL(*mock_cryptauth_device_manager_, GetTetherHosts()) 248 ON_CALL(*mock_cryptauth_device_manager_, GetTetherHosts())
251 .WillByDefault(Return(std::vector<cryptauth::ExternalDeviceInfo>())); 249 .WillByDefault(Return(std::vector<cryptauth::ExternalDeviceInfo>()));
252 250
253 CreateTetherService(); 251 CreateTetherService();
254 252
255 EXPECT_EQ( 253 EXPECT_EQ(
256 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE, 254 chromeos::NetworkStateHandler::TechnologyState::TECHNOLOGY_UNAVAILABLE,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 SetTetherTechnologyStateEnabled(false); 315 SetTetherTechnologyStateEnabled(false);
318 316
319 EXPECT_EQ(1, tether_service_->updated_technology_state_count()); 317 EXPECT_EQ(1, tether_service_->updated_technology_state_count());
320 318
321 SetTetherTechnologyStateEnabled(true); 319 SetTetherTechnologyStateEnabled(true);
322 SetTetherTechnologyStateEnabled(true); 320 SetTetherTechnologyStateEnabled(true);
323 SetTetherTechnologyStateEnabled(true); 321 SetTetherTechnologyStateEnabled(true);
324 322
325 EXPECT_EQ(2, tether_service_->updated_technology_state_count()); 323 EXPECT_EQ(2, tether_service_->updated_technology_state_count());
326 } 324 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/tether/tether_service_factory.cc ('k') | chromeos/chromeos_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698