Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java |
| index 25f52546a0eff01eafb00dd7425adaccb6ca6f09..079c8a5d533374ce3df2f6aa7bbc99a156dfee19 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java |
| @@ -172,6 +172,21 @@ public void testCalculateScaledPadding() { |
| assertEquals(0, CustomNotificationBuilder.calculateScaledPadding(1000.0f, metrics)); |
| } |
| + @SmallTest |
| + @Feature({"Browser", "Notifications"}) |
| + public void testPaintBitmap() { |
| + // The method under test uses PorterDuff.Mode.MULTIPLY so the more opaque the black you |
| + // paint with on the white, the darker it gets. |
| + assertEquals(Color.parseColor("#ffffffff"), CustomNotificationBuilder.paintBitmap( |
|
newt (away)
2015/11/16 17:50:09
You can just write "0xffffffff" instead of "Color.
Michael van Ouwerkerk
2015/11/17 12:00:24
Done. Nice cleanup.
|
| + createWhiteBitmap(), Color.parseColor("#00000000")).getPixel(0, 0)); |
| + assertEquals(Color.parseColor("#ffcccccc"), CustomNotificationBuilder.paintBitmap( |
| + createWhiteBitmap(), Color.parseColor("#33000000")).getPixel(0, 0)); |
| + assertEquals(Color.parseColor("#ff333333"), CustomNotificationBuilder.paintBitmap( |
| + createWhiteBitmap(), Color.parseColor("#cc000000")).getPixel(0, 0)); |
| + assertEquals(Color.parseColor("#ff000000"), CustomNotificationBuilder.paintBitmap( |
| + createWhiteBitmap(), Color.parseColor("#ff000000")).getPixel(0, 0)); |
| + } |
| + |
| /** |
| * Finds a TextView with the given id in each of the given views, and checks that they all |
| * contain the same text. |
| @@ -205,4 +220,13 @@ private static String createString(char character, int length) { |
| Arrays.fill(chars, character); |
| return new String(chars); |
| } |
| + |
| + /** |
| + * Creates a 1x1 white mutable Bitmap. |
| + */ |
| + private static Bitmap createWhiteBitmap() { |
| + int[] colors = {Color.WHITE}; |
| + Bitmap immutableBitmap = Bitmap.createBitmap(colors, 1, 1, Bitmap.Config.ARGB_8888); |
| + return immutableBitmap.copy(Bitmap.Config.ARGB_8888, true /* isMutable */); |
| + } |
| } |