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

Unified Diff: ui/gfx/image/image_unittest.cc

Issue 10378009: Get rid of Image::Image(SkBitmap*) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 8 years, 7 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
Index: ui/gfx/image/image_unittest.cc
diff --git a/ui/gfx/image/image_unittest.cc b/ui/gfx/image/image_unittest.cc
index 87935621c9446701bb51f2808dfa85567cefc239..7f275ad95610ca3047ac0ee08402c79c4be1b9b4 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
@@ -68,8 +67,8 @@ TEST_F(ImageTest, SkiaToSkia) {
}
TEST_F(ImageTest, SkiaRefToSkia) {
- scoped_ptr<SkBitmap> originalBitmap(gt::CreateBitmap(25, 25));
- gfx::Image image(*originalBitmap.get());
+ SkBitmap originalBitmap(gt::CreateBitmap(25, 25));
+ gfx::Image image(originalBitmap);
const SkBitmap* bitmap = image.ToSkBitmap();
EXPECT_TRUE(bitmap);
EXPECT_FALSE(bitmap->isNull());
@@ -104,7 +103,7 @@ TEST_F(ImageTest, SkiaToPlatform) {
if (!kUsesSkiaNatively)
EXPECT_FALSE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
- EXPECT_TRUE(gt::ToPlatformType(image));
+ EXPECT_TRUE(gt::PlatformRepresentationIsValid(image));
EXPECT_EQ(kRepCount, image.RepresentationCount());
const SkBitmap* bitmap = image.ToSkBitmap();
@@ -126,9 +125,10 @@ TEST_F(ImageTest, PlatformToSkia) {
const SkBitmap* bitmap = image.ToSkBitmap();
EXPECT_TRUE(bitmap);
EXPECT_FALSE(bitmap->isNull());
+
EXPECT_EQ(kRepCount, image.RepresentationCount());
- EXPECT_TRUE(gt::ToPlatformType(image));
+ EXPECT_TRUE(gt::PlatformRepresentationIsValid(image));
EXPECT_EQ(kRepCount, image.RepresentationCount());
EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepSkia));
@@ -136,11 +136,11 @@ TEST_F(ImageTest, PlatformToSkia) {
TEST_F(ImageTest, PlatformToPlatform) {
gfx::Image image(gt::CreatePlatformImage());
- EXPECT_TRUE(gt::ToPlatformType(image));
+ EXPECT_TRUE(gt::PlatformRepresentationIsValid(image));
EXPECT_EQ(1U, image.RepresentationCount());
// Make sure double conversion doesn't happen.
- EXPECT_TRUE(gt::ToPlatformType(image));
+ EXPECT_TRUE(gt::PlatformRepresentationIsValid(image));
EXPECT_EQ(1U, image.RepresentationCount());
EXPECT_TRUE(image.HasRepresentation(gt::GetPlatformRepresentationType()));
@@ -221,7 +221,8 @@ TEST_F(ImageTest, SwapRepresentations) {
image1.SwapRepresentations(&image2);
EXPECT_EQ(bitmap2, image1.ToSkBitmap());
- EXPECT_EQ(platform_image, gt::ToPlatformType(image1));
+ EXPECT_TRUE(gt::PlatformImagesEqual(platform_image,
+ gt::ToPlatformType(image1)));
EXPECT_EQ(bitmap1, image2.ToSkBitmap());
EXPECT_EQ(kRepCount, image1.RepresentationCount());
EXPECT_EQ(1U, image2.RepresentationCount());
@@ -237,7 +238,7 @@ TEST_F(ImageTest, Copy) {
EXPECT_EQ(1U, image2.RepresentationCount());
EXPECT_EQ(image1.ToSkBitmap(), image2.ToSkBitmap());
- EXPECT_TRUE(gt::ToPlatformType(image2));
+ EXPECT_TRUE(gt::PlatformRepresentationIsValid(image2));
EXPECT_EQ(kRepCount, image2.RepresentationCount());
EXPECT_EQ(kRepCount, image1.RepresentationCount());
}
@@ -258,8 +259,8 @@ TEST_F(ImageTest, MultiResolutionSkBitmap) {
const int height2 = 24;
std::vector<const SkBitmap*> bitmaps;
- bitmaps.push_back(gt::CreateBitmap(width1, height1));
- bitmaps.push_back(gt::CreateBitmap(width2, height2));
+ bitmaps.push_back(new SkBitmap(gt::CreateBitmap(width1, height1)));
+ bitmaps.push_back(new SkBitmap(gt::CreateBitmap(width2, height2)));
gfx::Image image(bitmaps);
EXPECT_EQ(1u, image.RepresentationCount());

Powered by Google App Engine
This is Rietveld 408576698