Skip to content

Commit 16034b5

Browse files
committed
Add verify request for tests
1 parent d9081fa commit 16034b5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

lib/src/views/disclosure_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ class _DisclosurePageState extends State<DisclosurePage>
316316
}
317317

318318
Future<void> _showPhoneSettings() async {
319-
// TODO(peter): find function to open phone settings directly if possible.
320319
await widget._service.openAppSettings();
321320
}
322321

test/widget_test/disclosure_page_test.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ void main() {
2323
when(prefs.getBool('Permission.location_requested')).thenReturn(false);
2424
when(prefs.setBool('Permission.location_requested', any))
2525
.thenAnswer((realInvocation) => Future.value(true));
26+
when(prefs.setBool('Permission.phone_requested', any))
27+
.thenAnswer((realInvocation) => Future.value(true));
2628

2729
testWidgets('Regular permission show dialog', (tester) async {
2830
final testStub = MockTestStub();
2931
when(testStub.getSharedPreference())
3032
.thenAnswer((realInvocation) => Future.value(prefs));
31-
when(testStub.request(Permission.location))
33+
when(testStub.request(Permission.phone))
3234
.thenAnswer((realInvocation) => Future.value(PermissionStatus.granted));
33-
when(testStub.status(Permission.location))
35+
when(testStub.status(Permission.phone))
3436
.thenAnswer((realInvocation) => Future.value(PermissionStatus.granted));
3537

3638
final config = FlutterForcePermissionConfig(
@@ -39,7 +41,7 @@ void main() {
3941
permissionItemConfigs: [
4042
PermissionItemConfig(
4143
permissions: [
42-
Permission.location,
44+
Permission.phone,
4345
],
4446
itemText: PermissionItemText(
4547
header: 'Foreground location',
@@ -49,7 +51,7 @@ void main() {
4951
],
5052
);
5153
final status = <Permission, PermissionServiceStatus>{
52-
Permission.location: PermissionServiceStatus(
54+
Permission.phone: PermissionServiceStatus(
5355
status: PermissionStatus.denied,
5456
requested: false,
5557
serviceStatus: ServiceStatus.enabled,
@@ -76,7 +78,8 @@ void main() {
7678
await tester.tap(find.text('Confirm'));
7779
await tester.pump();
7880

79-
verify(prefs.setBool('Permission.location_requested', true));
81+
verify(testStub.request(Permission.phone));
82+
verify(prefs.setBool('Permission.phone_requested', true));
8083

8184
await resumed.close();
8285
});
@@ -139,6 +142,7 @@ void main() {
139142
await tester.tap(find.text('Confirm'));
140143
await tester.pump();
141144

145+
verify(testStub.request(Permission.location));
142146
verify(prefs.setBool('Permission.location_requested', true));
143147

144148
await resumed.close();
@@ -205,6 +209,8 @@ void main() {
205209
await tester.tap(find.text('Confirm'));
206210
await tester.pump();
207211

212+
verify(testStub.request(Permission.location));
213+
208214
expect(find.text('Location required'), findsOneWidget);
209215
expect(find.text('Location needed for proper operation'), findsOneWidget);
210216
expect(find.text('Settings'), findsOneWidget);
@@ -481,11 +487,7 @@ void main() {
481487
await tester.tap(find.text('Confirm'));
482488
await tester.pump();
483489

484-
verify(testStub.openAppSettings());
485-
486-
resumed.add(true);
487-
await tester.pump();
488-
490+
verify(testStub.request(Permission.location));
489491
when(testStub.status(Permission.location)).thenAnswer(
490492
(realInvocation) => Future.value(PermissionStatus.granted),
491493
);

0 commit comments

Comments
 (0)