refactor(core): own editor UI and pin verified native releases
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

This commit is contained in:
lingjhf committed 2026-10-12 03:20:29 +08:00
1 parent 796a3852a2
commit 38ca180cf7
354 files changed
+29841 -642

No files matched your search

@@ -0,0 +1,100 @@
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/main.dart';
void main() {
const second = TimelineClock.ticksPerSecond;
final toggle = find.byKey(const Key('playback-toggle'));
TimelineViewController controller(WidgetTester tester) => tester
.widget<TimelineView>(find.byKey(const Key('timeline-surface')))
.controller;
testWidgets('play, pause and resume advance only presentation time', (
tester,
) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
final original = c.version;
c.seekTo(2 * second);
await tester.tap(toggle);
await tester.pump();
await tester.pump(const Duration(seconds: 2));
expect(c.playheadTick, 4 * second);
expect(find.byTooltip('暂停 / Pause'), findsOneWidget);
await tester.tap(toggle);
await tester.pump(const Duration(seconds: 3));
expect(c.playheadTick, 4 * second);
expect(find.byTooltip('播放 / Play'), findsOneWidget);
await tester.tap(toggle);
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(c.playheadTick, 4 * second + second ~/ 2);
expect(c.version, same(original));
expect(c.canUndo, isFalse);
await tester.pumpWidget(const SizedBox());
expect(tester.takeException(), isNull);
});
testWidgets('seek rebases playback; end pauses and play restarts', (
tester,
) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
final end = c.version.kernelVersion.query().storylineSpan(c.storyline);
await tester.tap(toggle);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
c.seekTo(10 * second);
await tester.pump(const Duration(seconds: 1));
expect(c.playheadTick, 11 * second);
c.seekTo(end - second ~/ 2);
await tester.pump(const Duration(seconds: 1));
expect(c.playheadTick, end);
expect(find.byTooltip('播放 / Play'), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
expect(c.playheadTick, end);
await tester.tap(toggle);
await tester.pump();
expect(c.playheadTick, 0);
await tester.pump(const Duration(seconds: 1));
expect(c.playheadTick, second);
await tester.pumpWidget(const SizedBox());
});
testWidgets('scene switch pauses the previous playhead', (tester) async {
await tester.pumpWidget(const TimelineExampleApp());
final short = controller(tester);
await tester.tap(toggle);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.tap(find.byTooltip('切换场景 / Switch scene'));
await tester.pump();
await tester.pump(const Duration(milliseconds: 300));
await tester.tap(find.text('3 小时 / 3 hours'));
await tester.pump();
final stopped = short.playheadTick;
await tester.pumpAndSettle();
expect(controller(tester), isNot(same(short)));
expect(find.byTooltip('播放 / Play'), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
expect(short.playheadTick, stopped);
expect(controller(tester).playheadTick, 0);
});
testWidgets('backgrounding pauses playback', (tester) async {
await tester.pumpWidget(const TimelineExampleApp());
final c = controller(tester);
await tester.tap(toggle);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
await tester.pump(const Duration(seconds: 2));
expect(c.playheadTick, second);
expect(find.byTooltip('播放 / Play'), findsOneWidget);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
await tester.pump(const Duration(seconds: 1));
expect(c.playheadTick, second);
});
}