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

Unified Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 11232049: Revert 162636 - Use LANCZOS3 resize algorithm to generate missing image reps for extension action i… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_actions_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
===================================================================
--- chrome/browser/extensions/api/extension_action/browser_action_apitest.cc (revision 163346)
+++ chrome/browser/extensions/api/extension_action/browser_action_apitest.cc (working copy)
@@ -30,7 +30,6 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
-#include "ui/gfx/size_conversions.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/skia_util.h"
@@ -170,6 +169,9 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_FALSE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
@@ -185,6 +187,9 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_FALSE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
@@ -201,6 +206,9 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_TRUE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
@@ -216,6 +224,9 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_TRUE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
@@ -232,24 +243,14 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_FALSE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
ui::SCALE_FACTOR_100P));
- const float scale = ui::GetScaleFactorScale(ui::SCALE_FACTOR_200P);
- const gfx::Size scaled_up_pixel_size = gfx::ToFlooredSize(
- action_icon.ToImageSkia()->size().Scale(scale));
-
- SkBitmap action_icon_scaled_up = skia::ImageOperations::Resize(
- *action_icon.ToSkBitmap(), skia::ImageOperations::RESIZE_LANCZOS3,
- scaled_up_pixel_size.width(), scaled_up_pixel_size.height());
-
- const gfx::ImageSkia* action_icon_skia = action_icon.ToImageSkia();
- EXPECT_TRUE(gfx::BitmapsAreEqual(
- action_icon_scaled_up,
- action_icon_skia->GetRepresentation(ui::SCALE_FACTOR_200P).sk_bitmap()));
-
// Tell the extension to update the icon using dictionary of paths, but
// setting only size 19.
GetBrowserActionsBar().Press(0);
@@ -261,6 +262,9 @@
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
+ EXPECT_FALSE(
+ action_icon.ToImageSkia()->HasRepresentation(ui::SCALE_FACTOR_200P));
+
EXPECT_TRUE(ImagesAreEqualAtScale(
AddBackgroundForViews(*action_icon.ToImageSkia()),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
@@ -273,21 +277,23 @@
action_icon = icon_factory.GetIcon(0);
+ const gfx::ImageSkia* action_icon_skia = action_icon.ToImageSkia();
+
+ EXPECT_FALSE(action_icon_skia->HasRepresentation(ui::SCALE_FACTOR_100P));
+ EXPECT_TRUE(action_icon_skia->HasRepresentation(ui::SCALE_FACTOR_200P));
+
action_icon_current_id = action_icon.ToSkBitmap()->getGenerationID();
EXPECT_GT(action_icon_current_id, action_icon_last_id);
action_icon_last_id = action_icon_current_id;
- EXPECT_TRUE(ImagesAreEqualAtScale(
- AddBackgroundForViews(*action_icon.ToImageSkia()),
- *GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
- ui::SCALE_FACTOR_100P));
+ EXPECT_TRUE(gfx::BitmapsAreEqual(
+ *action_icon.ToSkBitmap(),
+ action_icon_skia->GetRepresentation(ui::SCALE_FACTOR_200P).sk_bitmap()));
-#if !defined(TOOLKIT_GTK)
EXPECT_TRUE(ImagesAreEqualAtScale(
- AddBackgroundForViews(*action_icon.ToImageSkia()),
+ AddBackgroundForViews(*action_icon_skia),
*GetBrowserActionsBar().GetIcon(0).ToImageSkia(),
ui::SCALE_FACTOR_200P));
-#endif
// Try setting icon with empty dictionary of ImageData objects.
GetBrowserActionsBar().Press(0);
« no previous file with comments | « no previous file | chrome/browser/extensions/api/extension_action/extension_actions_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698