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

Side by Side Diff: chrome/browser/sync/glue/theme_util_unittest.cc

Issue 6803012: Profile shouldn't own DesktopNotificationService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 8 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/glue/theme_util.h" 5 #include "chrome/browser/sync/glue/theme_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 10 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 public: 95 public:
96 MOCK_METHOD0(SetNativeTheme, void()); 96 MOCK_METHOD0(SetNativeTheme, void());
97 MOCK_METHOD0(UseDefaultTheme, void()); 97 MOCK_METHOD0(UseDefaultTheme, void());
98 MOCK_CONST_METHOD0(GetThemeID, std::string()); 98 MOCK_CONST_METHOD0(GetThemeID, std::string());
99 }; 99 };
100 100
101 TEST_F(ThemeUtilTest, SetCurrentThemeDefaultTheme) { 101 TEST_F(ThemeUtilTest, SetCurrentThemeDefaultTheme) {
102 sync_pb::ThemeSpecifics theme_specifics; 102 sync_pb::ThemeSpecifics theme_specifics;
103 TestingProfile profile; 103 TestingProfile profile;
104 MockThemeService* mock_theme_service = new MockThemeService; 104 MockThemeService* mock_theme_service = new MockThemeService;
105 ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); 105 ThemeServiceFactory::GetInstance()->ForceAssociationBetween(&profile,
106 mock_theme_service);
106 107
107 EXPECT_CALL(*mock_theme_service, UseDefaultTheme()).Times(1); 108 EXPECT_CALL(*mock_theme_service, UseDefaultTheme()).Times(1);
108 109
109 SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile); 110 SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile);
110 } 111 }
111 112
112 TEST_F(ThemeUtilTest, SetCurrentThemeSystemTheme) { 113 TEST_F(ThemeUtilTest, SetCurrentThemeSystemTheme) {
113 sync_pb::ThemeSpecifics theme_specifics; 114 sync_pb::ThemeSpecifics theme_specifics;
114 theme_specifics.set_use_system_theme_by_default(true); 115 theme_specifics.set_use_system_theme_by_default(true);
115 116
116 TestingProfile profile; 117 TestingProfile profile;
117 MockThemeService* mock_theme_service = new MockThemeService; 118 MockThemeService* mock_theme_service = new MockThemeService;
118 ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); 119 ThemeServiceFactory::GetInstance()->ForceAssociationBetween(&profile,
120 mock_theme_service);
119 121
120 EXPECT_CALL(*mock_theme_service, SetNativeTheme()).Times(1); 122 EXPECT_CALL(*mock_theme_service, SetNativeTheme()).Times(1);
121 123
122 SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile); 124 SetCurrentThemeFromThemeSpecifics(theme_specifics, &profile);
123 } 125 }
124 126
125 // TODO(akalin): Make ExtensionService/ExtensionUpdater testable 127 // TODO(akalin): Make ExtensionService/ExtensionUpdater testable
126 // enough to be able to write a unittest for SetCurrentTheme for a 128 // enough to be able to write a unittest for SetCurrentTheme for a
127 // custom theme. 129 // custom theme.
128 130
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 EXPECT_TRUE(theme_specifics.has_use_system_theme_by_default()); 210 EXPECT_TRUE(theme_specifics.has_use_system_theme_by_default());
209 EXPECT_FALSE(theme_specifics.use_system_theme_by_default()); 211 EXPECT_FALSE(theme_specifics.use_system_theme_by_default());
210 EXPECT_EQ(kThemeName, theme_specifics.custom_theme_name()); 212 EXPECT_EQ(kThemeName, theme_specifics.custom_theme_name());
211 EXPECT_EQ(extension->id(), theme_specifics.custom_theme_id()); 213 EXPECT_EQ(extension->id(), theme_specifics.custom_theme_id());
212 EXPECT_EQ(kThemeUpdateUrl, theme_specifics.custom_theme_update_url()); 214 EXPECT_EQ(kThemeUpdateUrl, theme_specifics.custom_theme_update_url());
213 } 215 }
214 216
215 TEST_F(ThemeUtilTest, SetCurrentThemeIfNecessaryDefaultThemeNotNecessary) { 217 TEST_F(ThemeUtilTest, SetCurrentThemeIfNecessaryDefaultThemeNotNecessary) {
216 TestingProfile profile; 218 TestingProfile profile;
217 MockThemeService* mock_theme_service = new MockThemeService; 219 MockThemeService* mock_theme_service = new MockThemeService;
218 ThemeServiceFactory::ForceAssociationBetween(&profile, mock_theme_service); 220 ThemeServiceFactory::GetInstance()->ForceAssociationBetween(&profile,
221 mock_theme_service);
219 222
220 EXPECT_CALL(*mock_theme_service, GetThemeID()).WillRepeatedly(Return( 223 EXPECT_CALL(*mock_theme_service, GetThemeID()).WillRepeatedly(Return(
221 ThemeService::kDefaultThemeID)); 224 ThemeService::kDefaultThemeID));
222 225
223 // TODO(akalin): Mock out call to GetPrefs() under TOOLKIT_USES_GTK. 226 // TODO(akalin): Mock out call to GetPrefs() under TOOLKIT_USES_GTK.
224 227
225 sync_pb::ThemeSpecifics theme_specifics; 228 sync_pb::ThemeSpecifics theme_specifics;
226 SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics, 229 SetCurrentThemeFromThemeSpecificsIfNecessary(theme_specifics,
227 &profile); 230 &profile);
228 } 231 }
229 232
230 } // namespace 233 } // namespace
231 234
232 } // namespace browser_sync 235 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_keyed_service_factory.cc ('k') | chrome/browser/themes/theme_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698