Skip to content

Commit

Permalink
Refactor permissions tests to test location permission
Browse files Browse the repository at this point in the history
  • Loading branch information
piotruela committed Nov 3, 2024
1 parent b59aaa3 commit 66c1018
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void main() {
await _requestAndDenyMicrophonePermission($);
await _requestAndDenyMicrophonePermission($);

await _requestAndDenyContactsPermission($);
await _requestAndDenyContactsPermission($);
await _requestAndDenyLocationPermission($);
await _requestAndDenyLocationPermission($);
});
}

Expand Down Expand Up @@ -49,17 +49,17 @@ Future<void> _requestAndDenyMicrophonePermission(
expect($(#microphone).$(#statusText).text, 'Not granted');
}

Future<void> _requestAndDenyContactsPermission(
Future<void> _requestAndDenyLocationPermission(
PatrolIntegrationTester $,
) async {
if (!await Permission.contacts.isGranted) {
expect($(#contacts).$(#statusText).text, 'Not granted');
expect($(#location).$(#statusText).text, 'Not granted');
await $('Request contacts permission').tap();
if (await $.native.isPermissionDialogVisible(timeout: _timeout)) {
await $.native.denyPermission();
await $.pump();
}
}

expect($(#contacts).$(#statusText).text, 'Not granted');
expect($(#location).$(#statusText).text, 'Not granted');
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void main() {

await _requestAndGrantCameraPermission($);
await _requestAndGrantMicrophonePermission($);
await _requestAndDenyContactsPermission($);
await _requestAndDenyLocationPermission($);
});
}

Expand Down Expand Up @@ -44,17 +44,17 @@ Future<void> _requestAndGrantMicrophonePermission(
expect($(#microphone).$(#statusText).text, 'Granted');
}

Future<void> _requestAndDenyContactsPermission(
Future<void> _requestAndDenyLocationPermission(
PatrolIntegrationTester $,
) async {
if (!await Permission.contacts.isGranted) {
expect($(#contacts).$(#statusText).text, 'Not granted');
if (!await Permission.location.isGranted) {
expect($(#location).$(#statusText).text, 'Not granted');
await $('Request contacts permission').tap();
if (await $.native.isPermissionDialogVisible(timeout: _timeout)) {
await $.native.denyPermission();
await $.pump();
}
}

expect($(#contacts).$(#statusText).text, 'Not granted');
expect($(#location).$(#statusText).text, 'Not granted');
}

0 comments on commit 66c1018

Please sign in to comment.