| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T
EXT)); | 53 assertEquals("Hello", notification.extras.getString(Notification.EXTRA_T
EXT)); |
| 54 assertEquals(UrlUtilities.formatUrlForSecurityDisplay(getOrigin(), false
/* showScheme */), | 54 assertEquals(UrlUtilities.formatUrlForSecurityDisplay(getOrigin(), false
/* showScheme */), |
| 55 notification.extras.getString(Notification.EXTRA_SUB_TEXT)); | 55 notification.extras.getString(Notification.EXTRA_SUB_TEXT)); |
| 56 | 56 |
| 57 // Verify that the ticker text contains the notification's title and bod
y. | 57 // Verify that the ticker text contains the notification's title and bod
y. |
| 58 String tickerText = notification.tickerText.toString(); | 58 String tickerText = notification.tickerText.toString(); |
| 59 | 59 |
| 60 assertTrue(tickerText.contains("MyNotification")); | 60 assertTrue(tickerText.contains("MyNotification")); |
| 61 assertTrue(tickerText.contains("Hello")); | 61 assertTrue(tickerText.contains("Hello")); |
| 62 | 62 |
| 63 // Verify that the notification's timestamp is set in the past 60 second
s. This number has |
| 64 // no significance, but needs to be high enough to not cause flakiness a
s it's set by the |
| 65 // renderer process on notification creation. |
| 66 assertTrue(Math.abs(System.currentTimeMillis() - notification.when) < 60
* 1000); |
| 67 |
| 63 // Validate the appearance style of the notification. The EXTRA_TEMPLATE
was introduced | 68 // Validate the appearance style of the notification. The EXTRA_TEMPLATE
was introduced |
| 64 // in Android Lollipop, we cannot verify this in earlier versions. | 69 // in Android Lollipop, we cannot verify this in earlier versions. |
| 65 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP | 70 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP |
| 66 && !NotificationUIManager.useCustomLayouts()) { | 71 && !NotificationUIManager.useCustomLayouts()) { |
| 67 assertEquals("android.app.Notification$BigTextStyle", | 72 assertEquals("android.app.Notification$BigTextStyle", |
| 68 notification.extras.getString(Notification.EXTRA_TEMPLATE)); | 73 notification.extras.getString(Notification.EXTRA_TEMPLATE)); |
| 69 } | 74 } |
| 70 | 75 |
| 71 assertNotNull(notification.largeIcon); | 76 assertNotNull(notification.largeIcon); |
| 72 | 77 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 assertEquals(1, notifications.size()); | 303 assertEquals(1, notifications.size()); |
| 299 assertEquals("Two", | 304 assertEquals("Two", |
| 300 notifications.get(0).notification.extras.getString(Notification.
EXTRA_TITLE)); | 305 notifications.get(0).notification.extras.getString(Notification.
EXTRA_TITLE)); |
| 301 | 306 |
| 302 // Close the last notification and verify that none remain. | 307 // Close the last notification and verify that none remain. |
| 303 notifications.get(0).notification.contentIntent.send(); | 308 notifications.get(0).notification.contentIntent.send(); |
| 304 waitForNotificationManagerMutation(); | 309 waitForNotificationManagerMutation(); |
| 305 assertTrue(getNotificationEntries().isEmpty()); | 310 assertTrue(getNotificationEntries().isEmpty()); |
| 306 } | 311 } |
| 307 } | 312 } |
| OLD | NEW |