Files
cutdex/test/picture_keyframes_test.dart
lingjhf 06f1c26681
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
Move editor UI into the app and release verified Core dependencies (#14)
2026-10-11 19:59:40 +00:00

160 lines
5.9 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/picture_properties.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'support/preview_fixture.dart';
void main() {
testWidgets(
'compact keyframe inspector authors, seeks, interpolates and clears',
(tester) async {
final f = (await tester.runAsync(
() => createPreviewFixture(
Uri.file('/test/video.mov'),
clipDuration: RationalTime.seconds(5),
),
))!;
final view = f.timeline.view(SequenceId('one'));
final project = f.workspace.project!.info.id;
ClipAnimation current() {
final q = view.version.kernelVersion.query();
return ClipAnimation.at(
q,
q.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: AppTheme.propertiesPanelTheme(
EditorTheme.desktop(EditorTheme.penLight),
),
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 280,
child: SingleChildScrollView(
child: PictureProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: SequenceId('one'),
clip: current().record,
animationView: true,
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
Future<void> settleEdit() async {
await tester.pump();
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
Future<void> tap(String key) async {
await tester.ensureVisible(find.byKey(ValueKey(key)));
await tester.tap(find.byKey(ValueKey(key)));
await settleEdit();
}
Finder input(String key) => find.descendant(
of: find.byKey(ValueKey(key)),
matching: find.byType(TextField),
);
await tap('picture-key-position');
expect(current().keyed(TransformChannel.position), isTrue);
view.seekTo(2 * TimelineClock.ticksPerSecond);
await tester.pump();
await tester.enterText(input('picture-x'), '216');
await tester.testTextInput.receiveAction(TextInputAction.done);
await settleEdit();
expect(current().value.x, .2);
expect(current().keyTimes(TransformChannel.position).length, 2);
view.seekTo(TimelineClock.ticksPerSecond);
await tester.pump();
expect(
tester.widget<TextField>(input('picture-x')).controller!.text,
'108',
);
await tap('picture-key-previous-position');
expect(view.playheadTick, 0);
await tap('picture-key-menu-position');
await tester.tap(find.widgetWithText(MenuItemButton, '保持'));
await settleEdit();
view.seekTo(TimelineClock.ticksPerSecond);
await tester.pump();
expect(current().value.x, 0);
await tap('picture-key-next-position');
expect(view.playheadTick, 2 * TimelineClock.ticksPerSecond);
await tap('picture-key-position');
expect(current().keyTimes(TransformChannel.position), [0]);
await tap('picture-key-marker-position-0');
expect(view.playheadTick, 0);
await tap('picture-key-position');
expect(current().animated(TransformChannel.position), isFalse);
await tap('picture-key-scale');
await tap('picture-lock');
view.seekTo(2 * TimelineClock.ticksPerSecond);
await tester.pump();
await tester.enterText(input('picture-scale-y'), '200');
await tester.testTextInput.receiveAction(TextInputAction.done);
await settleEdit();
expect(current().value.scale, 1);
expect(current().value.scaleY, 2);
view.seekTo(TimelineClock.ticksPerSecond);
await tester.pump();
expect(
tester.widget<TextField>(input('picture-scale-y')).controller!.text,
'150',
);
await tap('picture-key-menu-scale');
await tester.tap(find.text('移除全部关键帧'));
await settleEdit();
expect(current().animated(TransformChannel.scale), isFalse);
expect(current().value.scaleY, 1.5);
// Unsubmitted text cannot leak into a different playhead position.
await tester.enterText(input('picture-x'), '999');
view.seekTo(3 * TimelineClock.ticksPerSecond);
await tester.pump();
await tester.testTextInput.receiveAction(TextInputAction.done);
await settleEdit();
expect(current().value.x, 0);
await tester.enterText(input('picture-rotation'), '25');
await tap('picture-key-rotation');
expect(current().value.rotation, 25);
expect(current().keyed(TransformChannel.rotation), isTrue);
await tester.pumpWidget(const SizedBox());
await tester.runAsync(() async {
await f.workspace.close();
await f.directory.delete(recursive: true);
});
},
);
}