Files
cutdex/test/picture_distortion_test.dart
T
lingjhf 789af7a68e feat(inspector): edit animated effects, strokes and corner distortion
Replace the shadow-only inspector with layered effect and stroke controls and per-corner distortion editors. Share color inputs, layer rows, keyframe controls and property edit boundaries; keep nested selection menus within their property popover and update localized labels.

Add property editing, preview interaction and benchmark comparison coverage. Validation: Dart analysis reports no issues and 160 targeted application tests pass. The macOS development app was rebuilt and visually checked during native rendering validation. Exclude local dependency override changes from the committed lockfile.
2026-10-10 16:55:27 +08:00

124 lines
4.3 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/distortion_properties.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex_sdk/editor.dart';
import 'package:cutdex_sdk/timeline/model.dart';
import 'package:cutdex_sdk/timeline/engine.dart';
import 'package:cutdex_ui/theme.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(
'four corner fields use paired keys; reset preserves animation; no px',
(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'),
clip = ElementId('clip'),
project = f.workspace.project!.info.id;
final view = f.timeline.view(sequence);
ElementRecord record() {
final q = view.version.kernelVersion.query();
return q.element(q.elementById(clip)!);
}
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: DistortionProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: sequence,
clip: clip,
),
),
),
),
),
),
),
);
Future<void> settle() async {
await tester.pump();
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
await settle();
expect(find.text('变形'), findsOneWidget);
expect(find.text('px'), findsNothing);
expect(find.text('X'), findsNWidgets(4));
expect(find.text('Y'), findsNWidgets(4));
expect(find.byType(TextField), findsNWidgets(8));
final key = find.byKey(const ValueKey('distortion-topLeft-key'));
await tester.tap(key);
await settle();
for (final id in ClipDistortion.ids.take(2)) {
expect(record().parameters![id]!.length, 1);
}
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
final input = find.descendant(
of: find.byKey(const ValueKey('distortion-topLeft-y')),
matching: find.byType(TextField),
);
await tester.enterText(input, '20');
await tester.testTextInput.receiveAction(TextInputAction.done);
await settle();
for (final id in ClipDistortion.ids.take(2)) {
expect(record().parameters![id]!.length, 2);
}
final y = record().parameters![ClipDistortion.ids[1]]!;
expect(y.valueAt(TimelineClock.ticksPerSecond), greaterThan(0));
for (final id in ClipDistortion.ids.skip(2)) {
expect(record().parameters?[id]?.length ?? 0, 0);
}
await tester.tap(find.byKey(const ValueKey('distortion-reset')));
await settle();
expect(record().parameters![ClipDistortion.ids[1]]!.length, 2);
expect(
record().parameters![ClipDistortion.ids[1]]!.valueAt(
TimelineClock.ticksPerSecond,
),
0,
);
await tester.pumpWidget(const SizedBox());
},
);
}