Skip to content

Commit 88e04d2

Browse files
authored
[permission_handler] Add regression integration tests based on upstream v12.0.1 (#1059)
1 parent 75ddd62 commit 88e04d2

2 files changed

Lines changed: 56 additions & 5 deletions

File tree

packages/permission_handler/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Add 8 integration test cases.
4+
15
## 1.4.4
26

37
* Remove Ecore API.

packages/permission_handler/example/integration_test/permission_handler_test.dart

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,64 @@
1+
// Copyright 2024 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
import 'package:flutter_test/flutter_test.dart';
26
import 'package:integration_test/integration_test.dart';
37
import 'package:permission_handler/permission_handler.dart';
48

59
void main() {
610
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
711

8-
testWidgets('get permission status', (tester) async {
9-
expect(await Permission.camera.status.isGranted, true);
12+
group('Permission.status', () {
13+
testWidgets('camera permission is granted', (tester) async {
14+
expect(await Permission.camera.status, PermissionStatus.granted);
15+
});
16+
17+
testWidgets('microphone permission is granted', (tester) async {
18+
expect(await Permission.microphone.status, PermissionStatus.granted);
19+
});
20+
21+
testWidgets('location permission is granted', (tester) async {
22+
expect(await Permission.location.status, PermissionStatus.granted);
23+
});
24+
25+
testWidgets('mediaLibrary permission is granted', (tester) async {
26+
expect(await Permission.mediaLibrary.status, PermissionStatus.granted);
27+
});
28+
29+
testWidgets('storage permission is granted', (tester) async {
30+
expect(await Permission.storage.status, PermissionStatus.granted);
31+
});
32+
33+
testWidgets('contacts permission is granted', (tester) async {
34+
expect(await Permission.contacts.status, PermissionStatus.granted);
35+
});
36+
});
37+
38+
group('Permission.serviceStatus', () {
39+
testWidgets('location service status is valid', (tester) async {
40+
final status = await Permission.location.serviceStatus;
41+
expect(status.isEnabled || status.isDisabled, true);
42+
});
1043
});
1144

12-
testWidgets('get location service status', (tester) async {
13-
var status = await Permission.location.serviceStatus;
14-
expect(status.isEnabled || status.isDisabled, true);
45+
group('Permission.request', () {
46+
testWidgets('requesting camera permission returns granted', (tester) async {
47+
final status = await Permission.camera.request();
48+
expect(status, PermissionStatus.granted);
49+
});
50+
51+
testWidgets('requesting multiple permissions returns granted',
52+
(tester) async {
53+
final statuses = await [
54+
Permission.camera,
55+
Permission.microphone,
56+
Permission.location,
57+
].request();
58+
expect(statuses[Permission.camera], PermissionStatus.granted);
59+
expect(statuses[Permission.microphone], PermissionStatus.granted);
60+
expect(statuses[Permission.location], PermissionStatus.granted);
61+
});
1562
});
1663

1764
testWidgets('open app settings', (tester) async {

0 commit comments

Comments
 (0)