The presenter view now doubles as a rehearsal clock that measures without coaching: a countdown against a target time, the time spent on the current slide, and an end-of-run summary (total vs. target and per-slide times, with copy-to-clipboard). Timing lives in a plain, unit-tested RehearsalController fed via an idempotent observe() on every build, so it captures every navigation path. The default target is stored in AppSettings; live adjustment is the K key (typed as MMSS). All rehearsal state is session-only -- nothing is written to disk or into the .md file. - New: models/rehearsal.dart, services/rehearsal_controller.dart, widgets/presentation/rehearsal_summary.dart, plus a controller unit test. - Presenter: countdown + per-slide timer in the clock bar, K to set the target, R resets the run, end-of-run summary dialog, and help/cheatsheet entries. - Settings: presentationTargetSeconds (default target) with a dropdown in the General tab, threaded into FullscreenPresenter.present(). - l10n: new Dutch source strings translated in all seven languages. - Docs: README, CHANGELOG, USER_GUIDE, SHORTCUTS, ARCHITECTURE. Also bundles a pre-existing in-progress change already in the working tree: wire the existing ThemeProfile.tableHeaderBackgroundColor into table rendering (preview, HTML export, file_service) and the settings dialog, plus its translations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
90 lines
3.2 KiB
Dart
90 lines
3.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:ocideck/services/rehearsal_controller.dart';
|
|
|
|
void main() {
|
|
// Bestuurbare klok zodat de timing deterministisch is.
|
|
late DateTime now;
|
|
DateTime clock() => now;
|
|
|
|
setUp(() => now = DateTime(2026, 1, 1, 10, 0, 0));
|
|
void advance(Duration d) => now = now.add(d);
|
|
|
|
test('elapsed loopt met de klok mee', () {
|
|
final c = RehearsalController(now: clock);
|
|
expect(c.elapsed, Duration.zero);
|
|
advance(const Duration(seconds: 90));
|
|
expect(c.elapsed, const Duration(seconds: 90));
|
|
});
|
|
|
|
test('per-slide-tijd telt op per slide en houdt volgorde aan', () {
|
|
final c = RehearsalController(now: clock);
|
|
c.observe('a', 0);
|
|
advance(const Duration(seconds: 30));
|
|
c.observe('b', 1);
|
|
advance(const Duration(seconds: 20));
|
|
c.observe('a', 0); // terug naar a
|
|
advance(const Duration(seconds: 10));
|
|
|
|
final run = c.finish();
|
|
expect(run.total, const Duration(seconds: 60));
|
|
expect(run.perSlide.map((t) => t.slideId).toList(), ['a', 'b']);
|
|
expect(run.perSlide[0].spent, const Duration(seconds: 40)); // 30 + 10
|
|
expect(run.perSlide[1].spent, const Duration(seconds: 20));
|
|
});
|
|
|
|
test('observe is idempotent: dezelfde slide sluit niet af', () {
|
|
final c = RehearsalController(now: clock);
|
|
c.observe('a', 0);
|
|
advance(const Duration(seconds: 5));
|
|
c.observe('a', 0); // geen wissel
|
|
advance(const Duration(seconds: 5));
|
|
expect(c.currentSlideElapsed, const Duration(seconds: 10));
|
|
});
|
|
|
|
test('aftelling: resterend wordt negatief na de doeltijd', () {
|
|
final c = RehearsalController(now: clock, target: const Duration(minutes: 1));
|
|
advance(const Duration(seconds: 40));
|
|
expect(c.remaining, const Duration(seconds: 20));
|
|
advance(const Duration(seconds: 30));
|
|
expect(c.remaining, const Duration(seconds: -10));
|
|
});
|
|
|
|
test('geen doeltijd → geen resterende tijd; nul-target zet aftelling uit', () {
|
|
final c = RehearsalController(now: clock);
|
|
expect(c.remaining, isNull);
|
|
c.target = Duration.zero;
|
|
expect(c.target, isNull);
|
|
c.target = const Duration(minutes: 5);
|
|
expect(c.target, const Duration(minutes: 5));
|
|
});
|
|
|
|
test('reset wist run en per-slide-tijden, behoudt doeltijd', () {
|
|
final c = RehearsalController(now: clock, target: const Duration(minutes: 1));
|
|
c.observe('a', 0);
|
|
advance(const Duration(seconds: 30));
|
|
c.reset();
|
|
expect(c.elapsed, Duration.zero);
|
|
expect(c.target, const Duration(minutes: 1));
|
|
// Na reset is er nog geen geregistreerde slide.
|
|
advance(const Duration(seconds: 5));
|
|
expect(c.finish().perSlide, isEmpty);
|
|
});
|
|
|
|
test('hasMeaningfulData vereist een slide én ≥10s', () {
|
|
final c = RehearsalController(now: clock);
|
|
expect(c.hasMeaningfulData, isFalse);
|
|
c.observe('a', 0);
|
|
advance(const Duration(seconds: 9));
|
|
expect(c.hasMeaningfulData, isFalse);
|
|
advance(const Duration(seconds: 1));
|
|
expect(c.hasMeaningfulData, isTrue);
|
|
});
|
|
|
|
test('delta beschrijft over/onder de doeltijd', () {
|
|
final c = RehearsalController(now: clock, target: const Duration(minutes: 1));
|
|
c.observe('a', 0);
|
|
advance(const Duration(seconds: 70));
|
|
final run = c.finish();
|
|
expect(run.delta, const Duration(seconds: 10)); // over de tijd
|
|
});
|
|
}
|