@@ -28,20 +28,24 @@ class Timeline {
2828 this ._description, {
2929 Directory ? directory,
3030 required String fileName,
31- GoldenSceneItemScaffold itemScaffold = minimalItemScaffold,
31+ Size ? windowSize,
32+ GoldenSceneItemScaffold itemScaffold = standardTimelineItemScaffold,
3233 required SceneLayout layout,
3334 GoldenSceneBackground ? goldenBackground,
3435 }) : _directory = directory,
3536 _fileName = fileName,
37+ _windowSize = windowSize,
38+ _itemScaffold = itemScaffold,
3639 _layout = layout,
37- _goldenBackground = goldenBackground,
38- _itemScaffold = itemScaffold;
40+ _goldenBackground = goldenBackground;
3941
4042 final String _description;
4143
4244 late final Directory ? _directory;
4345 final String _fileName;
4446
47+ final Size ? _windowSize;
48+
4549 final GoldenSceneItemScaffold _itemScaffold;
4650
4751 final GoldenSceneBackground ? _goldenBackground;
@@ -59,7 +63,11 @@ class Timeline {
5963 throw Exception ("Timeline was already set up, but tried to call setup() again." );
6064 }
6165
62- _setup = _TimelineSetup (delegate);
66+ _setup = _TimelineSetup ((tester) async {
67+ _configureWindowSize (tester);
68+
69+ await delegate (tester);
70+ });
6371
6472 return this ;
6573 }
@@ -73,6 +81,8 @@ class Timeline {
7381 }
7482
7583 _setup = _TimelineSetup ((tester) async {
84+ _configureWindowSize (tester);
85+
7686 final widgetTree = _itemScaffold (tester, sceneBuilder ());
7787 await tester.pumpWidget (widgetTree);
7888 });
@@ -89,13 +99,23 @@ class Timeline {
8999 }
90100
91101 _setup = _TimelineSetup ((tester) async {
102+ _configureWindowSize (tester);
103+
92104 final widgetTree = _itemScaffold (tester, widget);
93105 await tester.pumpWidget (widgetTree);
94106 });
95107
96108 return this ;
97109 }
98110
111+ void _configureWindowSize (WidgetTester tester) {
112+ if (_windowSize != null ) {
113+ final previousWindowSize = tester.view.physicalSize;
114+ tester.view.physicalSize = _windowSize;
115+ addTearDown (() => tester.view.physicalSize = previousWindowSize);
116+ }
117+ }
118+
99119 /// Take a golden photo screenshot of the current Flutter UI.
100120 ///
101121 /// {@template golden_image_bounds_default_finder}
@@ -566,7 +586,9 @@ class TimelineTestContext {
566586 final scratchPad = < String , dynamic > {};
567587}
568588
569- Widget minimalItemScaffold (WidgetTester tester, Widget content) {
589+ /// The standard [GoldenSceneItemScaffold] that wraps the content of a [Timeline] , which
590+ /// includes a dark theme, a dark background color, and some padding around the content.
591+ Widget standardTimelineItemScaffold (WidgetTester tester, Widget content) {
570592 return MaterialApp (
571593 theme: ThemeData (
572594 brightness: Brightness .dark,
@@ -586,3 +608,18 @@ Widget minimalItemScaffold(WidgetTester tester, Widget content) {
586608 debugShowCheckedModeBanner: false ,
587609 );
588610}
611+
612+ /// An absolute minimal [GoldenSceneItemScaffold] that wraps the content within a [Timeline] .
613+ Widget minimalTimelineItemScaffold (WidgetTester tester, Widget content) {
614+ return MaterialApp (
615+ theme: ThemeData (
616+ fontFamily: goldenBricks,
617+ ),
618+ home: Center (
619+ child: GoldenImageBounds (
620+ child: content,
621+ ),
622+ ),
623+ debugShowCheckedModeBanner: false ,
624+ );
625+ }
0 commit comments