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

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

Issue 1394423004: Initial skeleton of custom layouts for Web Notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilderTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilderTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1971ff2dfc2aefd375e553f1355aeb6259d5e36a
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/StandardNotificationBuilderTest.java
@@ -0,0 +1,69 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.notifications;
+
+import android.annotation.SuppressLint;
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.text.SpannableStringBuilder;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.R;
+
+/**
+ * Instrumentation unit tests for StandardNotificationBuilder.
+ */
+// TODO(peter): remove @SuppressLint once crbug.com/501900 is fixed.
+@SuppressLint("NewApi")
+public class StandardNotificationBuilderTest extends InstrumentationTestCase {
+ @SmallTest
+ @Feature({"Browser", "Notifications"})
+ public void testSetAll() {
+ Context context = getInstrumentation().getTargetContext();
+
+ Intent contentIntent = new Intent("contentIntent");
+ PendingIntent pendingContentIntent = PendingIntent.getBroadcast(
+ context, 0 /* requestCode */, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ Intent deleteIntent = new Intent("deleteIntent");
+ PendingIntent pendingDeleteIntent = PendingIntent.getBroadcast(
+ context, 1 /* requestCode */, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ Bitmap largeIcon = Bitmap.createBitmap(
+ new int[] {Color.RED}, 1 /* width */, 1 /* height */, Bitmap.Config.ARGB_8888);
+
+ Notification notification = new StandardNotificationBuilder(context)
+ .setSmallIcon(R.drawable.ic_chrome)
+ .setLargeIcon(largeIcon)
+ .setTitle("title")
+ .setBody("body")
+ .setOrigin("origin")
+ .setTicker(new SpannableStringBuilder("ticker"))
+ .setDefaults(Notification.DEFAULT_ALL)
+ .setVibrate(new long[] {100L})
+ .setContentIntent(pendingContentIntent)
+ .setDeleteIntent(pendingDeleteIntent)
+ .build();
+
+ assertEquals(R.drawable.ic_chrome, notification.icon);
+ assertNotNull(notification.largeIcon);
+ assertEquals("title", notification.extras.getString(Notification.EXTRA_TITLE));
+ assertEquals("body", notification.extras.getString(Notification.EXTRA_TEXT));
+ assertEquals("origin", notification.extras.getString(Notification.EXTRA_SUB_TEXT));
+ assertEquals("ticker", notification.tickerText.toString());
+ assertEquals(Notification.DEFAULT_ALL, notification.defaults);
+ assertEquals(1, notification.vibrate.length);
+ assertEquals(100L, notification.vibrate[0]);
+ assertEquals(pendingContentIntent, notification.contentIntent);
+ assertEquals(pendingDeleteIntent, notification.deleteIntent);
+ // TODO(mvanouwerkerk): Add coverage for action buttons.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698