fix(android): wire exact preview startup and device benchmarks
Gitea CI / Check code and tests (pull_request) Successful in 11m6s
Gitea CI / Build Android APK (pull_request) Successful in 5m15s
Gitea CI / Build Windows x64 app (pull_request) Successful in 2m41s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m2s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 51s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s

This commit is contained in:
lingjhf committed 2026-10-08 01:37:58 +08:00
1 parent b4cb12cbe3
commit 64a3a5b547
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);
}
},
);
}