feat(inspector): add animated independent corners and layered shadow controls

This commit is contained in:
lingjhf committed 2026-10-09 19:24:00 +08:00
1 parent 77dbb1897f
commit 8d1f8db7e8
23 files changed
+2375 -228

No files matched your search

+2 -1
View File
@@ -4,6 +4,7 @@ import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex/workspace/timeline_session.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -145,7 +146,7 @@ Widget _host(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: desktop
? EditorTheme.desktop(EditorTheme.penDark)
? AppTheme.propertiesPanelTheme(EditorTheme.desktop(EditorTheme.penDark))
: EditorTheme.penDark,
home: Scaffold(
body: CaptionProperties(session: session, sequence: _sequence, clipId: id),
+90 -13
View File
@@ -1,4 +1,7 @@
import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/editor/layouts/bounded_editor_layout.dart';
import 'package:cutdex/features/editor/editor_presentation_controller.dart';
import 'package:cutdex/integrations/platform/device_experience.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/picture_properties.dart';
import 'package:cutdex/features/properties/audio_properties.dart';
@@ -15,6 +18,50 @@ import 'package:flutter_test/flutter_test.dart';
import 'support/preview_fixture.dart';
void main() {
testWidgets(
'floating desktop inspector keeps the UI3 width in narrow windows',
(tester) async {
for (final width in [200.0, 320.0, 800.0]) {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
theme: EditorTheme.desktop(EditorTheme.penDark),
home: Scaffold(
body: Align(
alignment: Alignment.topRight,
child: SizedBox(
width: width,
height: 400,
child: BoundedEditorLayout(
experience: DeviceExperience.desktop,
editing: const SizedBox.expand(),
tool: EditorTool.properties,
media: const SizedBox.expand(),
properties: const SizedBox.expand(),
onCloseTool: () {},
),
),
),
),
),
);
await tester.pumpAndSettle();
expect(
tester.getSize(find.byKey(const Key('editor-tool-surface'))).width,
width < 240 ? width : 240,
);
final title = tester.widget<Text>(
find.byWidgetPredicate((w) => w is Text && w.style?.fontSize == 13),
);
expect(title.style!.fontSize, 13);
expect(title.style!.height, 22 / 13);
expect(tester.takeException(), isNull);
}
},
);
testWidgets(
'audio and speed controls fit desktop group headers at narrow widths',
(tester) async {
@@ -74,10 +121,10 @@ void main() {
of: find.byKey(const Key('audio-db')),
matching: find.byType(TextField),
);
expect(tester.getSize(field).height, 28);
expect(tester.getSize(field).height, 24);
expect(
tester.getRect(find.byKey(const Key('audio-key'))).bottom,
tester.getRect(field).top - 4,
tester.getRect(find.byKey(const Key('audio-key'))).center.dy,
tester.getRect(field).center.dy,
);
expect(find.byType(AppPropertyGroup), findsNWidgets(2));
expect(tester.takeException(), isNull);
@@ -120,6 +167,7 @@ void main() {
for (final brightness in Brightness.values) {
for (final (width, locale) in [
(220.0, 'de'),
(240.0, 'en'),
(280.0, 'zh'),
(360.0, 'en'),
]) {
@@ -157,13 +205,34 @@ void main() {
);
await tester.pumpAndSettle();
for (final name in ['x', 'y', 'scale-x', 'scale-y', 'rotation']) {
expect(tester.getSize(input(name)).height, 28);
expect(tester.getSize(input(name)).height, 24);
}
expect(tester.getRect(input('x')).left, 12);
expect(tester.getRect(input('x')).width, (width - 28) / 2);
expect(tester.getRect(input('x')).left, 16);
expect(tester.getRect(input('x')).width, (width - 64) / 2);
expect(tester.getRect(input('rotation')).width, (width - 64) / 2);
expect(find.byType(AppPropertyGroup), findsNWidgets(4));
expect(
tester.getRect(input('corner-radius')).width,
(width - 64) / 2,
);
expect(
tester.getSize(find.byType(AppPropertySection).first).height,
148,
);
final align = find.byKey(const ValueKey('picture-align-left'));
final verticalAlign = find.byKey(const ValueKey('picture-align-top'));
expect(
tester.getCenter(align).dy,
tester.getCenter(verticalAlign).dy,
);
for (final name in ['x', 'y', 'scale-x', 'scale-y', 'rotation']) {
final field = tester.widget<TextField>(input(name));
expect(field.decoration!.prefixIcon, isNotNull);
final handle = find.descendant(
of: find.byKey(ValueKey('picture-$name')),
matching: find.byType(AppScrubLabel),
);
expect(tester.getSize(handle).width, 24);
}
expect(
find.descendant(
@@ -194,12 +263,20 @@ void main() {
? 'scale-x'
: 'rotation',
);
expect(
tester.getRect(action).bottom,
tester.getRect(field).top - 4,
);
if (channel == 'scale') {
expect(
tester.getRect(action).bottom,
tester.getRect(field).top - 12,
);
} else {
expect(tester.getCenter(action).dy, tester.getCenter(field).dy);
}
}
expect(right, width - 12);
expect(
tester.getCenter(find.byKey(const Key('picture-lock'))).dy,
tester.getCenter(input('scale-x')).dy,
);
expect(right, width - 8);
expect(
tester.getRect(input('x')).left,
tester.getRect(input('rotation')).left,
@@ -215,8 +292,8 @@ void main() {
);
expect(
tester.getRect(input('rotation')).top -
tester.getRect(input('scale-x')).bottom,
40,
tester.getRect(input('x')).bottom,
8,
);
}
expect(
+226
View File
@@ -0,0 +1,226 @@
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/l10n/app_localizations.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.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('corner radius edits, scrubs, animates and survives undo', (
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 sequence = SequenceId('one');
final view = f.timeline.view(sequence);
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) => null),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
theme: AppTheme.propertiesPanelTheme(
EditorTheme.desktop(EditorTheme.penDark),
),
home: Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 240,
child: SingleChildScrollView(
child: PictureProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: sequence,
clip: current().record,
),
),
),
),
),
),
),
);
await tester.pumpAndSettle();
final input = find.descendant(
of: find.byKey(const ValueKey('picture-corner-radius')),
matching: find.byType(TextField),
);
Future<void> settle() async {
await tester.pump();
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
Future<void> enter(String value) async {
await tester.ensureVisible(input);
await tester.enterText(input, value);
await tester.testTextInput.receiveAction(TextInputAction.done);
await settle();
}
expect(current().value.cornerRadius, 0);
await enter('48');
expect(current().value.cornerRadius, 48);
expect(current().value.scale, 1);
expect(current().animated(TransformChannel.cornerRadius), isFalse);
view.undo();
await settle();
expect(current().value.cornerRadius, 0);
view.redo();
await settle();
expect(current().value.cornerRadius, 48);
await enter('-1');
expect(current().value.cornerRadius, 48);
await enter('48');
final label = find.descendant(
of: find.byKey(const ValueKey('picture-corner-radius')),
matching: find.byType(AppScrubLabel),
);
await tester.drag(label, const Offset(20, 0));
await settle();
expect(current().value.cornerRadius, greaterThan(48));
view.undo();
await settle();
expect(current().value.cornerRadius, 48);
final key = find.byKey(const ValueKey('picture-key-cornerRadius'));
await tester.ensureVisible(key);
await tester.tap(key);
await settle();
expect(current().keyed(TransformChannel.cornerRadius), isTrue);
view.seekTo(2 * TimelineClock.ticksPerSecond);
await settle();
await enter('96');
expect(current().keyed(TransformChannel.cornerRadius), isTrue);
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
expect(current().value.cornerRadius, 72);
expect(tester.widget<TextField>(input).controller!.text, '72');
expect(current().record.parameters?['canvas.cornerRadius']?.length, 2);
final toggle = find.byKey(const ValueKey('picture-independent-corners'));
final beforeToggle = view.version.kernelVersion;
await tester.tap(toggle);
await settle();
expect(identical(view.version.kernelVersion, beforeToggle), isTrue);
final topLeft = find.descendant(
of: find.byKey(const ValueKey('picture-corner-top-left')),
matching: find.byType(TextField),
);
final topRight = find.descendant(
of: find.byKey(const ValueKey('picture-corner-top-right')),
matching: find.byType(TextField),
);
expect(tester.getSize(topLeft), const Size(88, 24));
expect(tester.getTopLeft(topRight).dx - tester.getTopRight(topLeft).dx, 8);
expect(tester.widget<TextField>(topLeft).controller!.text, '72');
await tester.enterText(topLeft, '120');
await tester.testTextInput.receiveAction(TextInputAction.done);
await settle();
expect(current().value.cornerRadii, [120, 72, 72, 72]);
expect(current().keyed(TransformChannel.cornerRadius), isTrue);
expect(tester.widget<TextField>(input).controller!.text, '—');
view.undo();
await settle();
expect(current().value.cornerRadii, [72, 72, 72, 72]);
view.redo();
await settle();
expect(current().value.cornerRadii, [120, 72, 72, 72]);
// Collapsing mixed corners is a presentation change, not a timeline edit.
await tester.tap(toggle);
await settle();
expect(topLeft, findsNothing);
expect(tester.widget<TextField>(input).controller!.text, '—');
view.seekTo(TimelineClock.ticksPerSecond ~/ 2);
await settle();
expect(current().value.cornerRadii, [84, 60, 60, 60]);
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
await enter('0');
expect(current().value.cornerRadii, [0, 0, 0, 0]);
view.undo();
await settle();
final compiled = const ExecutionCompiler().compile(
ExecutionInput(
timeline: f.timeline.persistence.timeline(sequence),
renderSize: RenderSize(64, 64),
media: {
PayloadRef('source'): ExecutionMediaBinding(
media: MediaReference(
id: 'media',
uri: Uri.file('/test/video.mov'),
),
videoTrackSelection: TrackSelection.index(0),
),
},
parameterTargets: ClipTransform.targets,
),
);
final curves = compiled.plan.visualLayers.single.automation;
expect(
curves.firstWhere((c) => c.target == 'cornerRadius.topLeft').keys.length,
3,
);
final saved = await tester.runAsync(
() => f.workspace.project!.loadTimeline('project'),
);
expect(
saved!.sequences.first.elements.first.parameters.map(
(p) => p.definition.id,
),
containsAll(ClipTransform.cornerIds),
);
await tester.pumpWidget(const SizedBox());
});
test('corner radius rejects nonfinite and negative values', () {
expect(const ClipTransform().cornerRadius, 0);
expect(const ClipTransform(cornerRadius: -1).isValid, isFalse);
expect(const ClipTransform(cornerRadius: double.nan).isValid, isFalse);
expect(const ClipTransform(bottomRightRadius: -1).isValid, isFalse);
expect(
const ClipTransform(topLeftRadius: double.infinity).isValid,
isFalse,
);
final mixed = const ClipTransform(cornerRadius: 12, topLeftRadius: 30);
expect(mixed.copyWith(x: .2).cornerRadii, [30, 12, 12, 12]);
expect(mixed.copyWith(cornerRadius: 5).cornerRadii, [5, 5, 5, 5]);
expect(
const ClipTransform(cornerRadius: 40).copyWith(scale: 2).cornerRadius,
40,
);
});
}
+485
View File
@@ -0,0 +1,485 @@
import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/shadow_properties.dart';
import 'package:cutdex/features/properties/picture_properties.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/runtime.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_ui/theme.dart';
import 'package:cutdex_ui/widgets.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 'support/preview_fixture.dart';
void main() {
testWidgets(
'one shadow key captures all layers and structural edits preserve curves',
(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 seq = SequenceId('one');
final clip = ElementId('clip');
final view = f.timeline.view(seq);
final project = f.workspace.project!.info.id;
ClipShadowStack current() {
final q = view.version.kernelVersion.query();
final h = q.elementById(clip)!;
return ClipShadowStack(
q.element(h),
view.playheadTick - q.absoluteStart(h),
);
}
await tester.pumpWidget(
ProviderScope(
overrides: [
editorPreviewProvider(
project,
'project',
).overrideWith((ref) => null),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
theme: AppTheme.propertiesPanelTheme(
EditorTheme.desktop(EditorTheme.penDark),
),
home: Scaffold(
body: Align(
alignment: Alignment.topRight,
child: SizedBox(
width: 240,
child: SingleChildScrollView(
child: ShadowProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: seq,
clip: clip,
),
),
),
),
),
),
),
);
Future<void> settle() async {
await tester.pump();
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
Future<void> closeEditor() async {
final close = find.byWidgetPredicate(
(w) =>
w is IconButton &&
w.key is ValueKey<String> &&
(w.key! as ValueKey<String>).value.startsWith(
'shadow-editor-close-',
),
);
if (close.evaluate().isNotEmpty) {
await tester.tap(close);
await settle();
}
}
Future<void> tap(Key key) async {
await closeEditor();
final w = find.byKey(key);
await tester.ensureVisible(w);
await tester.tap(w);
await settle();
}
Future<void> enter(String id, String field, String value) async {
if (find.byKey(ValueKey('shadow-editor-$id')).evaluate().isEmpty) {
await closeEditor();
await tester.tap(find.byKey(ValueKey('shadow-settings-$id')));
await settle();
}
final input = find.descendant(
of: find.byKey(ValueKey('shadow-$id-$field')),
matching: find.byType(TextField),
);
await tester.ensureVisible(input);
await tester.enterText(input, value);
await tester.testTextInput.receiveAction(TextInputAction.done);
await settle();
}
await settle();
expect(current().layers, isEmpty);
expect(tester.getSize(find.byType(AppPropertySection)).height, 40);
await tap(const ValueKey('shadow-add'));
final a = current().layers.single.id;
await tap(const ValueKey('shadow-add'));
final b = current().layers.last.id;
expect(find.byType(TextField), findsNothing);
expect(
tester.getSize(find.byKey(ValueKey('shadow-layer-$a'))).height,
32,
);
await enter(a, 'x', '12');
expect(
tester.getSize(find.byKey(ValueKey('shadow-editor-$a'))).width,
240,
);
expect(
tester.getRect(find.byKey(ValueKey('shadow-editor-$a'))).right,
lessThan(tester.getRect(find.byKey(ValueKey('shadow-layer-$a'))).left),
);
final xField = find.descendant(
of: find.byKey(ValueKey('shadow-$a-x')),
matching: find.byType(TextField),
);
expect(tester.getSize(xField), const Size(100, 24));
expect(
tester.getSize(find.byKey(ValueKey('shadow-editor-$a'))).height,
225,
);
final yField = find.descendant(
of: find.byKey(ValueKey('shadow-$a-y')),
matching: find.byType(TextField),
);
expect(tester.getRect(yField).left - tester.getRect(xField).right, 8);
final blurInput = find.descendant(
of: find.byKey(ValueKey('shadow-$a-blur')),
matching: find.byType(TextField),
);
final blurLabel = find.descendant(
of: find.byKey(ValueKey('shadow-$a-blur')),
matching: find.text('模糊'),
);
final colorLabel = find.descendant(
of: find.byKey(ValueKey('shadow-editor-$a')),
matching: find.text('颜色'),
);
expect(tester.getSize(blurLabel).height, 16);
expect(
tester.getRect(blurInput).top - tester.getRect(blurLabel).bottom,
4,
);
expect(tester.getRect(blurLabel).top - tester.getRect(xField).bottom, 12);
expect(
tester.getRect(colorLabel).top - tester.getRect(blurInput).bottom,
12,
);
expect(tester.widget<Text>(blurLabel).style!.fontSize, 11);
expect(
tester.widget<Text>(blurLabel).style!.color,
Colors.white.withValues(alpha: .7),
);
expect(tester.widget<TextField>(xField).style!.fontSize, 11);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await settle();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await settle();
expect(find.byKey(ValueKey('shadow-editor-$a')), findsNothing);
await enter(b, 'blur', '20');
expect(current().animated, isFalse);
expect(current().layers[0].shadow.x, 12);
expect(current().layers[1].shadow.blur, 20);
await enter(a, 'color', 'FF8800');
expect(current().layers.first.shadow.red, 1);
expect(
tester.getSize(find.byKey(ValueKey('shadow-$a-color'))).width,
closeTo(
2 * tester.getSize(find.byKey(ValueKey('shadow-$a-opacity'))).width,
.01,
),
);
await tester.tap(find.byKey(const ValueKey('shadow-color-swatch')));
await settle();
final plane = tester.getRect(
find.byKey(const ValueKey('shadow-color-plane')),
);
await tester.tapAt(plane.topCenter + const Offset(0, 2));
await settle();
expect(current().layers.first.shadow.blue, greaterThan(.45));
expect(find.byKey(const ValueKey('shadow-color-plane')), findsOneWidget);
view.undo();
await settle();
expect(current().layers.first.shadow.green, closeTo(136 / 255, .001));
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await settle();
expect(find.byKey(const ValueKey('shadow-color-plane')), findsNothing);
await enter(a, 'blur', '-1');
expect(current().layers.first.shadow.blur, 8);
await tap(const ValueKey('shadow-key'));
expect(current().keyed, isTrue);
expect(current().parameterIds.length, 16);
expect(
current().parameterIds.every(
(id) => current().record.parameters?[id]?.length == 1,
),
isTrue,
);
view.seekTo(2 * TimelineClock.ticksPerSecond);
await settle();
await enter(a, 'x', '32');
await enter(b, 'blur', '40');
expect(
current().parameterIds.every(
(id) => current().record.parameters?[id]?.length == 2,
),
isTrue,
);
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
expect(current().layers[0].shadow.x, 22);
expect(current().layers[1].shadow.blur, 30);
final blurField = find.descendant(
of: find.byKey(ValueKey('shadow-$b-blur')),
matching: find.byType(TextField),
);
expect(tester.widget<TextField>(blurField).controller!.text, '30');
view.seekTo(0);
f.timeline.commands.editKeyframeChannel(
sequence: seq,
clip: clip,
tick: 0,
parameterIds: current().parameterIds,
action: KeyframeAction.set,
interpolation: ParameterInterpolation.hold,
);
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
expect(current().layers.first.shadow.x, 12);
expect(current().layers.last.shadow.blur, 20);
view.undo();
await settle();
expect(current().layers.first.shadow.x, 22);
f.timeline.commands.editKeyframeChannel(
sequence: seq,
clip: clip,
tick: view.playheadTick,
parameterIds: current().parameterIds,
action: KeyframeAction.clear,
);
await settle();
expect(current().animated, isFalse);
expect(current().layers.first.shadow.x, 22);
view.undo();
await settle();
expect(current().animated, isTrue);
final before = current()
.record
.parameters?[ShadowParameterTarget(a, 'x').parameterId];
await closeEditor();
final dragWidget = find.byKey(ValueKey('shadow-drag-$a'));
expect(
tester.widget<ReorderableDragStartListener>(dragWidget).enabled,
isTrue,
);
final drag = tester.getCenter(dragWidget);
final gesture = await tester.startGesture(drag);
await tester.pump();
await gesture.moveBy(const Offset(0, 12));
await tester.pump();
await gesture.moveBy(const Offset(0, 80));
await tester.pump(const Duration(milliseconds: 300));
await gesture.up();
await settle();
expect(current().layers.map((l) => l.id), [b, a]);
expect(
current().record.parameters?[ShadowParameterTarget(a, 'x').parameterId],
same(before),
);
await tap(ValueKey('shadow-enabled-$b'));
expect(current().layers.first.enabled, isFalse);
await tap(ValueKey('shadow-remove-$a'));
expect(current().layers.length, 1);
expect(
current().record.parameters?[ShadowParameterTarget(a, 'x').parameterId],
isNull,
);
view.undo();
await settle();
expect(current().layers.length, 2);
expect(current().layers.last.shadow.x, 22);
await tap(const ValueKey('shadow-add'));
final c = current().layers.last.id;
expect(
current()
.record
.parameters?[ShadowParameterTarget(c, 'x').parameterId]
?.length,
2,
);
await tap(const ValueKey('shadow-add'));
expect(current().layers.length, 4);
expect(
tester
.widget<IconButton>(find.byKey(const ValueKey('shadow-add')))
.onPressed,
isNull,
);
expect(
() => f.timeline.commands.addShadow(
sequence: seq,
clip: clip,
tick: view.playheadTick,
shadowId: 'fifth',
),
throwsA(isA<CommandRejected>()),
);
await tester.tap(find.byKey(ValueKey('shadow-settings-$a')));
await settle();
await tester.tapAt(const Offset(50, 500));
await settle();
expect(find.byKey(ValueKey('shadow-editor-$a')), findsNothing);
await tester.tap(find.byKey(ValueKey('shadow-settings-$a')));
await settle();
f.timeline.commands.removeShadow(
sequence: seq,
clip: clip,
tick: view.playheadTick,
shadowId: a,
);
await settle();
expect(find.byKey(ValueKey('shadow-editor-$a')), findsNothing);
view.undo();
await settle();
expect(current().layers.length, 4);
final compiled = const ExecutionCompiler().compile(
ExecutionInput(
timeline: f.timeline.persistence.timeline(seq),
renderSize: RenderSize(64, 64),
media: {
PayloadRef('source'): ExecutionMediaBinding(
media: MediaReference(
id: 'media',
uri: Uri.file('/test/video.mov'),
),
videoTrackSelection: TrackSelection.index(0),
),
},
parameterTargets: ClipTransform.targets,
),
);
expect(
compiled.plan.visualLayers.single.automation.map((a) => a.target),
contains(ShadowParameterTarget(a, 'x').parameterId),
);
expect(
compiled.plan.visualLayers.single.automation
.firstWhere(
(c) => c.target == ShadowParameterTarget(a, 'x').parameterId,
)
.keys
.length,
2,
);
// Existing persistence serializes all curves and feeds execution bindings unchanged.
final saved = await tester.runAsync(
() => f.workspace.project!.loadTimeline('project'),
);
expect(
saved!.sequences.first.elements.first.parameters.map(
(p) => p.definition.id,
),
contains(ShadowParameterTarget(a, 'x').parameterId),
);
await tester.pumpWidget(
ProviderScope(
overrides: [
editorPreviewProvider(
project,
'project',
).overrideWith((ref) => null),
],
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('zh'),
theme: AppTheme.propertiesPanelTheme(
EditorTheme.desktop(EditorTheme.penDark),
),
home: Scaffold(
body: SizedBox(
width: 240,
child: SingleChildScrollView(
child: PictureProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: seq,
clip: current().record,
animationView: true,
),
),
),
),
),
),
);
await settle();
expect(
find.byKey(const ValueKey('picture-key-marker-shadow-0')),
findsOneWidget,
);
expect(
find.byKey(
const ValueKey(
'picture-key-marker-shadow-${2 * TimelineClock.ticksPerSecond}',
),
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox());
},
);
test(
'shadow validation and retimed group keys use the existing source clock',
() {
expect(const ClipShadow(blur: -1).isValid, isFalse);
expect(const ClipShadow(opacity: 2).isValid, isFalse);
expect(const ClipShadow(x: double.nan).isValid, isFalse);
expect(RenderShadowTarget.parse('shadow.a.color.r')?.field, 'color.r');
expect(isRenderVisualTarget('shadow.a.blur'), isTrue);
expect(isRenderVisualTarget('shadow.a.invalid'), isFalse);
expect(ShadowParameterTarget.parse('shadow.中文.x'), isNull);
for (final delta in [8, -8]) {
final record = ElementRecord(
id: ElementId('clip'),
structure: ElementStructure.content,
duration: 4 * TimelineClock.ticksPerSecond,
sourceStart: 10 * TimelineClock.ticksPerSecond,
sourceDuration: 8 * TimelineClock.ticksPerSecond,
enabled: true,
retime: RetimeMapRecord([
RetimeSegmentRecord(
projectDuration: 4 * TimelineClock.ticksPerSecond,
sourceStart: 10 * TimelineClock.ticksPerSecond,
sourceDelta: delta * TimelineClock.ticksPerSecond,
),
]),
);
expect(
ClipShadowStack(record, TimelineClock.ticksPerSecond).sourceTick,
(10 + delta ~/ 4) * TimelineClock.ticksPerSecond,
);
}
},
);
}
+4 -4
View File
@@ -58,7 +58,7 @@ void main() {
tester
.getSize(find.byKey(const ValueKey('project-settings-edit')))
.height,
28,
24,
);
final rows = find.byWidgetPredicate(
(widget) => widget.runtimeType.toString() == '_Info',
@@ -86,7 +86,7 @@ void main() {
);
expect(
tester.getRect(value).right,
panelRight - AppInspectorMetrics.padding,
panelRight - AppInspectorMetrics.trailingPadding,
reason: '$locale at $width: ${tester.widget<Text>(value).data}',
);
}
@@ -144,8 +144,8 @@ void main() {
of: find.byWidget(row.widget),
matching: find.byType(Text),
);
expect(tester.getRect(texts.first).left, 12);
expect(tester.getRect(texts.last).right, width - 12);
expect(tester.getRect(texts.first).left, 16);
expect(tester.getRect(texts.last).right, width - 8);
expect(
tester.getTopLeft(texts.first).dy,
closeTo(tester.getTopLeft(texts.last).dy, .01),
+1 -1
View File
@@ -54,7 +54,7 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(tester.getSize(find.byType(TextField)).height, 28);
expect(tester.getSize(find.byType(TextField)).height, 24);
expect(
tester
.getRect(
+2 -2
View File
@@ -2023,7 +2023,7 @@ void main() {
matching: find.byType(ListView),
),
);
expect(row.left - list.left, desktop ? 12 : 14);
expect(row.left - list.left, desktop ? 16 : 14);
expect(number.left - row.left, 0);
expect(content.left - number.right, 6);
expect(number.right, lessThan(content.left));
@@ -2045,7 +2045,7 @@ void main() {
final wrapBounds = tester.getRect(
find.byKey(const ValueKey('caption-wrap-toggle')),
);
expect(searchBounds.height, 28);
expect(searchBounds.height, desktop ? 24 : 28);
expect(wrapBounds.height, desktop ? 24 : 28);
expect(searchBounds.center.dy, wrapBounds.center.dy);
await tester.enterText(search, ' searchable ');