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

Side by Side Diff: chrome/browser/extensions/extension_action_icon_factory_unittest.cc

Issue 1761913003: [Extensions] Default-enable the toolbar redesign on trunk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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/extensions/extension_action_icon_factory.h" 5 #include "chrome/browser/extensions/extension_action_icon_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Load an extension that has browser action without default icon set in the 204 // Load an extension that has browser action without default icon set in the
205 // manifest and does not call |SetIcon| by default. 205 // manifest and does not call |SetIcon| by default.
206 scoped_refptr<Extension> extension(CreateExtension( 206 scoped_refptr<Extension> extension(CreateExtension(
207 "browser_action/no_icon", Manifest::INVALID_LOCATION)); 207 "browser_action/no_icon", Manifest::INVALID_LOCATION));
208 ASSERT_TRUE(extension.get() != NULL); 208 ASSERT_TRUE(extension.get() != NULL);
209 ExtensionAction* browser_action = GetBrowserAction(*extension.get()); 209 ExtensionAction* browser_action = GetBrowserAction(*extension.get());
210 ASSERT_TRUE(browser_action); 210 ASSERT_TRUE(browser_action);
211 ASSERT_FALSE(browser_action->default_icon()); 211 ASSERT_FALSE(browser_action->default_icon());
212 ASSERT_TRUE(browser_action->GetExplicitlySetIcon(0 /*tab id*/).IsEmpty()); 212 ASSERT_TRUE(browser_action->GetExplicitlySetIcon(0 /*tab id*/).IsEmpty());
213 213
214 gfx::ImageSkia favicon = GetFavicon();
215
216 ExtensionActionIconFactory icon_factory( 214 ExtensionActionIconFactory icon_factory(
217 profile(), extension.get(), browser_action, this); 215 profile(), extension.get(), browser_action, this);
218 216
219 gfx::Image icon = icon_factory.GetIcon(0); 217 gfx::Image icon = icon_factory.GetIcon(0);
220 218
221 EXPECT_TRUE(ImageRepsAreEqual( 219 EXPECT_TRUE(ImageRepsAreEqual(
222 favicon.GetRepresentation(1.0f), 220 browser_action->GetDefaultIconImage().ToImageSkia()->GetRepresentation(
221 1.0f),
223 icon.ToImageSkia()->GetRepresentation(1.0f))); 222 icon.ToImageSkia()->GetRepresentation(1.0f)));
224 } 223 }
225 224
226 // If the icon has been set using |SetIcon|, the factory should return that 225 // If the icon has been set using |SetIcon|, the factory should return that
227 // icon. 226 // icon.
228 TEST_P(ExtensionActionIconFactoryTest, AfterSetIcon) { 227 TEST_P(ExtensionActionIconFactoryTest, AfterSetIcon) {
229 // Load an extension that has browser action without default icon set in the 228 // Load an extension that has browser action without default icon set in the
230 // manifest and does not call |SetIcon| by default (but has an browser action 229 // manifest and does not call |SetIcon| by default (but has an browser action
231 // icon resource). 230 // icon resource).
232 scoped_refptr<Extension> extension(CreateExtension( 231 scoped_refptr<Extension> extension(CreateExtension(
(...skipping 13 matching lines...) Expand all
246 245
247 ExtensionActionIconFactory icon_factory( 246 ExtensionActionIconFactory icon_factory(
248 profile(), extension.get(), browser_action, this); 247 profile(), extension.get(), browser_action, this);
249 248
250 gfx::Image icon = icon_factory.GetIcon(0); 249 gfx::Image icon = icon_factory.GetIcon(0);
251 250
252 EXPECT_TRUE(ImageRepsAreEqual( 251 EXPECT_TRUE(ImageRepsAreEqual(
253 set_icon.ToImageSkia()->GetRepresentation(1.0f), 252 set_icon.ToImageSkia()->GetRepresentation(1.0f),
254 icon.ToImageSkia()->GetRepresentation(1.0f))); 253 icon.ToImageSkia()->GetRepresentation(1.0f)));
255 254
256 // It should still return favicon for another tabs. 255 // It should still return the default icon for another tab.
257 icon = icon_factory.GetIcon(1); 256 icon = icon_factory.GetIcon(1);
258 257
259 EXPECT_TRUE(ImageRepsAreEqual( 258 EXPECT_TRUE(ImageRepsAreEqual(
260 GetFavicon().GetRepresentation(1.0f), 259 browser_action->GetDefaultIconImage().ToImageSkia()->GetRepresentation(
260 1.0f),
261 icon.ToImageSkia()->GetRepresentation(1.0f))); 261 icon.ToImageSkia()->GetRepresentation(1.0f)));
262 } 262 }
263 263
264 // If there is a default icon, and the icon has not been set using |SetIcon|, 264 // If there is a default icon, and the icon has not been set using |SetIcon|,
265 // the factory should return the default icon. 265 // the factory should return the default icon.
266 TEST_P(ExtensionActionIconFactoryTest, DefaultIcon) { 266 TEST_P(ExtensionActionIconFactoryTest, DefaultIcon) {
267 // Load an extension that has browser action without default icon set in the 267 // Load an extension that has browser action without default icon set in the
268 // manifest and does not call |SetIcon| by default (but has an browser action 268 // manifest and does not call |SetIcon| by default (but has an browser action
269 // icon resource). 269 // icon resource).
270 scoped_refptr<Extension> extension(CreateExtension( 270 scoped_refptr<Extension> extension(CreateExtension(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 icon = icon_factory.GetIcon(1); 310 icon = icon_factory.GetIcon(1);
311 311
312 EXPECT_TRUE(ImageRepsAreEqual( 312 EXPECT_TRUE(ImageRepsAreEqual(
313 default_icon.ToImageSkia()->GetRepresentation(1.0f), 313 default_icon.ToImageSkia()->GetRepresentation(1.0f),
314 icon.ToImageSkia()->GetRepresentation(1.0f))); 314 icon.ToImageSkia()->GetRepresentation(1.0f)));
315 315
316 } 316 }
317 317
318 } // namespace 318 } // namespace
319 } // namespace extensions 319 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698