roughike / image_test_utils Goto Github PK
View Code? Open in Web Editor NEWProvide mocked responses for Image.network widgets in Flutter widget tests.
License: BSD 2-Clause "Simplified" License
Provide mocked responses for Image.network widgets in Flutter widget tests.
License: BSD 2-Clause "Simplified" License
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)
Current mockito version is 4.0.0, whereas this package currently depends on mockito version 3.0.0.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.