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

Side by Side Diff: chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos_unittest.cc

Issue 348713004: Use a TestBrowserThreadBundle in the DeviceSettingsTestBase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/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/message_loop/message_loop_proxy.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
13 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
14 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
15 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h"
16 #include "chromeos/cryptohome/cryptohome_util.h" 17 #include "chromeos/cryptohome/cryptohome_util.h"
17 #include "chromeos/dbus/fake_cryptohome_client.h" 18 #include "chromeos/dbus/fake_cryptohome_client.h"
18 #include "policy/policy_constants.h" 19 #include "policy/policy_constants.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace policy { 22 namespace policy {
22 23
23 namespace { 24 namespace {
24 25
25 void CopyLockResult(base::RunLoop* loop, 26 void CopyLockResult(base::RunLoop* loop,
26 EnterpriseInstallAttributes::LockResult* out, 27 EnterpriseInstallAttributes::LockResult* out,
27 EnterpriseInstallAttributes::LockResult result) { 28 EnterpriseInstallAttributes::LockResult result) {
28 *out = result; 29 *out = result;
29 loop->Quit(); 30 loop->Quit();
30 } 31 }
31 32
32 } // namespace 33 } // namespace
33 34
34 class DeviceCloudPolicyStoreChromeOSTest 35 class DeviceCloudPolicyStoreChromeOSTest
35 : public chromeos::DeviceSettingsTestBase { 36 : public chromeos::DeviceSettingsTestBase {
36 protected: 37 protected:
37 DeviceCloudPolicyStoreChromeOSTest() 38 DeviceCloudPolicyStoreChromeOSTest()
38 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), 39 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()),
39 install_attributes_(new EnterpriseInstallAttributes( 40 install_attributes_(
40 fake_cryptohome_client_.get())), 41 new EnterpriseInstallAttributes(fake_cryptohome_client_.get())),
41 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, 42 store_(new DeviceCloudPolicyStoreChromeOS(
42 install_attributes_.get(), 43 &device_settings_service_,
43 loop_.message_loop_proxy())) { 44 install_attributes_.get(),
45 base::MessageLoopProxy::current())) {
44 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */); 46 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */);
45 } 47 }
46 48
47 virtual void SetUp() OVERRIDE { 49 virtual void SetUp() OVERRIDE {
48 DeviceSettingsTestBase::SetUp(); 50 DeviceSettingsTestBase::SetUp();
49 51
50 base::RunLoop loop; 52 base::RunLoop loop;
51 EnterpriseInstallAttributes::LockResult result; 53 EnterpriseInstallAttributes::LockResult result;
52 install_attributes_->LockDevice( 54 install_attributes_->LockDevice(
53 PolicyBuilder::kFakeUsername, 55 PolicyBuilder::kFakeUsername,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 98
97 void ResetToNonEnterprise() { 99 void ResetToNonEnterprise() {
98 store_.reset(); 100 store_.reset();
99 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", 101 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned",
100 std::string()); 102 std::string());
101 install_attributes_.reset(new EnterpriseInstallAttributes( 103 install_attributes_.reset(new EnterpriseInstallAttributes(
102 fake_cryptohome_client_.get())); 104 fake_cryptohome_client_.get()));
103 store_.reset( 105 store_.reset(
104 new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, 106 new DeviceCloudPolicyStoreChromeOS(&device_settings_service_,
105 install_attributes_.get(), 107 install_attributes_.get(),
106 loop_.message_loop_proxy())); 108 base::MessageLoopProxy::current()));
107 } 109 }
108 110
109 scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_; 111 scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_;
110 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; 112 scoped_ptr<EnterpriseInstallAttributes> install_attributes_;
111 113
112 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; 114 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_;
113 115
114 private: 116 private:
115 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); 117 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest);
116 }; 118 };
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 263
262 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { 264 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) {
263 PrepareNewSigningKey(); 265 PrepareNewSigningKey();
264 ResetToNonEnterprise(); 266 ResetToNonEnterprise();
265 store_->InstallInitialPolicy(device_policy_.policy()); 267 store_->InstallInitialPolicy(device_policy_.policy());
266 FlushDeviceSettings(); 268 FlushDeviceSettings();
267 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); 269 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE);
268 } 270 }
269 271
270 } // namespace policy 272 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698