perf(editor): integrate native preview and prioritize timeline interaction
Gitea CI / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Check code and tests (pull_request) Failing after 7m0s
Gitea CI / Gitea CI passed (pull_request) Failing after 5s
Gitea CI / Build Android APK (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Skipped
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
This commit is contained in:
1 parent
0ecf920669
commit
4f746be301
34 files changed
+3278
-145
No files matched your search
@@ -0,0 +1,146 @@
|
||||
import 'package:cutdex/app/editor_theme.dart';
|
||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||
import 'package:cutdex/features/properties/picture_properties.dart';
|
||||
import 'package:cutdex/features/properties/properties_inspector_controller.dart';
|
||||
import 'package:cutdex/l10n/app_localizations.dart';
|
||||
import 'package:cutdex_sdk/editor.dart';
|
||||
import 'package:cutdex_sdk/timeline/model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'support/preview_fixture.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('cursor changes preserve inspector selection subscriptions', (
|
||||
tester,
|
||||
) async {
|
||||
final f = (await tester.runAsync(
|
||||
() => createPreviewFixture(Uri.file('/test/video.mov')),
|
||||
))!;
|
||||
addTearDown(
|
||||
() => tester.runAsync(() async {
|
||||
await f.workspace.close();
|
||||
await f.directory.delete(recursive: true);
|
||||
}),
|
||||
);
|
||||
final inspector = PropertiesInspectorController(f.timeline);
|
||||
addTearDown(inspector.dispose);
|
||||
final view = f.timeline.view(SequenceId('one'));
|
||||
final clip = view.version.kernelVersion.query().elementById(
|
||||
ElementId('clip'),
|
||||
)!;
|
||||
var notifications = 0;
|
||||
inspector.addListener(() => notifications++);
|
||||
view.setSelection([clip]);
|
||||
expect(inspector.selectedClips.single.id, ElementId('clip'));
|
||||
final selectedCount = notifications;
|
||||
view.beginScrubbing();
|
||||
for (var i = 1; i <= 120; i++) {
|
||||
view.seekTo(i * TimelineClock.ticksPerSecond ~/ 120);
|
||||
}
|
||||
view.endScrubbing();
|
||||
expect(notifications, selectedCount);
|
||||
view.clearSelection();
|
||||
expect(notifications, greaterThan(selectedCount));
|
||||
expect(inspector.selectedClips, isEmpty);
|
||||
f.timeline.selectSequence(SequenceId('empty'));
|
||||
expect(inspector.sequence, SequenceId('empty'));
|
||||
final switchedCount = notifications;
|
||||
view.setSelection([clip]);
|
||||
expect(
|
||||
notifications,
|
||||
switchedCount,
|
||||
reason: 'Old sequence listener is detached',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('static controls stay stable and discard edits after a seek', (
|
||||
tester,
|
||||
) async {
|
||||
final f = (await tester.runAsync(
|
||||
() => createPreviewFixture(
|
||||
Uri.file('/test/video.mov'),
|
||||
clipDuration: RationalTime.seconds(5),
|
||||
),
|
||||
))!;
|
||||
addTearDown(
|
||||
() => tester.runAsync(() async {
|
||||
await f.workspace.close();
|
||||
await f.directory.delete(recursive: true);
|
||||
}),
|
||||
);
|
||||
final view = f.timeline.view(SequenceId('one'));
|
||||
final project = f.workspace.project!.info.id;
|
||||
ClipAnimation current() {
|
||||
final query = view.version.kernelVersion.query();
|
||||
return ClipAnimation.at(
|
||||
query,
|
||||
query.elementById(ElementId('clip'))!,
|
||||
view.playheadTick,
|
||||
TimelineClock.ticksPerSecond ~/ 30,
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
editorPreviewProvider(
|
||||
project,
|
||||
'project',
|
||||
).overrideWith((ref) async => throw StateError('No native preview')),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
locale: const Locale('zh'),
|
||||
theme: EditorTheme.penLight,
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
width: 280,
|
||||
child: SingleChildScrollView(
|
||||
child: PictureProperties(
|
||||
projectId: project,
|
||||
timelineId: 'project',
|
||||
session: f.timeline,
|
||||
sequence: SequenceId('one'),
|
||||
clip: current().record,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final input = find.descendant(
|
||||
of: find.byKey(const ValueKey('picture-x')),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
final initial = tester.widget<TextField>(input);
|
||||
view.seekTo(TimelineClock.ticksPerSecond);
|
||||
await tester.pump();
|
||||
expect(tester.widget<TextField>(input), same(initial));
|
||||
await tester.ensureVisible(input);
|
||||
await tester.enterText(input, '999');
|
||||
await tester.pump();
|
||||
view.seekTo(2 * TimelineClock.ticksPerSecond);
|
||||
await tester.pump();
|
||||
await tester.testTextInput.receiveAction(TextInputAction.done);
|
||||
await tester.runAsync(f.timeline.flush);
|
||||
await tester.pumpAndSettle();
|
||||
expect(current().value.x, 0);
|
||||
await tester.ensureVisible(
|
||||
find.byKey(const ValueKey('picture-key-position')),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('picture-key-position')));
|
||||
await tester.pump();
|
||||
await tester.runAsync(f.timeline.flush);
|
||||
await tester.pumpAndSettle();
|
||||
expect(current().keyTimes(TransformChannel.position), [
|
||||
2 * TimelineClock.ticksPerSecond,
|
||||
]);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user