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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 profile_.reset(new TestingProfile); | 160 profile_.reset(new TestingProfile); |
161 fake_theme_service_ = BuildForProfile(profile_.get()); | 161 fake_theme_service_ = BuildForProfile(profile_.get()); |
162 theme_sync_service_.reset(new ThemeSyncableService(profile_.get(), | 162 theme_sync_service_.reset(new ThemeSyncableService(profile_.get(), |
163 fake_theme_service_)); | 163 fake_theme_service_)); |
164 fake_change_processor_.reset(new FakeSyncChangeProcessor); | 164 fake_change_processor_.reset(new FakeSyncChangeProcessor); |
165 SetUpExtension(); | 165 SetUpExtension(); |
166 } | 166 } |
167 | 167 |
168 virtual void TearDown() { | 168 virtual void TearDown() { |
169 profile_.reset(); | 169 profile_.reset(); |
170 loop_.RunAllPending(); | 170 loop_.RunUntilIdle(); |
171 } | 171 } |
172 | 172 |
173 void SetUpExtension() { | 173 void SetUpExtension() { |
174 CommandLine command_line(CommandLine::NO_PROGRAM); | 174 CommandLine command_line(CommandLine::NO_PROGRAM); |
175 extensions::TestExtensionSystem* test_ext_system = | 175 extensions::TestExtensionSystem* test_ext_system = |
176 static_cast<extensions::TestExtensionSystem*>( | 176 static_cast<extensions::TestExtensionSystem*>( |
177 extensions::ExtensionSystem::Get(profile_.get())); | 177 extensions::ExtensionSystem::Get(profile_.get())); |
178 ExtensionService* service = | 178 ExtensionService* service = |
179 test_ext_system->CreateExtensionService(&command_line, | 179 test_ext_system->CreateExtensionService(&command_line, |
180 FilePath(kExtensionFilePath), | 180 FilePath(kExtensionFilePath), |
181 false); | 181 false); |
182 EXPECT_TRUE(service->extensions_enabled()); | 182 EXPECT_TRUE(service->extensions_enabled()); |
183 service->Init(); | 183 service->Init(); |
184 loop_.RunAllPending(); | 184 loop_.RunUntilIdle(); |
185 | 185 |
186 // Create and add custom theme extension so the ThemeSyncableService can | 186 // Create and add custom theme extension so the ThemeSyncableService can |
187 // find it. | 187 // find it. |
188 theme_extension_ = MakeThemeExtension(FilePath(kExtensionFilePath), | 188 theme_extension_ = MakeThemeExtension(FilePath(kExtensionFilePath), |
189 kCustomThemeName, kCustomThemeUrl); | 189 kCustomThemeName, kCustomThemeUrl); |
190 service->AddExtension(theme_extension_); | 190 service->AddExtension(theme_extension_); |
191 ASSERT_EQ(1u, service->extensions()->size()); | 191 ASSERT_EQ(1u, service->extensions()->size()); |
192 } | 192 } |
193 | 193 |
194 FakeThemeService* BuildForProfile(Profile* profile) { | 194 FakeThemeService* BuildForProfile(Profile* profile) { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 // use_system_theme_by_default bit should be preserved. | 551 // use_system_theme_by_default bit should be preserved. |
552 fake_theme_service_->UseDefaultTheme(); | 552 fake_theme_service_->UseDefaultTheme(); |
553 theme_sync_service_->OnThemeChange(); | 553 theme_sync_service_->OnThemeChange(); |
554 EXPECT_EQ(1u, change_list.size()); | 554 EXPECT_EQ(1u, change_list.size()); |
555 const sync_pb::ThemeSpecifics& change_specifics = | 555 const sync_pb::ThemeSpecifics& change_specifics = |
556 change_list[0].sync_data().GetSpecifics().theme(); | 556 change_list[0].sync_data().GetSpecifics().theme(); |
557 EXPECT_FALSE(change_specifics.use_custom_theme()); | 557 EXPECT_FALSE(change_specifics.use_custom_theme()); |
558 EXPECT_TRUE(change_specifics.use_system_theme_by_default()); | 558 EXPECT_TRUE(change_specifics.use_system_theme_by_default()); |
559 } | 559 } |
560 #endif | 560 #endif |
OLD | NEW |