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

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

Issue 10963064: Properly flip the CGContext during UIImage->SkBitmap conversions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review. Created 8 years, 3 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 c0b2489b8798dba861f6206cfb3cc1d011e71c89..0ad95ae5da7c5eeabb82667e5d088ed1a7284909 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -176,16 +176,12 @@ TEST_F(ImageTest, PNGDecodeToSkiaFailure) {
gt::CheckColor(bitmap->getColor(10, 10), true);
}
-// TODO(rohitrao): This test needs an iOS implementation of
-// GetPlatformImageColor().
-#if !defined(OS_IOS)
TEST_F(ImageTest, PNGDecodeToPlatformFailure) {
std::vector<unsigned char> png(100, 0);
gfx::Image image(&png.front(), png.size());
gt::CheckColor(gt::GetPlatformImageColor(gt::ToPlatformType(image), 10, 10),
true);
}
-#endif
TEST_F(ImageTest, SkiaToPlatform) {
gfx::Image image(gt::CreateBitmap(25, 25));
@@ -308,9 +304,6 @@ TEST_F(ImageTest, CheckSkiaColor) {
gt::CheckColor(bitmap->getColor(10, 10), false);
}
-// TODO(rohitrao): This test needs an iOS implementation of
-// GetPlatformImageColor().
-#if !defined(OS_IOS)
TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) {
const int width = 50;
const int height = 50;
@@ -324,27 +317,35 @@ TEST_F(ImageTest, SkBitmapConversionPreservesOrientation) {
SkPaint red;
red.setColor(SK_ColorRED);
canvas.drawRect(SkRect::MakeWH(width, height / 2), red);
- gt::CheckColor(bitmap.getColor(10, 10), true);
- gt::CheckColor(bitmap.getColor(10, 40), false);
+ {
+ SCOPED_TRACE("Checking color of the initial SkBitmap");
+ gt::CheckColor(bitmap.getColor(10, 10), true);
+ gt::CheckColor(bitmap.getColor(10, 40), false);
+ }
// Convert from SkBitmap to a platform representation, then check the upper
// half of the platform image to make sure it is red, not green.
gfx::Image from_skbitmap(bitmap);
- gt::CheckColor(
- gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10),
- true);
- gt::CheckColor(
- gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40),
- false);
+ {
+ SCOPED_TRACE("Checking color of the platform image");
+ gt::CheckColor(
+ gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 10),
+ true);
+ gt::CheckColor(
+ gt::GetPlatformImageColor(gt::ToPlatformType(from_skbitmap), 10, 40),
+ false);
+ }
// Force a conversion back to SkBitmap and check that the upper half is red.
gfx::Image from_platform(gt::CopyPlatformType(from_skbitmap));
const SkBitmap* bitmap2 = from_platform.ToSkBitmap();
SkAutoLockPixels auto_lock(*bitmap2);
- gt::CheckColor(bitmap2->getColor(10, 10), true);
- gt::CheckColor(bitmap2->getColor(10, 40), false);
+ {
+ SCOPED_TRACE("Checking color after conversion back to SkBitmap");
+ gt::CheckColor(bitmap2->getColor(10, 10), true);
+ gt::CheckColor(bitmap2->getColor(10, 40), false);
+ }
}
-#endif // !defined(OS_IOS)
TEST_F(ImageTest, SwapRepresentations) {
const size_t kRepCount = kUsesSkiaNatively ? 1U : 2U;

Powered by Google App Engine
This is Rietveld 408576698