[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,43 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:background_downloader/background_downloader.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class _FailingStorage implements PersistentStorage {
|
||||
final failure = StateError('download storage unavailable');
|
||||
@override
|
||||
Future<void> initialize() async => throw failure;
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test(
|
||||
'Android initialization failure reaches ready instead of unhandled future',
|
||||
() async {
|
||||
final previous = debugDefaultTargetPlatformOverride;
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = previous);
|
||||
final storage = _FailingStorage();
|
||||
final unhandled = <Object>[];
|
||||
final done = Completer<void>();
|
||||
Object? observed;
|
||||
runZonedGuarded(() async {
|
||||
final downloader = FileDownloader(persistentStorage: storage);
|
||||
try {
|
||||
await downloader.ready.timeout(const Duration(milliseconds: 200));
|
||||
} catch (error) {
|
||||
observed = error;
|
||||
} finally {
|
||||
done.complete();
|
||||
}
|
||||
}, (error, stack) => unhandled.add(error));
|
||||
await done.future;
|
||||
expect(observed, same(storage.failure));
|
||||
expect(unhandled, isEmpty);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user