import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:ocideck/models/settings.dart'; import 'package:ocideck/models/slide.dart'; import 'package:ocideck/widgets/slides/slide_preview.dart'; Widget _host(Slide slide, ThemeProfile profile, {int? number, int? count}) { return MaterialApp( home: Scaffold( body: Center( child: SizedBox( width: 800, height: 450, child: SlidePreviewWidget( slide: slide, themeProfile: profile, slideNumber: number, slideCount: count, ), ), ), ), ); } void main() { testWidgets('footer renders text tokens and page numbers', (tester) async { const profile = ThemeProfile( footerText: 'Vertrouwelijk · {page}/{total}', footerShowPageNumbers: true, ); await tester.pumpWidget( _host( Slide.create(SlideType.bullets).copyWith(title: 'T', bullets: ['a']), profile, number: 2, count: 5, ), ); await tester.pump(); expect(find.text('Vertrouwelijk · 2/5'), findsOneWidget); expect(find.text('2 / 5'), findsOneWidget); // page-number block }); testWidgets('footer can be hidden on an individual slide', (tester) async { const profile = ThemeProfile( footerText: 'Vertrouwelijk', footerShowPageNumbers: true, ); await tester.pumpWidget( _host( Slide.create( SlideType.bullets, ).copyWith(title: 'T', bullets: ['a'], showFooter: false), profile, number: 2, count: 5, ), ); await tester.pump(); expect(find.text('Vertrouwelijk'), findsNothing); expect(find.text('2 / 5'), findsNothing); }); testWidgets('footer position can be left center or right', (tester) async { Future footerLeft(String position) async { await tester.pumpWidget( _host( Slide.create(SlideType.bullets).copyWith(title: 'T', bullets: ['a']), ThemeProfile(footerText: 'Voettekst', footerPosition: position), number: 1, count: 3, ), ); await tester.pump(); return tester.getTopLeft(find.text('Voettekst')).dx; } final left = await footerLeft('left'); final center = await footerLeft('center'); final right = await footerLeft('right'); expect(left, lessThan(center)); expect(center, lessThan(right)); }); testWidgets('left footer aligns with the bullet content margin', ( tester, ) async { await tester.pumpWidget( _host( Slide.create(SlideType.bullets).copyWith(title: 'T', bullets: ['a']), const ThemeProfile(footerText: 'Voettekst', footerPosition: 'left'), number: 1, count: 3, ), ); await tester.pump(); // Bullets beginnen op w*0.07 (w=800 → 56px); de footer lijnt daarmee uit. final footerX = tester.getTopLeft(find.text('Voettekst')).dx; expect(footerX, closeTo(800 * 0.07, 2)); }); testWidgets('footer is hidden on title slides', (tester) async { const profile = ThemeProfile( footerText: 'Altijd zichtbaar', footerShowPageNumbers: true, ); await tester.pumpWidget( _host( Slide.create(SlideType.title).copyWith(title: 'Welkom'), profile, number: 1, count: 4, ), ); await tester.pump(); expect(find.text('Altijd zichtbaar'), findsNothing); }); testWidgets('no footer when profile has none configured', (tester) async { const profile = ThemeProfile(); await tester.pumpWidget( _host( Slide.create(SlideType.bullets).copyWith(title: 'T', bullets: ['a']), profile, number: 1, count: 3, ), ); await tester.pump(); expect(find.text('1 / 3'), findsNothing); }); }