Skip to content

Commit 6867587

Browse files
committed
clean up test, prep changelog
1 parent 1adeefe commit 6867587

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

packages/golden_toolkit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.5.1
4+
5+
Improved the reliability of the default behavior for ```tester.waitForAssets()``` to handle additional cases.
6+
37
## 0.5.0
48

59
### More intelligent behavior for loading assets

packages/golden_toolkit/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: golden_toolkit
22
description: Common patterns for screenshot-based widget testing using Goldens.
3-
version: 0.5.0
3+
version: 0.5.1
44
homepage: https://github.com/eBay/flutter_glove_box/
55
repository: https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit
66
issue_tracker: https://github.com/eBay/flutter_glove_box/issues

packages/golden_toolkit/test/image_loading/default/default_asset_loading_test.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ void main() {
6060
testWidgets('should load assets that have not come into view yet', (tester) async {
6161
await GoldenToolkit.runWithConfiguration(
6262
() async {
63-
await tester.pumpWidgetBuilder(const ListOfImages(height: 100), surfaceSize: const Size(300, 100));
63+
await tester.pumpWidgetBuilder(
64+
const ListOfItemsWithOneImage(
65+
itemSize: Size(100, 100),
66+
cacheExtent: 1000,
67+
indexThatContainsImage: 10,
68+
),
69+
surfaceSize: const Size(300, 100),
70+
);
6471
await tester.waitForAssets();
65-
await tester.drag(find.byType(Scrollable), const Offset(0, -20000));
72+
await tester.drag(find.byType(Scrollable), const Offset(0, -1000));
6673
await tester.pump();
6774
await expectLater(
68-
find.byType(ListOfImages).first, matchesGoldenFile('goldens/list_of_images_will_show.png'));
75+
find.byType(ListOfItemsWithOneImage).first, matchesGoldenFile('goldens/list_of_images_will_show.png'));
6976
},
7077
config: defaultConfiguration,
7178
);
-39 Bytes
Loading

packages/golden_toolkit/test/image_loading/image_loading_utils.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,37 @@ GoldenToolkitConfiguration get defaultConfiguration =>
3535
GoldenToolkit.configuration.copyWith(primeAssets: defaultPrimeAssets);
3636

3737
@immutable
38-
class ListOfImages extends StatelessWidget {
39-
const ListOfImages({@required this.height});
38+
class ListOfItemsWithOneImage extends StatelessWidget {
39+
const ListOfItemsWithOneImage({
40+
@required this.itemSize,
41+
@required this.indexThatContainsImage,
42+
@required this.cacheExtent,
43+
});
4044

41-
final double height;
45+
final Size itemSize;
46+
final int indexThatContainsImage;
47+
final double cacheExtent;
4248

4349
@override
4450
Widget build(BuildContext context) {
4551
return Container(
4652
color: Colors.grey,
4753
child: ListView.builder(
48-
primary: true,
49-
addAutomaticKeepAlives: false,
50-
addRepaintBoundaries: true,
51-
itemCount: 20,
5254
itemBuilder: (context, index) => Center(
5355
child: Row(
5456
children: [
5557
Text(index.toString()),
5658
const SizedBox(width: 8),
5759
Container(
58-
width: height,
59-
height: height,
60+
width: itemSize.width,
61+
height: itemSize.height,
6062
color: Colors.lightBlue,
61-
child: (index < 10) ? null : const ImageWidget(),
63+
child: (index == indexThatContainsImage) ? const ImageWidget() : null,
6264
),
6365
],
6466
),
6567
),
66-
cacheExtent: 2000,
68+
cacheExtent: cacheExtent,
6769
),
6870
);
6971
}

0 commit comments

Comments
 (0)