| 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.os.Build; | 8 import android.os.Build; |
| 9 import android.test.suitebuilder.annotation.MediumTest; | 9 import android.test.suitebuilder.annotation.MediumTest; |
| 10 import android.util.SparseArray; | 10 import android.util.SparseArray; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 assertEquals("android.app.Notification$BigTextStyle", | 141 assertEquals("android.app.Notification$BigTextStyle", |
| 142 notification.extras.getString(Notification.EXTRA_TEMPLATE)); | 142 notification.extras.getString(Notification.EXTRA_TEMPLATE)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Validate the notification's behavior. | 145 // Validate the notification's behavior. |
| 146 assertEquals(Notification.DEFAULT_ALL, notification.defaults); | 146 assertEquals(Notification.DEFAULT_ALL, notification.defaults); |
| 147 assertEquals(Notification.PRIORITY_DEFAULT, notification.priority); | 147 assertEquals(Notification.PRIORITY_DEFAULT, notification.priority); |
| 148 } | 148 } |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * Verifies that notifications created with the "silent" flag do not inherit
system defaults |
| 152 * in regards to their sound, vibration and light indicators. |
| 153 */ |
| 154 @MediumTest |
| 155 @Feature({"Browser", "Notifications"}) |
| 156 public void testNotificationSilentProperty() throws Exception { |
| 157 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); |
| 158 assertEquals(PERMISSION_GRANTED, runJavaScriptCodeInCurrentTab("Notifica
tion.permission")); |
| 159 |
| 160 Notification notification = showAndGetNotification("MyNotification", "{
silent: true }"); |
| 161 assertNotNull(notification); |
| 162 |
| 163 // Zero indicates that no defaults should be inherited from the system. |
| 164 assertEquals(0, notification.defaults); |
| 165 } |
| 166 |
| 167 /** |
| 151 * Verifies that notifications which specify an icon will have that icon fet
ched, converted into | 168 * Verifies that notifications which specify an icon will have that icon fet
ched, converted into |
| 152 * a Bitmap and included as the large icon in the notification. | 169 * a Bitmap and included as the large icon in the notification. |
| 153 */ | 170 */ |
| 154 @MediumTest | 171 @MediumTest |
| 155 @Feature({"Browser", "Notifications"}) | 172 @Feature({"Browser", "Notifications"}) |
| 156 public void testShowNotificationWithIcon() throws Exception { | 173 public void testShowNotificationWithIcon() throws Exception { |
| 157 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); | 174 setNotificationContentSettingForCurrentOrigin(ContentSetting.ALLOW); |
| 158 assertEquals(PERMISSION_GRANTED, runJavaScriptCodeInCurrentTab("Notifica
tion.permission")); | 175 assertEquals(PERMISSION_GRANTED, runJavaScriptCodeInCurrentTab("Notifica
tion.permission")); |
| 159 | 176 |
| 160 Notification notification = showAndGetNotification("MyNotification", "{i
con: 'icon.png'}"); | 177 Notification notification = showAndGetNotification("MyNotification", "{i
con: 'icon.png'}"); |
| 161 assertNotNull(notification); | 178 assertNotNull(notification); |
| 162 | 179 |
| 163 assertEquals("MyNotification", notification.extras.getString(Notificatio
n.EXTRA_TITLE)); | 180 assertEquals("MyNotification", notification.extras.getString(Notificatio
n.EXTRA_TITLE)); |
| 164 assertNotNull(notification.largeIcon); | 181 assertNotNull(notification.largeIcon); |
| 165 | 182 |
| 166 // These are the dimensions of //chrome/test/data/notifications/icon.png
at 1x scale. | 183 // These are the dimensions of //chrome/test/data/notifications/icon.png
at 1x scale. |
| 167 assertEquals(100, notification.largeIcon.getWidth()); | 184 assertEquals(100, notification.largeIcon.getWidth()); |
| 168 assertEquals(100, notification.largeIcon.getHeight()); | 185 assertEquals(100, notification.largeIcon.getHeight()); |
| 169 } | 186 } |
| 170 } | 187 } |
| OLD | NEW |