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
157 lines
5.8 KiB
Dart
157 lines
5.8 KiB
Dart
import 'package:cutdex/app/editor_theme.dart';
|
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
import 'package:cutdex/features/properties/stroke_properties.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(
|
|
'stroke weight 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;
|
|
ClipStrokeStack current() {
|
|
final query = view.version.kernelVersion.query();
|
|
final handle = query.elementById(clip)!;
|
|
return ClipStrokeStack(
|
|
query.element(handle),
|
|
view.playheadTick - query.absoluteStart(handle),
|
|
);
|
|
}
|
|
|
|
for (final id in ['a', 'b']) {
|
|
commands.addStroke(
|
|
sequence: sequence,
|
|
clip: clip,
|
|
tick: 0,
|
|
strokeId: id,
|
|
);
|
|
}
|
|
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: StrokeProperties(
|
|
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('stroke-settings-a')));
|
|
await settle();
|
|
await tester.tap(find.byKey(const ValueKey('stroke-a-width-key')));
|
|
await settle();
|
|
final blurId = const StrokeParameterTarget('a', 'width').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('stroke-a-width')),
|
|
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['width'], 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['width'], 1);
|
|
expect(current().layers.first.values['width'], closeTo(10.5, .001));
|
|
await settle();
|
|
// Structural selectors and dash fields update statically without keyframe controls.
|
|
await tester.tap(find.byKey(const ValueKey('stroke-a-alignment')));
|
|
await settle();
|
|
await tester.tap(find.text('外侧').last);
|
|
await settle();
|
|
expect(current().layers.first.alignment, ClipStrokeAlignment.outside);
|
|
expect(
|
|
find.byKey(const ValueKey('stroke-a-alignment-key')),
|
|
findsNothing,
|
|
);
|
|
await tester.tap(find.byKey(const ValueKey('stroke-a-style')));
|
|
await settle();
|
|
await tester.tap(find.text('虚线').last);
|
|
await settle();
|
|
expect(find.byKey(const ValueKey('stroke-a-dashLength')), findsOneWidget);
|
|
expect(
|
|
find.byKey(const ValueKey('stroke-a-dashLength-key')),
|
|
findsNothing,
|
|
);
|
|
expect(find.textContaining('px'), findsNothing);
|
|
await tester.tap(find.byKey(const ValueKey('stroke-editor-close-a')));
|
|
await settle();
|
|
await tester.tap(find.byKey(const ValueKey('stroke-enabled-a')));
|
|
await settle();
|
|
expect(current().layers.first.enabled, isFalse);
|
|
await tester.tap(find.byKey(const ValueKey('stroke-add')));
|
|
await settle();
|
|
expect(current().layers.length, 3);
|
|
await tester.tap(find.byKey(const ValueKey('stroke-remove-a')));
|
|
await settle();
|
|
expect(current().layers.map((l) => l.id), isNot(contains('a')));
|
|
expect(current().record.parameters?[blurId], isNull);
|
|
await tester.pumpWidget(const SizedBox());
|
|
},
|
|
);
|
|
}
|