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

Unified Diff: ui/gfx/image_unittest.cc

Issue 6849030: Add support for multi resolution icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/image_unittest.h ('k') | ui/gfx/image_unittest_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image_unittest.cc
diff --git a/ui/gfx/image_unittest.cc b/ui/gfx/image_unittest.cc
index 6f41bfe7b78fe220ca3bc740a84dbec1dcab8363..f02a2fa802e6ab8df3772193a3549a43579f0642 100644
--- a/ui/gfx/image_unittest.cc
+++ b/ui/gfx/image_unittest.cc
@@ -6,7 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image.h"
-#include "ui/gfx/image_unittest.h"
+#include "ui/gfx/image_unittest_util.h"
#if defined(OS_LINUX)
#include <gtk/gtk.h>
@@ -34,7 +34,7 @@ class ImageTest : public testing::Test {
namespace gt = gfx::test;
TEST_F(ImageTest, SkiaToSkia) {
- gfx::Image image(gt::CreateBitmap());
+ gfx::Image image(gt::CreateBitmap(25, 25));
const SkBitmap* bitmap = static_cast<const SkBitmap*>(image);
EXPECT_TRUE(bitmap);
EXPECT_FALSE(bitmap->isNull());
@@ -52,7 +52,7 @@ TEST_F(ImageTest, SkiaToSkia) {
}
TEST_F(ImageTest, SkiaToSkiaRef) {
- gfx::Image image(gt::CreateBitmap());
+ gfx::Image image(gt::CreateBitmap(25, 25));
const SkBitmap& bitmap = static_cast<const SkBitmap&>(image);
EXPECT_FALSE(bitmap.isNull());
@@ -68,7 +68,7 @@ TEST_F(ImageTest, SkiaToSkiaRef) {
}
TEST_F(ImageTest, SkiaToPlatform) {
- gfx::Image image(gt::CreateBitmap());
+ gfx::Image image(gt::CreateBitmap(25, 25));
const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;
EXPECT_TRUE(image.HasRepresentation(gfx::Image::kSkBitmapRep));
@@ -131,7 +131,7 @@ TEST_F(ImageTest, CheckSkiaColor) {
TEST_F(ImageTest, SwapRepresentations) {
const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;
- gfx::Image image1(gt::CreateBitmap());
+ gfx::Image image1(gt::CreateBitmap(25, 25));
const SkBitmap* bitmap1 = image1;
EXPECT_EQ(1U, GetRepCount(image1));
@@ -149,6 +149,41 @@ TEST_F(ImageTest, SwapRepresentations) {
EXPECT_EQ(1U, GetRepCount(image2));
}
+TEST_F(ImageTest, MultiResolutionSkBitmap) {
+ const int width1 = 10;
+ const int height1 = 12;
+ const int width2 = 20;
+ const int height2 = 24;
+
+ std::vector<const SkBitmap*> bitmaps;
+ bitmaps.push_back(gt::CreateBitmap(width1, height1));
+ bitmaps.push_back(gt::CreateBitmap(width2, height2));
+ gfx::Image image(bitmaps);
+
+ EXPECT_EQ(1u, GetRepCount(image));
+ EXPECT_EQ(2u, image.GetNumberOfSkBitmaps());
+
+ const SkBitmap* bitmap1 = image.GetSkBitmapAtIndex(0);
+ EXPECT_TRUE(bitmap1);
+ const SkBitmap* bitmap2 = image.GetSkBitmapAtIndex(1);
+ EXPECT_TRUE(bitmap2);
+
+ if (bitmap1->width() == width1) {
+ EXPECT_EQ(bitmap1->height(), height1);
+ EXPECT_EQ(bitmap2->width(), width2);
+ EXPECT_EQ(bitmap2->height(), height2);
+ } else {
+ EXPECT_EQ(bitmap1->width(), width2);
+ EXPECT_EQ(bitmap1->height(), height2);
+ EXPECT_EQ(bitmap2->width(), width1);
+ EXPECT_EQ(bitmap2->height(), height1);
+ }
+
+ // Sanity check.
+ EXPECT_EQ(1u, GetRepCount(image));
+ EXPECT_EQ(2u, image.GetNumberOfSkBitmaps());
+}
+
// Integration tests with UI toolkit frameworks require linking against the
// Views library and cannot be here (gfx_unittests doesn't include it). They
// instead live in /chrome/browser/ui/tests/ui_gfx_image_unittest.cc.
« no previous file with comments | « ui/gfx/image_unittest.h ('k') | ui/gfx/image_unittest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698