[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,65 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:background_downloader/background_downloader.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class _Storage implements PersistentStorage {
|
||||
@override
|
||||
Future<void> initialize() async {}
|
||||
@override
|
||||
Future<List<TaskRecord>> retrieveAllTaskRecords() async => [];
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
test('Android connectivity initialization error fails ready without detached error', () async {
|
||||
final previous = debugDefaultTargetPlatformOverride;
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = previous);
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
const connectivity = MethodChannel(
|
||||
'dev.fluttercommunity.plus/connectivity',
|
||||
);
|
||||
const events = MethodChannel(
|
||||
'dev.fluttercommunity.plus/connectivity_status',
|
||||
);
|
||||
messenger.setMockMethodCallHandler(
|
||||
connectivity,
|
||||
(_) async => throw PlatformException(code: 'network_unavailable'),
|
||||
);
|
||||
messenger.setMockMethodCallHandler(events, (_) async => null);
|
||||
addTearDown(() {
|
||||
messenger.setMockMethodCallHandler(connectivity, null);
|
||||
messenger.setMockMethodCallHandler(events, null);
|
||||
});
|
||||
final unhandled = <Object>[];
|
||||
final done = Completer<void>();
|
||||
Object? observed;
|
||||
runZonedGuarded(() async {
|
||||
final downloader = FileDownloader(persistentStorage: _Storage());
|
||||
try {
|
||||
await downloader.ready;
|
||||
} catch (error) {
|
||||
observed = error;
|
||||
} finally {
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
done.complete();
|
||||
}
|
||||
}, (error, stack) => unhandled.add(error));
|
||||
await done.future;
|
||||
expect(
|
||||
observed,
|
||||
isA<PlatformException>().having(
|
||||
(error) => error.code,
|
||||
'code',
|
||||
'network_unavailable',
|
||||
),
|
||||
);
|
||||
expect(unhandled, isEmpty);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user