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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilderTest.java

Issue 1441723002: Notification custom layouts: paint the button icon for Material. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documentation tweaks. Created 5 years, 1 month 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: 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 */);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698