Skip to content

Commit c3d54b6

Browse files
committed
Fix tests after deserialization return change
1 parent 7470bfe commit c3d54b6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,13 @@ AndroidNotificationIntentData SerializeDeserializeNotification(AndroidJavaObject
136136
{
137137
var dataStream = new AndroidJavaObject("java.io.DataInputStream", byteStream);
138138
// don't dispose notification, it is kept in AndroidNotificationIntentData
139-
var deserializedNotification = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotificationCustom", dataStream);
140-
Assert.IsNotNull(deserializedNotification);
141-
return AndroidNotificationCenter.GetNotificationData(deserializedNotification);
139+
using (var deserializedNotificationBuilder = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotificationCustom", dataStream))
140+
{
141+
Assert.IsNotNull(deserializedNotificationBuilder);
142+
var deserializedNotification = deserializedNotificationBuilder.Call<AndroidJavaObject>("build");
143+
Assert.IsNotNull(deserializedNotification);
144+
return AndroidNotificationCenter.GetNotificationData(deserializedNotification);
145+
}
142146
}
143147
}
144148

@@ -263,8 +267,10 @@ AndroidNotificationIntentData SerializeDeserializeNotification(AndroidJavaObject
263267
if (inBetween != null)
264268
inBetween(prefs);
265269

266-
var deserializedNotification = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotification", context, prefs);
270+
var deserializedNotificationBuilder = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotification", context, prefs);
267271
// don't dispose notification, it is kept in AndroidNotificationIntentData
272+
Assert.IsNotNull(deserializedNotificationBuilder);
273+
var deserializedNotification = deserializedNotificationBuilder.Call<AndroidJavaObject>("build");
268274
Assert.IsNotNull(deserializedNotification);
269275
return AndroidNotificationCenter.GetNotificationData(deserializedNotification);
270276
}
@@ -350,7 +356,9 @@ public void OldTypeSerializedNotificationCanBedeserialized()
350356
var serialized = parcel.Call<AndroidJavaObject>("marshall");
351357
Assert.IsNotNull(serialized);
352358

353-
var deserializedNotification = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotification", context, serialized);
359+
var deserializedNotificationBuilder = utilsClass.CallStatic<AndroidJavaObject>("deserializeNotification", context, serialized);
360+
Assert.IsNotNull(deserializedNotificationBuilder);
361+
var deserializedNotification = deserializedNotificationBuilder.Call<AndroidJavaObject>("build");
354362
Assert.IsNotNull(deserializedNotification);
355363
var notificationData = AndroidNotificationCenter.GetNotificationData(deserializedNotification);
356364
Assert.IsNotNull(notificationData);

0 commit comments

Comments
 (0)