@@ -7,17 +7,23 @@ import 'dart:convert';
7
7
8
8
/// A callback to use with [integrationDriver] .
9
9
///
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 .
12
12
///
13
13
/// The callback returns `true` if the test passes or `false` otherwise.
14
14
///
15
15
/// You can use this callback to store the bytes locally in a file or upload them to a service
16
16
/// that compares the image against a gold or baseline version.
17
17
///
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
+ ///
18
24
/// Since the function is executed on the host driving the test, you can access any environment
19
25
/// 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] );
21
27
22
28
/// Classes shared between `integration_test.dart` and `flutter drive` based
23
29
/// adoptor (ex: `integration_test_driver.dart` ).
@@ -247,9 +253,12 @@ class WebDriverCommand {
247
253
values = < String , dynamic > {};
248
254
249
255
/// Constructor for [WebDriverCommandType.noop] screenshot.
250
- WebDriverCommand .screenshot (String screenshotName)
256
+ WebDriverCommand .screenshot (String screenshotName, [ Map < String , Object ?> ? args] )
251
257
: 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
+ };
253
262
254
263
/// Type of the [WebDriverCommand] .
255
264
///
@@ -286,7 +295,7 @@ abstract class CallbackManager {
286
295
287
296
/// Takes a screenshot of the application.
288
297
/// 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] );
290
299
291
300
/// Android only. Converts the Flutter surface to an image view.
292
301
Future <void > convertFlutterSurfaceToImage ();
0 commit comments