File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
OneSignalSDK/unittest/src/test/java/com Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ public long getElapsedRealtime() {
20
20
return mockedElapsedTime != null ? mockedElapsedTime : super .getElapsedRealtime ();
21
21
}
22
22
23
+ public void freezeTime () {
24
+ mockedTime = getCurrentTimeMillis ();
25
+ mockedElapsedTime = getElapsedRealtime ();
26
+ }
27
+
23
28
public void setMockedTime (Long mockedTime ) {
24
29
this .mockedTime = mockedTime ;
25
30
}
Original file line number Diff line number Diff line change @@ -1271,11 +1271,14 @@ public void notShowNotificationPastTTL() throws Exception {
1271
1271
@ Test
1272
1272
@ Config (shadows = { ShadowGenerateNotification .class })
1273
1273
public void shouldSetExpireTimeCorrectlyWhenMissingFromPayload () throws Exception {
1274
+ time .freezeTime ();
1274
1275
NotificationBundleProcessor_ProcessFromFCMIntentService (blankActivity , getBaseNotifBundle ());
1275
1276
threadAndTaskWait ();
1276
1277
1278
+ long currentTime = time .getCurrentTimeMillis () / 1_000L ;
1277
1279
long expireTime = (Long )TestHelpers .getAllNotificationRecords (dbHelper ).get (0 ).get (NotificationTable .COLUMN_NAME_EXPIRE_TIME );
1278
- assertEquals ((System .currentTimeMillis () / 1_000L ) + 259_200 , expireTime );
1280
+ long expectedExpireTime = currentTime + 259_200 ;
1281
+ assertEquals (expectedExpireTime , expireTime );
1279
1282
}
1280
1283
1281
1284
// TODO: Once we figure out the correct way to process notifications with high priority using the WorkManager
You can’t perform that action at this time.
0 commit comments