OLD | NEW |
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; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 assertEquals(Notification.DEFAULT_ALL, notification.defaults); | 79 assertEquals(Notification.DEFAULT_ALL, notification.defaults); |
80 assertEquals(Notification.PRIORITY_DEFAULT, notification.priority); | 80 assertEquals(Notification.PRIORITY_DEFAULT, notification.priority); |
81 } | 81 } |
82 | 82 |
83 /** | 83 /** |
84 * Verifies that notifications created with the "silent" flag do not inherit
system defaults | 84 * Verifies that notifications created with the "silent" flag do not inherit
system defaults |
85 * in regards to their sound, vibration and light indicators. | 85 * in regards to their sound, vibration and light indicators. |
86 */ | 86 */ |
87 @MediumTest | 87 @MediumTest |
88 @Feature({"Browser", "Notifications"}) | 88 @Feature({"Browser", "Notifications"}) |
| 89 public void testNotificationRenotifyProperty() throws Exception { |
| 90 loadUrl(NOTIFICATION_TEST_PAGE); |
| 91 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); |
| 92 |
| 93 Notification notification = |
| 94 showAndGetNotification("MyNotification", "{ tag: 'myTag', renoti
fy: true }"); |
| 95 |
| 96 // Zero indicates that no defaults should be inherited from the system. |
| 97 assertEquals(0, notification.flags & Notification.FLAG_ONLY_ALERT_ONCE); |
| 98 } |
| 99 |
| 100 /** |
| 101 * Verifies that notifications created with the "silent" flag do not inherit
system defaults |
| 102 * in regards to their sound, vibration and light indicators. |
| 103 */ |
| 104 @MediumTest |
| 105 @Feature({"Browser", "Notifications"}) |
89 public void testNotificationSilentProperty() throws Exception { | 106 public void testNotificationSilentProperty() throws Exception { |
90 loadUrl(NOTIFICATION_TEST_PAGE); | 107 loadUrl(NOTIFICATION_TEST_PAGE); |
91 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); | 108 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); |
92 | 109 |
93 Notification notification = showAndGetNotification("MyNotification", "{
silent: true }"); | 110 Notification notification = showAndGetNotification("MyNotification", "{
silent: true }"); |
94 | 111 |
95 // Zero indicates that no defaults should be inherited from the system. | 112 // Zero indicates that no defaults should be inherited from the system. |
96 assertEquals(0, notification.defaults); | 113 assertEquals(0, notification.defaults); |
97 } | 114 } |
98 | 115 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 assertEquals(1, notifications.size()); | 320 assertEquals(1, notifications.size()); |
304 assertEquals("Two", | 321 assertEquals("Two", |
305 notifications.get(0).notification.extras.getString(Notification.
EXTRA_TITLE)); | 322 notifications.get(0).notification.extras.getString(Notification.
EXTRA_TITLE)); |
306 | 323 |
307 // Close the last notification and verify that none remain. | 324 // Close the last notification and verify that none remain. |
308 notifications.get(0).notification.contentIntent.send(); | 325 notifications.get(0).notification.contentIntent.send(); |
309 waitForNotificationManagerMutation(); | 326 waitForNotificationManagerMutation(); |
310 assertTrue(getNotificationEntries().isEmpty()); | 327 assertTrue(getNotificationEntries().isEmpty()); |
311 } | 328 } |
312 } | 329 } |
OLD | NEW |