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 "chrome/browser/chromeos/policy/device_policy_builder.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chromeos/dbus/dbus_thread_manager.h"
15 class FakeSessionManagerClient
;
20 class DevicePolicyCrosTestHelper
{
22 DevicePolicyCrosTestHelper();
23 ~DevicePolicyCrosTestHelper();
25 // Marks the device as enterprise-owned. Must be called to make device
26 // policies apply Chrome-wide. If this is not called, device policies will
27 // affect CrosSettings only.
28 void MarkAsEnterpriseOwned();
30 // Writes the owner key to disk. To be called before installing a policy.
31 void InstallOwnerKey();
33 DevicePolicyBuilder
* device_policy() { return &device_policy_
; }
38 // Carries Chrome OS device policies for tests.
39 DevicePolicyBuilder device_policy_
;
41 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosTestHelper
);
44 // Used to test Device policy changes in Chrome OS.
45 class DevicePolicyCrosBrowserTest
: public InProcessBrowserTest
{
47 DevicePolicyCrosBrowserTest();
48 ~DevicePolicyCrosBrowserTest() override
;
50 void SetUpInProcessBrowserTestFixture() override
;
51 void TearDownInProcessBrowserTestFixture() override
;
53 // Marks the device as enterprise-owned. Must be called to make device
54 // policies apply Chrome-wide. If this is not called, device policies will
55 // affect CrosSettings only.
56 void MarkAsEnterpriseOwned();
58 // Writes the owner key to disk. To be called before installing a policy.
59 void InstallOwnerKey();
61 // Reinstalls |device_policy_| as the policy (to be used when it was
63 void RefreshDevicePolicy();
65 chromeos::DBusThreadManagerSetter
* dbus_setter() {
66 return dbus_setter_
.get();
69 chromeos::FakeSessionManagerClient
* session_manager_client() {
70 return fake_session_manager_client_
;
73 DevicePolicyBuilder
* device_policy() { return test_helper_
.device_policy(); }
76 DevicePolicyCrosTestHelper test_helper_
;
78 // FakeDBusThreadManager uses FakeSessionManagerClient.
79 scoped_ptr
<chromeos::DBusThreadManagerSetter
> dbus_setter_
;
80 chromeos::FakeSessionManagerClient
* fake_session_manager_client_
;
82 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest
);
87 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_