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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java

Issue 2110543004: Move JNI bindings for url_formatter from chrome to //components/url_formatter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Notification; 8 import android.app.Notification;
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.res.Resources; 10 import android.content.res.Resources;
11 import android.graphics.Bitmap; 11 import android.graphics.Bitmap;
12 import android.os.Build; 12 import android.os.Build;
13 import android.test.suitebuilder.annotation.LargeTest; 13 import android.test.suitebuilder.annotation.LargeTest;
14 import android.test.suitebuilder.annotation.MediumTest; 14 import android.test.suitebuilder.annotation.MediumTest;
15 15
16 import org.chromium.base.ThreadUtils; 16 import org.chromium.base.ThreadUtils;
17 import org.chromium.base.annotations.SuppressFBWarnings; 17 import org.chromium.base.annotations.SuppressFBWarnings;
18 import org.chromium.base.test.util.Feature; 18 import org.chromium.base.test.util.Feature;
19 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 19 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
20 import org.chromium.chrome.browser.preferences.website.ContentSetting; 20 import org.chromium.chrome.browser.preferences.website.ContentSetting;
21 import org.chromium.chrome.browser.util.UrlUtilities;
22 import org.chromium.chrome.browser.widget.RoundedIconGenerator; 21 import org.chromium.chrome.browser.widget.RoundedIconGenerator;
23 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry; 22 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry;
23 import org.chromium.components.url_formatter.UrlFormatter;
24 import org.chromium.content.browser.test.util.Criteria; 24 import org.chromium.content.browser.test.util.Criteria;
25 import org.chromium.content.browser.test.util.CriteriaHelper; 25 import org.chromium.content.browser.test.util.CriteriaHelper;
26 26
27 import java.util.List; 27 import java.util.List;
28 28
29 /** 29 /**
30 * Instrumentation tests for the Notification Bridge. 30 * Instrumentation tests for the Notification Bridge.
31 * 31 *
32 * Web Notifications are only supported on Android JellyBean and beyond. 32 * Web Notifications are only supported on Android JellyBean and beyond.
33 */ 33 */
(...skipping 13 matching lines...) Expand all
47 @Feature({"Browser", "Notifications"}) 47 @Feature({"Browser", "Notifications"})
48 public void testDefaultNotificationProperties() throws Exception { 48 public void testDefaultNotificationProperties() throws Exception {
49 loadUrl(getTestServer().getURL(NOTIFICATION_TEST_PAGE)); 49 loadUrl(getTestServer().getURL(NOTIFICATION_TEST_PAGE));
50 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); 50 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
51 51
52 Notification notification = showAndGetNotification("MyNotification", "{ body: 'Hello' }"); 52 Notification notification = showAndGetNotification("MyNotification", "{ body: 'Hello' }");
53 53
54 // Validate the contents of the notification. 54 // Validate the contents of the notification.
55 assertEquals("MyNotification", notification.extras.getString(Notificatio n.EXTRA_TITLE)); 55 assertEquals("MyNotification", notification.extras.getString(Notificatio n.EXTRA_TITLE));
56 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T EXT)); 56 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T EXT));
57 assertEquals(UrlUtilities.formatUrlForSecurityDisplay(getOrigin(), false /* showScheme */), 57 assertEquals(UrlFormatter.formatUrlForSecurityDisplay(getOrigin(), false /* showScheme */),
58 notification.extras.getString(Notification.EXTRA_SUB_TEXT)); 58 notification.extras.getString(Notification.EXTRA_SUB_TEXT));
59 59
60 // Verify that the ticker text contains the notification's title and bod y. 60 // Verify that the ticker text contains the notification's title and bod y.
61 String tickerText = notification.tickerText.toString(); 61 String tickerText = notification.tickerText.toString();
62 62
63 assertTrue(tickerText.contains("MyNotification")); 63 assertTrue(tickerText.contains("MyNotification"));
64 assertTrue(tickerText.contains("Hello")); 64 assertTrue(tickerText.contains("Hello"));
65 65
66 // Verify that the notification's timestamp is set in the past 60 second s. This number has 66 // Verify that the notification's timestamp is set in the past 60 second s. This number has
67 // no significance, but needs to be high enough to not cause flakiness a s it's set by the 67 // no significance, but needs to be high enough to not cause flakiness a s it's set by the
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 assertEquals(1, notifications.size()); 431 assertEquals(1, notifications.size());
432 assertEquals("Two", 432 assertEquals("Two",
433 notifications.get(0).notification.extras.getString(Notification. EXTRA_TITLE)); 433 notifications.get(0).notification.extras.getString(Notification. EXTRA_TITLE));
434 434
435 // Close the last notification and verify that none remain. 435 // Close the last notification and verify that none remain.
436 notifications.get(0).notification.contentIntent.send(); 436 notifications.get(0).notification.contentIntent.send();
437 waitForNotificationManagerMutation(); 437 waitForNotificationManagerMutation();
438 assertTrue(getNotificationEntries().isEmpty()); 438 assertTrue(getNotificationEntries().isEmpty());
439 } 439 }
440 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698