Chromium Code Reviews| 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 | 13 |
| 14 import org.chromium.base.ThreadUtils; | 14 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.base.annotations.SuppressFBWarnings; | 15 import org.chromium.base.annotations.SuppressFBWarnings; |
| 16 import org.chromium.base.test.util.Feature; | 16 import org.chromium.base.test.util.Feature; |
| 17 import org.chromium.base.test.util.MinAndroidSdkLevel; | 17 import org.chromium.base.test.util.MinAndroidSdkLevel; |
| 18 import org.chromium.chrome.browser.preferences.website.ContentSetting; | 18 import org.chromium.chrome.browser.preferences.website.ContentSetting; |
| 19 import org.chromium.chrome.browser.preferences.website.PushNotificationInfo; | 19 import org.chromium.chrome.browser.preferences.website.PushNotificationInfo; |
| 20 import org.chromium.chrome.browser.widget.RoundedIconGenerator; | 20 import org.chromium.chrome.browser.widget.RoundedIconGenerator; |
| 21 import org.chromium.chrome.shell.ChromeShellTestBase; | 21 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 22 import org.chromium.chrome.test.util.TestHttpServerClient; | 22 import org.chromium.chrome.test.util.TestHttpServerClient; |
| 23 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy; | 23 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy; |
| 24 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry; | 24 import org.chromium.chrome.test.util.browser.notifications.MockNotificationManag erProxy.NotificationEntry; |
| 25 import org.chromium.content.browser.test.util.Criteria; | 25 import org.chromium.content.browser.test.util.Criteria; |
| 26 import org.chromium.content.browser.test.util.CriteriaHelper; | 26 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 27 import org.chromium.content.browser.test.util.JavaScriptUtils; | 27 import org.chromium.content.browser.test.util.JavaScriptUtils; |
| 28 | 28 |
| 29 import java.util.Arrays; | |
| 29 import java.util.List; | 30 import java.util.List; |
| 30 import java.util.concurrent.TimeoutException; | 31 import java.util.concurrent.TimeoutException; |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * Instrumentation tests for the Notification UI Manager implementation on Andro id. | 34 * Instrumentation tests for the Notification UI Manager implementation on Andro id. |
| 34 * | 35 * |
| 35 * Web Notifications are only supported on Android JellyBean and beyond. | 36 * Web Notifications are only supported on Android JellyBean and beyond. |
| 36 */ | 37 */ |
| 37 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN) | 38 @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN) |
| 38 public class NotificationUIManagerTest extends ChromeShellTestBase { | 39 public class NotificationUIManagerTest extends ChromeShellTestBase { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 assertNull(NotificationUIManager.getOriginFromTag("")); | 365 assertNull(NotificationUIManager.getOriginFromTag("")); |
| 365 assertNull(NotificationUIManager.getOriginFromTag(";")); | 366 assertNull(NotificationUIManager.getOriginFromTag(";")); |
| 366 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;")); | 367 assertNull(NotificationUIManager.getOriginFromTag(";;;;;;;")); |
| 367 assertNull(NotificationUIManager.getOriginFromTag( | 368 assertNull(NotificationUIManager.getOriginFromTag( |
| 368 "SystemDownloadNotifier;NotificationUIManager;42")); | 369 "SystemDownloadNotifier;NotificationUIManager;42")); |
| 369 assertNull(NotificationUIManager.getOriginFromTag( | 370 assertNull(NotificationUIManager.getOriginFromTag( |
| 370 "SystemDownloadNotifier;https://example.com;42")); | 371 "SystemDownloadNotifier;https://example.com;42")); |
| 371 assertNull(NotificationUIManager.getOriginFromTag( | 372 assertNull(NotificationUIManager.getOriginFromTag( |
| 372 "NotificationUIManager;SystemDownloadNotifier;42")); | 373 "NotificationUIManager;SystemDownloadNotifier;42")); |
| 373 } | 374 } |
| 375 | |
| 376 /** | |
| 377 * Verifies that the makeDefaults method returns the generated notification defaults. | |
| 378 */ | |
| 379 @SmallTest | |
| 380 @Feature({"Browser", "Notifications"}) | |
| 381 public void testMakeDefaults() throws Exception { | |
| 382 // 0 should be returned if silent is true and vibration's length is 0. | |
| 383 assertEquals(0, NotificationUIManager.makeDefaults(0, true)); | |
| 384 | |
| 385 // Notification.DEFAULT_ALL should be returned if silent is false and | |
| 386 // vibration's length is 0. | |
| 387 assertEquals(Notification.DEFAULT_ALL, | |
| 388 NotificationUIManager.makeDefaults(0, false)); | |
| 389 | |
| 390 // Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE should be re turned | |
| 391 // if silent is false and vibration's length is greater than 0. | |
| 392 assertEquals(Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, | |
| 393 NotificationUIManager.makeDefaults(10, false)); | |
| 394 } | |
| 395 | |
| 396 /** | |
| 397 * Verifies that the makeVibratePattern method returns vibration pattern use d | |
| 398 * in Android notification. | |
| 399 */ | |
| 400 @SmallTest | |
| 401 @Feature({"Browser", "Notifications"}) | |
| 402 public void testMakeVibratePattern() throws Exception { | |
| 403 assertTrue(Arrays.equals(new long[] {0, 100, 200, 300}, | |
| 404 NotificationUIManager.makeVibratePattern(new int[] {100, 200, 30 0}))); | |
|
Peter Beverloo
2015/05/01 17:17:59
You should be able to do this:
import org.junit.A
Sanghyun Park
2015/05/04 07:00:44
Thanks for your information.
Then, as I know, juni
Peter Beverloo
2015/05/05 13:11:56
No need to do that as part of this change.
| |
| 405 } | |
| 374 } | 406 } |
| OLD | NEW |