| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 using extensions::ExtensionRegistry; | 31 using extensions::ExtensionRegistry; |
| 32 | 32 |
| 33 namespace theme_service_internal { | 33 namespace theme_service_internal { |
| 34 | 34 |
| 35 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { | 35 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { |
| 36 public: | 36 public: |
| 37 ThemeServiceTest() : is_supervised_(false), | 37 ThemeServiceTest() : is_supervised_(false), |
| 38 registry_(NULL) {} | 38 registry_(NULL) {} |
| 39 virtual ~ThemeServiceTest() {} | 39 ~ThemeServiceTest() override {} |
| 40 | 40 |
| 41 // Moves a minimal theme to |temp_dir_path| and unpacks it from that | 41 // Moves a minimal theme to |temp_dir_path| and unpacks it from that |
| 42 // directory. | 42 // directory. |
| 43 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { | 43 std::string LoadUnpackedThemeAt(const base::FilePath& temp_dir) { |
| 44 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); | 44 base::FilePath dst_manifest_path = temp_dir.AppendASCII("manifest.json"); |
| 45 base::FilePath test_data_dir; | 45 base::FilePath test_data_dir; |
| 46 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 46 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); |
| 47 base::FilePath src_manifest_path = | 47 base::FilePath src_manifest_path = |
| 48 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json"); | 48 test_data_dir.AppendASCII("extensions/theme_minimal/manifest.json"); |
| 49 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path)); | 49 EXPECT_TRUE(base::CopyFile(src_manifest_path, dst_manifest_path)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 79 extensions::UnpackedInstaller::Create(service_)); | 79 extensions::UnpackedInstaller::Create(service_)); |
| 80 content::WindowedNotificationObserver observer(updated_notification, | 80 content::WindowedNotificationObserver observer(updated_notification, |
| 81 content::Source<Profile>(profile_.get())); | 81 content::Source<Profile>(profile_.get())); |
| 82 installer->Load(path); | 82 installer->Load(path); |
| 83 observer.Wait(); | 83 observer.Wait(); |
| 84 | 84 |
| 85 // Let the ThemeService finish creating the theme pack. | 85 // Let the ThemeService finish creating the theme pack. |
| 86 base::MessageLoop::current()->RunUntilIdle(); | 86 base::MessageLoop::current()->RunUntilIdle(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void SetUp() { | 89 void SetUp() override { |
| 90 extensions::ExtensionServiceTestBase::SetUp(); | 90 extensions::ExtensionServiceTestBase::SetUp(); |
| 91 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params = | 91 extensions::ExtensionServiceTestBase::ExtensionServiceInitParams params = |
| 92 CreateDefaultInitParams(); | 92 CreateDefaultInitParams(); |
| 93 params.profile_is_supervised = is_supervised_; | 93 params.profile_is_supervised = is_supervised_; |
| 94 InitializeExtensionService(params); | 94 InitializeExtensionService(params); |
| 95 service_->Init(); | 95 service_->Init(); |
| 96 registry_ = ExtensionRegistry::Get(profile_.get()); | 96 registry_ = ExtensionRegistry::Get(profile_.get()); |
| 97 ASSERT_TRUE(registry_); | 97 ASSERT_TRUE(registry_); |
| 98 } | 98 } |
| 99 | 99 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 UpdateUnpackedTheme(extension1_id); | 234 UpdateUnpackedTheme(extension1_id); |
| 235 EXPECT_EQ(extension2_id, theme_service->GetThemeID()); | 235 EXPECT_EQ(extension2_id, theme_service->GetThemeID()); |
| 236 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, | 236 EXPECT_TRUE(registry_->GetExtensionById(extension1_id, |
| 237 ExtensionRegistry::DISABLED)); | 237 ExtensionRegistry::DISABLED)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 #if defined(ENABLE_MANAGED_USERS) | 240 #if defined(ENABLE_MANAGED_USERS) |
| 241 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { | 241 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { |
| 242 public: | 242 public: |
| 243 ThemeServiceSupervisedUserTest() {} | 243 ThemeServiceSupervisedUserTest() {} |
| 244 virtual ~ThemeServiceSupervisedUserTest() {} | 244 ~ThemeServiceSupervisedUserTest() override {} |
| 245 | 245 |
| 246 virtual void SetUp() override { | 246 void SetUp() override { |
| 247 is_supervised_ = true; | 247 is_supervised_ = true; |
| 248 ThemeServiceTest::SetUp(); | 248 ThemeServiceTest::SetUp(); |
| 249 } | 249 } |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 // Checks that supervised users have their own default theme. | 252 // Checks that supervised users have their own default theme. |
| 253 TEST_F(ThemeServiceSupervisedUserTest, | 253 TEST_F(ThemeServiceSupervisedUserTest, |
| 254 SupervisedUserThemeReplacesDefaultTheme) { | 254 SupervisedUserThemeReplacesDefaultTheme) { |
| 255 ThemeService* theme_service = | 255 ThemeService* theme_service = |
| 256 ThemeServiceFactory::GetForProfile(profile_.get()); | 256 ThemeServiceFactory::GetForProfile(profile_.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 271 theme_service->UseDefaultTheme(); | 271 theme_service->UseDefaultTheme(); |
| 272 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 272 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
| 273 EXPECT_TRUE(get_theme_supplier(theme_service)); | 273 EXPECT_TRUE(get_theme_supplier(theme_service)); |
| 274 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 274 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
| 275 CustomThemeSupplier::SUPERVISED_USER_THEME); | 275 CustomThemeSupplier::SUPERVISED_USER_THEME); |
| 276 } | 276 } |
| 277 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 277 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 278 #endif // defined(ENABLE_MANAGED_USERS) | 278 #endif // defined(ENABLE_MANAGED_USERS) |
| 279 | 279 |
| 280 }; // namespace theme_service_internal | 280 }; // namespace theme_service_internal |
| OLD | NEW |