| 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_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "chrome/browser/chromeos/cros/mock_cryptohome_library.h" | |
| 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 13 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 16 #include "chromeos/cryptohome/mock_cryptohome_library.h" |
| 17 #include "chromeos/dbus/mock_cryptohome_client.h" | 17 #include "chromeos/dbus/mock_cryptohome_client.h" |
| 18 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace policy { | 21 namespace policy { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 void CopyLockResult(base::RunLoop* loop, | 25 void CopyLockResult(base::RunLoop* loop, |
| 26 EnterpriseInstallAttributes::LockResult* out, | 26 EnterpriseInstallAttributes::LockResult* out, |
| 27 EnterpriseInstallAttributes::LockResult result) { | 27 EnterpriseInstallAttributes::LockResult result) { |
| 28 *out = result; | 28 *out = result; |
| 29 loop->Quit(); | 29 loop->Quit(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 class DeviceCloudPolicyStoreChromeOSTest | 34 class DeviceCloudPolicyStoreChromeOSTest |
| 35 : public chromeos::DeviceSettingsTestBase { | 35 : public chromeos::DeviceSettingsTestBase { |
| 36 protected: | 36 protected: |
| 37 DeviceCloudPolicyStoreChromeOSTest() | 37 DeviceCloudPolicyStoreChromeOSTest() |
| 38 : cryptohome_library_(chromeos::CryptohomeLibrary::GetImpl(true)), | 38 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), |
| 39 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( | 39 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( |
| 40 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), | 40 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), |
| 41 install_attributes_(new EnterpriseInstallAttributes( | 41 install_attributes_(new EnterpriseInstallAttributes( |
| 42 cryptohome_library_.get(), stub_cryptohome_client_.get())), | 42 cryptohome_library_.get(), stub_cryptohome_client_.get())), |
| 43 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 43 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
| 44 install_attributes_.get())) {} | 44 install_attributes_.get())) {} |
| 45 | 45 |
| 46 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 47 DeviceSettingsTestBase::SetUp(); | 47 DeviceSettingsTestBase::SetUp(); |
| 48 | 48 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 210 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
| 211 PrepareNewSigningKey(); | 211 PrepareNewSigningKey(); |
| 212 ResetToNonEnterprise(); | 212 ResetToNonEnterprise(); |
| 213 store_->InstallInitialPolicy(device_policy_.policy()); | 213 store_->InstallInitialPolicy(device_policy_.policy()); |
| 214 FlushDeviceSettings(); | 214 FlushDeviceSettings(); |
| 215 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 215 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace policy | 218 } // namespace policy |
| OLD | NEW |