| 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_syncable_service.h" | 5 #include "chrome/browser/themes/theme_syncable_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/run_loop.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/test_extension_system.h" | 17 #include "chrome/browser/extensions/test_extension_system.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
| 19 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 profile_.reset(new TestingProfile); | 173 profile_.reset(new TestingProfile); |
| 173 fake_theme_service_ = BuildForProfile(profile_.get()); | 174 fake_theme_service_ = BuildForProfile(profile_.get()); |
| 174 theme_sync_service_.reset(new ThemeSyncableService(profile_.get(), | 175 theme_sync_service_.reset(new ThemeSyncableService(profile_.get(), |
| 175 fake_theme_service_)); | 176 fake_theme_service_)); |
| 176 fake_change_processor_.reset(new syncer::FakeSyncChangeProcessor); | 177 fake_change_processor_.reset(new syncer::FakeSyncChangeProcessor); |
| 177 SetUpExtension(); | 178 SetUpExtension(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void TearDown() override { | 181 void TearDown() override { |
| 181 profile_.reset(); | 182 profile_.reset(); |
| 182 loop_.RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void SetUpExtension() { | 186 void SetUpExtension() { |
| 186 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 187 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 187 extensions::TestExtensionSystem* test_ext_system = | 188 extensions::TestExtensionSystem* test_ext_system = |
| 188 static_cast<extensions::TestExtensionSystem*>( | 189 static_cast<extensions::TestExtensionSystem*>( |
| 189 extensions::ExtensionSystem::Get(profile_.get())); | 190 extensions::ExtensionSystem::Get(profile_.get())); |
| 190 ExtensionService* service = test_ext_system->CreateExtensionService( | 191 ExtensionService* service = test_ext_system->CreateExtensionService( |
| 191 &command_line, base::FilePath(kExtensionFilePath), false); | 192 &command_line, base::FilePath(kExtensionFilePath), false); |
| 192 EXPECT_TRUE(service->extensions_enabled()); | 193 EXPECT_TRUE(service->extensions_enabled()); |
| 193 service->Init(); | 194 service->Init(); |
| 194 loop_.RunUntilIdle(); | 195 base::RunLoop().RunUntilIdle(); |
| 195 | 196 |
| 196 // Create and add custom theme extension so the ThemeSyncableService can | 197 // Create and add custom theme extension so the ThemeSyncableService can |
| 197 // find it. | 198 // find it. |
| 198 theme_extension_ = MakeThemeExtension(base::FilePath(kExtensionFilePath), | 199 theme_extension_ = MakeThemeExtension(base::FilePath(kExtensionFilePath), |
| 199 kCustomThemeName, | 200 kCustomThemeName, |
| 200 GetThemeLocation(), | 201 GetThemeLocation(), |
| 201 kCustomThemeUrl); | 202 kCustomThemeUrl); |
| 202 extensions::ExtensionPrefs::Get(profile_.get()) | 203 extensions::ExtensionPrefs::Get(profile_.get()) |
| 203 ->AddGrantedPermissions(theme_extension_->id(), | 204 ->AddGrantedPermissions(theme_extension_->id(), |
| 204 extensions::PermissionSet()); | 205 extensions::PermissionSet()); |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 657 |
| 657 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { | 658 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { |
| 658 // Set up theme service to use custom theme that was installed by policy. | 659 // Set up theme service to use custom theme that was installed by policy. |
| 659 fake_theme_service_->SetTheme(theme_extension_.get()); | 660 fake_theme_service_->SetTheme(theme_extension_.get()); |
| 660 | 661 |
| 661 syncer::SyncDataList data_list = | 662 syncer::SyncDataList data_list = |
| 662 theme_sync_service_->GetAllSyncData(syncer::THEMES); | 663 theme_sync_service_->GetAllSyncData(syncer::THEMES); |
| 663 | 664 |
| 664 ASSERT_EQ(0u, data_list.size()); | 665 ASSERT_EQ(0u, data_list.size()); |
| 665 } | 666 } |
| OLD | NEW |