-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our tests
Description
After #16758 lands, we'll ostensibly have the ability to capture a screenshot in a widget test running via flutter_tester and compare it to a golden file, as follows:
testWidgets('test', (WidgetTester tester) async {
await tester.pumpWidget(new MyApp());
// Get the bytes of the screenshot
RenderRepaintBoundary repaintRenderBoundary = tester
.allRenderObjects
.firstWhere((RenderObject object) => object is RenderRepaintBoundary);
ui.Image image = await repaintRenderBoundary.toImage();
ByteData bytes = await image.toByteData(format: ui.ImageByteFormat.png);
// Get the bytes of the golden file
File golden = new ui.File('/path/to/golden.png');
List<int> goldenBytes = await golden.readAsBytes();
// Fail the test if the screenshot isn't within tolerance of golden
...
});But doing so causes the following exception due to flutter_test's use of FakeAsync:
TimeoutException after 0:00:05.000000: Test timed out after 5 seconds.
dart:async _startMicrotaskLoop
A hacked up attempt to call _fakeAsync.flushTimers() ends up yielding the same exception when we await that call.
Metadata
Metadata
Assignees
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our tests