@@ -7,17 +7,23 @@ import 'dart:convert';
77
88/// A callback to use with [integrationDriver] .
99///
10- /// The callback receives the name of screenshot passed to `binding.takeScreenshot(<name>)` and
11- /// a PNG byte buffer.
10+ /// The callback receives the name of screenshot passed to `binding.takeScreenshot(<name>)` ,
11+ /// a PNG byte buffer representing the screenshot, and an optional `Map` of arguments .
1212///
1313/// The callback returns `true` if the test passes or `false` otherwise.
1414///
1515/// You can use this callback to store the bytes locally in a file or upload them to a service
1616/// that compares the image against a gold or baseline version.
1717///
18+ /// The optional `Map` of arguments can be passed from the
19+ /// `binding.takeScreenshot(<name>, <args>)` callsite in the integration test,
20+ /// and then the arguments can be used in the `onScreenshot` handler that is defined by
21+ /// the Flutter driver. This `Map` should only contain values that can be serialized
22+ /// to JSON.
23+ ///
1824/// Since the function is executed on the host driving the test, you can access any environment
1925/// variable from it.
20- typedef ScreenshotCallback = Future <bool > Function (String name, List <int > image);
26+ typedef ScreenshotCallback = Future <bool > Function (String name, List <int > image, [ Map < String , Object ?> ? args] );
2127
2228/// Classes shared between `integration_test.dart` and `flutter drive` based
2329/// adoptor (ex: `integration_test_driver.dart` ).
@@ -247,9 +253,12 @@ class WebDriverCommand {
247253 values = < String , dynamic > {};
248254
249255 /// Constructor for [WebDriverCommandType.noop] screenshot.
250- WebDriverCommand .screenshot (String screenshotName)
256+ WebDriverCommand .screenshot (String screenshotName, [ Map < String , Object ?> ? args] )
251257 : type = WebDriverCommandType .screenshot,
252- values = < String , dynamic > {'screenshot_name' : screenshotName};
258+ values = < String , dynamic > {
259+ 'screenshot_name' : screenshotName,
260+ if (args != null ) 'args' : args,
261+ };
253262
254263 /// Type of the [WebDriverCommand] .
255264 ///
@@ -286,7 +295,7 @@ abstract class CallbackManager {
286295
287296 /// Takes a screenshot of the application.
288297 /// Returns the data that is sent back to the host.
289- Future <Map <String , dynamic >> takeScreenshot (String screenshot);
298+ Future <Map <String , dynamic >> takeScreenshot (String screenshot, [ Map < String , Object ?> ? args] );
290299
291300 /// Android only. Converts the Flutter surface to an image view.
292301 Future <void > convertFlutterSurfaceToImage ();
0 commit comments