Skip to content

Commit 450c8e7

Browse files
committed
Add test for not showing in foreground
1 parent 183005d commit 450c8e7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,27 @@ public IEnumerator SendNotification_CanReschedule()
329329

330330
Assert.AreEqual(1, currentHandler.receivedNotificationCount);
331331
}
332+
333+
[UnityTest]
334+
[UnityPlatform(RuntimePlatform.Android)]
335+
public IEnumerator SendNotificationNotShownInForeground_IsDeliveredButNotShown()
336+
{
337+
var n = new AndroidNotification();
338+
n.Title = "SendNotificationNotShownInForeground_ISDeliveredButNotShown";
339+
n.Text = "SendNotificationNotShownInForeground_ISDeliveredButNotShown Text";
340+
n.FireTime = System.DateTime.Now;
341+
n.ShowInForeground = false;
342+
343+
Debug.LogWarning("SendNotificationNotShownInForeground_ISDeliveredButNotShown sends notification");
344+
345+
int originalId = AndroidNotificationCenter.SendNotification(n, kDefaultTestChannel);
346+
yield return WaitForNotification(5.0f);
347+
348+
Debug.LogWarning("SendNotificationNotShownInForeground_ISDeliveredButNotShown sends completed");
349+
350+
Assert.AreEqual(1, currentHandler.receivedNotificationCount);
351+
yield return new WaitForSeconds(2.0f); // give some time, since on some devices we don't immediately get infor on delivered notifications
352+
var status = AndroidNotificationCenter.CheckScheduledNotificationStatus(originalId);
353+
Assert.AreEqual(NotificationStatus.Unknown, status); // status should be unknown, rather than Delivered
354+
}
332355
}

0 commit comments

Comments
 (0)