[verified] Publish ReelBox source under GPLv3
This commit is contained in:
commit
db2b505ca3
445 files changed
+105274
No files matched your search
@@ -0,0 +1,60 @@
|
||||
// Exercise the pinned Android protocol without constructing connectivity/jobs.
|
||||
// ignore: implementation_imports
|
||||
import 'package:background_downloader/src/permissions.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
const channel = MethodChannel('com.bbflight.background_downloader');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
|
||||
tearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
test(
|
||||
'failed permission dispatch releases slot for the next request',
|
||||
() async {
|
||||
final service = AndroidPermissionsService();
|
||||
var calls = 0;
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
if (++calls == 1) {
|
||||
throw PlatformException(
|
||||
code: 'activity_detached',
|
||||
message: 'No activity',
|
||||
);
|
||||
}
|
||||
service.onPermissionRequestResult(PermissionStatus.granted);
|
||||
return true;
|
||||
});
|
||||
await expectLater(
|
||||
service.request(PermissionType.notifications),
|
||||
throwsA(isA<PlatformException>()),
|
||||
);
|
||||
expect(
|
||||
await service.request(PermissionType.notifications),
|
||||
PermissionStatus.granted,
|
||||
);
|
||||
expect(calls, 2);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'notification result preceding native request reply completes request',
|
||||
() async {
|
||||
final service = AndroidPermissionsService();
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
expect(call.method, 'requestPermission');
|
||||
expect(call.arguments, PermissionType.notifications.index);
|
||||
// Android may deliver its activity callback before the method reply.
|
||||
service.onPermissionRequestResult(PermissionStatus.denied);
|
||||
return true;
|
||||
});
|
||||
expect(
|
||||
await service.request(PermissionType.notifications),
|
||||
PermissionStatus.denied,
|
||||
);
|
||||
expect(service.permissionStatusCompleter, isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user