Skip to content

Commit 6e4dcef

Browse files
committed
Make sure we don't have manager when simulating rescheduling
1 parent 1ca606d commit 6e4dcef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

com.unity.mobile.notifications/Tests/Runtime/Android/AndroidNotificationSendingTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ public IEnumerator SendNotification_CanReschedule()
317317
int id = AndroidNotificationCenter.SendNotification(n, kDefaultTestChannel);
318318
yield return new WaitForSeconds(0.2f);
319319

320+
// temporary null the manager, cause that's what we have in reality
321+
var manager = managerClass.GetStatic<AndroidJavaObject>("mUnityNotificationManager");
322+
managerClass.SetStatic<AndroidJavaObject>("mUnityNotificationManager", null);
323+
320324
// simulate reboot by directly cancelling scheduled alarms preserving saves
321325
managerClass.CallStatic("cancelPendingNotificationIntent", context, id);
322326
yield return new WaitForSeconds(0.2f);
@@ -327,6 +331,8 @@ public IEnumerator SendNotification_CanReschedule()
327331

328332
Debug.LogWarning("SendNotification_CanReschedule completed");
329333

334+
// restore manager (to not ruin other tests)
335+
managerClass.SetStatic("mUnityNotificationManager", manager);
330336
Assert.AreEqual(1, currentHandler.receivedNotificationCount);
331337
}
332338
}

0 commit comments

Comments
 (0)