@@ -23,14 +23,16 @@ void main() {
23
23
when (prefs.getBool ('Permission.location_requested' )).thenReturn (false );
24
24
when (prefs.setBool ('Permission.location_requested' , any))
25
25
.thenAnswer ((realInvocation) => Future .value (true ));
26
+ when (prefs.setBool ('Permission.phone_requested' , any))
27
+ .thenAnswer ((realInvocation) => Future .value (true ));
26
28
27
29
testWidgets ('Regular permission show dialog' , (tester) async {
28
30
final testStub = MockTestStub ();
29
31
when (testStub.getSharedPreference ())
30
32
.thenAnswer ((realInvocation) => Future .value (prefs));
31
- when (testStub.request (Permission .location ))
33
+ when (testStub.request (Permission .phone ))
32
34
.thenAnswer ((realInvocation) => Future .value (PermissionStatus .granted));
33
- when (testStub.status (Permission .location ))
35
+ when (testStub.status (Permission .phone ))
34
36
.thenAnswer ((realInvocation) => Future .value (PermissionStatus .granted));
35
37
36
38
final config = FlutterForcePermissionConfig (
@@ -39,7 +41,7 @@ void main() {
39
41
permissionItemConfigs: [
40
42
PermissionItemConfig (
41
43
permissions: [
42
- Permission .location ,
44
+ Permission .phone ,
43
45
],
44
46
itemText: PermissionItemText (
45
47
header: 'Foreground location' ,
@@ -49,7 +51,7 @@ void main() {
49
51
],
50
52
);
51
53
final status = < Permission , PermissionServiceStatus > {
52
- Permission .location : PermissionServiceStatus (
54
+ Permission .phone : PermissionServiceStatus (
53
55
status: PermissionStatus .denied,
54
56
requested: false ,
55
57
serviceStatus: ServiceStatus .enabled,
@@ -76,7 +78,8 @@ void main() {
76
78
await tester.tap (find.text ('Confirm' ));
77
79
await tester.pump ();
78
80
79
- verify (prefs.setBool ('Permission.location_requested' , true ));
81
+ verify (testStub.request (Permission .phone));
82
+ verify (prefs.setBool ('Permission.phone_requested' , true ));
80
83
81
84
await resumed.close ();
82
85
});
@@ -139,6 +142,7 @@ void main() {
139
142
await tester.tap (find.text ('Confirm' ));
140
143
await tester.pump ();
141
144
145
+ verify (testStub.request (Permission .location));
142
146
verify (prefs.setBool ('Permission.location_requested' , true ));
143
147
144
148
await resumed.close ();
@@ -205,6 +209,8 @@ void main() {
205
209
await tester.tap (find.text ('Confirm' ));
206
210
await tester.pump ();
207
211
212
+ verify (testStub.request (Permission .location));
213
+
208
214
expect (find.text ('Location required' ), findsOneWidget);
209
215
expect (find.text ('Location needed for proper operation' ), findsOneWidget);
210
216
expect (find.text ('Settings' ), findsOneWidget);
@@ -481,11 +487,7 @@ void main() {
481
487
await tester.tap (find.text ('Confirm' ));
482
488
await tester.pump ();
483
489
484
- verify (testStub.openAppSettings ());
485
-
486
- resumed.add (true );
487
- await tester.pump ();
488
-
490
+ verify (testStub.request (Permission .location));
489
491
when (testStub.status (Permission .location)).thenAnswer (
490
492
(realInvocation) => Future .value (PermissionStatus .granted),
491
493
);
0 commit comments