Skip to content

Commit 050a8ef

Browse files
committed
Fix testTimedMessageIsDisplayedOncePerSession fackyness
* Like some previous commits we are adding Awaitility and exending the max time an existing one to fix the flaky testTimedMessageIsDisplayedOncePerSession test.
1 parent ffbbbe5 commit 050a8ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

OneSignalSDK/unittest/src/test/java/com/test/onesignal/InAppMessageIntegrationTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import static junit.framework.Assert.assertEquals;
7676
import static junit.framework.Assert.assertFalse;
7777
import static junit.framework.Assert.assertTrue;
78+
import static org.junit.Assert.fail;
7879

7980
@Config(packageName = "com.onesignal.example",
8081
shadows = {
@@ -362,7 +363,7 @@ public void testTimedMessageIsDisplayedOncePerSession() throws Exception {
362363
// for the correct amount of time, so all we are doing here is checking to
363364
// make sure the message actually gets displayed once the timer fires
364365
Awaitility.await()
365-
.atMost(new Duration(150, TimeUnit.MILLISECONDS))
366+
.atMost(new Duration(1_000, TimeUnit.MILLISECONDS))
366367
.pollInterval(new Duration(10, TimeUnit.MILLISECONDS))
367368
.until(() -> OneSignalPackagePrivateHelper.getInAppMessageDisplayQueue().size() == 1);
368369

@@ -380,7 +381,10 @@ public void run() {
380381
OneSignalPackagePrivateHelper.dismissCurrentMessage();
381382

382383
// Check that the IAM is not displayed again
383-
assertEquals(0, OneSignalPackagePrivateHelper.getInAppMessageDisplayQueue().size());
384+
Awaitility.await()
385+
.atMost(new Duration(1_000, TimeUnit.MILLISECONDS))
386+
.pollInterval(new Duration(10, TimeUnit.MILLISECONDS))
387+
.until(() -> OneSignalPackagePrivateHelper.getInAppMessageDisplayQueue().size() == 0);
384388
}
385389

386390
@Test

0 commit comments

Comments
 (0)