Skip to content

Commit a98a485

Browse files
authored
Register local notification device test (#4294)
1 parent f2347d8 commit a98a485

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
7070
new MediaPlaybackScreenshotTest(),
7171
new OrientationLockScreenshotTest(),
7272
new InPlaceEditViewTest(),
73-
new AccessibilityTest()));
73+
new AccessibilityTest(),
74+
new LocalNotificationTest()));
7475

7576
public static void addTest(BaseTest test) {
7677
TEST_CLASSES.add(0, test);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.codenameone.examples.hellocodenameone.tests;
2+
3+
import com.codename1.notifications.LocalNotification;
4+
import com.codename1.ui.Display;
5+
import com.codename1.ui.util.UITimer;
6+
7+
public class LocalNotificationTest extends BaseTest {
8+
@Override
9+
public boolean shouldTakeScreenshot() {
10+
return false;
11+
}
12+
13+
@Override
14+
public boolean runTest() throws Exception {
15+
LocalNotification n1 = new LocalNotification();
16+
n1.setId("test-notification-1");
17+
n1.setAlertTitle("Test Notification 1");
18+
n1.setAlertBody("This is a test notification");
19+
Display.getInstance().scheduleLocalNotification(n1, System.currentTimeMillis() + 1000, LocalNotification.REPEAT_NONE);
20+
21+
LocalNotification n2 = new LocalNotification();
22+
n2.setId("test-notification-2");
23+
n2.setAlertTitle("Test Notification 2");
24+
n2.setAlertBody("This is a repeating notification");
25+
Display.getInstance().scheduleLocalNotification(n2, System.currentTimeMillis() + 2000, LocalNotification.REPEAT_MINUTE);
26+
27+
LocalNotification n3 = new LocalNotification();
28+
n3.setId("test-notification-3");
29+
n3.setAlertTitle("Test Notification 3");
30+
n3.setAlertBody("This is a notification with badge");
31+
n3.setBadgeNumber(5);
32+
Display.getInstance().scheduleLocalNotification(n3, System.currentTimeMillis() + 3000, LocalNotification.REPEAT_NONE);
33+
34+
UITimer.timer(4000, false, () -> {
35+
Display.getInstance().cancelLocalNotification("test-notification-1");
36+
Display.getInstance().cancelLocalNotification("test-notification-2");
37+
Display.getInstance().cancelLocalNotification("test-notification-3");
38+
done();
39+
});
40+
41+
return true;
42+
}
43+
}

0 commit comments

Comments
 (0)