From 1745402d766949008c3c01f9ffd0fb83bb4a3432 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Wed, 8 Sep 2021 17:12:04 -0700 Subject: [PATCH] Document multi-timeline usage (#88604) --- .../lib/integration_test.dart | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/integration_test/lib/integration_test.dart b/packages/integration_test/lib/integration_test.dart index 10548c47bf..d221bc061c 100644 --- a/packages/integration_test/lib/integration_test.dart +++ b/packages/integration_test/lib/integration_test.dart @@ -282,8 +282,8 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab ); } - /// This is a convenience wrap of [traceTimeline] and send the result back to - /// the host for the [flutter_driver] style tests. + /// This is a convenience method that calls [traceTimeline] and sends the + /// result back to the host for the [flutter_driver] style tests. /// /// This records the timeline during `action` and adds the result to /// [reportData] with `reportKey`. The [reportData] contains extra information @@ -293,7 +293,30 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab /// to `build/integration_response_data.json` with the key `timeline`. /// /// For tests with multiple calls of this method, `reportKey` needs to be a - /// unique key, otherwise the later result will override earlier one. + /// unique key, otherwise the later result will override earlier one. Tests + /// that call this multiple times must also provide a custom + /// [ResponseDataCallback] to decide where and how to write the output + /// timelines. For example, + /// + /// ```dart + /// import 'package:integration_test/integration_test_driver.dart'; + /// + /// Future main() { + /// return integrationDriver( + /// responseDataCallback: (data) async { + /// if (data != null) { + /// for (var entry in data.entries) { + /// print('Writing ${entry.key} to the disk.'); + /// await writeResponseData( + /// entry.value as Map, + /// testOutputFilename: entry.key, + /// ); + /// } + /// } + /// }, + /// ); + /// } + /// ``` /// /// The `streams` and `retainPriorEvents` parameters are passed as-is to /// [traceTimeline].