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
136 lines
4.6 KiB
Dart
136 lines
4.6 KiB
Dart
import 'package:cutdex_core/editor.dart';
|
|
import 'package:cutdex_core/timeline/model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'support/preview_fixture.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
test(
|
|
'grouped keys interpolate, retain other channels, undo and persist',
|
|
() async {
|
|
final f = await createPreviewFixture(
|
|
Uri.file('/test/video.mov'),
|
|
clipDuration: RationalTime.seconds(5),
|
|
);
|
|
addTearDown(() async {
|
|
await f.workspace.close();
|
|
await f.directory.delete(recursive: true);
|
|
});
|
|
final id = SequenceId('one');
|
|
final clip = ElementId('clip');
|
|
final view = f.timeline.view(id);
|
|
ClipAnimation at(int second) {
|
|
final q = view.version.kernelVersion.query();
|
|
return ClipAnimation.at(
|
|
q,
|
|
q.elementById(clip)!,
|
|
second * TimelineClock.ticksPerSecond,
|
|
TimelineClock.ticksPerSecond ~/ 30,
|
|
);
|
|
}
|
|
|
|
void commit(List<ParameterCurveDto> curves) =>
|
|
f.timeline.commitParameters(
|
|
id,
|
|
f.timeline.previewParameters(id, clip, curves),
|
|
parameterTargets: ClipTransform.targets,
|
|
);
|
|
commit(at(0).toggle(TransformChannel.position));
|
|
commit(at(2).edit(at(2).value.copyWith(x: .4, y: .2)));
|
|
expect(at(1).value.x, closeTo(.2, 1e-10));
|
|
expect(at(1).value.y, closeTo(.1, 1e-10));
|
|
expect(at(2).keyed(TransformChannel.position), isTrue);
|
|
expect(at(0).keyTimes(TransformChannel.position), [
|
|
0,
|
|
2 * TimelineClock.ticksPerSecond,
|
|
]);
|
|
commit(at(1).edit(at(1).value.copyWith(rotation: 45)));
|
|
expect(at(0).value.rotation, 45);
|
|
expect(at(2).value.x, .4);
|
|
final before = view.version.kernelVersion;
|
|
commit(
|
|
at(0).setInterpolation(
|
|
TransformChannel.position,
|
|
ParameterInterpolation.hold,
|
|
),
|
|
);
|
|
expect(at(1).value.x, 0);
|
|
view.undo();
|
|
expect(view.version.kernelVersion, same(before));
|
|
expect(at(1).value.x, closeTo(.2, 1e-10));
|
|
view.redo();
|
|
expect(at(1).value.x, 0);
|
|
view.undo();
|
|
await f.timeline.flush();
|
|
final saved = await f.workspace.project!.loadTimeline('project');
|
|
final savedClip = saved.sequences.first.elements.single;
|
|
expect(
|
|
savedClip.parameters
|
|
.firstWhere((p) => p.definition.id == 'canvas.position.x')
|
|
.keyframes
|
|
.length,
|
|
2,
|
|
);
|
|
expect(
|
|
saved.settings['parameterTargets'],
|
|
containsPair('canvas.position.y', 'position.y'),
|
|
);
|
|
commit(at(2).toggle(TransformChannel.position));
|
|
expect(at(2).value.x, 0);
|
|
commit(at(0).toggle(TransformChannel.position));
|
|
expect(at(0).animated(TransformChannel.position), isFalse);
|
|
},
|
|
);
|
|
|
|
test(
|
|
'independent dimensions remain grouped and clearing holds evaluated values',
|
|
() async {
|
|
final f = await createPreviewFixture(
|
|
Uri.file('/test/video.mov'),
|
|
clipDuration: RationalTime.seconds(5),
|
|
);
|
|
addTearDown(() async {
|
|
await f.workspace.close();
|
|
await f.directory.delete(recursive: true);
|
|
});
|
|
final id = SequenceId('one');
|
|
final clip = ElementId('clip');
|
|
final view = f.timeline.view(id);
|
|
ClipAnimation at(int seconds) {
|
|
final q = view.version.kernelVersion.query();
|
|
return ClipAnimation.at(
|
|
q,
|
|
q.elementById(clip)!,
|
|
seconds * TimelineClock.ticksPerSecond,
|
|
TimelineClock.ticksPerSecond ~/ 30,
|
|
);
|
|
}
|
|
|
|
void commit(List<ParameterCurveDto> curves) =>
|
|
f.timeline.commitParameters(
|
|
id,
|
|
f.timeline.previewParameters(id, clip, curves),
|
|
parameterTargets: ClipTransform.targets,
|
|
);
|
|
commit(at(0).toggle(TransformChannel.scale));
|
|
commit(at(2).edit(at(2).value.copyWith(scaleY: 3)));
|
|
expect(at(1).value.scale, 1);
|
|
expect(at(1).value.scaleY, 2);
|
|
expect(at(2).keyed(TransformChannel.scale), isTrue);
|
|
commit(at(1).clear(TransformChannel.scale));
|
|
expect(at(0).animated(TransformChannel.scale), isFalse);
|
|
expect(at(0).value.scaleY, 2);
|
|
expect(at(4).value.scaleY, 2);
|
|
expect(at(5).containsPlayhead, isFalse);
|
|
expect(() => at(5).toggle(TransformChannel.scale), throwsStateError);
|
|
commit(at(2).toggle(TransformChannel.rotation));
|
|
commit(at(2).edit(at(2).value.copyWith(rotation: 90)));
|
|
commit(at(2).toggle(TransformChannel.rotation));
|
|
expect(at(0).animated(TransformChannel.rotation), isFalse);
|
|
expect(at(0).value.rotation, 90);
|
|
},
|
|
);
|
|
}
|