easy_mock_permission_handler 0.1.0 copy "easy_mock_permission_handler: ^0.1.0" to clipboard
easy_mock_permission_handler: ^0.1.0 copied to clipboard

Readable test mock for the permission_handler platform channel, built on easy_mock_channel. Narrate scenarios (granted / denied / service status) with no dependency on permission_handler — it speaks t [...]

easy_mock_permission_handler #

A readable test mock for the permission_handler platform channel, built on easy_mock_channel. It speaks the channel's raw wire codes directly, so it has no dependency on permission_handler. You narrate the story — "camera denied", "service disabled" — and the real permission_handler Dart code (in your app) reads it back. Scoped to camera and notification for now.

Usage #

import 'package:easy_mock_permission_handler/easy_mock_permission_handler.dart';

testWidgets('blocks the camera step when denied', (tester) async {
  mockPermissionHandler.init();          // harness usually does this
  mockPermissionHandler.camera.deny();

  // ... drive the code under test that calls Permission.camera.request() ...
});

mockPermissionHandler — defaults: camera & notification granted, service enabled, app settings openable, no rationale.

  • per permissionmockPermissionHandler.camera / .notification: grant() / deny() / permanentlyDeny() / restrict() / limit() / provisional()
  • service: serviceEnabled() / serviceDisabled() / serviceNotApplicable()
  • app settings: openAppSetting() / doNotOpenAppSetting()
  • rationale: showRequestPermissionRationale() / doNotShowRequestPermissionRationale()
  • install() — set up the channel and reset to defaults; call once per test (usually from the harness).

Needs the Flutter test binding (inside testWidgets, or TestWidgetsFlutterBinding.ensureInitialized() in a plain test). Only camera and notification are supported for now.

0
likes
140
points
119
downloads

Documentation

API reference

Publisher

verified publisherahmedomar.com.ly

Weekly Downloads

Readable test mock for the permission_handler platform channel, built on easy_mock_channel. Narrate scenarios (granted / denied / service status) with no dependency on permission_handler — it speaks the channel's raw codes.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

easy_mock_channel, flutter, flutter_test

More

Packages that depend on easy_mock_permission_handler