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/file_util.h" | 7 #include "base/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_unittest.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_service_test_base.h" |
11 #include "chrome/browser/extensions/unpacked_installer.h" | 12 #include "chrome/browser/extensions/unpacked_installer.h" |
12 #include "chrome/browser/managed_mode/managed_user_service.h" | 13 #include "chrome/browser/managed_mode/managed_user_service.h" |
13 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 14 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
14 #include "chrome/browser/themes/custom_theme_supplier.h" | 15 #include "chrome/browser/themes/custom_theme_supplier.h" |
15 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
20 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
21 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
23 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 using extensions::ExtensionRegistry; | 27 using extensions::ExtensionRegistry; |
27 | 28 |
28 namespace theme_service_internal { | 29 namespace theme_service_internal { |
29 | 30 |
30 class ThemeServiceTest : public ExtensionServiceTestBase { | 31 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { |
31 public: | 32 public: |
32 ThemeServiceTest() : is_managed_(false), | 33 ThemeServiceTest() : is_managed_(false), |
33 registry_(NULL) {} | 34 registry_(NULL) {} |
34 virtual ~ThemeServiceTest() {} | 35 virtual ~ThemeServiceTest() {} |
35 | 36 |
36 // Moves a minimal theme to |temp_dir_path| and unpacks it from that | 37 // Moves a minimal theme to |temp_dir_path| and unpacks it from that |
37 // directory. | 38 // directory. |
38 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { | 39 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { |
39 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); | 40 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); |
40 base::FilePath test_data_dir; | 41 base::FilePath test_data_dir; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 content::WindowedNotificationObserver observer(updated_notification, | 76 content::WindowedNotificationObserver observer(updated_notification, |
76 content::Source<Profile>(profile_.get())); | 77 content::Source<Profile>(profile_.get())); |
77 installer->Load(path); | 78 installer->Load(path); |
78 observer.Wait(); | 79 observer.Wait(); |
79 | 80 |
80 // Let the ThemeService finish creating the theme pack. | 81 // Let the ThemeService finish creating the theme pack. |
81 base::MessageLoop::current()->RunUntilIdle(); | 82 base::MessageLoop::current()->RunUntilIdle(); |
82 } | 83 } |
83 | 84 |
84 virtual void SetUp() { | 85 virtual void SetUp() { |
85 ExtensionServiceTestBase::SetUp(); | 86 extensions::ExtensionServiceTestBase::SetUp(); |
86 ExtensionServiceTestBase::ExtensionServiceInitParams params = | 87 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params = |
87 CreateDefaultInitParams(); | 88 CreateDefaultInitParams(); |
88 params.profile_is_managed = is_managed_; | 89 params.profile_is_managed = is_managed_; |
89 InitializeExtensionService(params); | 90 InitializeExtensionService(params); |
90 service_->Init(); | 91 service_->Init(); |
91 registry_ = ExtensionRegistry::Get(profile_.get()); | 92 registry_ = ExtensionRegistry::Get(profile_.get()); |
92 ASSERT_TRUE(registry_); | 93 ASSERT_TRUE(registry_); |
93 } | 94 } |
94 | 95 |
95 const CustomThemeSupplier* get_theme_supplier(ThemeService* theme_service) { | 96 const CustomThemeSupplier* get_theme_supplier(ThemeService* theme_service) { |
96 return theme_service->get_theme_supplier(); | 97 return theme_service->get_theme_supplier(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 ThemeServiceFactory::GetForProfile(profile_.get()); | 261 ThemeServiceFactory::GetForProfile(profile_.get()); |
261 theme_service->UseDefaultTheme(); | 262 theme_service->UseDefaultTheme(); |
262 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 263 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
263 EXPECT_TRUE(get_theme_supplier(theme_service)); | 264 EXPECT_TRUE(get_theme_supplier(theme_service)); |
264 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 265 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
265 CustomThemeSupplier::MANAGED_USER_THEME); | 266 CustomThemeSupplier::MANAGED_USER_THEME); |
266 } | 267 } |
267 #endif | 268 #endif |
268 | 269 |
269 }; // namespace theme_service_internal | 270 }; // namespace theme_service_internal |
OLD | NEW |