Skip to content

Commit

Permalink
clean up test, prep changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
coreysprague committed Jun 26, 2020
1 parent 1adeefe commit 6867587
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
4 changes: 4 additions & 0 deletions packages/golden_toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.5.1

Improved the reliability of the default behavior for ```tester.waitForAssets()``` to handle additional cases.

## 0.5.0

### More intelligent behavior for loading assets
Expand Down
2 changes: 1 addition & 1 deletion packages/golden_toolkit/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: golden_toolkit
description: Common patterns for screenshot-based widget testing using Goldens.
version: 0.5.0
version: 0.5.1
homepage: https://github.com/eBay/flutter_glove_box/
repository: https://github.com/eBay/flutter_glove_box/tree/master/packages/golden_toolkit
issue_tracker: https://github.com/eBay/flutter_glove_box/issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,19 @@ void main() {
testWidgets('should load assets that have not come into view yet', (tester) async {
await GoldenToolkit.runWithConfiguration(
() async {
await tester.pumpWidgetBuilder(const ListOfImages(height: 100), surfaceSize: const Size(300, 100));
await tester.pumpWidgetBuilder(
const ListOfItemsWithOneImage(
itemSize: Size(100, 100),
cacheExtent: 1000,
indexThatContainsImage: 10,
),
surfaceSize: const Size(300, 100),
);
await tester.waitForAssets();
await tester.drag(find.byType(Scrollable), const Offset(0, -20000));
await tester.drag(find.byType(Scrollable), const Offset(0, -1000));
await tester.pump();
await expectLater(
find.byType(ListOfImages).first, matchesGoldenFile('goldens/list_of_images_will_show.png'));
find.byType(ListOfItemsWithOneImage).first, matchesGoldenFile('goldens/list_of_images_will_show.png'));
},
config: defaultConfiguration,
);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 deletions packages/golden_toolkit/test/image_loading/image_loading_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,37 @@ GoldenToolkitConfiguration get defaultConfiguration =>
GoldenToolkit.configuration.copyWith(primeAssets: defaultPrimeAssets);

@immutable
class ListOfImages extends StatelessWidget {
const ListOfImages({@required this.height});
class ListOfItemsWithOneImage extends StatelessWidget {
const ListOfItemsWithOneImage({
@required this.itemSize,
@required this.indexThatContainsImage,
@required this.cacheExtent,
});

final double height;
final Size itemSize;
final int indexThatContainsImage;
final double cacheExtent;

@override
Widget build(BuildContext context) {
return Container(
color: Colors.grey,
child: ListView.builder(
primary: true,
addAutomaticKeepAlives: false,
addRepaintBoundaries: true,
itemCount: 20,
itemBuilder: (context, index) => Center(
child: Row(
children: [
Text(index.toString()),
const SizedBox(width: 8),
Container(
width: height,
height: height,
width: itemSize.width,
height: itemSize.height,
color: Colors.lightBlue,
child: (index < 10) ? null : const ImageWidget(),
child: (index == indexThatContainsImage) ? const ImageWidget() : null,
),
],
),
),
cacheExtent: 2000,
cacheExtent: cacheExtent,
),
);
}
Expand Down

0 comments on commit 6867587

Please sign in to comment.