Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/permission_handler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Add 8 integration test cases.

## 1.4.4

* Remove Ecore API.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,64 @@
// Copyright 2024 Samsung Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:permission_handler/permission_handler.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('get permission status', (tester) async {
expect(await Permission.camera.status.isGranted, true);
group('Permission.status', () {
testWidgets('camera permission is granted', (tester) async {
expect(await Permission.camera.status, PermissionStatus.granted);
});

testWidgets('microphone permission is granted', (tester) async {
expect(await Permission.microphone.status, PermissionStatus.granted);
});

testWidgets('location permission is granted', (tester) async {
expect(await Permission.location.status, PermissionStatus.granted);
});

testWidgets('mediaLibrary permission is granted', (tester) async {
expect(await Permission.mediaLibrary.status, PermissionStatus.granted);
});

testWidgets('storage permission is granted', (tester) async {
expect(await Permission.storage.status, PermissionStatus.granted);
});

testWidgets('contacts permission is granted', (tester) async {
expect(await Permission.contacts.status, PermissionStatus.granted);
});
});
Comment thread
seungsoo47 marked this conversation as resolved.

group('Permission.serviceStatus', () {
testWidgets('location service status is valid', (tester) async {
final status = await Permission.location.serviceStatus;
expect(status.isEnabled || status.isDisabled, true);
});
});

testWidgets('get location service status', (tester) async {
var status = await Permission.location.serviceStatus;
expect(status.isEnabled || status.isDisabled, true);
group('Permission.request', () {
testWidgets('requesting camera permission returns granted', (tester) async {
final status = await Permission.camera.request();
expect(status, PermissionStatus.granted);
});

testWidgets('requesting multiple permissions returns granted',
(tester) async {
final statuses = await [
Permission.camera,
Permission.microphone,
Permission.location,
].request();
expect(statuses[Permission.camera], PermissionStatus.granted);
expect(statuses[Permission.microphone], PermissionStatus.granted);
expect(statuses[Permission.location], PermissionStatus.granted);
});
});
Comment thread
seungsoo47 marked this conversation as resolved.

testWidgets('open app settings', (tester) async {
Expand Down
Loading