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

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

Issue 1388483002: Implement the Notification `timestamp` property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
8 8
9 import android.annotation.SuppressLint; 9 import android.annotation.SuppressLint;
10 import android.app.Notification; 10 import android.app.Notification;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 assertEquals("MyNotification", notification.extras.getString(Notificatio n.EXTRA_TITLE)); 158 assertEquals("MyNotification", notification.extras.getString(Notificatio n.EXTRA_TITLE));
159 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T EXT)); 159 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T EXT));
160 assertEquals(getOrigin(), notification.extras.getString(Notification.EXT RA_SUB_TEXT)); 160 assertEquals(getOrigin(), notification.extras.getString(Notification.EXT RA_SUB_TEXT));
161 161
162 // Verify that the ticker text contains the notification's title and bod y. 162 // Verify that the ticker text contains the notification's title and bod y.
163 String tickerText = notification.tickerText.toString(); 163 String tickerText = notification.tickerText.toString();
164 164
165 assertTrue(tickerText.contains("MyNotification")); 165 assertTrue(tickerText.contains("MyNotification"));
166 assertTrue(tickerText.contains("Hello")); 166 assertTrue(tickerText.contains("Hello"));
167 167
168 // Verify that the notification's timestamp is set in the past 30 second s. This number has
169 // no significance, but needs to be high enough to not cause flakiness a s it's set by the
170 // renderer process on notification creation.
171 assertTrue((System.currentTimeMillis() - notification.when) < 30 * 1000) ;
johnme 2015/10/20 17:12:20 Is it worth throwing in a Math.abs just in case th
Peter Beverloo 2016/01/28 17:18:29 Done.
172
168 // Validate the appearance style of the notification. The EXTRA_TEMPLATE was inroduced 173 // Validate the appearance style of the notification. The EXTRA_TEMPLATE was inroduced
169 // in Android Lollipop, we cannot verify this in earlier versions. 174 // in Android Lollipop, we cannot verify this in earlier versions.
170 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 175 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
171 assertEquals("android.app.Notification$BigTextStyle", 176 assertEquals("android.app.Notification$BigTextStyle",
172 notification.extras.getString(Notification.EXTRA_TEMPLATE)); 177 notification.extras.getString(Notification.EXTRA_TEMPLATE));
173 } 178 }
174 179
175 assertNotNull(notification.largeIcon); 180 assertNotNull(notification.largeIcon);
176 181
177 // Validate the notification's behavior. 182 // Validate the notification's behavior.
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 * Verifies that the makeVibrationPattern method returns vibration pattern u sed 463 * Verifies that the makeVibrationPattern method returns vibration pattern u sed
459 * in Android notification. 464 * in Android notification.
460 */ 465 */
461 @SmallTest 466 @SmallTest
462 @Feature({"Browser", "Notifications"}) 467 @Feature({"Browser", "Notifications"})
463 public void testMakeVibrationPattern() throws Exception { 468 public void testMakeVibrationPattern() throws Exception {
464 assertTrue(Arrays.equals(new long[] {0, 100, 200, 300}, 469 assertTrue(Arrays.equals(new long[] {0, 100, 200, 300},
465 NotificationUIManager.makeVibrationPattern(new int[] {100, 200, 300}))); 470 NotificationUIManager.makeVibrationPattern(new int[] {100, 200, 300})));
466 } 471 }
467 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698