Skip to content

Commit 4407784

Browse files
author
Justin Yang
committed
Add comments for Thread.sleep
1 parent 2f96d94 commit 4407784

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

iterableapi/src/androidTest/java/com/iterable/iterableapi/IterableNotificationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public void testNotificationText() throws Exception {
6363
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), notif, Application.class);
6464
IterableNotification.postNotificationOnDevice(appContext, iterableNotification);
6565
assertEquals("IterableAPI", iterableNotification.mContentTitle);
66+
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
67+
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
6668
Thread.sleep(100);
6769
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
6870
Bundle notificationExtras = mNotificationManager.getActiveNotifications()[0].getNotification().extras;
@@ -78,6 +80,8 @@ public void testMessage() throws Exception {
7880

7981
IterableNotification iterableNotification = IterableNotification.createNotification(getContext(), notif1, Application.class);
8082
IterableNotification.postNotificationOnDevice(appContext, iterableNotification);
83+
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
84+
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
8185
Thread.sleep(100);
8286
assertFalse(iterableNotification.iterableNotificationData.getIsGhostPush());
8387
assertEquals("11111111111111111111111111111111", iterableNotification.iterableNotificationData.getMessageId());
@@ -94,6 +98,8 @@ public void testMessage() throws Exception {
9498

9599
IterableNotification iterableNotification2 = IterableNotification.createNotification(getContext(), notif2, Application.class);
96100
IterableNotification.postNotificationOnDevice(appContext, iterableNotification2);
101+
// It looks like mNotificationManager.notify(iterableNotification.requestCode, iterableNotification.build());
102+
// is the culprit here for the flaky tests. This thread is spun up by the android system. Unless we do dependency injection and mock the notificationManager, it'll be hard to make this unflake.
97103
Thread.sleep(100);
98104
assertFalse(iterableNotification2.iterableNotificationData.getIsGhostPush());
99105
assertEquals("22222222222222222222222222222222", iterableNotification2.iterableNotificationData.getMessageId());

0 commit comments

Comments
 (0)