@@ -210,8 +210,8 @@ void main() {
210210 NotificationChannelManager .kDefaultNotificationSound.resourceName;
211211 String fakeStoredUrl (String resourceName) =>
212212 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 ' ;
215215
216216 test ('on Android 28 (and lower) resource file is used for notification sound' , () async {
217217 addTearDown (testBinding.reset);
@@ -227,7 +227,30 @@ void main() {
227227 .isEmpty ();
228228 check (androidNotificationHost.takeCreatedChannels ())
229229 .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+ ));
231254 });
232255
233256 test ('notification sound resource files are being copied to the media store' , () async {
@@ -315,7 +338,7 @@ void main() {
315338 .isEmpty ();
316339 check (androidNotificationHost.takeCreatedChannels ())
317340 .single
318- .soundUrl.equals (fakeResourceUrl (defaultSoundResourceName));
341+ .soundUrl.equals (fakeResourceUrl (resourceName : defaultSoundResourceName));
319342 });
320343 });
321344
0 commit comments