Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
20a49e1b
Commit
20a49e1b
authored
Mar 17, 2021
by
Jan-Derk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated pubspec, readme, CHANGELOG for platform interface
parent
077b908e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
132 deletions
+8
-132
permission_handler/test/permission_handler_test.dart
+0
-129
permission_handler_platform_interface/CHANGELOG.md
+5
-0
permission_handler_platform_interface/README.md
+1
-1
permission_handler_platform_interface/pubspec.yaml
+1
-1
permission_handler_platform_interface/test/src/permissions_test.dart
+1
-1
No files found.
permission_handler/test/permission_handler_test.dart
deleted
100644 → 0
View file @
077b908e
import
'package:flutter_test/flutter_test.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
import
'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'
;
import
'package:plugin_platform_interface/plugin_platform_interface.dart'
;
import
'package:mockito/mockito.dart'
;
void
main
(
)
{
group
(
'PermissionHandler'
,
()
{
setUp
(()
{
PermissionHandlerPlatform
.
instance
=
MockPermissionHandlerPlatform
();
});
test
(
'openAppSettings'
,
()
async
{
final
hasOpened
=
await
openAppSettings
();
expect
(
hasOpened
,
true
);
});
test
(
'PermissionActions on Permission: get status'
,
()
async
{
final
permissionStatus
=
await
Permission
.
calendar
.
status
;
expect
(
permissionStatus
,
PermissionStatus
.
granted
);
});
test
(
// ignore: lines_longer_than_80_chars
'PermissionActions on Permission: get shouldShowRequestRationale should return true when on android'
,
()
async
{
final
mockPermissionHandlerPlatform
=
PermissionHandlerPlatform
.
instance
;
when
(
mockPermissionHandlerPlatform
.
shouldShowRequestPermissionRationale
(
Permission
.
calendar
))
.
thenAnswer
((
_
)
=>
Future
.
value
(
true
));
await
Permission
.
calendar
.
shouldShowRequestRationale
;
verify
(
mockPermissionHandlerPlatform
.
shouldShowRequestPermissionRationale
(
Permission
.
calendar
))
.
called
(
1
);
});
test
(
'PermissionActions on Permission: request()'
,
()
async
{
final
permissionRequest
=
Permission
.
calendar
.
request
();
expect
(
permissionRequest
,
isA
<
Future
<
PermissionStatus
>>());
});
test
(
'PermissionCheckShortcuts on Permission: get isGranted'
,
()
async
{
final
isGranted
=
await
Permission
.
calendar
.
isGranted
;
expect
(
isGranted
,
true
);
});
test
(
'PermissionCheckShortcuts on Permission: get isDenied'
,
()
async
{
final
isDenied
=
await
Permission
.
calendar
.
isDenied
;
expect
(
isDenied
,
false
);
});
test
(
'PermissionCheckShortcuts on Permission: get isRestricted'
,
()
async
{
final
isRestricted
=
await
Permission
.
calendar
.
isRestricted
;
expect
(
isRestricted
,
false
);
});
test
(
'PermissionCheckShortcuts on Permission: get isLimited'
,
()
async
{
final
isLimited
=
await
Permission
.
calendar
.
isLimited
;
expect
(
isLimited
,
false
);
});
test
(
'PermissionCheckShortcuts on Permission: get isPermanentlyDenied'
,
()
async
{
final
isPermanentlyDenied
=
await
Permission
.
calendar
.
isPermanentlyDenied
;
expect
(
isPermanentlyDenied
,
false
);
});
test
(
// ignore: lines_longer_than_80_chars
'ServicePermissionActions on PermissionWithService: get ServiceStatus returns the right service status'
,
()
async
{
var
serviceStatus
=
await
Permission
.
phone
.
serviceStatus
;
expect
(
serviceStatus
,
ServiceStatus
.
enabled
);
});
test
(
// ignore: lines_longer_than_80_chars
'PermissionListActions on List<Permission>: request() on a list returns a Map<Permission, PermissionStatus>'
,
()
async
{
var
permissionList
=
<
Permission
>[];
final
permissionMap
=
await
permissionList
.
request
();
expect
(
permissionMap
,
isA
<
Map
<
Permission
,
PermissionStatus
>>());
});
});
}
class
MockPermissionHandlerPlatform
extends
Mock
with
// ignore: prefer_mixin
MockPlatformInterfaceMixin
implements
PermissionHandlerPlatform
{
@override
Future
<
PermissionStatus
>
checkPermissionStatus
(
Permission
permission
)
=>
Future
.
value
(
PermissionStatus
.
granted
);
@override
Future
<
ServiceStatus
>
checkServiceStatus
(
Permission
permission
)
=>
Future
.
value
(
ServiceStatus
.
enabled
);
@override
Future
<
bool
>
openAppSettings
()
=>
Future
.
value
(
true
);
@override
Future
<
Map
<
Permission
,
PermissionStatus
>>
requestPermissions
(
List
<
Permission
>
permissions
)
{
var
permissionsMap
=
<
Permission
,
PermissionStatus
>{};
return
Future
.
value
(
permissionsMap
);
}
@override
Future
<
bool
>
shouldShowRequestPermissionRationale
(
Permission
?
permission
)
{
return
super
.
noSuchMethod
(
Invocation
.
method
(
#shouldShowPermissionRationale
,
[
permission
],
),
returnValue:
Future
.
value
(
true
),
);
}
}
permission_handler_platform_interface/CHANGELOG.md
View file @
20a49e1b
## 3.1.1
*
Fixed conversion issue where
`PermissionStatus.denied`
was not translated to the correct index.
*
Added unit-tests to guard API against breaking changes.
## 3.1.0
## 3.1.0
*
Added support for bluetooth permissions.
*
Added support for bluetooth permissions.
...
...
permission_handler_platform_interface/README.md
View file @
20a49e1b
# permission_handler_platform_interface
# permission_handler_platform_interface
[

](https://pub.dartlang.org/packages/permission_handler_platform_interface) !
[
Build status
](
https://github.com/Baseflow/flutter-permission-handler/workflows/platform_interface_package/badge.svg?branch=master
)
[
![style: effective dart
]
(https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
[

](https://pub.dartlang.org/packages/permission_handler_platform_interface) !
[
Build status
](
https://github.com/Baseflow/flutter-permission-handler/workflows/platform_interface_package/badge.svg?branch=master
)
[
![style: effective dart
]
(https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
[

](https://codecov.io/gh/Baseflow/flutter-permission-handler)
A common platform interface for the
[
`permission_handler`
][
1
]
plugin.
A common platform interface for the
[
`permission_handler`
][
1
]
plugin.
...
...
permission_handler_platform_interface/pubspec.yaml
View file @
20a49e1b
...
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
...
@@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin.
homepage
:
https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
homepage
:
https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version
:
3.1.
0
version
:
3.1.
1
dependencies
:
dependencies
:
flutter
:
flutter
:
...
...
permission_handler_platform_interface/test/src/permissions_test.dart
View file @
20a49e1b
...
@@ -17,7 +17,7 @@ void main() {
...
@@ -17,7 +17,7 @@ void main() {
}
}
});
});
test
(
'check if
byValue returns corresponding PermissionGroup valu
e'
,
()
{
test
(
'check if
toString method returns the corresponding nam
e'
,
()
{
var
permissionWithService
=
PermissionWithService
.
private
(
0
);
var
permissionWithService
=
PermissionWithService
.
private
(
0
);
var
permissionName
=
permissionWithService
.
toString
();
var
permissionName
=
permissionWithService
.
toString
();
expect
(
permissionName
,
'Permission.calendar'
);
expect
(
permissionName
,
'Permission.calendar'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment