forked from eBay/flutter_glove_box
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgolden_builder_test.dart
87 lines (82 loc) · 3.2 KB
/
golden_builder_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/// ***************************************************
/// Copyright 2019-2020 eBay Inc.
///
/// Use of this source code is governed by a BSD-style
/// license that can be found in the LICENSE file or at
/// https://opensource.org/licenses/BSD-3-Clause
/// ***************************************************
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
void main() {
group('GoldenBuilder', () {
testGoldens('Scenario Builder example', (tester) async {
final builder = GoldenBuilder.grid(
columns: 2,
widthToHeightRatio: 1,
)
..addScenarioBuilder("Primary Color", (context) {
var color = Theme.of(context).colorScheme.primary;
return Container(
color: color,
);
})
..addScenarioBuilder("Secondary Color", (context) {
var color = Theme.of(context).colorScheme.primary;
return Container(
color: color,
);
});
await tester.pumpWidgetBuilder(builder.build());
await screenMatchesGolden(tester, 'golden_builder_theme');
});
testGoldens('Column layout example', (tester) async {
await tester.pumpWidgetBuilder(
Center(
child: (GoldenBuilder.column()
..addScenario('red',
Container(height: 50, width: 50, color: Colors.red))
..addScenario('green',
Container(height: 50, width: 50, color: Colors.green))
..addScenario('blue',
Container(height: 50, width: 50, color: Colors.blue)))
.build()),
surfaceSize: const Size(100, 300),
);
await screenMatchesGolden(tester, 'golden_builder_column',
autoHeight: true);
});
testGoldens('Grid layout example', (tester) async {
await tester.pumpWidgetBuilder(
Center(
child: (GoldenBuilder.grid(columns: 2, widthToHeightRatio: 1)
..addScenario('red',
Container(height: 50, width: 50, color: Colors.red))
..addScenario('green',
Container(height: 50, width: 50, color: Colors.green))
..addScenario('blue',
Container(height: 50, width: 50, color: Colors.blue)))
.build()),
surfaceSize: const Size(300, 300),
);
await screenMatchesGolden(tester, 'golden_builder_grid',
autoHeight: true);
});
testGoldens('TextScaleScenario', (tester) async {
await tester.pumpWidgetBuilder(
Center(
child: (GoldenBuilder.column()
..addTextScaleScenario('small', const Text('text'),
textScaleFactor: 1.0)
..addTextScaleScenario('medium', const Text('text'),
textScaleFactor: 2.0)
..addTextScaleScenario('large', const Text('text'),
textScaleFactor: 3.2))
.build()),
surfaceSize: const Size(100, 300),
);
await screenMatchesGolden(tester, 'golden_builder_textscale',
autoHeight: true);
});
});
}