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
@@ -33,6 +33,8 @@ android {
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId = "com.example.cutdex"
|
||||
manifestPlaceholders["cutdexPreviewReverseCacheMiB"] = "0"
|
||||
manifestPlaceholders["cutdexNativeSurfacePreview"] = "false"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||
minSdk = 31
|
||||
@@ -50,7 +52,17 @@ android {
|
||||
create("development") {
|
||||
dimension = "environment"
|
||||
applicationIdSuffix = ".dev"
|
||||
resValue("string", "app_name", "Cutdex Dev")
|
||||
// Device validation can coexist with an app signed on another machine.
|
||||
val validationId = providers.gradleProperty("cutdexValidationApplicationId")
|
||||
.orElse(providers.environmentVariable("CUTDEX_VALIDATION_APPLICATION_ID")).orNull
|
||||
if (validationId != null) applicationId = validationId
|
||||
resValue("string", "app_name", if (validationId == null) "Cutdex Dev" else "Cutdex Decoder Test")
|
||||
manifestPlaceholders["cutdexPreviewReverseCacheMiB"] = providers
|
||||
.gradleProperty("cutdexPreviewReverseCacheMiB")
|
||||
.orElse(providers.environmentVariable("CUTDEX_PREVIEW_REVERSE_CACHE_MIB")).getOrElse("0")
|
||||
manifestPlaceholders["cutdexNativeSurfacePreview"] = providers
|
||||
.gradleProperty("cutdexNativeSurfacePreview")
|
||||
.orElse(providers.environmentVariable("CUTDEX_NATIVE_SURFACE_PREVIEW")).getOrElse("false")
|
||||
}
|
||||
create("production") {
|
||||
dimension = "environment"
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
android:label="@string/app_name"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/cutdex_launcher">
|
||||
<meta-data android:name="dev.cutdex.previewReverseCacheMiB"
|
||||
android:value="${cutdexPreviewReverseCacheMiB}" />
|
||||
<meta-data android:name="dev.cutdex.nativeSurfacePreview"
|
||||
android:value="${cutdexNativeSurfacePreview}" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
|
||||
@@ -6,6 +6,80 @@ backends. `test_driver/integration_test.dart` is the host driver used by
|
||||
media, models, reports and credentials are supplied locally and stay outside
|
||||
version control. Normal release builds use `lib/main.dart`.
|
||||
|
||||
## Android navigation and playhead measurements
|
||||
|
||||
`android_decoder_material_performance_test.dart` extends the production workspace
|
||||
benchmark to other source rates and variable timestamps. Supply
|
||||
`CUTDEX_TEST_SOURCE_PTS` as an independent, sorted list of original frame PTS
|
||||
(one integer source tick per line), with `CUTDEX_TEST_SOURCE_TIMESCALE` set to
|
||||
that clock's denominator, such as 90000. The default timescale is 1000000 for
|
||||
existing integer-microsecond fixtures; preserve original source ticks for frame
|
||||
boundaries that cannot be represented in microseconds. `CUTDEX_TEST_FRAME_STEP_US`
|
||||
is the nominal frame period rounded to microseconds. Its eight `matchedSeeks` use
|
||||
the standalone benchmark's exact request sequence. Full-source ruler drags and
|
||||
20-frame local drags use the production timeline and are reported separately;
|
||||
their inputs differ from the standalone source replay.
|
||||
|
||||
`CUTDEX_TEST_CALIBRATE=true` explicitly runs native/software calibration before
|
||||
opening the workspace and verifies both sets against the external PTS list.
|
||||
It asserts the admitted backend throughout later navigation and gestures.
|
||||
The application opens no calibration workload automatically.
|
||||
|
||||
If the device's installed application has a different signing certificate,
|
||||
build the development flavor with
|
||||
`CUTDEX_VALIDATION_APPLICATION_ID=com.example.cutdex.decoder_validation`.
|
||||
This creates `com.example.cutdex.decoder_validation.dev`, labeled
|
||||
`Cutdex Decoder Test`, while preserving the installed application and its data.
|
||||
For a cache baseline, set `CUTDEX_PREVIEW_REVERSE_CACHE_MIB=24`;
|
||||
set it to `0` for normal device policy. These properties affect development only.
|
||||
Use matching private file paths and retain the app between runs.
|
||||
|
||||
`android_navigation_performance_test.dart` mounts the production `EditorWorkspace`
|
||||
with real `Projects`, preview and native playback providers. Its project and
|
||||
application database are isolated. Supply a complete original video through
|
||||
`CUTDEX_TEST_SOURCE` and an app-writable JSON path through `CUTDEX_TEST_REPORT`.
|
||||
The test keeps production audible-skimming policy and uses touch input on real
|
||||
timeline tabs and the timeline ruler. It measures cold/cached selection, rapid
|
||||
selection replacement, exact seeks, full-source fit-to-viewport and local
|
||||
20-frame drags, and both immediate release and a one-second stationary hold.
|
||||
The source-frame containment checks currently require an untrimmed CFR
|
||||
2997/100 fps source.
|
||||
Use `--dart-define=CUTDEX_TEST_DECODER=ffmpeg` to assert the actual decoder
|
||||
from initial load through seeks, both drag directions and final release.
|
||||
Reports retain per-layer backend and selection-reason diagnostics.
|
||||
|
||||
```powershell
|
||||
fvm dart tool/flutter_local.dart drive --profile --flavor development -d DEVICE_ID --keep-app-running `
|
||||
--driver=test_driver/integration_test.dart `
|
||||
--target=integration_test/android_navigation_performance_test.dart `
|
||||
--dart-define=CUTDEX_TEST_SOURCE=/data/user/0/com.example.cutdex.dev/files/cutdex-validation/source.mp4 `
|
||||
--dart-define=CUTDEX_TEST_REPORT=/data/user/0/com.example.cutdex.dev/files/cutdex-validation/results.json
|
||||
```
|
||||
|
||||
The pinned SDK uses the published Android 0.1.3 Maven artifacts. Use explicit SDK
|
||||
and Android source overrides only when comparing unpublished changes. Calibration
|
||||
requires a `--debug` build; profile/production hosts do not register its channel.
|
||||
UI timing ends at the
|
||||
target workspace's post-frame callback. Native diagnostics record queued output
|
||||
frames/content timestamps and backend seek/reuse counters; those do not measure
|
||||
physical display refresh. The planned drag input rate is 60 Hz; retain actual
|
||||
input timestamps and report achieved input cadence. The test uses `fullyLive`
|
||||
frame scheduling and does not pump a Flutter frame for every pointer input.
|
||||
Native polling has at most
|
||||
one outstanding request, so decoder latency cannot accumulate diagnostic reads.
|
||||
Source PTS is distinct from the requested timeline sample. A stationary release
|
||||
must preserve source PTS, output-frame count and seek count; the final source
|
||||
frame must cover the target tick. These counters measure queued native output,
|
||||
not physical scanout. A cached timeline's nonzero frame counter alone does not
|
||||
prove that its new Surface has displayed the retained frame.
|
||||
Rebuild/install the normal `lib/main.dart` entry point after testing. Do not clear
|
||||
app data or uninstall merely to obtain a cold sample.
|
||||
Always pass `--keep-app-running`: Flutter drive otherwise uninstalls the Android
|
||||
application during cleanup, which also deletes its application data.
|
||||
On devices that deny access to ADB-created external app directories, copy the
|
||||
fixture into the installed debuggable development app's internal files using
|
||||
`run-as`, and export its report with `adb exec-out run-as PACKAGE cat PATH`.
|
||||
|
||||
## Desktop plugin registration
|
||||
|
||||
`native_desktop_plugins_test.dart` checks the real application's registration of
|
||||
@@ -416,3 +490,41 @@ remove the test's own project and exports afterward.
|
||||
Some devices disconnect the host driver while DocumentsUI is foreground. In
|
||||
that case, inspect the original application's log and private JSON reports; a
|
||||
driver disconnection alone does not establish whether the import succeeded.
|
||||
|
||||
## Android native Surface preview comparison
|
||||
|
||||
The development build can enable the experimental native source with the Gradle
|
||||
property `cutdexNativeSurfacePreview=true` or environment variable
|
||||
`CUTDEX_NATIVE_SURFACE_PREVIEW=true`. Production and default development builds
|
||||
leave it disabled. `android_decoder_material_performance_test.dart` uses the real
|
||||
EditorWorkspace with the whole original clip fitted into the timeline viewport.
|
||||
Set `CUTDEX_TEST_DECODER=media3-surface` to fail if the source falls back; use
|
||||
`ffmpeg` for the paired baseline. `CUTDEX_TEST_PLAYBACK=true` additionally records
|
||||
three seconds of unique frame changes, play/pause acknowledgments and a frozen
|
||||
paused frame. The existing seek/drag assertions independently check every observed
|
||||
frame against original rational packet PTS and require zero extra release seek
|
||||
or presentation for an already precise held picture.
|
||||
|
||||
Use a separate validation application ID to preserve the installed development
|
||||
application and its projects. Supply media and PTS files inside that validation
|
||||
app's sandbox; no personal fixture or benchmark report is committed here.
|
||||
For example, an explicitly admitted 60 fps / 90000 Hz source can be measured with:
|
||||
|
||||
```powershell
|
||||
$env:CUTDEX_VALIDATION_APPLICATION_ID = 'com.example.cutdex.decoder_validation'
|
||||
$env:CUTDEX_NATIVE_SURFACE_PREVIEW = 'true'
|
||||
fvm dart tool/flutter_local.dart drive --profile --flavor development -d DEVICE_ID --keep-app-running `
|
||||
--driver=test_driver/integration_test.dart `
|
||||
--target=integration_test/android_decoder_material_performance_test.dart `
|
||||
--dart-define=CUTDEX_TEST_SOURCE=/data/user/0/com.example.cutdex.decoder_validation.dev/files/source.mp4 `
|
||||
--dart-define=CUTDEX_TEST_SOURCE_PTS=/data/user/0/com.example.cutdex.decoder_validation.dev/files/source-pts.txt `
|
||||
--dart-define=CUTDEX_TEST_SOURCE_TIMESCALE=90000 --dart-define=CUTDEX_TEST_FRAME_STEP_US=16667 `
|
||||
--dart-define=CUTDEX_TEST_DECODER=media3-surface --dart-define=CUTDEX_TEST_PLAYBACK=true `
|
||||
--dart-define=CUTDEX_TEST_REPORT=/data/user/0/com.example.cutdex.decoder_validation.dev/files/native-results.json
|
||||
```
|
||||
|
||||
Repeat with `CUTDEX_NATIVE_SURFACE_PREVIEW=false`, `CUTDEX_TEST_DECODER=ffmpeg`
|
||||
and another report path for the software baseline. Restore the default environment
|
||||
and normal application entry point after testing. Record first-source indexing
|
||||
separately from warm seek timings. Only compare inputs with matching source clocks,
|
||||
targets, drag trajectories, audio/UI workloads and achieved input cadence.
|
||||
@@ -0,0 +1,730 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
import 'package:cutdex/features/editor/editor_page.dart';
|
||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex/persistence/app_database.dart';
|
||||
import 'package:cutdex/workspace/project_state.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/preview.dart';
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:cutdex_sdk/runtime.dart';
|
||||
import 'package:cutdex_sdk/timeline/layout.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import '../test/support/preview_fixture.dart';
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
const source = String.fromEnvironment('CUTDEX_TEST_SOURCE');
|
||||
const output = String.fromEnvironment('CUTDEX_TEST_REPORT');
|
||||
const ptsFile = String.fromEnvironment('CUTDEX_TEST_SOURCE_PTS');
|
||||
const sourceStepUs = int.fromEnvironment('CUTDEX_TEST_FRAME_STEP_US');
|
||||
const sourceTimescale = int.fromEnvironment(
|
||||
'CUTDEX_TEST_SOURCE_TIMESCALE',
|
||||
defaultValue: 1000000,
|
||||
);
|
||||
testWidgets(
|
||||
'Android material decoder production workspace performance',
|
||||
(tester) async {
|
||||
expect(Platform.isAndroid, isTrue);
|
||||
final file = File(source);
|
||||
final before = await file.stat();
|
||||
expect(before.size, greaterThan(0));
|
||||
expect(sourceStepUs, greaterThan(0));
|
||||
expect(sourceTimescale, greaterThan(0));
|
||||
final report = File(output);
|
||||
await report.parent.create(recursive: true);
|
||||
final result = <String, Object?>{
|
||||
'status': 'running',
|
||||
'source': source,
|
||||
'sourceBytes': before.size,
|
||||
'buildMode': const bool.fromEnvironment('dart.vm.product')
|
||||
? 'release'
|
||||
: const bool.fromEnvironment('dart.vm.profile')
|
||||
? 'profile'
|
||||
: 'debug',
|
||||
'scope': 'Production EditorWorkspace, Projects, preview and real touch ruler input; isolated project/database',
|
||||
'measurement': 'Native queued-frame counters and content timestamp, not physical display scanout',
|
||||
'switches': <Map<String, Object?>>[],
|
||||
'seeks': <Map<String, Object?>>[],
|
||||
'drags': <Map<String, Object?>>[],
|
||||
'heldRelease': <Map<String, Object?>>[],
|
||||
};
|
||||
void save() => report.writeAsStringSync(
|
||||
const JsonEncoder.withIndent(' ').convert(result),
|
||||
);
|
||||
save();
|
||||
final runtime = CutdexRuntime();
|
||||
final info = await runtime.probe(
|
||||
MediaReference(id: 'media', uri: file.uri),
|
||||
);
|
||||
result['durationSeconds'] = info.duration.seconds;
|
||||
final sourcePtsTicks = (await File(
|
||||
ptsFile,
|
||||
).readAsLines()).map(int.parse).toList(growable: false);
|
||||
double expectedSourceUs(int numerator, int denominator) {
|
||||
final target = BigInt.from(numerator) * BigInt.from(sourceTimescale);
|
||||
final divisor = BigInt.from(denominator);
|
||||
var low = 0;
|
||||
var high = sourcePtsTicks.length;
|
||||
while (low < high) {
|
||||
final middle = (low + high) ~/ 2;
|
||||
if (BigInt.from(sourcePtsTicks[middle]) * divisor <= target) {
|
||||
low = middle + 1;
|
||||
} else {
|
||||
high = middle;
|
||||
}
|
||||
}
|
||||
expectSync(low, greaterThan(0));
|
||||
return sourcePtsTicks[low - 1] * 1000000 / sourceTimescale;
|
||||
}
|
||||
|
||||
result['independentSourcePtsCount'] = sourcePtsTicks.length;
|
||||
result['sourcePtsTimescale'] = sourceTimescale;
|
||||
if (const bool.fromEnvironment('CUTDEX_TEST_CALIBRATE')) {
|
||||
const diagnostics = MethodChannel('cutdex_decoder_diagnostics');
|
||||
const stepUs = sourceStepUs;
|
||||
final calibrated = (await diagnostics.invokeMapMethod<String, dynamic>(
|
||||
'calibrate',
|
||||
{
|
||||
'source': file.uri.toString(),
|
||||
'targetsMicros': [
|
||||
60000000,
|
||||
2000000000,
|
||||
2000000000 + stepUs,
|
||||
2000000000 + stepUs * 2,
|
||||
2000000000 + stepUs,
|
||||
2000000000 + stepUs * 3,
|
||||
120000567,
|
||||
60000000,
|
||||
],
|
||||
},
|
||||
))!;
|
||||
result['calibration'] = calibrated;
|
||||
save();
|
||||
for (final sample in calibrated['samples'] as List) {
|
||||
final requested = sample['requestedTime'] as Map;
|
||||
final actual = sample['actualTime'] as Map;
|
||||
final pts =
|
||||
int.parse('${actual['numerator']}') /
|
||||
(actual['denominator'] as num);
|
||||
expect(
|
||||
(pts * 1000000 -
|
||||
expectedSourceUs(
|
||||
int.parse('${requested['numerator']}'),
|
||||
requested['denominator'] as int,
|
||||
))
|
||||
.abs(),
|
||||
lessThanOrEqualTo(2),
|
||||
);
|
||||
}
|
||||
}
|
||||
final fixture = await createPreviewFixture(
|
||||
file.uri,
|
||||
hasAudio: info.audioTrackCount > 0,
|
||||
clipDuration: RationalTime(
|
||||
info.duration.numerator,
|
||||
info.duration.denominator,
|
||||
),
|
||||
renderSize: {'width': 1280, 'height': 720},
|
||||
);
|
||||
final document = await fixture.workspace.project!.loadTimeline('project');
|
||||
for (final id in ['cold', 'third']) {
|
||||
await fixture.workspace.project!.saveTimeline(
|
||||
TimelineDocument(
|
||||
id: id,
|
||||
name: id,
|
||||
sequences: document.sequences,
|
||||
defaultSequenceId: document.defaultSequenceId,
|
||||
payloads: document.payloads,
|
||||
settings: document.settings,
|
||||
),
|
||||
);
|
||||
}
|
||||
await fixture.workspace.close();
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
final container = ProviderContainer(
|
||||
overrides: [appDatabaseProvider.overrideWithValue(database)],
|
||||
);
|
||||
final projects = container.read(projectsProvider.notifier);
|
||||
Future<void> until(
|
||||
bool Function() ready,
|
||||
String label, {
|
||||
int seconds = 60,
|
||||
}) async {
|
||||
final clock = Stopwatch()..start();
|
||||
while (!ready()) {
|
||||
if (clock.elapsed.inSeconds >= seconds) throw TimeoutException(label);
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
}
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
Future<void> advance(int milliseconds) async {
|
||||
final clock = Stopwatch()..start();
|
||||
while (clock.elapsedMilliseconds < milliseconds) {
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
}
|
||||
}
|
||||
|
||||
PreviewController? activePreview() {
|
||||
final state = container.read(projectsProvider).value;
|
||||
if (state?.timeline == null || state!.openingTimelineId != null) {
|
||||
return null;
|
||||
}
|
||||
return container
|
||||
.read(
|
||||
editorPreviewProvider(
|
||||
state.activeProject!.id,
|
||||
state.timeline!.id,
|
||||
),
|
||||
)
|
||||
.value;
|
||||
}
|
||||
|
||||
const nativeChannel = MethodChannel('cutdex_runtime');
|
||||
const configuredDecoder = String.fromEnvironment('CUTDEX_TEST_DECODER');
|
||||
final calibration = result['calibration'] as Map?;
|
||||
final expectedDecoder = configuredDecoder.isNotEmpty
|
||||
? configuredDecoder
|
||||
: calibration == null
|
||||
? ''
|
||||
: calibration['backend'] == 'NATIVE'
|
||||
? 'mediaCodec'
|
||||
: 'ffmpeg';
|
||||
Future<Map<String, dynamic>> diagnostic(PreviewController preview) async {
|
||||
final value = (await nativeChannel.invokeMapMethod<String, dynamic>(
|
||||
'previewDiagnostics',
|
||||
{'contractVersion': 1, 'sessionId': preview.session!.id},
|
||||
))!;
|
||||
if (expectedDecoder.isNotEmpty) {
|
||||
final backends = value['decoderBackends'] as Map?;
|
||||
// Diagnostics also run from a timer while WidgetTester.pump is active.
|
||||
expectSync(value['executionBackend'], 'direct');
|
||||
expectSync(backends, isNotEmpty);
|
||||
expectSync(backends!.values, everyElement(expectedDecoder));
|
||||
expectSync(value['decoderSelectionReasons'], isNotEmpty);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int frames(Map<String, dynamic> value) =>
|
||||
int.tryParse('${value['presentedVideoFrameCount']}') ?? 0;
|
||||
double sourcePts(Map<String, dynamic> value) {
|
||||
final time = value['presentedSourceFrameTime'] as Map?;
|
||||
expect(time, isNotNull, reason: 'Actual source PTS must be available');
|
||||
return int.parse('${time!['numerator']}') /
|
||||
(time['denominator'] as num);
|
||||
}
|
||||
|
||||
void expectExactSource(Map<String, dynamic> value, int tick) {
|
||||
final pts = sourcePts(value);
|
||||
expect(
|
||||
(pts * 1000000 - expectedSourceUs(tick, TimelineClock.ticksPerSecond))
|
||||
.abs(),
|
||||
lessThanOrEqualTo(2),
|
||||
reason: 'Independent packet PTS must identify the exact source frame',
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
expect(
|
||||
await projects.open(
|
||||
'${fixture.directory.path}/Preview.cutdex',
|
||||
timelineId: 'project',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
theme: EditorTheme.penDark,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
home: const Scaffold(body: _Workspace()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await until(
|
||||
() =>
|
||||
activePreview()?.ready == true &&
|
||||
activePreview()?.session != null,
|
||||
'initial preview ready',
|
||||
);
|
||||
await until(
|
||||
() =>
|
||||
(activePreview()!.session!.snapshot?.presentedVideoFrameCount ??
|
||||
0) >
|
||||
0,
|
||||
'initial native frame',
|
||||
);
|
||||
expect(activePreview()!.error, isNull);
|
||||
result['initialNative'] = await diagnostic(activePreview()!);
|
||||
save();
|
||||
final projectId = container
|
||||
.read(projectsProvider)
|
||||
.requireValue
|
||||
.activeProject!
|
||||
.id;
|
||||
final switches = result['switches']! as List<Map<String, Object?>>;
|
||||
Future<void> switchTo(String id, String name) async {
|
||||
final workspaceElement = find
|
||||
.byType(EditorWorkspace)
|
||||
.evaluate()
|
||||
.single;
|
||||
final clock = Stopwatch()..start();
|
||||
double? dataMs, uiMs;
|
||||
final startupTrace = <Map<String, Object?>>[];
|
||||
final traceTimer = Timer.periodic(const Duration(milliseconds: 100), (
|
||||
_,
|
||||
) {
|
||||
final controller = activePreview();
|
||||
final views = find.byType(RuntimePreview).evaluate();
|
||||
final row = <String, Object?>{
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
'pending': container
|
||||
.read(projectsProvider)
|
||||
.value
|
||||
?.openingTimelineId,
|
||||
'controller': controller != null,
|
||||
'ready': controller?.ready,
|
||||
'durationTick': controller?.durationTick,
|
||||
'session': controller?.session?.id,
|
||||
'views': views
|
||||
.map((e) => (e.widget as RuntimePreview).session.id)
|
||||
.toList(),
|
||||
};
|
||||
startupTrace.add(row);
|
||||
});
|
||||
final subscription = container.listen(projectsProvider, (_, next) {
|
||||
if (next.value?.timeline?.id == id &&
|
||||
next.value?.openingTimelineId == null) {
|
||||
dataMs ??= clock.elapsedMicroseconds / 1000;
|
||||
}
|
||||
});
|
||||
void observeFrame(Duration _) {
|
||||
final workspace = workspaceElement.widget as EditorWorkspace;
|
||||
if (workspace.timelineId == id) {
|
||||
uiMs ??= clock.elapsedMicroseconds / 1000;
|
||||
}
|
||||
if (uiMs == null && clock.elapsedMilliseconds < 60000) {
|
||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
||||
WidgetsBinding.instance.scheduleFrame();
|
||||
}
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
||||
try {
|
||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
||||
await until(() => uiMs != null, 'selected UI $id');
|
||||
await until(
|
||||
() =>
|
||||
dataMs != null &&
|
||||
activePreview()?.ready == true &&
|
||||
activePreview()?.session != null,
|
||||
'metadata/preview $id',
|
||||
);
|
||||
result['switchBeforeFirstFrame'] = {
|
||||
'timelineId': id,
|
||||
'native': await diagnostic(activePreview()!),
|
||||
};
|
||||
save();
|
||||
await until(
|
||||
() =>
|
||||
(activePreview()!
|
||||
.session!
|
||||
.snapshot
|
||||
?.presentedVideoFrameCount ??
|
||||
0) >
|
||||
0,
|
||||
'native frame $id',
|
||||
);
|
||||
switches.add({
|
||||
'scenario': name,
|
||||
'uiPostFrameMs': uiMs,
|
||||
'dataMs': dataMs,
|
||||
'nativeFrameObservedMs': clock.elapsedMicroseconds / 1000,
|
||||
'startupTrace': startupTrace,
|
||||
});
|
||||
expect(activePreview()!.error, isNull);
|
||||
save();
|
||||
} finally {
|
||||
traceTimer.cancel();
|
||||
subscription.close();
|
||||
}
|
||||
}
|
||||
|
||||
await switchTo('cold', 'cold');
|
||||
for (var i = 0; i < 3; i++) {
|
||||
await switchTo('project', 'warm-return-$i');
|
||||
await switchTo('cold', 'warm-target-$i');
|
||||
}
|
||||
final rapid = <String>[];
|
||||
final rapidSub = container.listen(projectsProvider, (_, next) {
|
||||
if (next.value?.visibleTimelineId case final id?) rapid.add(id);
|
||||
});
|
||||
for (final id in ['third', 'project', 'cold', 'project', 'cold']) {
|
||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.visibleTimelineId,
|
||||
id,
|
||||
);
|
||||
}
|
||||
await advance(1000);
|
||||
rapidSub.close();
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.timeline!.id,
|
||||
'cold',
|
||||
);
|
||||
result['rapidSelection'] = rapid;
|
||||
await until(
|
||||
() => activePreview()?.ready == true,
|
||||
'preview after rapid selection',
|
||||
);
|
||||
final preview = activePreview()!;
|
||||
final session = await container.read(
|
||||
editorTimelineProvider(projectId, 'cold').future,
|
||||
);
|
||||
final sequence = session.activeSequenceId!;
|
||||
final view = session.view(sequence);
|
||||
Future<void> seek(int frame) => preview.controlPreview(
|
||||
sequence,
|
||||
PreviewAction.seek,
|
||||
at: CommandTime(frame, 30),
|
||||
);
|
||||
final matchedSeeks = <Map<String, Object?>>[];
|
||||
result['matchedSeeks'] = matchedSeeks;
|
||||
for (final targetUs in [
|
||||
60000000,
|
||||
2000000000,
|
||||
2000000000 + sourceStepUs,
|
||||
2000000000 + sourceStepUs * 2,
|
||||
2000000000 + sourceStepUs,
|
||||
2000000000 + sourceStepUs * 3,
|
||||
120000567,
|
||||
60000000,
|
||||
]) {
|
||||
final timer = Stopwatch()..start();
|
||||
await preview.session!.seek(MediaTime(targetUs, 1000000));
|
||||
timer.stop();
|
||||
final value = await diagnostic(preview);
|
||||
matchedSeeks.add({
|
||||
'targetUs': targetUs,
|
||||
'latencyMs': timer.elapsedMicroseconds / 1000,
|
||||
'sourcePtsUs': sourcePts(value) * 1000000,
|
||||
'diagnostics': value,
|
||||
});
|
||||
save();
|
||||
expect(
|
||||
(sourcePts(value) * 1000000 - expectedSourceUs(targetUs, 1000000))
|
||||
.abs(),
|
||||
lessThanOrEqualTo(2),
|
||||
);
|
||||
}
|
||||
final seeks = result['seeks']! as List<Map<String, Object?>>;
|
||||
for (final frame in [1800, 60000, 60001, 60002, 60001]) {
|
||||
final before = await diagnostic(preview);
|
||||
final clock = Stopwatch()..start();
|
||||
await seek(frame);
|
||||
final after = await diagnostic(preview);
|
||||
seeks.add({
|
||||
'frame': frame,
|
||||
'acknowledgmentMs': clock.elapsedMicroseconds / 1000,
|
||||
'frames': frames(after) - frames(before),
|
||||
'native': after,
|
||||
});
|
||||
expect(preview.error, isNull);
|
||||
save();
|
||||
}
|
||||
final drags = result['drags']! as List<Map<String, Object?>>;
|
||||
for (var round = 0; round < 2; round++) {
|
||||
for (final local in [false, true]) {
|
||||
view.fitTimeline();
|
||||
await advance(200);
|
||||
final rulerFinder = find.byType(TimelineRuler);
|
||||
final ruler = tester.renderObject<RenderBox>(rulerFinder);
|
||||
final viewport = TimelineViewportRect(
|
||||
width: ruler.size.width,
|
||||
height: ruler.size.height,
|
||||
);
|
||||
final durationFrames = (info.duration.seconds * 30).floor();
|
||||
if (local) {
|
||||
view.setCamera(
|
||||
TimelineCamera(
|
||||
baseTick: TimelineClock.standard.toTicks(
|
||||
RationalTime(59980, 30),
|
||||
),
|
||||
pixelsPerTick:
|
||||
4 / TimelineClock.standard.toTicks(RationalTime(1, 30)),
|
||||
verticalOffset: view.camera.verticalOffset,
|
||||
),
|
||||
);
|
||||
await advance(100);
|
||||
}
|
||||
Offset position(int frame) => ruler.localToGlobal(
|
||||
Offset(
|
||||
view.camera.screenXForTick(
|
||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
||||
viewport,
|
||||
),
|
||||
ruler.size.height / 2,
|
||||
),
|
||||
);
|
||||
final startFrame = local ? 60000 : (durationFrames * .05).round();
|
||||
await seek(startFrame);
|
||||
await advance(150);
|
||||
var initial = await diagnostic(preview);
|
||||
final observations = <Map<String, Object?>>[];
|
||||
final inputs = <Map<String, Object?>>[];
|
||||
final clock = Stopwatch()..start();
|
||||
Future<void>? pending;
|
||||
Object? sampleError;
|
||||
void sample() {
|
||||
if (pending != null) return;
|
||||
pending = diagnostic(preview)
|
||||
.then((d) {
|
||||
observations.add({
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
...d,
|
||||
});
|
||||
})
|
||||
.catchError((Object e) {
|
||||
sampleError = e;
|
||||
})
|
||||
.whenComplete(() => pending = null);
|
||||
}
|
||||
|
||||
final gesture = await tester.startGesture(
|
||||
position(startFrame),
|
||||
kind: PointerDeviceKind.touch,
|
||||
);
|
||||
// Acquire the real ruler's drag recognizer before measuring movement.
|
||||
await gesture.moveBy(const Offset(30, 0));
|
||||
await tester.pump();
|
||||
expect(view.isScrubbing, isTrue);
|
||||
await gesture.moveTo(position(startFrame));
|
||||
await advance(350);
|
||||
initial = await diagnostic(preview);
|
||||
clock.reset();
|
||||
final timer = Timer.periodic(
|
||||
const Duration(milliseconds: 20),
|
||||
(_) => sample(),
|
||||
);
|
||||
for (var i = 0; i < 120; i++) {
|
||||
final dueUs = (i * 1000000 / 60).round();
|
||||
final remaining = dueUs - clock.elapsedMicroseconds;
|
||||
if (remaining > 0) {
|
||||
await Future<void>.delayed(Duration(microseconds: remaining));
|
||||
}
|
||||
final phase = i < 60 ? i : 119 - i;
|
||||
final target = local
|
||||
? 60000 + (i % 40 < 20 ? i % 40 : 39 - i % 40)
|
||||
: (durationFrames * (.05 + .9 * phase / 59)).round();
|
||||
await gesture.moveTo(position(target));
|
||||
inputs.add({
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
'dueMs': dueUs / 1000,
|
||||
'idealFrame': target,
|
||||
'actualTick': view.playheadTick,
|
||||
});
|
||||
}
|
||||
final releaseAt = clock.elapsedMicroseconds / 1000;
|
||||
final finalTick = view.playheadTick;
|
||||
await gesture.up();
|
||||
await tester.pump();
|
||||
await preview.waitForPendingPreview().timeout(
|
||||
const Duration(seconds: 60),
|
||||
);
|
||||
final settled = await diagnostic(preview);
|
||||
final settledMs = clock.elapsedMicroseconds / 1000;
|
||||
await advance(500);
|
||||
final frozen = await diagnostic(preview);
|
||||
timer.cancel();
|
||||
await pending;
|
||||
expect(sampleError, isNull);
|
||||
expect(preview.error, isNull);
|
||||
final snapshot = await preview.session!.refresh();
|
||||
final clockTick =
|
||||
(BigInt.from(snapshot.position.numerator) *
|
||||
BigInt.from(TimelineClock.ticksPerSecond) ~/
|
||||
BigInt.from(snapshot.position.denominator))
|
||||
.toInt();
|
||||
expectExactSource(settled, finalTick);
|
||||
expect(
|
||||
(clockTick - finalTick).abs(),
|
||||
lessThanOrEqualTo(TimelineClock.ticksPerSecond ~/ 1000000),
|
||||
);
|
||||
drags.add({
|
||||
'round': round,
|
||||
'scenario': local ? 'local-20-frame' : 'fit-entire-source',
|
||||
'viewportWidth': ruler.size.width,
|
||||
'inputs': inputs,
|
||||
'observations': observations,
|
||||
'before': initial,
|
||||
'settled': settled,
|
||||
'frozen': frozen,
|
||||
'releaseAtMs': releaseAt,
|
||||
'settledAtMs': settledMs,
|
||||
'releaseWaitMs': settledMs - releaseAt,
|
||||
'finalTick': finalTick,
|
||||
'clockTick': clockTick,
|
||||
'postSettleFrames': frames(frozen) - frames(settled),
|
||||
});
|
||||
save();
|
||||
}
|
||||
}
|
||||
final ruler = tester.renderObject<RenderBox>(
|
||||
find.byType(TimelineRuler),
|
||||
);
|
||||
final viewport = TimelineViewportRect(
|
||||
width: ruler.size.width,
|
||||
height: ruler.size.height,
|
||||
);
|
||||
Offset heldPosition(int frame) => ruler.localToGlobal(
|
||||
Offset(
|
||||
view.camera.screenXForTick(
|
||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
||||
viewport,
|
||||
),
|
||||
ruler.size.height / 2,
|
||||
),
|
||||
);
|
||||
await seek(60000);
|
||||
final hold = await tester.startGesture(
|
||||
heldPosition(60000),
|
||||
kind: PointerDeviceKind.touch,
|
||||
);
|
||||
await hold.moveBy(const Offset(30, 0));
|
||||
await tester.pump();
|
||||
await hold.moveTo(heldPosition(60010));
|
||||
await advance(1000);
|
||||
final heldTick = view.playheadTick;
|
||||
final heldBefore = await diagnostic(preview);
|
||||
final releaseClock = Stopwatch()..start();
|
||||
await hold.up();
|
||||
await tester.pump();
|
||||
await preview.waitForPendingPreview().timeout(
|
||||
const Duration(seconds: 60),
|
||||
);
|
||||
final heldAfter = await diagnostic(preview);
|
||||
final heldReleaseMs = releaseClock.elapsedMicroseconds / 1000;
|
||||
await advance(500);
|
||||
final heldFrozen = await diagnostic(preview);
|
||||
(result['heldRelease']! as List<Map<String, Object?>>).add({
|
||||
'holdMilliseconds': 1000,
|
||||
'targetTick': heldTick,
|
||||
'before': heldBefore,
|
||||
'after': heldAfter,
|
||||
'frozen': heldFrozen,
|
||||
'releaseWaitMs': heldReleaseMs,
|
||||
});
|
||||
save();
|
||||
expectExactSource(heldBefore, heldTick);
|
||||
expectExactSource(heldAfter, heldTick);
|
||||
expect(sourcePts(heldAfter), sourcePts(heldBefore));
|
||||
expect(frames(heldAfter), frames(heldBefore));
|
||||
expect(heldAfter['seekRequestCount'], heldBefore['seekRequestCount']);
|
||||
expect(frames(heldFrozen), frames(heldAfter));
|
||||
if (const bool.fromEnvironment('CUTDEX_TEST_PLAYBACK')) {
|
||||
await preview.session!.seek(MediaTime(60000000, 1000000));
|
||||
final beforePlay = await diagnostic(preview);
|
||||
final clock = Stopwatch()..start();
|
||||
await preview.session!.play();
|
||||
final playAckMs = clock.elapsedMicroseconds / 1000;
|
||||
await advance(3000);
|
||||
final pauseClock = Stopwatch()..start();
|
||||
await preview.session!.pause();
|
||||
final pauseAckMs = pauseClock.elapsedMicroseconds / 1000;
|
||||
final paused = await diagnostic(preview);
|
||||
clock.stop();
|
||||
await advance(250);
|
||||
final frozen = await diagnostic(preview);
|
||||
int unique(Map<String, dynamic> value) =>
|
||||
int.parse('${value['uniquePresentedVideoFrameCount']}');
|
||||
result['playback'] = {
|
||||
'before': beforePlay,
|
||||
'paused': paused,
|
||||
'frozen': frozen,
|
||||
'playAcknowledgmentMs': playAckMs,
|
||||
'pauseAcknowledgmentMs': pauseAckMs,
|
||||
'elapsedMs': clock.elapsedMicroseconds / 1000,
|
||||
'uniqueFrameChanges': unique(paused) - unique(beforePlay),
|
||||
'uniqueFramesPerSecond':
|
||||
(unique(paused) - unique(beforePlay)) *
|
||||
1000000 /
|
||||
clock.elapsedMicroseconds,
|
||||
};
|
||||
save();
|
||||
expect(unique(paused) - unique(beforePlay), greaterThan(30));
|
||||
expect(frames(frozen), frames(paused));
|
||||
expect(sourcePts(frozen), sourcePts(paused));
|
||||
expect(paused['playbackError'], isNull);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
final after = await file.stat();
|
||||
expect(after.size, before.size);
|
||||
expect(after.modified, before.modified);
|
||||
result['status'] = 'passed';
|
||||
result['sourceUnchanged'] = true;
|
||||
save();
|
||||
} catch (error, stack) {
|
||||
result['status'] = 'failed';
|
||||
result['error'] = '$error';
|
||||
result['stack'] = '$stack';
|
||||
save();
|
||||
rethrow;
|
||||
} finally {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
container.dispose();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 300));
|
||||
await database.close();
|
||||
await SystemChrome.setPreferredOrientations([]);
|
||||
}
|
||||
},
|
||||
skip: source.isEmpty || output.isEmpty,
|
||||
timeout: const Timeout(Duration(minutes: 15)),
|
||||
);
|
||||
}
|
||||
|
||||
class _Workspace extends ConsumerWidget {
|
||||
const _Workspace();
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final state = ref.watch(projectsProvider).requireValue;
|
||||
return EditorWorkspace(
|
||||
projectId: state.activeProject!.id,
|
||||
projectName: state.activeProject!.name,
|
||||
timelineId: state.visibleTimelineId!,
|
||||
projectLoading: state.projectBusy,
|
||||
timelineLoading: state.openingTimelineId != null,
|
||||
integratedTitlebar: false,
|
||||
headerLeading: const SizedBox.shrink(),
|
||||
experience: DeviceExperience.tablet,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,589 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
import 'package:cutdex/features/editor/editor_page.dart';
|
||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex/persistence/app_database.dart';
|
||||
import 'package:cutdex/workspace/project_state.dart';
|
||||
import 'package:cutdex/workspace/projects.dart';
|
||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/preview.dart';
|
||||
import 'package:cutdex_sdk/project.dart';
|
||||
import 'package:cutdex_sdk/runtime.dart';
|
||||
import 'package:cutdex_sdk/timeline/layout.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import '../test/support/preview_fixture.dart';
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
const source = String.fromEnvironment('CUTDEX_TEST_SOURCE');
|
||||
const output = String.fromEnvironment('CUTDEX_TEST_REPORT');
|
||||
testWidgets(
|
||||
'Android production workspace navigation and exact-stop timing',
|
||||
(tester) async {
|
||||
expect(Platform.isAndroid, isTrue);
|
||||
final file = File(source);
|
||||
final before = await file.stat();
|
||||
expect(before.size, greaterThan(0));
|
||||
final report = File(output);
|
||||
await report.parent.create(recursive: true);
|
||||
final result = <String, Object?>{
|
||||
'status': 'running',
|
||||
'source': source,
|
||||
'sourceBytes': before.size,
|
||||
'buildMode': const bool.fromEnvironment('dart.vm.product')
|
||||
? 'release'
|
||||
: const bool.fromEnvironment('dart.vm.profile')
|
||||
? 'profile'
|
||||
: 'debug',
|
||||
'scope': 'Production EditorWorkspace, Projects, preview and real touch ruler input; isolated project/database',
|
||||
'measurement': 'Native queued-frame counters and content timestamp, not physical display scanout',
|
||||
'switches': <Map<String, Object?>>[],
|
||||
'seeks': <Map<String, Object?>>[],
|
||||
'drags': <Map<String, Object?>>[],
|
||||
'heldRelease': <Map<String, Object?>>[],
|
||||
};
|
||||
void save() => report.writeAsStringSync(
|
||||
const JsonEncoder.withIndent(' ').convert(result),
|
||||
);
|
||||
save();
|
||||
final runtime = CutdexRuntime();
|
||||
final info = await runtime.probe(
|
||||
MediaReference(id: 'media', uri: file.uri),
|
||||
);
|
||||
result['durationSeconds'] = info.duration.seconds;
|
||||
final fixture = await createPreviewFixture(
|
||||
file.uri,
|
||||
hasAudio: info.audioTrackCount > 0,
|
||||
clipDuration: RationalTime(
|
||||
info.duration.numerator,
|
||||
info.duration.denominator,
|
||||
),
|
||||
renderSize: {'width': 1280, 'height': 720},
|
||||
);
|
||||
final document = await fixture.workspace.project!.loadTimeline('project');
|
||||
for (final id in ['cold', 'third']) {
|
||||
await fixture.workspace.project!.saveTimeline(
|
||||
TimelineDocument(
|
||||
id: id,
|
||||
name: id,
|
||||
sequences: document.sequences,
|
||||
defaultSequenceId: document.defaultSequenceId,
|
||||
payloads: document.payloads,
|
||||
settings: document.settings,
|
||||
),
|
||||
);
|
||||
}
|
||||
await fixture.workspace.close();
|
||||
final database = AppDatabase(NativeDatabase.memory());
|
||||
final container = ProviderContainer(
|
||||
overrides: [appDatabaseProvider.overrideWithValue(database)],
|
||||
);
|
||||
final projects = container.read(projectsProvider.notifier);
|
||||
Future<void> until(
|
||||
bool Function() ready,
|
||||
String label, {
|
||||
int seconds = 60,
|
||||
}) async {
|
||||
final clock = Stopwatch()..start();
|
||||
while (!ready()) {
|
||||
if (clock.elapsed.inSeconds >= seconds) throw TimeoutException(label);
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
}
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
Future<void> advance(int milliseconds) async {
|
||||
final clock = Stopwatch()..start();
|
||||
while (clock.elapsedMilliseconds < milliseconds) {
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
}
|
||||
}
|
||||
|
||||
PreviewController? activePreview() {
|
||||
final state = container.read(projectsProvider).value;
|
||||
if (state?.timeline == null || state!.openingTimelineId != null) {
|
||||
return null;
|
||||
}
|
||||
return container
|
||||
.read(
|
||||
editorPreviewProvider(
|
||||
state.activeProject!.id,
|
||||
state.timeline!.id,
|
||||
),
|
||||
)
|
||||
.value;
|
||||
}
|
||||
|
||||
const nativeChannel = MethodChannel('cutdex_runtime');
|
||||
const expectedDecoder = String.fromEnvironment('CUTDEX_TEST_DECODER');
|
||||
Future<Map<String, dynamic>> diagnostic(PreviewController preview) async {
|
||||
final value = (await nativeChannel.invokeMapMethod<String, dynamic>(
|
||||
'previewDiagnostics',
|
||||
{'contractVersion': 1, 'sessionId': preview.session!.id},
|
||||
))!;
|
||||
if (expectedDecoder.isNotEmpty) {
|
||||
final backends = value['decoderBackends'] as Map?;
|
||||
// Diagnostics also run from a timer while WidgetTester.pump is active.
|
||||
expectSync(value['executionBackend'], 'direct');
|
||||
expectSync(backends, isNotEmpty);
|
||||
expectSync(backends!.values, everyElement(expectedDecoder));
|
||||
expectSync(value['decoderSelectionReasons'], isNotEmpty);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
int frames(Map<String, dynamic> value) =>
|
||||
int.tryParse('${value['presentedVideoFrameCount']}') ?? 0;
|
||||
double sourcePts(Map<String, dynamic> value) {
|
||||
final time = value['presentedSourceFrameTime'] as Map?;
|
||||
expect(time, isNotNull, reason: 'Actual source PTS must be available');
|
||||
return int.parse('${time!['numerator']}') /
|
||||
(time['denominator'] as num);
|
||||
}
|
||||
|
||||
void expectExactSource(Map<String, dynamic> value, int tick) {
|
||||
final target = tick / TimelineClock.ticksPerSecond;
|
||||
final pts = sourcePts(value);
|
||||
// This original is untrimmed CFR 2997/100, so the preceding source
|
||||
// frame owns this sample. Allow only microsecond timestamp precision.
|
||||
expect(pts, lessThanOrEqualTo(target + 0.000002));
|
||||
expect(target - pts, lessThan(100 / 2997 + 0.000002));
|
||||
}
|
||||
|
||||
try {
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
expect(
|
||||
await projects.open(
|
||||
'${fixture.directory.path}/Preview.cutdex',
|
||||
timelineId: 'project',
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: MaterialApp(
|
||||
theme: EditorTheme.penDark,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
home: const Scaffold(body: _Workspace()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await until(
|
||||
() =>
|
||||
activePreview()?.ready == true &&
|
||||
activePreview()?.session != null,
|
||||
'initial preview ready',
|
||||
);
|
||||
await until(
|
||||
() =>
|
||||
(activePreview()!.session!.snapshot?.presentedVideoFrameCount ??
|
||||
0) >
|
||||
0,
|
||||
'initial native frame',
|
||||
);
|
||||
expect(activePreview()!.error, isNull);
|
||||
result['initialNative'] = await diagnostic(activePreview()!);
|
||||
save();
|
||||
final projectId = container
|
||||
.read(projectsProvider)
|
||||
.requireValue
|
||||
.activeProject!
|
||||
.id;
|
||||
final switches = result['switches']! as List<Map<String, Object?>>;
|
||||
Future<void> switchTo(String id, String name) async {
|
||||
final workspaceElement = find
|
||||
.byType(EditorWorkspace)
|
||||
.evaluate()
|
||||
.single;
|
||||
final clock = Stopwatch()..start();
|
||||
double? dataMs, uiMs;
|
||||
final startupTrace = <Map<String, Object?>>[];
|
||||
final traceTimer = Timer.periodic(const Duration(milliseconds: 100), (
|
||||
_,
|
||||
) {
|
||||
final controller = activePreview();
|
||||
final views = find.byType(RuntimePreview).evaluate();
|
||||
final row = <String, Object?>{
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
'pending': container
|
||||
.read(projectsProvider)
|
||||
.value
|
||||
?.openingTimelineId,
|
||||
'controller': controller != null,
|
||||
'ready': controller?.ready,
|
||||
'durationTick': controller?.durationTick,
|
||||
'session': controller?.session?.id,
|
||||
'views': views
|
||||
.map((e) => (e.widget as RuntimePreview).session.id)
|
||||
.toList(),
|
||||
};
|
||||
startupTrace.add(row);
|
||||
});
|
||||
final subscription = container.listen(projectsProvider, (_, next) {
|
||||
if (next.value?.timeline?.id == id &&
|
||||
next.value?.openingTimelineId == null) {
|
||||
dataMs ??= clock.elapsedMicroseconds / 1000;
|
||||
}
|
||||
});
|
||||
void observeFrame(Duration _) {
|
||||
final workspace = workspaceElement.widget as EditorWorkspace;
|
||||
if (workspace.timelineId == id) {
|
||||
uiMs ??= clock.elapsedMicroseconds / 1000;
|
||||
}
|
||||
if (uiMs == null && clock.elapsedMilliseconds < 60000) {
|
||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
||||
WidgetsBinding.instance.scheduleFrame();
|
||||
}
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
||||
try {
|
||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
||||
await until(() => uiMs != null, 'selected UI $id');
|
||||
await until(
|
||||
() =>
|
||||
dataMs != null &&
|
||||
activePreview()?.ready == true &&
|
||||
activePreview()?.session != null,
|
||||
'metadata/preview $id',
|
||||
);
|
||||
result['switchBeforeFirstFrame'] = {
|
||||
'timelineId': id,
|
||||
'native': await diagnostic(activePreview()!),
|
||||
};
|
||||
save();
|
||||
await until(
|
||||
() =>
|
||||
(activePreview()!
|
||||
.session!
|
||||
.snapshot
|
||||
?.presentedVideoFrameCount ??
|
||||
0) >
|
||||
0,
|
||||
'native frame $id',
|
||||
);
|
||||
switches.add({
|
||||
'scenario': name,
|
||||
'uiPostFrameMs': uiMs,
|
||||
'dataMs': dataMs,
|
||||
'nativeFrameObservedMs': clock.elapsedMicroseconds / 1000,
|
||||
'startupTrace': startupTrace,
|
||||
});
|
||||
expect(activePreview()!.error, isNull);
|
||||
save();
|
||||
} finally {
|
||||
traceTimer.cancel();
|
||||
subscription.close();
|
||||
}
|
||||
}
|
||||
|
||||
await switchTo('cold', 'cold');
|
||||
for (var i = 0; i < 3; i++) {
|
||||
await switchTo('project', 'warm-return-$i');
|
||||
await switchTo('cold', 'warm-target-$i');
|
||||
}
|
||||
final rapid = <String>[];
|
||||
final rapidSub = container.listen(projectsProvider, (_, next) {
|
||||
if (next.value?.visibleTimelineId case final id?) rapid.add(id);
|
||||
});
|
||||
for (final id in ['third', 'project', 'cold', 'project', 'cold']) {
|
||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.visibleTimelineId,
|
||||
id,
|
||||
);
|
||||
}
|
||||
await advance(1000);
|
||||
rapidSub.close();
|
||||
expect(
|
||||
container.read(projectsProvider).requireValue.timeline!.id,
|
||||
'cold',
|
||||
);
|
||||
result['rapidSelection'] = rapid;
|
||||
await until(
|
||||
() => activePreview()?.ready == true,
|
||||
'preview after rapid selection',
|
||||
);
|
||||
final preview = activePreview()!;
|
||||
final session = await container.read(
|
||||
editorTimelineProvider(projectId, 'cold').future,
|
||||
);
|
||||
final sequence = session.activeSequenceId!;
|
||||
final view = session.view(sequence);
|
||||
Future<void> seek(int frame) => preview.controlPreview(
|
||||
sequence,
|
||||
PreviewAction.seek,
|
||||
at: CommandTime(frame, 30),
|
||||
);
|
||||
final seeks = result['seeks']! as List<Map<String, Object?>>;
|
||||
for (final frame in [1800, 60000, 60001, 60002, 60001]) {
|
||||
final before = await diagnostic(preview);
|
||||
final clock = Stopwatch()..start();
|
||||
await seek(frame);
|
||||
final after = await diagnostic(preview);
|
||||
seeks.add({
|
||||
'frame': frame,
|
||||
'acknowledgmentMs': clock.elapsedMicroseconds / 1000,
|
||||
'frames': frames(after) - frames(before),
|
||||
'native': after,
|
||||
});
|
||||
expect(preview.error, isNull);
|
||||
save();
|
||||
}
|
||||
final drags = result['drags']! as List<Map<String, Object?>>;
|
||||
for (var round = 0; round < 2; round++) {
|
||||
for (final local in [false, true]) {
|
||||
view.fitTimeline();
|
||||
await advance(200);
|
||||
final rulerFinder = find.byType(TimelineRuler);
|
||||
final ruler = tester.renderObject<RenderBox>(rulerFinder);
|
||||
final viewport = TimelineViewportRect(
|
||||
width: ruler.size.width,
|
||||
height: ruler.size.height,
|
||||
);
|
||||
final durationFrames = (info.duration.seconds * 30).floor();
|
||||
if (local) {
|
||||
view.setCamera(
|
||||
TimelineCamera(
|
||||
baseTick: TimelineClock.standard.toTicks(
|
||||
RationalTime(59980, 30),
|
||||
),
|
||||
pixelsPerTick:
|
||||
4 / TimelineClock.standard.toTicks(RationalTime(1, 30)),
|
||||
verticalOffset: view.camera.verticalOffset,
|
||||
),
|
||||
);
|
||||
await advance(100);
|
||||
}
|
||||
Offset position(int frame) => ruler.localToGlobal(
|
||||
Offset(
|
||||
view.camera.screenXForTick(
|
||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
||||
viewport,
|
||||
),
|
||||
ruler.size.height / 2,
|
||||
),
|
||||
);
|
||||
final startFrame = local ? 60000 : (durationFrames * .05).round();
|
||||
await seek(startFrame);
|
||||
await advance(150);
|
||||
var initial = await diagnostic(preview);
|
||||
final observations = <Map<String, Object?>>[];
|
||||
final inputs = <Map<String, Object?>>[];
|
||||
final clock = Stopwatch()..start();
|
||||
Future<void>? pending;
|
||||
Object? sampleError;
|
||||
void sample() {
|
||||
if (pending != null) return;
|
||||
pending = diagnostic(preview)
|
||||
.then((d) {
|
||||
observations.add({
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
...d,
|
||||
});
|
||||
})
|
||||
.catchError((Object e) {
|
||||
sampleError = e;
|
||||
})
|
||||
.whenComplete(() => pending = null);
|
||||
}
|
||||
|
||||
final gesture = await tester.startGesture(
|
||||
position(startFrame),
|
||||
kind: PointerDeviceKind.touch,
|
||||
);
|
||||
// Acquire the real ruler's drag recognizer before measuring movement.
|
||||
await gesture.moveBy(const Offset(30, 0));
|
||||
await tester.pump();
|
||||
expect(view.isScrubbing, isTrue);
|
||||
await gesture.moveTo(position(startFrame));
|
||||
await advance(350);
|
||||
initial = await diagnostic(preview);
|
||||
clock.reset();
|
||||
final timer = Timer.periodic(
|
||||
const Duration(milliseconds: 20),
|
||||
(_) => sample(),
|
||||
);
|
||||
for (var i = 0; i < 120; i++) {
|
||||
final dueUs = (i * 1000000 / 60).round();
|
||||
final remaining = dueUs - clock.elapsedMicroseconds;
|
||||
if (remaining > 0) {
|
||||
await Future<void>.delayed(Duration(microseconds: remaining));
|
||||
}
|
||||
final phase = i < 60 ? i : 119 - i;
|
||||
final target = local
|
||||
? 60000 + (i % 40 < 20 ? i % 40 : 39 - i % 40)
|
||||
: (durationFrames * (.05 + .9 * phase / 59)).round();
|
||||
await gesture.moveTo(position(target));
|
||||
inputs.add({
|
||||
'ms': clock.elapsedMicroseconds / 1000,
|
||||
'dueMs': dueUs / 1000,
|
||||
'idealFrame': target,
|
||||
'actualTick': view.playheadTick,
|
||||
});
|
||||
}
|
||||
final releaseAt = clock.elapsedMicroseconds / 1000;
|
||||
final finalTick = view.playheadTick;
|
||||
await gesture.up();
|
||||
await tester.pump();
|
||||
await preview.waitForPendingPreview().timeout(
|
||||
const Duration(seconds: 60),
|
||||
);
|
||||
final settled = await diagnostic(preview);
|
||||
final settledMs = clock.elapsedMicroseconds / 1000;
|
||||
await advance(500);
|
||||
final frozen = await diagnostic(preview);
|
||||
timer.cancel();
|
||||
await pending;
|
||||
expect(sampleError, isNull);
|
||||
expect(preview.error, isNull);
|
||||
final snapshot = await preview.session!.refresh();
|
||||
final clockTick =
|
||||
(BigInt.from(snapshot.position.numerator) *
|
||||
BigInt.from(TimelineClock.ticksPerSecond) ~/
|
||||
BigInt.from(snapshot.position.denominator))
|
||||
.toInt();
|
||||
expectExactSource(settled, finalTick);
|
||||
expect(
|
||||
(clockTick - finalTick).abs(),
|
||||
lessThanOrEqualTo(TimelineClock.ticksPerSecond ~/ 1000000),
|
||||
);
|
||||
drags.add({
|
||||
'round': round,
|
||||
'scenario': local ? 'local-20-frame' : 'fit-entire-source',
|
||||
'viewportWidth': ruler.size.width,
|
||||
'inputs': inputs,
|
||||
'observations': observations,
|
||||
'before': initial,
|
||||
'settled': settled,
|
||||
'frozen': frozen,
|
||||
'releaseAtMs': releaseAt,
|
||||
'settledAtMs': settledMs,
|
||||
'releaseWaitMs': settledMs - releaseAt,
|
||||
'finalTick': finalTick,
|
||||
'clockTick': clockTick,
|
||||
'postSettleFrames': frames(frozen) - frames(settled),
|
||||
});
|
||||
save();
|
||||
}
|
||||
}
|
||||
final ruler = tester.renderObject<RenderBox>(
|
||||
find.byType(TimelineRuler),
|
||||
);
|
||||
final viewport = TimelineViewportRect(
|
||||
width: ruler.size.width,
|
||||
height: ruler.size.height,
|
||||
);
|
||||
Offset heldPosition(int frame) => ruler.localToGlobal(
|
||||
Offset(
|
||||
view.camera.screenXForTick(
|
||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
||||
viewport,
|
||||
),
|
||||
ruler.size.height / 2,
|
||||
),
|
||||
);
|
||||
await seek(60000);
|
||||
final hold = await tester.startGesture(
|
||||
heldPosition(60000),
|
||||
kind: PointerDeviceKind.touch,
|
||||
);
|
||||
await hold.moveBy(const Offset(30, 0));
|
||||
await tester.pump();
|
||||
await hold.moveTo(heldPosition(60010));
|
||||
await advance(1000);
|
||||
final heldTick = view.playheadTick;
|
||||
final heldBefore = await diagnostic(preview);
|
||||
final releaseClock = Stopwatch()..start();
|
||||
await hold.up();
|
||||
await tester.pump();
|
||||
await preview.waitForPendingPreview().timeout(
|
||||
const Duration(seconds: 60),
|
||||
);
|
||||
final heldAfter = await diagnostic(preview);
|
||||
final heldReleaseMs = releaseClock.elapsedMicroseconds / 1000;
|
||||
await advance(500);
|
||||
final heldFrozen = await diagnostic(preview);
|
||||
(result['heldRelease']! as List<Map<String, Object?>>).add({
|
||||
'holdMilliseconds': 1000,
|
||||
'targetTick': heldTick,
|
||||
'before': heldBefore,
|
||||
'after': heldAfter,
|
||||
'frozen': heldFrozen,
|
||||
'releaseWaitMs': heldReleaseMs,
|
||||
});
|
||||
save();
|
||||
expectExactSource(heldBefore, heldTick);
|
||||
expectExactSource(heldAfter, heldTick);
|
||||
expect(sourcePts(heldAfter), sourcePts(heldBefore));
|
||||
expect(frames(heldAfter), frames(heldBefore));
|
||||
expect(heldAfter['seekRequestCount'], heldBefore['seekRequestCount']);
|
||||
expect(frames(heldFrozen), frames(heldAfter));
|
||||
expect(tester.takeException(), isNull);
|
||||
final after = await file.stat();
|
||||
expect(after.size, before.size);
|
||||
expect(after.modified, before.modified);
|
||||
result['status'] = 'passed';
|
||||
result['sourceUnchanged'] = true;
|
||||
save();
|
||||
} catch (error, stack) {
|
||||
result['status'] = 'failed';
|
||||
result['error'] = '$error';
|
||||
result['stack'] = '$stack';
|
||||
save();
|
||||
rethrow;
|
||||
} finally {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
container.dispose();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 300));
|
||||
await database.close();
|
||||
await SystemChrome.setPreferredOrientations([]);
|
||||
}
|
||||
},
|
||||
skip: source.isEmpty || output.isEmpty,
|
||||
timeout: const Timeout(Duration(minutes: 15)),
|
||||
);
|
||||
}
|
||||
|
||||
class _Workspace extends ConsumerWidget {
|
||||
const _Workspace();
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final state = ref.watch(projectsProvider).requireValue;
|
||||
return EditorWorkspace(
|
||||
projectId: state.activeProject!.id,
|
||||
projectName: state.activeProject!.name,
|
||||
timelineId: state.visibleTimelineId!,
|
||||
projectLoading: state.projectBusy,
|
||||
timelineLoading: state.openingTimelineId != null,
|
||||
integratedTitlebar: false,
|
||||
headerLeading: const SizedBox.shrink(),
|
||||
experience: DeviceExperience.tablet,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -183,11 +183,9 @@ class _EditorPreviewContent extends ConsumerWidget {
|
||||
final watched = pending
|
||||
? const AsyncData<PreviewController?>(null)
|
||||
: ref.watch(provider);
|
||||
final registry = ref.watch(previewControllerRegistryProvider);
|
||||
final cached = watched.isLoading && !watched.hasError
|
||||
? ref.read(previewControllerRegistryProvider).cached((
|
||||
projectId,
|
||||
timelineId,
|
||||
))
|
||||
? registry.cached((projectId, timelineId))
|
||||
: null;
|
||||
final state = cached == null
|
||||
? watched
|
||||
|
||||
@@ -13,6 +13,9 @@ part 'preview_controller_registry.g.dart';
|
||||
PreviewControllerRegistry previewControllerRegistry(Ref ref) {
|
||||
final registry = PreviewControllerRegistry(
|
||||
ref.read(runtimeConnectionProvider),
|
||||
onChanged: () => scheduleMicrotask(() {
|
||||
if (ref.mounted) ref.notifyListeners();
|
||||
}),
|
||||
);
|
||||
ref.onDispose(registry.dispose);
|
||||
return registry;
|
||||
@@ -21,9 +24,10 @@ PreviewControllerRegistry previewControllerRegistry(Ref ref) {
|
||||
/// Owns native preview controllers independently of the currently visible
|
||||
/// timeline. Prepared controllers make timeline selection a synchronous swap.
|
||||
final class PreviewControllerRegistry {
|
||||
PreviewControllerRegistry(this._runtime);
|
||||
PreviewControllerRegistry(this._runtime, {this._onChanged});
|
||||
|
||||
final CutdexRuntime _runtime;
|
||||
final void Function()? _onChanged;
|
||||
final _controllers = <(String, String), PreviewController>{};
|
||||
final _preparing = <(String, String), Future<PreviewController>>{};
|
||||
bool _disposed = false;
|
||||
@@ -39,10 +43,10 @@ final class PreviewControllerRegistry {
|
||||
if (sequence == null || timeline.sequenceDurationTicks(sequence) == 0) {
|
||||
return null;
|
||||
}
|
||||
final cached = _controllers[ids];
|
||||
if (cached != null) return cached;
|
||||
final pending = _preparing[ids];
|
||||
if (pending != null) return pending;
|
||||
final cached = _controllers[ids];
|
||||
if (cached != null) return cached;
|
||||
final future = _initialize(ids, timeline);
|
||||
_preparing[ids] = future;
|
||||
return future;
|
||||
@@ -58,15 +62,22 @@ final class PreviewControllerRegistry {
|
||||
viewForSequence: timeline.view,
|
||||
runtime: _runtime,
|
||||
);
|
||||
// Mount native output while initialization is pending. Android exact seeks
|
||||
// cannot complete their first frame before the SurfaceView is attached.
|
||||
_controllers[ids] = controller;
|
||||
_onChanged?.call();
|
||||
try {
|
||||
await controller.initialize();
|
||||
if (_disposed) {
|
||||
if (_disposed || !identical(_controllers[ids], controller)) {
|
||||
await controller.close();
|
||||
throw StateError('Preview registry is closed');
|
||||
}
|
||||
_controllers[ids] = controller;
|
||||
return controller;
|
||||
} catch (_) {
|
||||
if (identical(_controllers[ids], controller)) {
|
||||
_controllers.remove(ids);
|
||||
_onChanged?.call();
|
||||
}
|
||||
await controller.close().catchError((Object _) {});
|
||||
rethrow;
|
||||
} finally {
|
||||
@@ -76,6 +87,7 @@ final class PreviewControllerRegistry {
|
||||
|
||||
Future<void> invalidate((String, String) ids) async {
|
||||
final controller = _controllers.remove(ids);
|
||||
if (controller != null) _onChanged?.call();
|
||||
if (controller != null) await controller.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,4 +55,4 @@ final class PreviewControllerRegistryProvider
|
||||
}
|
||||
|
||||
String _$previewControllerRegistryHash() =>
|
||||
r'ec6788d52acb279d31cd745f0e244d604f09a890';
|
||||
r'2ca41396aa3bffe169b2dff87753440aac6ff33a';
|
||||
+18
-18
@@ -214,8 +214,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/editor"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -223,8 +223,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/mcp"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -232,8 +232,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/preview"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -241,8 +241,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/project"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -250,8 +250,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/runtime"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -259,8 +259,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -268,8 +268,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/timeline"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.2.0"
|
||||
@@ -277,8 +277,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/timeline_ui"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
@@ -286,8 +286,8 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "packages/tools"
|
||||
ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
resolved-ref: "710475e84fb1d9bf71952e8782be6a6e583f6b7a"
|
||||
ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
resolved-ref: "58088065ee707e94dbd154265aa287ddbf33109c"
|
||||
url: "ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ dependencies:
|
||||
cutdex_sdk:
|
||||
git:
|
||||
url: ssh://git@git.orangraph.com:2222/lingjhf/cutdex_sdk.git
|
||||
ref: 710475e84fb1d9bf71952e8782be6a6e583f6b7a
|
||||
ref: 58088065ee707e94dbd154265aa287ddbf33109c
|
||||
cutdex_agent:
|
||||
git:
|
||||
url: https://github.com/cutdex-ai/cutdex_agent.git
|
||||
|
||||
@@ -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