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.app.Notification; | 7 import android.app.Notification; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.test.suitebuilder.annotation.LargeTest; | 10 import android.test.suitebuilder.annotation.LargeTest; |
11 import android.test.suitebuilder.annotation.MediumTest; | 11 import android.test.suitebuilder.annotation.MediumTest; |
12 import android.test.suitebuilder.annotation.SmallTest; | 12 import android.test.suitebuilder.annotation.SmallTest; |
13 import android.util.SparseArray; | 13 import android.util.SparseArray; |
14 | 14 |
15 import org.chromium.base.ThreadUtils; | 15 import org.chromium.base.ThreadUtils; |
| 16 import org.chromium.base.annotations.SuppressFBWarnings; |
16 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
17 import org.chromium.base.test.util.MinAndroidSdkLevel; | 18 import org.chromium.base.test.util.MinAndroidSdkLevel; |
18 import org.chromium.chrome.browser.preferences.website.ContentSetting; | 19 import org.chromium.chrome.browser.preferences.website.ContentSetting; |
19 import org.chromium.chrome.browser.preferences.website.PushNotificationInfo; | 20 import org.chromium.chrome.browser.preferences.website.PushNotificationInfo; |
20 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 21 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
21 import org.chromium.chrome.shell.ChromeShellTestBase; | 22 import org.chromium.chrome.shell.ChromeShellTestBase; |
22 import org.chromium.chrome.test.util.TestHttpServerClient; | 23 import org.chromium.chrome.test.util.TestHttpServerClient; |
23 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag
erProxy; | 24 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag
erProxy; |
24 import org.chromium.content.browser.test.util.Criteria; | 25 import org.chromium.content.browser.test.util.Criteria; |
25 import org.chromium.content.browser.test.util.CriteriaHelper; | 26 import org.chromium.content.browser.test.util.CriteriaHelper; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 assertTrue(waitForNotificationManagerMutation()); | 271 assertTrue(waitForNotificationManagerMutation()); |
271 | 272 |
272 SparseArray<Notification> notifications = mMockNotificationManager.getNo
tifications(); | 273 SparseArray<Notification> notifications = mMockNotificationManager.getNo
tifications(); |
273 assertEquals(0, notifications.size()); | 274 assertEquals(0, notifications.size()); |
274 } | 275 } |
275 | 276 |
276 /** | 277 /** |
277 * Verifies that creating a notification with an associated "tag" will cause
any previous | 278 * Verifies that creating a notification with an associated "tag" will cause
any previous |
278 * notification with the same tag to be dismissed prior to being shown. | 279 * notification with the same tag to be dismissed prior to being shown. |
279 */ | 280 */ |
| 281 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") |
280 @MediumTest | 282 @MediumTest |
281 @Feature({"Browser", "Notifications"}) | 283 @Feature({"Browser", "Notifications"}) |
282 public void testNotificationTagReplacement() throws Exception { | 284 public void testNotificationTagReplacement() throws Exception { |
283 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); | 285 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); |
284 | 286 |
285 Notification notification = showAndGetNotification("MyNotification", "{t
ag: 'myTag'}"); | 287 Notification notification = showAndGetNotification("MyNotification", "{t
ag: 'myTag'}"); |
286 | 288 |
287 // Show the second notification with the same tag. We can't use showAndG
etNotification for | 289 // Show the second notification with the same tag. We can't use showAndG
etNotification for |
288 // this purpose since a second notification would be shown. | 290 // this purpose since a second notification would be shown. |
289 runJavaScriptCodeInCurrentTab("showNotification('SecondNotification', {t
ag: 'myTag'});"); | 291 runJavaScriptCodeInCurrentTab("showNotification('SecondNotification', {t
ag: 'myTag'});"); |
(...skipping 28 matching lines...) Expand all Loading... |
318 assertNull(NotificationUIManager.getOriginFromTag(";")); | 320 assertNull(NotificationUIManager.getOriginFromTag(";")); |
319 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;")); | 321 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;")); |
320 assertNull(NotificationUIManager.getOriginFromTag( | 322 assertNull(NotificationUIManager.getOriginFromTag( |
321 "SystemDownloadNotifier;NotificationUIManager;42")); | 323 "SystemDownloadNotifier;NotificationUIManager;42")); |
322 assertNull(NotificationUIManager.getOriginFromTag( | 324 assertNull(NotificationUIManager.getOriginFromTag( |
323 "SystemDownloadNotifier;https://example.com;42")); | 325 "SystemDownloadNotifier;https://example.com;42")); |
324 assertNull(NotificationUIManager.getOriginFromTag( | 326 assertNull(NotificationUIManager.getOriginFromTag( |
325 "NotificationUIManager;SystemDownloadNotifier;42")); | 327 "NotificationUIManager;SystemDownloadNotifier;42")); |
326 } | 328 } |
327 } | 329 } |
OLD | NEW |