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

Unified Diff: ui/gfx/skbitmap_operations_unittest.cc

Issue 10823012: Fix the errors of ui unittests caused by packing colors for Android (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 5 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/skbitmap_operations_unittest.cc
diff --git a/ui/gfx/skbitmap_operations_unittest.cc b/ui/gfx/skbitmap_operations_unittest.cc
index f5c89f86fde3c8ee0a86b334490c3158002392d0..af1dd23d58a4dcf86f314f864a72f19e33731e62 100644
--- a/ui/gfx/skbitmap_operations_unittest.cc
+++ b/ui/gfx/skbitmap_operations_unittest.cc
@@ -20,6 +20,11 @@ inline bool ColorsClose(uint32_t a, uint32_t b) {
abs(static_cast<int>(SkColorGetA(a) - SkColorGetA(b))) <= 2;
}
+inline uint32_t SetPackedColor(uint8_t a, uint8_t r, uint8_t g, uint8_t b) {
+ return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
+ (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
+}
+
inline bool MultipliedColorsClose(uint32_t a, uint32_t b) {
return ColorsClose(SkUnPreMultiply::PMColorToColor(a),
SkUnPreMultiply::PMColorToColor(b));
@@ -274,7 +279,7 @@ TEST(SkBitmapOperationsTest, CreateHSLShiftedBitmapHueOnly) {
for (int y = 0, i = 0; y < src_h; y++) {
for (int x = 0; x < src_w; x++) {
EXPECT_TRUE(ColorsClose(*shifted.getAddr32(x, y),
- SkColorSetARGB(255, i % 255, 0, 0)));
+ SetPackedColor(255, i % 255, 0, 0)));
i++;
}
}
@@ -489,7 +494,11 @@ TEST(SkBitmapOperationsTest, UnPreMultiply) {
SkAutoLockPixels lock(result);
EXPECT_EQ(0x80000000, *result.getAddr32(0, 0));
EXPECT_EQ(0x80FFFFFF, *result.getAddr32(1, 0));
+#if defined(OS_ANDROID)
+ EXPECT_EQ(0xff88cc00, *result.getAddr32(0, 1));
+#else
EXPECT_EQ(0xFF00CC88, *result.getAddr32(0, 1));
+#endif
EXPECT_EQ(0x00000000u, *result.getAddr32(1, 1)); // "Division by zero".
}

Powered by Google App Engine
This is Rietveld 408576698