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

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

Issue 1072043003: Clean up the NotificationUIManagerAndroid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-Integrate
Patch Set: Created 5 years, 8 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.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.FlakyTest;
11 import android.test.suitebuilder.annotation.LargeTest; 10 import android.test.suitebuilder.annotation.LargeTest;
12 import android.test.suitebuilder.annotation.MediumTest; 11 import android.test.suitebuilder.annotation.MediumTest;
13 import android.test.suitebuilder.annotation.SmallTest; 12 import android.test.suitebuilder.annotation.SmallTest;
14 13
15 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
16 import org.chromium.base.annotations.SuppressFBWarnings; 15 import org.chromium.base.annotations.SuppressFBWarnings;
17 import org.chromium.base.test.util.DisabledTest; 16 import org.chromium.base.test.util.DisabledTest;
18 import org.chromium.base.test.util.Feature; 17 import org.chromium.base.test.util.Feature;
19 import org.chromium.base.test.util.MinAndroidSdkLevel; 18 import org.chromium.base.test.util.MinAndroidSdkLevel;
20 import org.chromium.chrome.browser.preferences.website.ContentSetting; 19 import org.chromium.chrome.browser.preferences.website.ContentSetting;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 assertNotNull(generator); 225 assertNotNull(generator);
227 226
228 Bitmap generatedIcon = generator.generateIconForUrl(getOrigin()); 227 Bitmap generatedIcon = generator.generateIconForUrl(getOrigin());
229 assertNotNull(generatedIcon); 228 assertNotNull(generatedIcon);
230 229
231 assertEquals(generatedIcon.getWidth(), notification.largeIcon.getWidth() ); 230 assertEquals(generatedIcon.getWidth(), notification.largeIcon.getWidth() );
232 assertEquals(generatedIcon.getHeight(), notification.largeIcon.getHeight ()); 231 assertEquals(generatedIcon.getHeight(), notification.largeIcon.getHeight ());
233 } 232 }
234 233
235 /* 234 /*
236 * Verifies that starting the PendingIntent stored as the notification's del ete intent will
237 * close the notification.
238 */
239 /* @MediumTest */
240 @FlakyTest
241 @Feature({"Browser", "Notifications"})
242 public void testNotificationDeleteIntentClosesNotification() throws Exceptio n {
johnme 2015/04/09 17:00:01 I don't understand why this test doesn't make sens
Peter Beverloo 2015/04/09 17:34:41 Firstly - good point, I'm now removing this test i
243 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
244
245 Notification notification = showAndGetNotification("MyNotification", "{} ");
246 assertEquals(1, mMockNotificationManager.getNotifications().size());
247
248 // Sending the PendingIntent simulates dismissing (swiping away) the not ification.
249 assertNotNull(notification.deleteIntent);
250 notification.deleteIntent.send();
251 // The deleteIntent should trigger a call to cancel() in the Notificatio nManager.
252 assertTrue(waitForNotificationManagerMutation());
253
254 assertEquals(0, mMockNotificationManager.getNotifications().size());
255 }
256
257 /*
258 * Verifies that starting the PendingIntent stored as the notification's con tent intent will 235 * Verifies that starting the PendingIntent stored as the notification's con tent intent will
259 * start up the associated Service Worker, where the JavaScript code will cl ose the notification 236 * start up the associated Service Worker, where the JavaScript code will cl ose the notification
260 * by calling event.notification.close(). 237 * by calling event.notification.close().
261 */ 238 */
262 @LargeTest 239 @LargeTest
263 @Feature({"Browser", "Notifications"}) 240 @Feature({"Browser", "Notifications"})
264 public void testNotificationContentIntentClosesNotification() throws Excepti on { 241 public void testNotificationContentIntentClosesNotification() throws Excepti on {
265 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); 242 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW);
266 243
267 Notification notification = showAndGetNotification("MyNotification", "{} "); 244 Notification notification = showAndGetNotification("MyNotification", "{} ");
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 assertNull(NotificationUIManager.getOriginFromTag(";")); 370 assertNull(NotificationUIManager.getOriginFromTag(";"));
394 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;")); 371 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;"));
395 assertNull(NotificationUIManager.getOriginFromTag( 372 assertNull(NotificationUIManager.getOriginFromTag(
396 "SystemDownloadNotifier;NotificationUIManager;42")); 373 "SystemDownloadNotifier;NotificationUIManager;42"));
397 assertNull(NotificationUIManager.getOriginFromTag( 374 assertNull(NotificationUIManager.getOriginFromTag(
398 "SystemDownloadNotifier;https://example.com;42")); 375 "SystemDownloadNotifier;https://example.com;42"));
399 assertNull(NotificationUIManager.getOriginFromTag( 376 assertNull(NotificationUIManager.getOriginFromTag(
400 "NotificationUIManager;SystemDownloadNotifier;42")); 377 "NotificationUIManager;SystemDownloadNotifier;42"));
401 } 378 }
402 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698