| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 11 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
| 12 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 12 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
| 13 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 13 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
| 14 #include "chromeos/dbus/fake_session_manager_client.h" | 14 #include "chromeos/dbus/fake_session_manager_client.h" |
| 15 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" | 15 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace policy { | 18 namespace policy { |
| 19 | 19 |
| 20 // Used to test Device policy changes in Chrome OS. | 20 // Used to test Device policy changes in Chrome OS. |
| 21 class DevicePolicyCrosBrowserTest : | 21 class DevicePolicyCrosBrowserTest : |
| 22 public chromeos::CrosInProcessBrowserTest { | 22 public chromeos::CrosInProcessBrowserTest { |
| 23 public: | |
| 24 // Marks the device as enterprise-owned. Must be called to make device | |
| 25 // policies apply Chrome-wide. If this is not called, device policies will | |
| 26 // affect CrosSettings only. | |
| 27 static void MarkAsEnterpriseOwned(base::ScopedTempDir* temp_dir); | |
| 28 | |
| 29 protected: | 23 protected: |
| 30 DevicePolicyCrosBrowserTest(); | 24 DevicePolicyCrosBrowserTest(); |
| 31 virtual ~DevicePolicyCrosBrowserTest(); | 25 virtual ~DevicePolicyCrosBrowserTest(); |
| 32 | 26 |
| 33 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 27 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 34 | 28 |
| 35 // Writes the owner key to disk. To be called before installing a policy. | 29 // Writes the owner key to disk. To be called before installing a policy. |
| 36 void InstallOwnerKey(); | 30 void InstallOwnerKey(); |
| 37 | 31 |
| 38 // Reinstalls |device_policy_| as the policy (to be used when it was | 32 // Reinstalls |device_policy_| as the policy (to be used when it was |
| 39 // recently changed). | 33 // recently changed). |
| 40 void RefreshDevicePolicy(); | 34 void RefreshDevicePolicy(); |
| 41 | 35 |
| 42 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; | 36 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
| 43 | 37 |
| 44 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager() { | 38 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager() { |
| 45 return mock_dbus_thread_manager_; | 39 return mock_dbus_thread_manager_; |
| 46 } | 40 } |
| 47 | 41 |
| 48 chromeos::FakeSessionManagerClient* session_manager_client() { | 42 chromeos::FakeSessionManagerClient* session_manager_client() { |
| 49 return mock_dbus_thread_manager_->fake_session_manager_client(); | 43 return mock_dbus_thread_manager_->fake_session_manager_client(); |
| 50 } | 44 } |
| 51 | 45 |
| 52 DevicePolicyBuilder* device_policy() { return &device_policy_; } | 46 DevicePolicyBuilder* device_policy() { return &device_policy_; } |
| 53 | 47 |
| 54 // Stores the device owner key and the install attributes. | |
| 55 base::ScopedTempDir temp_dir_; | |
| 56 | |
| 57 private: | 48 private: |
| 58 // MockDBusThreadManagerWithoutGMock uses FakeSessionManagerClient. | 49 // MockDBusThreadManagerWithoutGMock uses FakeSessionManagerClient. |
| 59 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager_; | 50 chromeos::MockDBusThreadManagerWithoutGMock* mock_dbus_thread_manager_; |
| 60 | 51 |
| 61 // Carries Chrome OS device policies for tests. | 52 // Carries Chrome OS device policies for tests. |
| 62 DevicePolicyBuilder device_policy_; | 53 DevicePolicyBuilder device_policy_; |
| 63 | 54 |
| 55 // Stores the device owner key. |
| 56 base::ScopedTempDir temp_dir_; |
| 57 |
| 64 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest); | 58 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCrosBrowserTest); |
| 65 }; | 59 }; |
| 66 | 60 |
| 67 } // namespace policy | 61 } // namespace policy |
| 68 | 62 |
| 69 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ | 63 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_POLICY_CROS_BROWSER_TEST_H_ |
| OLD | NEW |