OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 17 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
18 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
19 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
20 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" | 19 #include "chrome/browser/chromeos/settings/mock_owner_key_util.h" |
21 #include "chromeos/dbus/session_manager_client.h" | 20 #include "chromeos/dbus/session_manager_client.h" |
22 #include "content/public/test/test_browser_thread.h" | 21 #include "content/public/test/test_browser_thread.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 | 23 |
25 namespace chromeos { | 24 namespace chromeos { |
26 | 25 |
27 // A helper class for tests mocking out session_manager's device settings | 26 // A helper class for tests mocking out session_manager's device settings |
28 // interface. The pattern is to initialize DeviceSettingsService with the helper | 27 // interface. The pattern is to initialize DeviceSettingsService with the helper |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 public: | 134 public: |
136 ScopedDeviceSettingsTestHelper(); | 135 ScopedDeviceSettingsTestHelper(); |
137 virtual ~ScopedDeviceSettingsTestHelper(); | 136 virtual ~ScopedDeviceSettingsTestHelper(); |
138 | 137 |
139 private: | 138 private: |
140 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); | 139 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); |
141 }; | 140 }; |
142 | 141 |
143 // A convenience test base class that initializes a DeviceSettingsService | 142 // A convenience test base class that initializes a DeviceSettingsService |
144 // instance for testing and allows for straightforward updating of device | 143 // instance for testing and allows for straightforward updating of device |
145 // settings. |device_settings_service_| starts out in uninitialized state, so | 144 // settings. The DeviceSettingsService starts out in uninitialized state, so |
146 // startup code gets tested as well. | 145 // startup code gets tested as well. |
147 class DeviceSettingsTestBase : public testing::Test { | 146 class DeviceSettingsTestBase : public testing::Test { |
148 protected: | 147 protected: |
149 DeviceSettingsTestBase(); | 148 DeviceSettingsTestBase(); |
150 virtual ~DeviceSettingsTestBase(); | 149 virtual ~DeviceSettingsTestBase(); |
151 | 150 |
152 virtual void SetUp() OVERRIDE; | 151 virtual void SetUp() OVERRIDE; |
153 virtual void TearDown() OVERRIDE; | 152 virtual void TearDown() OVERRIDE; |
154 | 153 |
155 // Flushes any pending device settings operations. | 154 // Flushes any pending device settings operations. |
156 void FlushDeviceSettings(); | 155 void FlushDeviceSettings(); |
157 | 156 |
158 // Triggers an owner key and device settings reload on | 157 // Triggers an owner key and device settings reload on the |
159 // |device_settings_service_| and flushes the resulting load operation. | 158 // DeviceSettingsService and flushes the resulting load operation. |
160 void ReloadDeviceSettings(); | 159 void ReloadDeviceSettings(); |
161 | 160 |
162 MessageLoop loop_; | 161 MessageLoop loop_; |
163 content::TestBrowserThread ui_thread_; | 162 content::TestBrowserThread ui_thread_; |
164 content::TestBrowserThread file_thread_; | 163 content::TestBrowserThread file_thread_; |
165 | 164 |
166 policy::DevicePolicyBuilder device_policy_; | 165 policy::DevicePolicyBuilder device_policy_; |
167 | 166 |
168 DeviceSettingsTestHelper device_settings_test_helper_; | 167 DeviceSettingsTestHelper device_settings_test_helper_; |
169 scoped_refptr<MockOwnerKeyUtil> owner_key_util_; | 168 scoped_refptr<MockOwnerKeyUtil> owner_key_util_; |
170 // Local DeviceSettingsService instance for tests. Avoid using in combination | |
171 // with the global instance (DeviceSettingsService::Get()). | |
172 DeviceSettingsService device_settings_service_; | |
173 | 169 |
174 private: | 170 private: |
175 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); | 171 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); |
176 }; | 172 }; |
177 | 173 |
178 } // namespace chromeos | 174 } // namespace chromeos |
179 | 175 |
180 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ | 176 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
OLD | NEW |