OLD | NEW |
---|---|
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/policy/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 namespace policy { | 51 namespace policy { |
52 namespace { | 52 namespace { |
53 | 53 |
54 void CopyLockResult(base::RunLoop* loop, | 54 void CopyLockResult(base::RunLoop* loop, |
55 EnterpriseInstallAttributes::LockResult* out, | 55 EnterpriseInstallAttributes::LockResult* out, |
56 EnterpriseInstallAttributes::LockResult result) { | 56 EnterpriseInstallAttributes::LockResult result) { |
57 *out = result; | 57 *out = result; |
58 loop->Quit(); | 58 loop->Quit(); |
59 } | 59 } |
60 | 60 |
61 void CopyTokenService(chromeos::DeviceOAuth2TokenService** out_token_service, | |
62 chromeos::DeviceOAuth2TokenService* in_token_service) { | |
63 *out_token_service = in_token_service; | |
64 } | |
65 | |
61 class DeviceCloudPolicyManagerChromeOSTest | 66 class DeviceCloudPolicyManagerChromeOSTest |
62 : public chromeos::DeviceSettingsTestBase { | 67 : public chromeos::DeviceSettingsTestBase { |
63 protected: | 68 protected: |
64 DeviceCloudPolicyManagerChromeOSTest() : store_(NULL) { | 69 DeviceCloudPolicyManagerChromeOSTest() : store_(NULL) { |
65 EXPECT_CALL(mock_statistics_provider_, | 70 EXPECT_CALL(mock_statistics_provider_, |
66 GetMachineStatistic(_, _)) | 71 GetMachineStatistic(_, _)) |
67 .WillRepeatedly(Return(false)); | 72 .WillRepeatedly(Return(false)); |
68 EXPECT_CALL(mock_statistics_provider_, | 73 EXPECT_CALL(mock_statistics_provider_, |
69 GetMachineStatistic("serial_number", _)) | 74 GetMachineStatistic("serial_number", _)) |
70 .WillRepeatedly(DoAll(SetArgumentPointee<1>(std::string("test_sn")), | 75 .WillRepeatedly(DoAll(SetArgumentPointee<1>(std::string("test_sn")), |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 | 382 |
378 // Key installation, policy load and refresh token save. | 383 // Key installation, policy load and refresh token save. |
379 device_settings_test_helper_.set_policy_blob(loaded_blob_); | 384 device_settings_test_helper_.set_policy_blob(loaded_blob_); |
380 owner_key_util_->SetPublicKeyFromPrivateKey( | 385 owner_key_util_->SetPublicKeyFromPrivateKey( |
381 *device_policy_.GetNewSigningKey()); | 386 *device_policy_.GetNewSigningKey()); |
382 ReloadDeviceSettings(); | 387 ReloadDeviceSettings(); |
383 | 388 |
384 if (done_) | 389 if (done_) |
385 return; | 390 return; |
386 | 391 |
387 chromeos::DeviceOAuth2TokenService* token_service = | 392 chromeos::DeviceOAuth2TokenService* token_service = NULL; |
388 chromeos::DeviceOAuth2TokenServiceFactory::Get(); | 393 chromeos::DeviceOAuth2TokenServiceFactory::Get( |
394 base::Bind(&CopyTokenService, &token_service)); | |
395 base::RunLoop().RunUntilIdle(); | |
hashimoto
2013/10/22 08:49:51
nit: How about having ASSERT_TRUE(token_service) h
satorux1
2013/10/22 09:56:43
good idea. will do.
satorux1
2013/10/23 06:35:44
Done.
| |
396 | |
389 // Process robot refresh token store. | 397 // Process robot refresh token store. |
390 EXPECT_EQ( | 398 EXPECT_EQ( |
391 "refreshToken4Test", | 399 "refreshToken4Test", |
392 token_service->GetRefreshToken(token_service->GetRobotAccountId())); | 400 token_service->GetRefreshToken(token_service->GetRobotAccountId())); |
393 } | 401 } |
394 | 402 |
395 bool is_auto_enrollment_; | 403 bool is_auto_enrollment_; |
396 | 404 |
397 DeviceManagementStatus register_status_; | 405 DeviceManagementStatus register_status_; |
398 em::DeviceManagementResponse register_response_; | 406 em::DeviceManagementResponse register_response_; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { | 519 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { |
512 loaded_blob_.clear(); | 520 loaded_blob_.clear(); |
513 RunTest(); | 521 RunTest(); |
514 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 522 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
515 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, | 523 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, |
516 status_.store_status()); | 524 status_.store_status()); |
517 } | 525 } |
518 | 526 |
519 } // namespace | 527 } // namespace |
520 } // namespace policy | 528 } // namespace policy |
OLD | NEW |