|
| 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 | + |
1 | 5 | import 'package:flutter_test/flutter_test.dart'; |
2 | 6 | import 'package:integration_test/integration_test.dart'; |
3 | 7 | import 'package:permission_handler/permission_handler.dart'; |
4 | 8 |
|
5 | 9 | void main() { |
6 | 10 | IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
7 | 11 |
|
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 | + }); |
10 | 43 | }); |
11 | 44 |
|
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 | + }); |
15 | 62 | }); |
16 | 63 |
|
17 | 64 | testWidgets('open app settings', (tester) async { |
|
0 commit comments