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_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chromeos/dbus/dbus_thread_manager.h"
17 class FakeSessionManagerClient
;
22 class DevicePolicyCrosTestHelper
{
24 DevicePolicyCrosTestHelper();
25 ~DevicePolicyCrosTestHelper();
27 // Marks the device as enterprise-owned. Must be called to make device
28 // policies apply Chrome-wide. If this is not called, device policies will
29 // affect CrosSettings only.
30 static void MarkAsEnterpriseOwnedBy(const std::string
& user_name
);
31 void MarkAsEnterpriseOwned();
33 // Writes the owner key to disk. To be called before installing a policy.
34 void InstallOwnerKey();
36 DevicePolicyBuilder
* device_policy() { return &device_policy_
; }
39 static void OverridePaths();
41 // Carries Chrome OS device policies for tests.
42 DevicePolicyBuilder device_policy_
;
44 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosTestHelper
);
47 // Used to test Device policy changes in Chrome OS.
48 class DevicePolicyCrosBrowserTest
: public InProcessBrowserTest
{
50 DevicePolicyCrosBrowserTest();
51 ~DevicePolicyCrosBrowserTest() override
;
53 void SetUpInProcessBrowserTestFixture() override
;
54 void TearDownInProcessBrowserTestFixture() override
;
56 // Marks the device as enterprise-owned. Must be called to make device
57 // policies apply Chrome-wide. If this is not called, device policies will
58 // affect CrosSettings only.
59 void MarkAsEnterpriseOwned();
61 // Writes the owner key to disk. To be called before installing a policy.
62 void InstallOwnerKey();
64 // Reinstalls |device_policy_| as the policy (to be used when it was
66 void RefreshDevicePolicy();
68 chromeos::DBusThreadManagerSetter
* dbus_setter() {
69 return dbus_setter_
.get();
72 chromeos::FakeSessionManagerClient
* session_manager_client() {
73 return fake_session_manager_client_
;
76 DevicePolicyBuilder
* device_policy() { return test_helper_
.device_policy(); }
79 DevicePolicyCrosTestHelper test_helper_
;
81 // FakeDBusThreadManager uses FakeSessionManagerClient.
82 scoped_ptr
<chromeos::DBusThreadManagerSetter
> dbus_setter_
;
83 chromeos::FakeSessionManagerClient
* fake_session_manager_client_
;
85 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest
);
90 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_