Skip to content

Commit fff14d0

Browse files
committed
Add additional tests for channels
1 parent 01d8d27 commit fff14d0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,47 @@ public void CreateNotificationChannel_NotificationChannelIsCreated()
3939
Assert.AreEqual(currentChannelCount, AndroidNotificationCenter.GetNotificationChannels().Length);
4040
}
4141

42+
[Test]
43+
[UnityPlatform(RuntimePlatform.Android)]
44+
public void GetNotificationChannel_ReturnsTheChannel()
45+
{
46+
var channel = AndroidNotificationCenter.GetNotificationChannel(kChannelId);
47+
Assert.IsNotNull(channel);
48+
Assert.AreEqual("SerializeDeserializeNotification channel", channel.Name);
49+
Assert.AreEqual("SerializeDeserializeNotification channel", channel.Description);
50+
Assert.AreEqual(Importance.High, channel.Importance);
51+
}
52+
53+
[Test]
54+
[UnityPlatform(RuntimePlatform.Android)]
55+
public void GetNotificationChannel_NonExistentChannel_ReturnsNull()
56+
{
57+
var channel = AndroidNotificationCenter.GetNotificationChannel("DoesNotExist");
58+
Assert.IsNotNull(channel);
59+
}
60+
61+
[Test]
62+
[UnityPlatform(RuntimePlatform.Android)]
63+
public void GetNotificationChannels_NoChannels_ReturnsEmptyArray()
64+
{
65+
var channels = AndroidNotificationCenter.GetNotificationChannels();
66+
foreach (var channel in channels)
67+
AndroidNotificationCenter.DeleteNotificationChannel(channel.Id);
68+
69+
try
70+
{
71+
var chans = AndroidNotificationCenter.GetNotificationChannels();
72+
Assert.IsNotNull(chans);
73+
Assert.AreEqual(0, chans.Length);
74+
}
75+
finally
76+
{
77+
// recreate test channels to not break other tests
78+
foreach (var channel in channels)
79+
AndroidNotificationCenter.RegisterNotificationChannel(channel);
80+
}
81+
}
82+
4283
[Test]
4384
[UnityPlatform(RuntimePlatform.Android)]
4485
public void DeleteNotificationChannel_NotificationChannelIsDeleted()

0 commit comments

Comments
 (0)