Gitea CI / Check code and tests (pull_request) Failing after 8s
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 / Gitea CI passed (pull_request) Failing after 1s
234 lines
7.6 KiB
Dart
234 lines
7.6 KiB
Dart
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_core/editor.dart';
|
|
import 'package:cutdex_core/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('inactive picture properties ignore replacement notifications', (
|
|
tester,
|
|
) async {
|
|
final fixture = (await tester.runAsync(
|
|
() =>
|
|
createPreviewFixture(Uri.file('/test/image.png'), mediaType: 'image'),
|
|
))!;
|
|
addTearDown(
|
|
() => tester.runAsync(() async {
|
|
await fixture.workspace.close();
|
|
await fixture.directory.delete(recursive: true);
|
|
}),
|
|
);
|
|
final view = fixture.timeline.view(SequenceId('one'));
|
|
final clip = view.version.kernelVersion.query().element(
|
|
view.version.kernelVersion.query().elementById(ElementId('clip'))!,
|
|
);
|
|
final project = fixture.workspace.project!.info.id;
|
|
final container = ProviderContainer(
|
|
overrides: [
|
|
editorPreviewProvider(project, 'project').overrideWith((ref) => null),
|
|
],
|
|
);
|
|
addTearDown(container.dispose);
|
|
Widget host(Widget child) => UncontrolledProviderScope(
|
|
container: container,
|
|
child: MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
locale: const Locale('zh'),
|
|
theme: EditorTheme.penLight,
|
|
home: Scaffold(body: SingleChildScrollView(child: child)),
|
|
),
|
|
);
|
|
await tester.pumpWidget(
|
|
host(
|
|
PictureProperties(
|
|
projectId: project,
|
|
timelineId: 'project',
|
|
session: fixture.timeline,
|
|
sequence: SequenceId('one'),
|
|
clip: clip,
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const ValueKey('picture-x')), findsOneWidget);
|
|
await tester.pumpWidget(
|
|
host(_NotifyOnMount(() => view.seekTo(TimelineClock.ticksPerSecond))),
|
|
);
|
|
expect(view.playheadTick, TimelineClock.ticksPerSecond);
|
|
expect(find.byType(PictureProperties), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
await tester.pumpWidget(const SizedBox());
|
|
});
|
|
|
|
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;
|
|
f.timeline.commands.setTransform(
|
|
sequence: SequenceId('one'),
|
|
clip: ElementId('clip'),
|
|
tick: 0,
|
|
change: (value) => value.copyWith(x: .25),
|
|
);
|
|
expect(
|
|
notifications,
|
|
selectedCount,
|
|
reason: 'Property values belong to editors, not selection shell',
|
|
);
|
|
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',
|
|
);
|
|
await tester.runAsync(f.timeline.flush);
|
|
});
|
|
|
|
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());
|
|
});
|
|
}
|
|
|
|
class _NotifyOnMount extends StatefulWidget {
|
|
const _NotifyOnMount(this.notify);
|
|
final VoidCallback notify;
|
|
|
|
@override
|
|
State<_NotifyOnMount> createState() => _NotifyOnMountState();
|
|
}
|
|
|
|
class _NotifyOnMountState extends State<_NotifyOnMount> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
widget.notify();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const SizedBox();
|
|
}
|