@@ -235,8 +235,9 @@ void main() {
235235 final testStub = MockTestStub ();
236236 when (testStub.getSharedPreference ())
237237 .thenAnswer ((realInvocation) => Future .value (prefs));
238- when (testStub.status (Permission .location))
239- .thenAnswer ((realInvocation) => Future .value (PermissionStatus .permanentlyDenied));
238+ when (testStub.status (Permission .location)).thenAnswer (
239+ (realInvocation) => Future .value (PermissionStatus .permanentlyDenied),
240+ );
240241 when (testStub.openAppSettings ())
241242 .thenAnswer ((realInvocation) => Future .value ());
242243
@@ -412,83 +413,89 @@ void main() {
412413 await resumed.close ();
413414 });
414415
415- testWidgets ('Required permission denied with custom dialog callback `showDialogCallback`' , (tester) async {
416- final testStub = MockTestStub ();
417- when (testStub.getSharedPreference ())
418- .thenAnswer ((realInvocation) => Future .value (prefs));
419- when (testStub.request (Permission .location))
420- .thenAnswer ((realInvocation) => Future .value (PermissionStatus .denied));
421- when (testStub.status (Permission .location))
422- .thenAnswer ((realInvocation) => Future .value (PermissionStatus .denied));
423- when (testStub.openAppSettings ())
424- .thenAnswer ((realInvocation) => Future .value ());
425-
426- final config = FlutterForcePermissionConfig (
427- title: 'Title' ,
428- confirmText: 'Confirm' ,
429- permissionItemConfigs: [
430- PermissionItemConfig (
431- permissions: [
432- Permission .location,
433- ],
434- itemText: PermissionItemText (
435- header: 'Foreground location' ,
436- rationaleText: 'Rationale' ,
437- forcedPermissionDialogConfig: ForcedPermissionDialogConfig (
438- title: 'Location required' ,
439- text: 'Location needed for proper operation' ,
440- buttonText: 'Settings' ,
416+ testWidgets (
417+ 'Required permission denied with custom dialog callback `showDialogCallback`' ,
418+ (tester) async {
419+ final testStub = MockTestStub ();
420+ when (testStub.getSharedPreference ())
421+ .thenAnswer ((realInvocation) => Future .value (prefs));
422+ when (testStub.request (Permission .location)).thenAnswer (
423+ (realInvocation) => Future .value (PermissionStatus .denied),
424+ );
425+ when (testStub.status (Permission .location)).thenAnswer (
426+ (realInvocation) => Future .value (PermissionStatus .denied),
427+ );
428+ when (testStub.openAppSettings ())
429+ .thenAnswer ((realInvocation) => Future .value ());
430+
431+ final config = FlutterForcePermissionConfig (
432+ title: 'Title' ,
433+ confirmText: 'Confirm' ,
434+ permissionItemConfigs: [
435+ PermissionItemConfig (
436+ permissions: [
437+ Permission .location,
438+ ],
439+ itemText: PermissionItemText (
440+ header: 'Foreground location' ,
441+ rationaleText: 'Rationale' ,
442+ forcedPermissionDialogConfig: ForcedPermissionDialogConfig (
443+ title: 'Location required' ,
444+ text: 'Location needed for proper operation' ,
445+ buttonText: 'Settings' ,
446+ ),
441447 ),
448+ required : true ,
442449 ),
443- required : true ,
450+ ],
451+ showDialogCallback: (context, title, text, button, callback) {
452+ callback ();
453+ },
454+ );
455+ final status = < Permission , PermissionServiceStatus > {
456+ Permission .location: PermissionServiceStatus (
457+ status: PermissionStatus .denied,
458+ requested: false ,
459+ serviceStatus: ServiceStatus .enabled,
444460 ),
445- ],
446- showDialogCallback: (context, title, text, button, callback) {
447- callback ();
448- },
449- );
450- final status = < Permission , PermissionServiceStatus > {
451- Permission .location: PermissionServiceStatus (
452- status: PermissionStatus .denied,
453- requested: false ,
454- serviceStatus: ServiceStatus .enabled,
455- ),
456- };
457- final StreamController <bool > resumed = StreamController .broadcast ()
458- ..add (true );
459-
460- await tester.pumpWidget (
461- MaterialApp (
462- home: DisclosurePage .stub (
463- permissionConfig: config,
464- permissionStatuses: status,
465- service: testStub,
466- resumed: resumed,
461+ };
462+ final StreamController <bool > resumed = StreamController .broadcast ()
463+ ..add (true );
464+
465+ await tester.pumpWidget (
466+ MaterialApp (
467+ home: DisclosurePage .stub (
468+ permissionConfig: config,
469+ permissionStatuses: status,
470+ service: testStub,
471+ resumed: resumed,
472+ ),
467473 ),
468- ),
469- );
474+ );
470475
471- expect (find.text ('Title' ), findsOneWidget);
472- expect (find.text ('Foreground location' ), findsOneWidget);
473- expect (find.text ('Rationale' ), findsOneWidget);
474- expect (find.text ('Confirm' ), findsOneWidget);
476+ expect (find.text ('Title' ), findsOneWidget);
477+ expect (find.text ('Foreground location' ), findsOneWidget);
478+ expect (find.text ('Rationale' ), findsOneWidget);
479+ expect (find.text ('Confirm' ), findsOneWidget);
475480
476- await tester.tap (find.text ('Confirm' ));
477- await tester.pump ();
481+ await tester.tap (find.text ('Confirm' ));
482+ await tester.pump ();
478483
479- verify (testStub.openAppSettings ());
484+ verify (testStub.openAppSettings ());
480485
481- resumed.add (true );
482- await tester.pump ();
486+ resumed.add (true );
487+ await tester.pump ();
483488
484- when (testStub.status (Permission .location))
485- .thenAnswer ((realInvocation) => Future .value (PermissionStatus .granted));
486- resumed.add (true );
487- await tester.pump ();
489+ when (testStub.status (Permission .location)).thenAnswer (
490+ (realInvocation) => Future .value (PermissionStatus .granted),
491+ );
492+ resumed.add (true );
493+ await tester.pump ();
488494
489- verify (testStub.openAppSettings ());
490- expect (find.text ('Settings' ), findsNothing);
495+ verify (testStub.openAppSettings ());
496+ expect (find.text ('Settings' ), findsNothing);
491497
492- await resumed.close ();
493- });
498+ await resumed.close ();
499+ },
500+ );
494501}
0 commit comments