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

Side by Side Diff: chrome/browser/chromeos/login/login_utils_browsertest.cc

Issue 24869003: cryptohome: Move stateless wrapper functions out of CryptohomeLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 2 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 mock_input_method_manager_ = new input_method::MockInputMethodManager(); 219 mock_input_method_manager_ = new input_method::MockInputMethodManager();
220 input_method::InitializeForTesting(mock_input_method_manager_); 220 input_method::InitializeForTesting(mock_input_method_manager_);
221 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_); 221 disks::DiskMountManager::InitializeForTesting(&mock_disk_mount_manager_);
222 mock_disk_mount_manager_.SetupDefaultReplies(); 222 mock_disk_mount_manager_.SetupDefaultReplies();
223 223
224 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller; 224 mock_async_method_caller_ = new cryptohome::MockAsyncMethodCaller;
225 cryptohome::AsyncMethodCaller::InitializeForTesting( 225 cryptohome::AsyncMethodCaller::InitializeForTesting(
226 mock_async_method_caller_); 226 mock_async_method_caller_);
227 227
228 cryptohome_.reset(new MockCryptohomeLibrary()); 228 cryptohome_.reset(new MockCryptohomeLibrary());
229 EXPECT_CALL(*cryptohome_, InstallAttributesIsInvalid())
230 .WillRepeatedly(Return(false));
231 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall())
232 .WillRepeatedly(Return(true));
233 EXPECT_CALL(*cryptohome_, TpmIsEnabled())
234 .WillRepeatedly(Return(false));
235 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwned, kTrue))
236 .WillRepeatedly(Return(true));
237 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttributeOwner,
238 kUsername))
239 .WillRepeatedly(Return(true));
240 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseDomain,
241 kDomain))
242 .WillRepeatedly(Return(true));
243 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseMode,
244 kMode))
245 .WillRepeatedly(Return(true));
246 EXPECT_CALL(*cryptohome_, InstallAttributesSet(kAttrEnterpriseDeviceId,
247 kDeviceId))
248 .WillRepeatedly(Return(true));
249 EXPECT_CALL(*cryptohome_, InstallAttributesFinalize())
250 .WillRepeatedly(Return(true));
251 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwned, _))
252 .WillRepeatedly(DoAll(SetArgPointee<1>(kTrue),
253 Return(true)));
254 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeConsumerKiosk, _))
255 .WillRepeatedly(DoAll(SetArgPointee<1>(kFalse),
256 Return(true)));
257 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttributeOwner, _))
258 .WillRepeatedly(DoAll(SetArgPointee<1>(kUsername),
259 Return(true)));
260 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseDomain, _))
261 .WillRepeatedly(DoAll(SetArgPointee<1>(kDomain),
262 Return(true)));
263 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseMode, _))
264 .WillRepeatedly(DoAll(SetArgPointee<1>(kMode),
265 Return(true)));
266 EXPECT_CALL(*cryptohome_, InstallAttributesGet(kAttrEnterpriseDeviceId, _))
267 .WillRepeatedly(DoAll(SetArgPointee<1>(kDeviceId),
268 Return(true)));
269 CryptohomeLibrary::SetForTest(cryptohome_.get()); 229 CryptohomeLibrary::SetForTest(cryptohome_.get());
270 230
271 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService); 231 test_device_settings_service_.reset(new ScopedTestDeviceSettingsService);
272 test_cros_settings_.reset(new ScopedTestCrosSettings); 232 test_cros_settings_.reset(new ScopedTestCrosSettings);
273 test_user_manager_.reset(new ScopedTestUserManager); 233 test_user_manager_.reset(new ScopedTestUserManager);
274 234
275 // IOThread creates ProxyConfigServiceImpl and 235 // IOThread creates ProxyConfigServiceImpl and
276 // BrowserPolicyConnector::Init() creates a NetworkConfigurationUpdater, 236 // BrowserPolicyConnector::Init() creates a NetworkConfigurationUpdater,
277 // which both access NetworkHandler. Thus initialize it here before creating 237 // which both access NetworkHandler. Thus initialize it here before creating
278 // IOThread and before calling BrowserPolicyConnector::Init(). 238 // IOThread and before calling BrowserPolicyConnector::Init().
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 FAIL() << "OnLoginFailure not expected"; 354 FAIL() << "OnLoginFailure not expected";
395 } 355 }
396 356
397 virtual void OnLoginSuccess(const UserContext& user_context, 357 virtual void OnLoginSuccess(const UserContext& user_context,
398 bool pending_requests, 358 bool pending_requests,
399 bool using_oauth) OVERRIDE { 359 bool using_oauth) OVERRIDE {
400 FAIL() << "OnLoginSuccess not expected"; 360 FAIL() << "OnLoginSuccess not expected";
401 } 361 }
402 362
403 void EnrollDevice(const std::string& username) { 363 void EnrollDevice(const std::string& username) {
404 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall())
405 .WillOnce(Return(true))
406 .WillRepeatedly(Return(false));
407
408 base::RunLoop loop; 364 base::RunLoop loop;
409 policy::EnterpriseInstallAttributes::LockResult result; 365 policy::EnterpriseInstallAttributes::LockResult result;
410 connector_->GetInstallAttributes()->LockDevice( 366 connector_->GetInstallAttributes()->LockDevice(
411 username, policy::DEVICE_MODE_ENTERPRISE, kDeviceId, 367 username, policy::DEVICE_MODE_ENTERPRISE, kDeviceId,
412 base::Bind(&CopyLockResult, &loop, &result)); 368 base::Bind(&CopyLockResult, &loop, &result));
413 loop.Run(); 369 loop.Run();
414 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result); 370 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, result);
415 RunUntilIdle(); 371 RunUntilIdle();
416 } 372 }
417 373
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 682 }
727 683
728 INSTANTIATE_TEST_CASE_P( 684 INSTANTIATE_TEST_CASE_P(
729 LoginUtilsBlockingLoginTestInstance, 685 LoginUtilsBlockingLoginTestInstance,
730 LoginUtilsBlockingLoginTest, 686 LoginUtilsBlockingLoginTest,
731 testing::Values(0, 1, 2, 3, 4, 5)); 687 testing::Values(0, 1, 2, 3, 4, 5));
732 688
733 } // namespace 689 } // namespace
734 690
735 } // namespace chromeos 691 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698