Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: chrome/browser/themes/theme_service_unittest.cc

Issue 11445038: Revert changes to have ExtensionService notify ThemeService directly for themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge error Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "chrome/browser/extensions/extension_service_unittest.h" 8 #include "chrome/browser/extensions/extension_service_unittest.h"
9 #include "chrome/browser/themes/theme_service_factory.h" 9 #include "chrome/browser/themes/theme_service_factory.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // Installs then uninstalls a theme and makes sure that the ThemeService 87 // Installs then uninstalls a theme and makes sure that the ThemeService
88 // reverts to the default theme after the uninstall. 88 // reverts to the default theme after the uninstall.
89 TEST_F(ThemeServiceTest, ThemeInstallUninstall) { 89 TEST_F(ThemeServiceTest, ThemeInstallUninstall) {
90 base::ScopedTempDir temp_dir; 90 base::ScopedTempDir temp_dir;
91 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 91 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
92 ThemeService* theme_service = 92 ThemeService* theme_service =
93 ThemeServiceFactory::GetForProfile(profile_.get()); 93 ThemeServiceFactory::GetForProfile(profile_.get());
94 theme_service->UseDefaultTheme(); 94 theme_service->UseDefaultTheme();
95 scoped_refptr<extensions::Extension> extension = 95 scoped_refptr<extensions::Extension> extension =
96 MakeThemeExtension(temp_dir.path()); 96 MakeThemeExtension(temp_dir.path());
97 service_->FinishInstallationForTest(extension); 97 service_->AddExtension(extension);
98 // Let ThemeService finish creating the theme pack. 98 // Let ThemeService finish creating the theme pack.
99 MessageLoop::current()->RunUntilIdle(); 99 MessageLoop::current()->RunUntilIdle();
100 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 100 EXPECT_FALSE(theme_service->UsingDefaultTheme());
101 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); 101 EXPECT_EQ(extension->id(), theme_service->GetThemeID());
102 102
103 // Now unload the extension, should revert to the default theme. 103 // Now unload the extension, should revert to the default theme.
104 service_->UnloadExtension(extension->id(), 104 service_->UnloadExtension(extension->id(),
105 extension_misc::UNLOAD_REASON_UNINSTALL); 105 extension_misc::UNLOAD_REASON_UNINSTALL);
106 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 106 EXPECT_TRUE(theme_service->UsingDefaultTheme());
107 } 107 }
108 108
109 // Upgrades a theme and ensures that the ThemeService does not revert to the 109 // Upgrades a theme and ensures that the ThemeService does not revert to the
110 // default theme. 110 // default theme.
111 TEST_F(ThemeServiceTest, ThemeUpgrade) { 111 TEST_F(ThemeServiceTest, ThemeUpgrade) {
112 base::ScopedTempDir temp_dir; 112 base::ScopedTempDir temp_dir;
113 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 113 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
114 ThemeService* theme_service = 114 ThemeService* theme_service =
115 ThemeServiceFactory::GetForProfile(profile_.get()); 115 ThemeServiceFactory::GetForProfile(profile_.get());
116 theme_service->UseDefaultTheme(); 116 theme_service->UseDefaultTheme();
117 scoped_refptr<extensions::Extension> extension = 117 scoped_refptr<extensions::Extension> extension =
118 MakeThemeExtension(temp_dir.path()); 118 MakeThemeExtension(temp_dir.path());
119 service_->FinishInstallationForTest(extension); 119 service_->AddExtension(extension);
120 // Let ThemeService finish creating the theme pack. 120 // Let ThemeService finish creating the theme pack.
121 MessageLoop::current()->RunUntilIdle(); 121 MessageLoop::current()->RunUntilIdle();
122 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 122 EXPECT_FALSE(theme_service->UsingDefaultTheme());
123 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); 123 EXPECT_EQ(extension->id(), theme_service->GetThemeID());
124 124
125 // Now unload the extension, should revert to the default theme. 125 // Now unload the extension, should revert to the default theme.
126 service_->UnloadExtension(extension->id(), 126 service_->UnloadExtension(extension->id(),
127 extension_misc::UNLOAD_REASON_UPDATE); 127 extension_misc::UNLOAD_REASON_UPDATE);
128 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 128 EXPECT_FALSE(theme_service->UsingDefaultTheme());
129 } 129 }
130 130
131 }; // namespace 131 }; // namespace
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/ui/gtk/gtk_theme_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698