Skip to content

Commit

Permalink
Modify now failing tests after changes
Browse files Browse the repository at this point in the history
These two tests now fail after moving away from using thread time.
- notShowNotificationPastTTL
- shouldSetExpireTimeCorrectlyWhenMissingFromPayload

Modify the test code to not use thread time
  • Loading branch information
nan-li committed Feb 3, 2022
1 parent eb5427a commit 528a908
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1252,15 +1252,15 @@ public void shouldSetExpireTimeCorrectlyFromGoogleTTL() throws Exception {
@Test
@Config (sdk = 23, shadows = { ShadowGenerateNotification.class })
public void notShowNotificationPastTTL() throws Exception {
long sentTime = time.getCurrentThreadTimeMillis();
long sentTime = time.getCurrentTimeMillis();
long ttl = 60L;

Bundle bundle = getBaseNotifBundle();
bundle.putLong(OneSignalPackagePrivateHelper.GOOGLE_SENT_TIME_KEY, sentTime);
bundle.putLong(OneSignalPackagePrivateHelper.GOOGLE_TTL_KEY, ttl);

// Go forward just past the TTL of the notification
time.advanceThreadTimeBy(ttl + 1);
time.advanceSystemTimeBy(ttl + 1);

NotificationBundleProcessor_ProcessFromFCMIntentService(blankActivity, bundle);
threadAndTaskWait();
Expand All @@ -1275,7 +1275,7 @@ public void shouldSetExpireTimeCorrectlyWhenMissingFromPayload() throws Exceptio
threadAndTaskWait();

long expireTime = (Long)TestHelpers.getAllNotificationRecords(dbHelper).get(0).get(NotificationTable.COLUMN_NAME_EXPIRE_TIME);
assertEquals((SystemClock.currentThreadTimeMillis() / 1_000L) + 259_200, expireTime);
assertEquals((System.currentTimeMillis() / 1_000L) + 259_200, expireTime);
}

// TODO: Once we figure out the correct way to process notifications with high priority using the WorkManager
Expand Down

0 comments on commit 528a908

Please sign in to comment.