Skip to content

Commit 2709688

Browse files
authored
Merge pull request #162 from Unity-Technologies/android/improve-tests
[Android] improve tests
2 parents 1b143a8 + 1d2d6d0 commit 2709688

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public IEnumerator ScheduleRepeatableNotification_NotificationsAreReceived()
149149
var n = new AndroidNotification();
150150
n.Title = "Repeating Notification Title";
151151
n.Text = "Repeating Notification Text";
152-
n.FireTime = System.DateTime.Now;
152+
n.FireTime = System.DateTime.Now.AddSeconds(2);
153153
n.RepeatInterval = new System.TimeSpan(0, 0, 5); // interval needs to be quite big for test to be reliable
154154

155155
Debug.LogWarning("ScheduleRepeatableNotification_NotificationsAreReceived sends notification");
@@ -158,8 +158,8 @@ public IEnumerator ScheduleRepeatableNotification_NotificationsAreReceived()
158158

159159
// we use inexact scheduling, so repeated notification may take a while to appear
160160
// inexact also can group, so for test purposes we only check that it repeats at least once
161-
yield return WaitForNotification(8.0f);
162-
yield return WaitForNotification(30.0f);
161+
yield return WaitForNotification(120.0f);
162+
yield return WaitForNotification(120.0f);
163163
AndroidNotificationCenter.CancelScheduledNotification(originalId);
164164

165165
Debug.LogWarning("ScheduleRepeatableNotification_NotificationsAreReceived completed");

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ AndroidJavaObject CreateBitmap()
209209
var configClass = new AndroidJavaClass("android.graphics.Bitmap$Config");
210210
var ARGB_8888 = configClass.GetStatic<AndroidJavaObject>("ARGB_8888");
211211
var bitmapClass = new AndroidJavaClass("android.graphics.Bitmap");
212-
return bitmapClass.CallStatic<AndroidJavaObject>("createBitmap", 10000, 10000, ARGB_8888);
212+
return bitmapClass.CallStatic<AndroidJavaObject>("createBitmap", 1000, 1000, ARGB_8888);
213213
}
214214

215215
[Test]
@@ -259,7 +259,8 @@ AndroidNotificationIntentData SerializeDeserializeNotificationIntent(AndroidJava
259259
intent.Call<AndroidJavaObject>("putExtra", "unityNotification", javaNotif).Dispose();
260260
var utilsClass = new AndroidJavaClass("com.unity.androidnotifications.UnityNotificationUtilities");
261261

262-
var prefs = context.Call<AndroidJavaObject>("getSharedPreferences", "android.notification.test.key", context.GetStatic<int>("MODE_PRIVATE"));
262+
// context.GetStatic<int>("MODE_PRIVATE") fails on older android, did investigate why, simply using it's value from docs
263+
var prefs = context.Call<AndroidJavaObject>("getSharedPreferences", "android.notification.test.key", 0 /* MODE_PRIVATE */);
263264
utilsClass.CallStatic("serializeNotificationIntent", prefs, intent);
264265

265266
if (inBetween != null)

0 commit comments

Comments
 (0)