| Index: chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java
|
| index 390fce3eaca31444473a23996e9b727bb8b57b74..298382a2284eb93fe743d9c1bb712e36675c9e30 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java
|
| @@ -13,8 +13,10 @@
|
| import android.test.suitebuilder.annotation.LargeTest;
|
| import android.test.suitebuilder.annotation.MediumTest;
|
|
|
| +import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.annotations.SuppressFBWarnings;
|
| import org.chromium.base.test.util.Feature;
|
| +import org.chromium.chrome.browser.preferences.PrefServiceBridge;
|
| import org.chromium.chrome.browser.preferences.website.ContentSetting;
|
| import org.chromium.chrome.browser.util.UrlUtilities;
|
| import org.chromium.chrome.browser.widget.RoundedIconGenerator;
|
| @@ -80,8 +82,7 @@ public void testDefaultNotificationProperties() throws Exception {
|
| }
|
|
|
| /**
|
| - * Verifies that notifications created with the "silent" flag do not inherit system defaults
|
| - * in regards to their sound, vibration and light indicators.
|
| + * Verifies that the ONLY_ALERT_ONCE flag is not set when renotify is true.
|
| */
|
| @MediumTest
|
| @Feature({"Browser", "Notifications"})
|
| @@ -92,7 +93,6 @@ public void testNotificationRenotifyProperty() throws Exception {
|
| Notification notification =
|
| showAndGetNotification("MyNotification", "{ tag: 'myTag', renotify: true }");
|
|
|
| - // Zero indicates that no defaults should be inherited from the system.
|
| assertEquals(0, notification.flags & Notification.FLAG_ONLY_ALERT_ONCE);
|
| }
|
|
|
| @@ -113,6 +113,94 @@ public void testNotificationSilentProperty() throws Exception {
|
| }
|
|
|
| /**
|
| + * Verifies that when notification vibration is disabled in preferences and no custom pattern is
|
| + * specified, no vibration is requested from the framework.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Browser", "Notifications"})
|
| + public void testNotificationVibratePreferenceDisabledDefault() throws Exception {
|
| + loadUrl(getTestServer().getURL(NOTIFICATION_TEST_PAGE));
|
| + setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
|
| +
|
| + // Disable notification vibration in preferences.
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PrefServiceBridge.getInstance().setNotificationsVibrateEnabled(false);
|
| + }
|
| + });
|
| +
|
| + Notification notification = showAndGetNotification("MyNotification", "{}");
|
| +
|
| + // Vibration should not be in the defaults.
|
| + assertEquals(
|
| + Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, notification.defaults);
|
| +
|
| + // There should be a custom no-op vibration pattern.
|
| + assertEquals(1, notification.vibrate.length);
|
| + assertEquals(0L, notification.vibrate[0]);
|
| + }
|
| +
|
| + /**
|
| + * Verifies that when notification vibration is disabled in preferences and a custom pattern is
|
| + * specified, no vibration is requested from the framework.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Browser", "Notifications"})
|
| + public void testNotificationVibratePreferenceDisabledCustomPattern() throws Exception {
|
| + loadUrl(getTestServer().getURL(NOTIFICATION_TEST_PAGE));
|
| + setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
|
| +
|
| + // Disable notification vibration in preferences.
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + PrefServiceBridge.getInstance().setNotificationsVibrateEnabled(false);
|
| + }
|
| + });
|
| +
|
| + Notification notification = showAndGetNotification("MyNotification", "{ vibrate: 42}");
|
| +
|
| + // Vibration should not be in the defaults.
|
| + assertEquals(
|
| + Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, notification.defaults);
|
| +
|
| + // There should be a custom no-op vibration pattern.
|
| + assertEquals(1, notification.vibrate.length);
|
| + assertEquals(0L, notification.vibrate[0]);
|
| + }
|
| +
|
| + /**
|
| + * Verifies that by default the notification vibration preference is enabled, and a custom
|
| + * pattern is passed along.
|
| + */
|
| + @MediumTest
|
| + @Feature({"Browser", "Notifications"})
|
| + public void testNotificationVibrateCustomPattern() throws Exception {
|
| + loadUrl(getTestServer().getURL(NOTIFICATION_TEST_PAGE));
|
| + setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
|
| +
|
| + // By default, vibration is enabled in notifications.
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + assertTrue(PrefServiceBridge.getInstance().isNotificationsVibrateEnabled());
|
| + }
|
| + });
|
| +
|
| + Notification notification = showAndGetNotification("MyNotification", "{ vibrate: 42}");
|
| +
|
| + // Vibration should not be in the defaults, a custom pattern was provided.
|
| + assertEquals(
|
| + Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, notification.defaults);
|
| +
|
| + // The custom pattern should have been passed along.
|
| + assertEquals(2, notification.vibrate.length);
|
| + assertEquals(0L, notification.vibrate[0]);
|
| + assertEquals(42L, notification.vibrate[1]);
|
| + }
|
| +
|
| + /**
|
| * Verifies that notifications which specify an icon will have that icon fetched, converted into
|
| * a Bitmap and included as the large icon in the notification.
|
| */
|
|
|