cryptohome: Move stateless wrapper functions out of CryptohomeLibrary
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / device_policy_cros_browser_test.h
blob1a0dafc97482996b743a783e03d78941b3bf3630
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/files/scoped_temp_dir.h"
11 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h"
15 namespace chromeos {
16 class FakeSessionManagerClient;
19 namespace policy {
21 class DevicePolicyCrosTestHelper {
22 public:
23 DevicePolicyCrosTestHelper();
24 ~DevicePolicyCrosTestHelper();
26 // Marks the device as enterprise-owned. Must be called to make device
27 // policies apply Chrome-wide. If this is not called, device policies will
28 // affect CrosSettings only.
29 void MarkAsEnterpriseOwned();
31 // Writes the owner key to disk. To be called before installing a policy.
32 void InstallOwnerKey();
34 DevicePolicyBuilder* device_policy() { return &device_policy_; }
36 private:
37 // Stores the device owner key and the install attributes.
38 base::ScopedTempDir temp_dir_;
40 // Carries Chrome OS device policies for tests.
41 DevicePolicyBuilder device_policy_;
43 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosTestHelper);
46 // Used to test Device policy changes in Chrome OS.
47 class DevicePolicyCrosBrowserTest : public InProcessBrowserTest {
48 protected:
49 DevicePolicyCrosBrowserTest();
50 virtual ~DevicePolicyCrosBrowserTest();
52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
53 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
55 // Marks the device as enterprise-owned. Must be called to make device
56 // policies apply Chrome-wide. If this is not called, device policies will
57 // affect CrosSettings only.
58 void MarkAsEnterpriseOwned();
60 // Writes the owner key to disk. To be called before installing a policy.
61 void InstallOwnerKey();
63 // Reinstalls |device_policy_| as the policy (to be used when it was
64 // recently changed).
65 void RefreshDevicePolicy();
67 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager() {
68 return mock_dbus_thread_manager_;
71 chromeos::FakeSessionManagerClient* session_manager_client() {
72 return mock_dbus_thread_manager_->fake_session_manager_client();
75 DevicePolicyBuilder* device_policy() { return test_helper_.device_policy(); }
77 private:
78 DevicePolicyCrosTestHelper test_helper_;
80 // MockDBusThreadManagerWithoutGMock uses FakeSessionManagerClient.
81 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager_;
83 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest);
86 } // namespace policy
88 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_