Move editor UI into the app and release verified Core dependencies (#14)
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

This commit was merged in pull request #14.
This commit is contained in:
lingjhf committed 2026-10-11 19:59:40 +00:00
1 parent abc1868550
commit 06f1c26681
452 files changed
+43806 -2329

No files matched your search

@@ -0,0 +1,249 @@
import 'dart:math' as math;
import 'package:cutdex_core/timeline/layout.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:timeline_ui_example/demo_timeline.dart';
import 'package:timeline_ui_example/main.dart';
Finder thumb(Axis axis) => find.byKey(ValueKey('timeline-${axis.name}-thumb'));
Finder bar(Axis axis) =>
find.byKey(ValueKey('timeline-${axis.name}-scrollbar'));
final surface = find.byKey(const Key('timeline-surface'));
TimelineViewController controller(WidgetTester tester) =>
tester.widget<TimelineView>(surface).controller;
void main() {
testWidgets('scrollbar navigation then clip drop uses the current camera', (
tester,
) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
final g = await tester.startGesture(
tester.getCenter(thumb(Axis.horizontal)),
);
await g.moveBy(const Offset(30, 0));
await g.up();
await tester.pump();
const second = TimelineClock.ticksPerSecond;
final v = TimelineViewportRect(
width: tester.getSize(surface).width,
height: tester.getSize(surface).height,
);
final id = c.version.kernelVersion.query().elementById(ElementId('title'))!;
final point = Offset(
c.camera.screenXForTick(3 * second, v),
c.camera.screenYForWorld(100, v),
);
final clip = await tester.startGesture(tester.getTopLeft(surface) + point);
await clip.moveBy(Offset(2 * second * c.camera.pixelsPerTick, 0));
await clip.up();
await tester.pump();
expect(
c.version.kernelVersion.query().absoluteStart(id),
closeTo(4 * second, 1),
);
expect(c.canUndo, isTrue);
expect(tester.takeException(), isNull);
});
for (final axis in Axis.values) {
testWidgets('$axis thumb drag pans only that axis and retains roots', (
tester,
) async {
final c = createDemoController();
addTearDown(c.dispose);
await tester.pumpWidget(
MaterialApp(
home: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 400,
height: 120,
child: TimelineViewport(
controller: c,
showRuler: false,
child: const SizedBox.expand(),
),
),
),
),
);
await tester.pumpAndSettle();
// Begin at the start of both scroll ranges with guaranteed overflow.
c.panBy(horizontalPixels: -200, verticalPixels: -300);
await tester.pump();
final before = c.camera;
final version = c.version;
final initial = tester.getRect(thumb(axis));
final gesture = await tester.startGesture(initial.center);
final delta = axis == Axis.horizontal
? const Offset(35, 0)
: const Offset(0, 35);
await gesture.moveBy(delta);
await tester.pump();
final moved = tester.getRect(thumb(axis));
expect(moved.width, closeTo(initial.width, 1e-6));
expect(moved.height, closeTo(initial.height, 1e-6));
expect((moved.topLeft - initial.topLeft).distance, closeTo(35, 1e-6));
await gesture.up();
await tester.pump();
if (axis == Axis.horizontal) {
expect(c.camera.baseTick, greaterThan(before.baseTick));
expect(c.camera.verticalOffset, before.verticalOffset);
} else {
expect(c.camera.verticalOffset, greaterThan(before.verticalOffset));
expect(c.camera.baseTick, before.baseTick);
expect(c.camera.fractionalTick, before.fractionalTick);
}
expect(c.version, same(version));
expect(c.canUndo, isFalse);
expect(c.selectedIdentities, isEmpty);
expect(tester.takeException(), isNull);
});
}
testWidgets('zoom resizes thumb, pan updates position, track click pages', (
tester,
) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
final width = tester.getSize(thumb(Axis.horizontal)).width;
c.navigate(
from: Offset.zero,
to: Offset.zero,
scale: 2,
viewport: TimelineViewportRect(
width: tester.getSize(surface).width,
height: 0,
),
);
await tester.pump();
expect(tester.getSize(thumb(Axis.horizontal)).width, lessThan(width));
final left = tester.getTopLeft(thumb(Axis.horizontal)).dx;
c.panBy(horizontalPixels: 100);
await tester.pump();
expect(tester.getTopLeft(thumb(Axis.horizontal)).dx, greaterThan(left));
final before = c.camera;
final track = tester.getRect(bar(Axis.horizontal));
await tester.tapAt(Offset(track.right - 2, track.center.dy));
await tester.pump();
expect(c.camera.baseTick, greaterThan(before.baseTick));
expect(c.canUndo, isFalse);
});
testWidgets('external zoom during thumb drag cannot restore stale camera', (
tester,
) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
final gesture = await tester.startGesture(
tester.getCenter(thumb(Axis.horizontal)),
);
await gesture.moveBy(const Offset(25, 0));
await tester.pump();
c.navigate(
from: Offset.zero,
to: Offset.zero,
scale: 2,
viewport: TimelineViewportRect(
width: tester.getSize(surface).width,
height: 0,
),
);
await tester.pump();
final zoomed = c.camera;
await gesture.moveBy(const Offset(25, 0));
await gesture.up();
expect(c.camera, same(zoomed));
});
testWidgets('small and fitting viewports remain finite and do not scroll', (
tester,
) async {
final c = createDemoController();
addTearDown(c.dispose);
c.setCamera(
TimelineCamera(baseTick: 0, pixelsPerTick: c.camera.pixelsPerTick / 100),
);
await tester.pumpWidget(
MaterialApp(
home: TimelineViewport(
controller: c,
showRuler: false,
child: const SizedBox.expand(),
),
),
);
expect(thumb(Axis.vertical), findsNothing);
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox(
width: 8,
height: 8,
child: TimelineViewport(
showRuler: false,
controller: c,
child: const SizedBox.expand(),
),
),
),
),
);
expect(tester.takeException(), isNull);
});
test(
'scroll extent getters agree with body scans and projected placements',
() {
final c = createDemoController();
addTearDown(c.dispose);
final v = c.version;
for (final entry in v.rangeIndexRoot.entries) {
final bodies = v.partitionBodies[entry.key]!.map(
(id) => v.scene.bodies[id]!,
);
if (bodies.isEmpty) {
expect(entry.value.timeBounds, isNull);
} else {
expect(entry.value.timeBounds, (
start: bodies.map((b) => b.start).reduce(math.min),
end: bodies.map((b) => b.end).reduce(math.max),
));
}
}
for (final entry in v.domainRoot.entries) {
final placements = v.placements.values.where(
(p) => p.partition.stack == entry.key,
);
for (final p in placements) {
final outer = entry.value.outerBoundary;
expect(outer <= p.top || outer >= p.top + p.height, isTrue);
}
}
},
);
test('scrollbar theme tokens copy and interpolate', () {
const a = TimelineThemeData.dark();
final b = a.copyWith(
scrollbarThickness: 20,
scrollbarThumbColor: Colors.red,
scrollbarTrackColor: Colors.blue,
);
expect(b, isNot(a));
expect(b.copyWith(), b);
expect(a.lerp(b, .5).scrollbarThickness, 16);
expect(
a.lerp(b, .5).scrollbarThumbColor,
Color.lerp(a.scrollbarThumbColor, Colors.red, .5),
);
expect(
a.lerp(b, .5).scrollbarTrackColor,
Color.lerp(a.scrollbarTrackColor, Colors.blue, .5),
);
});
}