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

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: Test fixes 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(); 214 gfx::ImageSkia favicon = GetFavicon();
lazyboy 2016/03/04 03:13:53 Remove?
Devlin 2016/03/04 03:36:41 Done.
215 215
216 ExtensionActionIconFactory icon_factory( 216 ExtensionActionIconFactory icon_factory(
217 profile(), extension.get(), browser_action, this); 217 profile(), extension.get(), browser_action, this);
218 218
219 gfx::Image icon = icon_factory.GetIcon(0); 219 gfx::Image icon = icon_factory.GetIcon(0);
220 220
221 EXPECT_TRUE(ImageRepsAreEqual( 221 EXPECT_TRUE(ImageRepsAreEqual(
222 favicon.GetRepresentation(1.0f), 222 browser_action->GetDefaultIconImage().ToImageSkia()->GetRepresentation(
223 1.0f),
223 icon.ToImageSkia()->GetRepresentation(1.0f))); 224 icon.ToImageSkia()->GetRepresentation(1.0f)));
224 } 225 }
225 226
226 // If the icon has been set using |SetIcon|, the factory should return that 227 // If the icon has been set using |SetIcon|, the factory should return that
227 // icon. 228 // icon.
228 TEST_P(ExtensionActionIconFactoryTest, AfterSetIcon) { 229 TEST_P(ExtensionActionIconFactoryTest, AfterSetIcon) {
229 // Load an extension that has browser action without default icon set in the 230 // 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 231 // manifest and does not call |SetIcon| by default (but has an browser action
231 // icon resource). 232 // icon resource).
232 scoped_refptr<Extension> extension(CreateExtension( 233 scoped_refptr<Extension> extension(CreateExtension(
(...skipping 13 matching lines...) Expand all
246 247
247 ExtensionActionIconFactory icon_factory( 248 ExtensionActionIconFactory icon_factory(
248 profile(), extension.get(), browser_action, this); 249 profile(), extension.get(), browser_action, this);
249 250
250 gfx::Image icon = icon_factory.GetIcon(0); 251 gfx::Image icon = icon_factory.GetIcon(0);
251 252
252 EXPECT_TRUE(ImageRepsAreEqual( 253 EXPECT_TRUE(ImageRepsAreEqual(
253 set_icon.ToImageSkia()->GetRepresentation(1.0f), 254 set_icon.ToImageSkia()->GetRepresentation(1.0f),
254 icon.ToImageSkia()->GetRepresentation(1.0f))); 255 icon.ToImageSkia()->GetRepresentation(1.0f)));
255 256
256 // It should still return favicon for another tabs. 257 // It should still return the default icon for another tab.
257 icon = icon_factory.GetIcon(1); 258 icon = icon_factory.GetIcon(1);
258 259
259 EXPECT_TRUE(ImageRepsAreEqual( 260 EXPECT_TRUE(ImageRepsAreEqual(
260 GetFavicon().GetRepresentation(1.0f), 261 browser_action->GetDefaultIconImage().ToImageSkia()->GetRepresentation(
262 1.0f),
261 icon.ToImageSkia()->GetRepresentation(1.0f))); 263 icon.ToImageSkia()->GetRepresentation(1.0f)));
262 } 264 }
263 265
264 // If there is a default icon, and the icon has not been set using |SetIcon|, 266 // If there is a default icon, and the icon has not been set using |SetIcon|,
265 // the factory should return the default icon. 267 // the factory should return the default icon.
266 TEST_P(ExtensionActionIconFactoryTest, DefaultIcon) { 268 TEST_P(ExtensionActionIconFactoryTest, DefaultIcon) {
267 // Load an extension that has browser action without default icon set in the 269 // 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 270 // manifest and does not call |SetIcon| by default (but has an browser action
269 // icon resource). 271 // icon resource).
270 scoped_refptr<Extension> extension(CreateExtension( 272 scoped_refptr<Extension> extension(CreateExtension(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 icon = icon_factory.GetIcon(1); 312 icon = icon_factory.GetIcon(1);
311 313
312 EXPECT_TRUE(ImageRepsAreEqual( 314 EXPECT_TRUE(ImageRepsAreEqual(
313 default_icon.ToImageSkia()->GetRepresentation(1.0f), 315 default_icon.ToImageSkia()->GetRepresentation(1.0f),
314 icon.ToImageSkia()->GetRepresentation(1.0f))); 316 icon.ToImageSkia()->GetRepresentation(1.0f)));
315 317
316 } 318 }
317 319
318 } // namespace 320 } // namespace
319 } // namespace extensions 321 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698