OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
8 import static org.junit.Assert.assertNull; | 8 import static org.junit.Assert.assertNull; |
9 import static org.junit.Assert.assertTrue; | 9 import static org.junit.Assert.assertTrue; |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 assertNull(NotificationPlatformBridge.getOriginFromTag( | 51 assertNull(NotificationPlatformBridge.getOriginFromTag( |
52 "NotificationPlatformBridge;SystemDownloadNotifier;42")); | 52 "NotificationPlatformBridge;SystemDownloadNotifier;42")); |
53 } | 53 } |
54 | 54 |
55 /** | 55 /** |
56 * Verifies that the makeDefaults method returns the generated notification
defaults. | 56 * Verifies that the makeDefaults method returns the generated notification
defaults. |
57 */ | 57 */ |
58 @Test | 58 @Test |
59 @Feature({"Browser", "Notifications"}) | 59 @Feature({"Browser", "Notifications"}) |
60 public void testMakeDefaults() throws Exception { | 60 public void testMakeDefaults() throws Exception { |
61 // 0 should be returned if silent is true and vibration's length is 0. | 61 // 0 should be returned if pattern length is 0, silent is true, and vibr
ation is enabled. |
62 assertEquals(0, NotificationPlatformBridge.makeDefaults(0, true)); | 62 assertEquals(0, NotificationPlatformBridge.makeDefaults(0, true, true)); |
63 | 63 |
64 // Notification.DEFAULT_ALL should be returned if silent is false and | 64 // Notification.DEFAULT_ALL should be returned if pattern length is 0, s
ilent is false and |
65 // vibration's length is 0. | 65 // vibration is enabled. |
66 assertEquals(Notification.DEFAULT_ALL, NotificationPlatformBridge.makeDe
faults(0, false)); | 66 assertEquals( |
| 67 Notification.DEFAULT_ALL, NotificationPlatformBridge.makeDefault
s(0, false, true)); |
67 | 68 |
68 // Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE should be re
turned | 69 // Vibration should be removed from the defaults if pattern length is gr
eater than 0, silent |
69 // if silent is false and vibration's length is greater than 0. | 70 // is false, and vibration is enabled. |
70 assertEquals(Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, | 71 assertEquals(Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, |
71 NotificationPlatformBridge.makeDefaults(10, false)); | 72 NotificationPlatformBridge.makeDefaults(10, false, true)); |
| 73 |
| 74 // Vibration should be removed from the defaults if pattern length is gr
eater than 0, silent |
| 75 // is false, and vibration is disabled. |
| 76 assertEquals(Notification.DEFAULT_ALL & ~Notification.DEFAULT_VIBRATE, |
| 77 NotificationPlatformBridge.makeDefaults(7, false, false)); |
72 } | 78 } |
73 | 79 |
74 /** | 80 /** |
75 * Verifies that the makeVibrationPattern method returns vibration pattern u
sed | 81 * Verifies that the makeVibrationPattern method returns vibration pattern u
sed |
76 * in Android notification. | 82 * in Android notification. |
77 */ | 83 */ |
78 @Test | 84 @Test |
79 @Feature({"Browser", "Notifications"}) | 85 @Feature({"Browser", "Notifications"}) |
80 public void testMakeVibrationPattern() throws Exception { | 86 public void testMakeVibrationPattern() throws Exception { |
81 assertTrue(Arrays.equals(new long[] {0, 100, 200, 300}, | 87 assertTrue(Arrays.equals(new long[] {0, 100, 200, 300}, |
82 NotificationPlatformBridge.makeVibrationPattern(new int[] {100,
200, 300}))); | 88 NotificationPlatformBridge.makeVibrationPattern(new int[] {100,
200, 300}))); |
83 } | 89 } |
84 } | 90 } |
OLD | NEW |