image_test_utils
image_test_utils copied to clipboard
custom imageBytes not working?
Hi,
I'm trying to return a custom image in my tests.
Using the imageBytes property I tried to place my bytes inside, but it seems as thought nothing gets shown on screen.
Is this broken?
void main() {
testWidgets('should not crash', (WidgetTester tester) async {
final imageFile = File("/Users/timrijckaert/local_image.png");
final customImageBytes = imageFile.readAsBytesSync();
await provideMockedNetworkImages(() async {
await tester.pumpWidget(
MaterialApp(
home: Image.network('https://example.com/image.png'),
),
);
}, imageBytes: customImageBytes);
await expectLater(find.byType(MaterialApp), matchesGoldenFile("custom_image_bytes.png"));
});
}
Did something change the way Flutter calls this in tests? I don't see my breakpoint going inside of:
when(response.listen(any)).thenAnswer((Invocation invocation) {
final void Function(List<int>) onData = invocation.positionalArguments[0];
final void Function() onDone = invocation.namedArguments[#onDone];
final void Function(Object, [StackTrace]) onError = invocation.namedArguments[#onError];
final bool cancelOnError = invocation.namedArguments[#cancelOnError];
return Stream<List<int>>.fromIterable(<List<int>>[imageBytes])
.listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError);
});
My Flutter version
Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (8 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)