Files
cutdex/test/fullscreen_playback_bar_test.dart
T
lingjhf 38ca180cf7
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
refactor(core): own editor UI and pin verified native releases
2026-10-12 03:20:29 +08:00

116 lines
3.8 KiB
Dart

import 'package:cutdex/app/editor_theme.dart';
import 'package:cutdex/features/preview/fullscreen_playback_bar.dart';
import 'package:cutdex/l10n/l10n.dart';
import 'package:cutdex_core/timeline/model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'fullscreen transport previews during dragging and settles on release',
(tester) async {
final seeks = <int>[];
final updates = <int>[];
final ends = <int>[];
var starts = 0;
var plays = 0;
var exits = 0;
const second = TimelineClock.ticksPerSecond;
await tester.pumpWidget(
MaterialApp(
theme: EditorTheme.penDark,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
home: Scaffold(
body: Center(
child: SizedBox(
width: 560,
child: FullscreenPlaybackBar(
positionTick: second,
durationTick: 48 * 60 * second,
frameTick: second ~/ 30,
playing: false,
onPlayPause: () => plays++,
onSeek: seeks.add,
onExit: () => exits++,
onScrubStart: () => starts++,
onScrubUpdate: updates.add,
onScrubEnd: ends.add,
),
),
),
),
),
);
expect(find.text('00:01'), findsOneWidget);
expect(find.text('-47:59'), findsOneWidget);
await tester.tap(find.byTooltip('Play'));
await tester.tap(find.byTooltip('Exit fullscreen'));
expect(plays, 1);
expect(exits, 1);
await tester.tap(find.byTooltip('Previous frame'));
await tester.tap(find.byTooltip('Next frame'));
expect(seeks, [second - second ~/ 30, second + second ~/ 30]);
seeks.clear();
final rect = tester.getRect(find.byKey(const Key('fullscreen-progress')));
final gesture = await tester.startGesture(
Offset(rect.left + 20, rect.center.dy),
);
await gesture.moveTo(rect.center);
await tester.pump();
expect(seeks, isEmpty);
expect(starts, 1);
expect(updates, isNotEmpty);
expect(updates.last, closeTo(24 * 60 * second, second));
expect(ends, isEmpty);
await gesture.up();
await tester.pump();
expect(ends, hasLength(1));
expect(ends.single, closeTo(24 * 60 * second, second));
await tester.tap(find.byTooltip('Go to start'));
expect(seeks.last, 0);
expect(tester.takeException(), isNull);
},
);
testWidgets('empty fullscreen transport stays usable at narrow widths', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
home: Scaffold(
body: Center(
child: SizedBox(
width: 280,
child: FullscreenPlaybackBar(
positionTick: 0,
durationTick: 0,
frameTick: TimelineClock.ticksPerSecond ~/ 30,
playing: false,
onPlayPause: null,
onSeek: null,
onExit: () {},
onScrubStart: null,
onScrubUpdate: null,
onScrubEnd: null,
),
),
),
),
),
);
expect(tester.widget<Slider>(find.byType(Slider)).onChanged, isNull);
expect(
tester
.widget<IconButton>(find.byKey(const Key('preview-fullscreen')))
.onPressed,
isNotNull,
);
expect(tester.takeException(), isNull);
});
}