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 #include "chrome/browser/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_service_test_base.h" | 11 #include "chrome/browser/extensions/extension_service_test_base.h" |
12 #include "chrome/browser/extensions/unpacked_installer.h" | 12 #include "chrome/browser/extensions/unpacked_installer.h" |
13 #include "chrome/browser/supervised_user/supervised_user_service.h" | |
14 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | |
15 #include "chrome/browser/themes/custom_theme_supplier.h" | 13 #include "chrome/browser/themes/custom_theme_supplier.h" |
16 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
17 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
19 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
20 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
21 #include "chrome/test/base/testing_profile_manager.h" | 19 #include "chrome/test/base/testing_profile_manager.h" |
22 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
23 #include "extensions/browser/extension_registry.h" | 21 #include "extensions/browser/extension_registry.h" |
24 #include "extensions/browser/uninstall_reason.h" | 22 #include "extensions/browser/uninstall_reason.h" |
25 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
27 | 25 |
| 26 #if defined(ENABLE_MANAGED_USERS) |
| 27 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 28 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 29 #endif |
| 30 |
28 using extensions::ExtensionRegistry; | 31 using extensions::ExtensionRegistry; |
29 | 32 |
30 namespace theme_service_internal { | 33 namespace theme_service_internal { |
31 | 34 |
32 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { | 35 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { |
33 public: | 36 public: |
34 ThemeServiceTest() : is_supervised_(false), | 37 ThemeServiceTest() : is_supervised_(false), |
35 registry_(NULL) {} | 38 registry_(NULL) {} |
36 virtual ~ThemeServiceTest() {} | 39 virtual ~ThemeServiceTest() {} |
37 | 40 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, | 230 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, |
228 ExtensionRegistry::DISABLED)); | 231 ExtensionRegistry::DISABLED)); |
229 | 232 |
230 // 2) Upgrading a disabled theme should not change the current theme. | 233 // 2) Upgrading a disabled theme should not change the current theme. |
231 UpdateUnpackedTheme(extension1_id); | 234 UpdateUnpackedTheme(extension1_id); |
232 EXPECT_EQ(extension2_id, theme_service->GetThemeID()); | 235 EXPECT_EQ(extension2_id, theme_service->GetThemeID()); |
233 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, | 236 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, |
234 ExtensionRegistry::DISABLED)); | 237 ExtensionRegistry::DISABLED)); |
235 } | 238 } |
236 | 239 |
| 240 #if defined(ENABLE_MANAGED_USERS) |
237 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { | 241 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { |
238 public: | 242 public: |
239 ThemeServiceSupervisedUserTest() {} | 243 ThemeServiceSupervisedUserTest() {} |
240 virtual ~ThemeServiceSupervisedUserTest() {} | 244 virtual ~ThemeServiceSupervisedUserTest() {} |
241 | 245 |
242 virtual void SetUp() OVERRIDE { | 246 virtual void SetUp() OVERRIDE { |
243 is_supervised_ = true; | 247 is_supervised_ = true; |
244 ThemeServiceTest::SetUp(); | 248 ThemeServiceTest::SetUp(); |
245 } | 249 } |
246 }; | 250 }; |
(...skipping 16 matching lines...) Expand all Loading... |
263 TEST_F(ThemeServiceSupervisedUserTest, SupervisedUserThemeReplacesNativeTheme) { | 267 TEST_F(ThemeServiceSupervisedUserTest, SupervisedUserThemeReplacesNativeTheme) { |
264 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); | 268 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); |
265 ThemeService* theme_service = | 269 ThemeService* theme_service = |
266 ThemeServiceFactory::GetForProfile(profile_.get()); | 270 ThemeServiceFactory::GetForProfile(profile_.get()); |
267 theme_service->UseDefaultTheme(); | 271 theme_service->UseDefaultTheme(); |
268 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 272 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
269 EXPECT_TRUE(get_theme_supplier(theme_service)); | 273 EXPECT_TRUE(get_theme_supplier(theme_service)); |
270 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 274 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
271 CustomThemeSupplier::SUPERVISED_USER_THEME); | 275 CustomThemeSupplier::SUPERVISED_USER_THEME); |
272 } | 276 } |
273 #endif | 277 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 278 #endif // defined(ENABLE_MANAGED_USERS) |
274 | 279 |
275 }; // namespace theme_service_internal | 280 }; // namespace theme_service_internal |
OLD | NEW |