|
2 | 2 | A toolkit for writing golden tests.
|
3 | 3 |
|
4 | 4 | ## Getting Started
|
5 |
| -The following shows an example of how to define a golden test that captures |
6 |
| -a variety of independent UIs as a gallery. |
| 5 | +Learn how to use `flutter_test_goldens` at [FlutterGoldens.com](https://fluttergoldens.com). |
7 | 6 |
|
8 |
| -```dart |
9 |
| -testGoldenSceneOnMac("extended floating action button gallery", (tester) async { |
10 |
| - await Gallery( |
11 |
| - tester, |
12 |
| - itemDecorator: (context, child) { |
13 |
| - return FlutterWidgetScaffold( |
14 |
| - child: child, |
15 |
| - ); |
16 |
| - }, |
17 |
| - items: [ |
18 |
| - GalleryItem.withWidget( |
19 |
| - id: "1", |
20 |
| - description: "Icon + Text", |
21 |
| - child: FloatingActionButton.extended( |
22 |
| - icon: Icon(Icons.edit), |
23 |
| - label: Text("Hello"), |
24 |
| - onPressed: () {}, |
25 |
| - ), |
26 |
| - ), |
27 |
| - GalleryItem.withWidget( |
28 |
| - id: "2", |
29 |
| - description: "Icon", |
30 |
| - child: FloatingActionButton.extended( |
31 |
| - icon: Icon(Icons.edit), |
32 |
| - label: Text(""), |
33 |
| - onPressed: () {}, |
34 |
| - ), |
35 |
| - ), |
36 |
| - GalleryItem.withWidget( |
37 |
| - id: "3", |
38 |
| - description: "Text", |
39 |
| - child: FloatingActionButton.extended( |
40 |
| - label: Text("Hello"), |
41 |
| - onPressed: () {}, |
42 |
| - ), |
43 |
| - ), |
44 |
| - ], |
45 |
| - ).renderOrCompareGolden( |
46 |
| - goldenName: "button_extended_fab_gallery", |
47 |
| - layout: SceneLayout.row, |
48 |
| - ); |
49 |
| -}); |
50 |
| -``` |
| 7 | +## Examples |
| 8 | +The following are examples of what you can render in your golden tests with `flutter_test_goldens`: |
51 | 9 |
|
52 |
| -The following shows an example of how to define a golden test that captures |
53 |
| -screenshots over time, placing all of them in a single scene file. |
| 10 | +### Single Shot Galleries |
| 11 | + |
54 | 12 |
|
55 |
| -```dart |
56 |
| -testGoldenSceneOnMac("elevated button interactions", (tester) async { |
57 |
| - final goldenKey = GlobalKey(); |
| 13 | +### Multi-Golden Galleries |
| 14 | + |
58 | 15 |
|
59 |
| - await FilmStrip(tester) |
60 |
| - // Setup the widget tree. |
61 |
| - .setupWithPump(() { |
62 |
| - return FlutterWidgetScaffold( |
63 |
| - goldenKey: goldenKey, |
64 |
| - child: ElevatedButton( |
65 |
| - onPressed: () {}, |
66 |
| - child: Text("Hello"), |
67 |
| - ), |
68 |
| - ); |
69 |
| - }) |
70 |
| - // Take a photo. |
71 |
| - .takePhoto(find.byKey(goldenKey), "idle") |
72 |
| - // Adjust the existing widget tree by hovering over the ElevatedButton. |
73 |
| - .hoverOver(find.byType(ElevatedButton)) |
74 |
| - // Take a photo. |
75 |
| - .takePhoto(find.byKey(goldenKey), "hover") |
76 |
| - // Adjust the existing widget tree by pressing down at the current offset. |
77 |
| - .pressHover() |
78 |
| - // Take a photo. |
79 |
| - .takePhoto(find.byKey(goldenKey), "pressed") |
80 |
| - // Either stitch the photos into a single scene file, or compare them against |
81 |
| - // an existing scene file. |
82 |
| - .renderOrCompareGolden( |
83 |
| - goldenName: "button_elevated_interactions", |
84 |
| - layout: SceneLayout.row, |
85 |
| - ); |
86 |
| -}); |
87 |
| -``` |
| 16 | +### Magazine Galleries |
| 17 | + |
| 18 | + |
| 19 | +### Animation Timelines |
| 20 | + |
| 21 | + |
| 22 | +### Interaction Timelines |
| 23 | + |
0 commit comments