fix(preview): 接入已合并 SDK 与 Android 0.1.3 预览验证 (#12)
Gitea CI / Build Windows x64 app (push) Successful in 2m38s
Gitea CI / Check code and tests (push) Successful in 5m19s
Gitea CI / Build Android APK (push) Successful in 3m13s
Gitea CI / Audit and package Windows x64 (push) Successful in 2m49s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 59s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea CI / Build Windows x64 app (push) Successful in 2m38s
Gitea CI / Check code and tests (push) Successful in 5m19s
Gitea CI / Build Android APK (push) Successful in 3m13s
Gitea CI / Audit and package Windows x64 (push) Successful in 2m49s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 59s
Gitea CI / Gitea CI passed (push) Successful in 2s
This commit was merged in pull request #12.
This commit is contained in:
1 parent
b4cb12cbe3
commit
aa5255d1e4
11 files changed
+1577
-30
No files matched your search
@@ -0,0 +1,90 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
||||
import 'package:cutdex_sdk/runtime.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../support/preview_fixture.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
const channel = MethodChannel('registry-startup-test');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
|
||||
test(
|
||||
'pending startup exposes its controller and callers share initialization',
|
||||
() async {
|
||||
final gate = Completer<void>();
|
||||
final started = Completer<void>();
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
expect(call.method, 'capabilities');
|
||||
started.complete();
|
||||
await gate.future;
|
||||
throw PlatformException(code: 'failed', message: 'startup failed');
|
||||
});
|
||||
final fixture = await createPreviewFixture(
|
||||
Uri.parse('file:///fixture.mp4'),
|
||||
);
|
||||
final registry = PreviewControllerRegistry(
|
||||
CutdexRuntime(channel: channel),
|
||||
);
|
||||
try {
|
||||
final pending = registry.prepare(('p', 't'), fixture.timeline);
|
||||
final failure = expectLater(pending, throwsA(isA<RuntimeException>()));
|
||||
await started.future;
|
||||
expect(registry.cached(('p', 't')), isNotNull);
|
||||
expect(registry.cached(('p', 't'))!.ready, isFalse);
|
||||
expect(registry.prepare(('p', 't'), fixture.timeline), same(pending));
|
||||
gate.complete();
|
||||
await failure;
|
||||
expect(registry.cached(('p', 't')), isNull);
|
||||
} finally {
|
||||
registry.dispose();
|
||||
messenger.setMockMethodCallHandler(channel, null);
|
||||
await fixture.workspace.close();
|
||||
await fixture.directory.delete(recursive: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
'invalidating pending startup cannot publish a closed controller',
|
||||
() async {
|
||||
final gate = Completer<void>();
|
||||
final started = Completer<void>();
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
expect(call.method, 'capabilities');
|
||||
started.complete();
|
||||
await gate.future;
|
||||
return {
|
||||
'contractVersion': 1,
|
||||
'features': {'playback.preview': 'conditional'},
|
||||
};
|
||||
});
|
||||
final fixture = await createPreviewFixture(
|
||||
Uri.parse('file:///fixture.mp4'),
|
||||
);
|
||||
final registry = PreviewControllerRegistry(
|
||||
CutdexRuntime(channel: channel),
|
||||
);
|
||||
try {
|
||||
final pending = registry.prepare(('p', 't'), fixture.timeline);
|
||||
final failure = expectLater(pending, throwsStateError);
|
||||
await started.future;
|
||||
final invalidation = registry.invalidate(('p', 't'));
|
||||
expect(registry.cached(('p', 't')), isNull);
|
||||
gate.complete();
|
||||
await failure;
|
||||
await invalidation;
|
||||
expect(registry.cached(('p', 't')), isNull);
|
||||
} finally {
|
||||
registry.dispose();
|
||||
messenger.setMockMethodCallHandler(channel, null);
|
||||
await fixture.workspace.close();
|
||||
await fixture.directory.delete(recursive: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user