| 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.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" | 13 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 14 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 14 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 15 #include "chrome/browser/themes/custom_theme_supplier.h" | 15 #include "chrome/browser/themes/custom_theme_supplier.h" |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
| 22 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 23 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 using extensions::ExtensionRegistry; | 27 using extensions::ExtensionRegistry; |
| 28 using extensions::UninstalledExtensionInfo; |
| 28 | 29 |
| 29 namespace theme_service_internal { | 30 namespace theme_service_internal { |
| 30 | 31 |
| 31 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { | 32 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { |
| 32 public: | 33 public: |
| 33 ThemeServiceTest() : is_supervised_(false), | 34 ThemeServiceTest() : is_supervised_(false), |
| 34 registry_(NULL) {} | 35 registry_(NULL) {} |
| 35 virtual ~ThemeServiceTest() {} | 36 virtual ~ThemeServiceTest() {} |
| 36 | 37 |
| 37 // Moves a minimal theme to |temp_dir_path| and unpacks it from that | 38 // Moves a minimal theme to |temp_dir_path| and unpacks it from that |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 base::MessageLoop::current()->RunUntilIdle(); | 114 base::MessageLoop::current()->RunUntilIdle(); |
| 114 | 115 |
| 115 base::ScopedTempDir temp_dir; | 116 base::ScopedTempDir temp_dir; |
| 116 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 117 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 117 const std::string& extension_id = LoadUnpackedThemeAt(temp_dir.path()); | 118 const std::string& extension_id = LoadUnpackedThemeAt(temp_dir.path()); |
| 118 EXPECT_FALSE(theme_service->UsingDefaultTheme()); | 119 EXPECT_FALSE(theme_service->UsingDefaultTheme()); |
| 119 EXPECT_EQ(extension_id, theme_service->GetThemeID()); | 120 EXPECT_EQ(extension_id, theme_service->GetThemeID()); |
| 120 | 121 |
| 121 // Now uninstall the extension, should revert to the default theme. | 122 // Now uninstall the extension, should revert to the default theme. |
| 122 service_->UninstallExtension( | 123 service_->UninstallExtension( |
| 123 extension_id, ExtensionService::UNINSTALL_REASON_FOR_TESTING, NULL); | 124 extension_id, UninstalledExtensionInfo::REASON_FOR_TESTING, NULL); |
| 124 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 125 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
| 125 } | 126 } |
| 126 | 127 |
| 127 // Test that a theme extension is disabled when not in use. A theme may be | 128 // Test that a theme extension is disabled when not in use. A theme may be |
| 128 // installed but not in use if it there is an infobar to revert to the previous | 129 // installed but not in use if it there is an infobar to revert to the previous |
| 129 // theme. | 130 // theme. |
| 130 TEST_F(ThemeServiceTest, DisableUnusedTheme) { | 131 TEST_F(ThemeServiceTest, DisableUnusedTheme) { |
| 131 ThemeService* theme_service = | 132 ThemeService* theme_service = |
| 132 ThemeServiceFactory::GetForProfile(profile_.get()); | 133 ThemeServiceFactory::GetForProfile(profile_.get()); |
| 133 theme_service->UseDefaultTheme(); | 134 theme_service->UseDefaultTheme(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 ThemeServiceFactory::GetForProfile(profile_.get()); | 264 ThemeServiceFactory::GetForProfile(profile_.get()); |
| 264 theme_service->UseDefaultTheme(); | 265 theme_service->UseDefaultTheme(); |
| 265 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 266 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
| 266 EXPECT_TRUE(get_theme_supplier(theme_service)); | 267 EXPECT_TRUE(get_theme_supplier(theme_service)); |
| 267 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 268 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
| 268 CustomThemeSupplier::SUPERVISED_USER_THEME); | 269 CustomThemeSupplier::SUPERVISED_USER_THEME); |
| 269 } | 270 } |
| 270 #endif | 271 #endif |
| 271 | 272 |
| 272 }; // namespace theme_service_internal | 273 }; // namespace theme_service_internal |
| OLD | NEW |