1
1
import 'dart:async' ;
2
- import 'dart:io' ;
3
2
4
3
import 'package:flutter/foundation.dart' ;
5
4
import 'package:flutter/material.dart' show Colors, MaterialApp, Scaffold, ThemeData;
@@ -11,19 +10,9 @@ import 'package:flutter_test_goldens/src/goldens/golden_collections.dart';
11
10
import 'package:flutter_test_goldens/src/goldens/golden_comparisons.dart' ;
12
11
import 'package:flutter_test_goldens/src/goldens/golden_rendering.dart' ;
13
12
import 'package:flutter_test_goldens/src/goldens/golden_scenes.dart' ;
14
- import 'package:flutter_test_goldens/src/scenes/golden_files.dart' ;
15
13
import 'package:golden_bricks/golden_bricks.dart' ;
16
14
17
- /// A theme, which is applied to various [GoldenScene] s.
18
- ///
19
- /// The purpose of [GoldenSceneTheme] is to make it easy to configure similar visual styles
20
- /// for all [GoldenScene] s in a project, file, group, or within a test.
21
- ///
22
- /// A [GoldenSceneTheme] captures various details that are visually common among
23
- /// [GoldenScene] s. For example, a theme includes an [itemScaffold] and [itemDecorator] that are
24
- /// built around every golden in a scene. It includes a [background] that renders behind the
25
- /// golden images. For logistics, it includes a relative [directory] path, which says where
26
- /// to store [GoldenScene] s in relation to each golden test file.
15
+ /// A theme, which contains visual aspects that are common to most types of Golden Scenes.
27
16
class GoldenSceneTheme {
28
17
/// The [GoldenSceneTheme] that should be used for the currently executing test.
29
18
///
@@ -50,16 +39,16 @@ class GoldenSceneTheme {
50
39
addTearDown (() => GoldenSceneTheme .pop ());
51
40
}
52
41
53
- /// Pushes the given [theme] on to the global theme stack, which will make it
42
+ /// Pushes the given [theme] on to the global config stack, which will make it
54
43
/// the global theme until there's a call to [pop] .
55
44
///
56
45
/// Pushing and popping themes is useful within group and test setups and teardowns
57
46
/// to configure a [GoldenSceneTheme] for that group or test.
58
47
static void push (GoldenSceneTheme theme) => _themeStack.add (theme);
59
48
60
- /// Removes to the top theme on the global stack, which was added with [push] .
49
+ /// Removes to the top config on the global stack, which was added with [push] .
61
50
///
62
- /// If there is no corresponding theme that was added by an earlier [push] , then
51
+ /// If there is no corresponding config that was added by an earlier [push] , then
63
52
/// this method does nothing.
64
53
static void pop () {
65
54
if (_themeStack.length > 1 ) {
@@ -69,7 +58,6 @@ class GoldenSceneTheme {
69
58
70
59
/// The default [GoldenSceneTheme] for all tests.
71
60
static final standard = GoldenSceneTheme (
72
- directory: defaultGoldenDirectory,
73
61
background: defaultGoldenSceneBackground,
74
62
defaultTextStyle: TextStyle (
75
63
color: Colors .black,
@@ -84,7 +72,6 @@ class GoldenSceneTheme {
84
72
/// This theme isn't used anywhere by default, but it's a convenient theme if
85
73
/// you want a dark theme and you don't care about all the specifics.
86
74
static final standardDark = GoldenSceneTheme (
87
- directory: defaultGoldenDirectory,
88
75
background: defaultDarkGoldenSceneBackground,
89
76
defaultTextStyle: TextStyle (
90
77
color: Colors .white,
@@ -96,20 +83,12 @@ class GoldenSceneTheme {
96
83
);
97
84
98
85
const GoldenSceneTheme ({
99
- required this .directory,
100
86
required this .background,
101
87
required this .defaultTextStyle,
102
88
required this .itemScaffold,
103
89
required this .itemDecorator,
104
90
});
105
91
106
- /// The relative path from a running test to where that test's goldens are
107
- /// stored.
108
- ///
109
- /// The [standard] directory is `Directory("./goldens/")` . To store goldens in the same
110
- /// directory as the running tests, use `Directory(".")` .
111
- final Directory directory;
112
-
113
92
/// The background that's painted full-bleed across the scene, behind the goldens.
114
93
///
115
94
/// The [standard] background is a color.
@@ -133,14 +112,12 @@ class GoldenSceneTheme {
133
112
final GoldenSceneItemDecorator itemDecorator;
134
113
135
114
GoldenSceneTheme copyWith ({
136
- Directory ? directory,
137
115
GoldenSceneBackground ? background,
138
116
TextStyle ? defaultTextStyle,
139
117
GoldenSceneItemScaffold ? itemScaffold,
140
118
GoldenSceneItemDecorator ? itemDecorator,
141
119
}) {
142
120
return GoldenSceneTheme (
143
- directory: directory ?? this .directory,
144
121
background: background ?? this .background,
145
122
defaultTextStyle: defaultTextStyle ?? this .defaultTextStyle,
146
123
itemScaffold: itemScaffold ?? this .itemScaffold,
0 commit comments