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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 public: | 137 public: |
139 ScopedDeviceSettingsTestHelper(); | 138 ScopedDeviceSettingsTestHelper(); |
140 virtual ~ScopedDeviceSettingsTestHelper(); | 139 virtual ~ScopedDeviceSettingsTestHelper(); |
141 | 140 |
142 private: | 141 private: |
143 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); | 142 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); |
144 }; | 143 }; |
145 | 144 |
146 // A convenience test base class that initializes a DeviceSettingsService | 145 // A convenience test base class that initializes a DeviceSettingsService |
147 // instance for testing and allows for straightforward updating of device | 146 // instance for testing and allows for straightforward updating of device |
148 // settings. |device_settings_service_| starts out in uninitialized state, so | 147 // settings. The DeviceSettingsService starts out in uninitialized state, so |
149 // startup code gets tested as well. | 148 // startup code gets tested as well. |
150 class DeviceSettingsTestBase : public testing::Test { | 149 class DeviceSettingsTestBase : public testing::Test { |
151 protected: | 150 protected: |
152 DeviceSettingsTestBase(); | 151 DeviceSettingsTestBase(); |
153 virtual ~DeviceSettingsTestBase(); | 152 virtual ~DeviceSettingsTestBase(); |
154 | 153 |
155 virtual void SetUp() OVERRIDE; | 154 virtual void SetUp() OVERRIDE; |
156 virtual void TearDown() OVERRIDE; | 155 virtual void TearDown() OVERRIDE; |
157 | 156 |
158 // Flushes any pending device settings operations. | 157 // Flushes any pending device settings operations. |
159 void FlushDeviceSettings(); | 158 void FlushDeviceSettings(); |
160 | 159 |
161 // Triggers an owner key and device settings reload on | 160 // Triggers an owner key and device settings reload on the |
162 // |device_settings_service_| and flushes the resulting load operation. | 161 // DeviceSettingsService and flushes the resulting load operation. |
163 void ReloadDeviceSettings(); | 162 void ReloadDeviceSettings(); |
164 | 163 |
165 MessageLoop loop_; | 164 MessageLoop loop_; |
166 content::TestBrowserThread ui_thread_; | 165 content::TestBrowserThread ui_thread_; |
167 content::TestBrowserThread file_thread_; | 166 content::TestBrowserThread file_thread_; |
168 | 167 |
169 policy::DevicePolicyBuilder device_policy_; | 168 policy::DevicePolicyBuilder device_policy_; |
170 | 169 |
171 DeviceSettingsTestHelper device_settings_test_helper_; | 170 DeviceSettingsTestHelper device_settings_test_helper_; |
172 scoped_refptr<MockOwnerKeyUtil> owner_key_util_; | 171 scoped_refptr<MockOwnerKeyUtil> owner_key_util_; |
173 // Local DeviceSettingsService instance for tests. Avoid using in combination | |
174 // with the global instance (DeviceSettingsService::Get()). | |
175 DeviceSettingsService device_settings_service_; | |
Mattias Nissler (ping if slow)
2013/05/15 09:38:47
And everything moves in the direction of global si
bartfab (slow)
2013/05/17 11:14:28
I agree. For some reason, I thought it would be mu
| |
176 | 172 |
177 private: | 173 private: |
178 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); | 174 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestBase); |
179 }; | 175 }; |
180 | 176 |
181 } // namespace chromeos | 177 } // namespace chromeos |
182 | 178 |
183 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ | 179 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
OLD | NEW |