Files
cutdex/test/fullscreen_playback_bar_test.dart
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +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_sdk/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);
});
}