@@ -210,8 +210,8 @@ void main() {
210
210
NotificationChannelManager .kDefaultNotificationSound.resourceName;
211
211
String fakeStoredUrl (String resourceName) =>
212
212
testBinding.androidNotificationHost.fakeStoredNotificationSoundUrl (resourceName);
213
- String fakeResourceUrl (String resourceName) =>
214
- 'android.resource://com.zulip.flutter /raw/$resourceName ' ;
213
+ String fakeResourceUrl ({ required String resourceName, String ? packageName} ) =>
214
+ 'android.resource://${ packageName ?? eg . packageInfo (). packageName } /raw/$resourceName ' ;
215
215
216
216
test ('on Android 28 (and lower) resource file is used for notification sound' , () async {
217
217
addTearDown (testBinding.reset);
@@ -227,7 +227,30 @@ void main() {
227
227
.isEmpty ();
228
228
check (androidNotificationHost.takeCreatedChannels ())
229
229
.single
230
- .soundUrl.equals (fakeResourceUrl (defaultSoundResourceName));
230
+ .soundUrl.equals (fakeResourceUrl (resourceName: defaultSoundResourceName));
231
+ });
232
+
233
+ test ('generates resource file URL from app package name' , () async {
234
+ addTearDown (testBinding.reset);
235
+ final androidNotificationHost = testBinding.androidNotificationHost;
236
+
237
+ testBinding.packageInfoResult = eg.packageInfo (packageName: 'com.example.test' );
238
+
239
+ // Force the default sound URL to be the resource file URL, by forcing
240
+ // the Android version to the one where we don't store sounds through the
241
+ // media store.
242
+ testBinding.deviceInfoResult =
243
+ const AndroidDeviceInfo (sdkInt: 28 , release: '9' );
244
+
245
+ await NotificationChannelManager .ensureChannel ();
246
+ check (androidNotificationHost.takeCopySoundResourceToMediaStoreCalls ())
247
+ .isEmpty ();
248
+ check (androidNotificationHost.takeCreatedChannels ())
249
+ .single
250
+ .soundUrl.equals (fakeResourceUrl (
251
+ resourceName: defaultSoundResourceName,
252
+ packageName: 'com.example.test' ,
253
+ ));
231
254
});
232
255
233
256
test ('notification sound resource files are being copied to the media store' , () async {
@@ -315,7 +338,7 @@ void main() {
315
338
.isEmpty ();
316
339
check (androidNotificationHost.takeCreatedChannels ())
317
340
.single
318
- .soundUrl.equals (fakeResourceUrl (defaultSoundResourceName));
341
+ .soundUrl.equals (fakeResourceUrl (resourceName : defaultSoundResourceName));
319
342
});
320
343
});
321
344
0 commit comments