Files
cutdex/test/picture_effect_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

200 lines
6.8 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/preview/preview_panel.dart';
import 'package:cutdex/features/properties/effect_properties.dart';
import 'package:cutdex/features/properties/effect_labels.dart';
import 'package:cutdex/l10n/app_localizations.dart';
import 'package:cutdex_core/editor.dart';
import 'package:cutdex_core/timeline/model.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(
'blur input and keyframe control edit only the selected property',
(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');
final view = f.timeline.view(sequence);
final commands = f.timeline.commands;
ClipEffectStack current() {
final query = view.version.kernelVersion.query();
final handle = query.elementById(clip)!;
return ClipEffectStack(
query.element(handle),
view.playheadTick - query.absoluteStart(handle),
);
}
for (final id in ['a', 'b']) {
commands.addEffect(
sequence: sequence,
clip: clip,
tick: 0,
effectId: id,
type: ClipEffectType.dropShadow,
);
}
final project = f.workspace.project!.info.id;
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: EffectProperties(
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();
await tester.tap(find.byKey(const ValueKey('effect-settings-a')));
await settle();
await tester.tap(find.byKey(const ValueKey('effect-a-blur-key')));
await settle();
final blurId = const EffectParameterTarget('a', 'blur').parameterId;
expect(current().record.parameters?[blurId]?.length, 1);
for (final id in current().parameterIds.where((id) => id != blurId)) {
expect(current().record.parameters?[id]?.length, 0);
}
view.seekTo(TimelineClock.ticksPerSecond);
await settle();
final input = find.descendant(
of: find.byKey(const ValueKey('effect-a-blur')),
matching: find.byType(TextField),
);
await tester.enterText(input, '20');
await tester.testTextInput.receiveAction(TextInputAction.done);
await settle();
expect(current().record.parameters?[blurId]?.length, 2);
expect(current().layers.first.values['blur'], 20);
for (final id in current().parameterIds.where((id) => id != blurId)) {
expect(current().record.parameters?[id]?.length, 0);
}
view.seekTo(TimelineClock.ticksPerSecond ~/ 2);
expect(current().layers.last.values['blur'], 8);
expect(current().layers.first.values['blur'], closeTo(14, .001));
await settle();
await tester.pumpWidget(const SizedBox());
},
);
for (final type in ClipEffectType.values) {
testWidgets('${type.name} exposes valid controls at 240 width', (
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 sequence = SequenceId('one'), clip = ElementId('clip');
f.timeline.commands.addEffect(
sequence: sequence,
clip: clip,
tick: 0,
effectId: 'test',
type: type,
);
final project = f.workspace.project!.info.id;
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: EffectProperties(
projectId: project,
timelineId: 'project',
session: f.timeline,
sequence: sequence,
clip: clip,
),
),
),
),
),
),
),
);
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('effect-settings-test')));
await tester.runAsync(f.timeline.flush);
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('effect-editor-test')), findsOneWidget);
expect(
find.text(type.label(tester.element(find.byType(EffectProperties)))),
findsWidgets,
);
expect(tester.takeException(), isNull);
await tester.runAsync(f.timeline.flush);
await tester.pumpWidget(const SizedBox());
});
}
}