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/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | |
14 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 13 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
18 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 17 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
19 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 18 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
20 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" | 19 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" |
21 #include "chrome/browser/prefs/browser_prefs.h" | 20 #include "chrome/browser/prefs/browser_prefs.h" |
| 21 #include "chromeos/cryptohome/cryptohome_library.h" |
22 #include "chromeos/dbus/cryptohome_client.h" | 22 #include "chromeos/dbus/cryptohome_client.h" |
23 #include "chromeos/dbus/dbus_client_implementation_type.h" | 23 #include "chromeos/dbus/dbus_client_implementation_type.h" |
24 #include "policy/policy_constants.h" | 24 #include "policy/policy_constants.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 using testing::AnyNumber; | 28 using testing::AnyNumber; |
29 using testing::AtMost; | 29 using testing::AtMost; |
30 using testing::DoAll; | 30 using testing::DoAll; |
31 using testing::Mock; | 31 using testing::Mock; |
32 using testing::SaveArg; | 32 using testing::SaveArg; |
33 using testing::_; | 33 using testing::_; |
34 | 34 |
35 namespace em = enterprise_management; | 35 namespace em = enterprise_management; |
36 | 36 |
37 namespace policy { | 37 namespace policy { |
38 namespace { | 38 namespace { |
39 | 39 |
40 void CopyLockResult(base::RunLoop* loop, | 40 void CopyLockResult(base::RunLoop* loop, |
41 EnterpriseInstallAttributes::LockResult* out, | 41 EnterpriseInstallAttributes::LockResult* out, |
42 EnterpriseInstallAttributes::LockResult result) { | 42 EnterpriseInstallAttributes::LockResult result) { |
43 *out = result; | 43 *out = result; |
44 loop->Quit(); | 44 loop->Quit(); |
45 } | 45 } |
46 | 46 |
47 class DeviceCloudPolicyManagerChromeOSTest | 47 class DeviceCloudPolicyManagerChromeOSTest |
48 : public chromeos::DeviceSettingsTestBase { | 48 : public chromeos::DeviceSettingsTestBase { |
49 protected: | 49 protected: |
50 DeviceCloudPolicyManagerChromeOSTest() | 50 DeviceCloudPolicyManagerChromeOSTest() |
51 : cryptohome_library_(chromeos::CryptohomeLibrary::GetImpl(true)), | 51 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), |
52 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( | 52 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( |
53 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), | 53 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), |
54 install_attributes_(cryptohome_library_.get(), | 54 install_attributes_(cryptohome_library_.get(), |
55 stub_cryptohome_client_.get()), | 55 stub_cryptohome_client_.get()), |
56 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 56 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
57 &install_attributes_)), | 57 &install_attributes_)), |
58 manager_(make_scoped_ptr(store_), &install_attributes_) {} | 58 manager_(make_scoped_ptr(store_), &install_attributes_) {} |
59 | 59 |
60 virtual void SetUp() OVERRIDE { | 60 virtual void SetUp() OVERRIDE { |
61 DeviceSettingsTestBase::SetUp(); | 61 DeviceSettingsTestBase::SetUp(); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { | 361 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { |
362 loaded_blob_.clear(); | 362 loaded_blob_.clear(); |
363 RunTest(); | 363 RunTest(); |
364 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 364 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
365 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, | 365 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, |
366 status_.store_status()); | 366 status_.store_status()); |
367 } | 367 } |
368 | 368 |
369 } // namespace | 369 } // namespace |
370 } // namespace policy | 370 } // namespace policy |
OLD | NEW |