diff --git a/.vscode/launch.json b/.vscode/launch.json index 1d2b113..b139440 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -57,6 +57,7 @@ "name": "Integration Test", "request": "launch", "type": "dart", + "flutterMode": "profile", "args": [ "--flavor", "prod", diff --git a/integration_test/widget_dialog_animated_test.dart b/integration_test/widget_dialog_animated_test.dart index 5bea94d..c7a9f07 100644 --- a/integration_test/widget_dialog_animated_test.dart +++ b/integration_test/widget_dialog_animated_test.dart @@ -9,7 +9,7 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container import 'mocks/application_mock.dart'; void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('AnimatedDialogPicker test', () { testWidgets('Tap on `ReadingValueContainer`, verify opened', (tester) async { @@ -17,10 +17,16 @@ void main() { expect(find.text('Film'), findsOneWidget); expect(find.text('None'), findsOneWidget); - await tester.tap(find.byType(AnimatedDialogPicker)); - await tester.pumpAndSettle(Dimens.durationL); - expect(find.text('Film'), findsNWidgets(2)); - expect(find.text('None'), findsNWidgets(2)); + await binding.traceAction( + () async { + await tester.tap(find.byType(AnimatedDialogPicker)); + await tester.pumpAndSettle(Dimens.durationL); + }, + reportKey: 'dialog_opening_timeline', + ); + + expect(find.text('Film'), findsNWidgets(3)); + expect(find.text('None'), findsNWidgets(3)); }); }); } diff --git a/pubspec.yaml b/pubspec.yaml index 9f0fa2a..6fb0faf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,8 @@ dependencies: dev_dependencies: bloc_test: 9.1.3 build_runner: ^2.1.7 + flutter_driver: + sdk: flutter flutter_launcher_icons: 0.11.0 flutter_native_splash: 2.2.16 flutter_test: diff --git a/test_driver/performance_driver.dart b/test_driver/performance_driver.dart new file mode 100644 index 0000000..e06e259 --- /dev/null +++ b/test_driver/performance_driver.dart @@ -0,0 +1,27 @@ +import 'package:flutter_driver/flutter_driver.dart' as driver; +import 'package:integration_test/integration_test_driver.dart'; + +Future main() { + return integrationDriver( + responseDataCallback: (data) async { + if (data != null) { + final timeline = + driver.Timeline.fromJson(data['dialog_opening_timeline'] as Map); + + // Convert the Timeline into a TimelineSummary that's easier to + // read and understand. + final summary = driver.TimelineSummary.summarize(timeline); + + // Then, write the entire timeline to disk in a json format. + // This file can be opened in the Chrome browser's tracing tools + // found by navigating to chrome://tracing. + // Optionally, save the summary to disk by setting includeSummary + // to true + await summary.writeTimelineToFile( + 'dialog_opening_timeline', + pretty: true, + ); + } + }, + ); +} diff --git a/test_driver/test_driver.md b/test_driver/test_driver.md new file mode 100644 index 0000000..81aa51a --- /dev/null +++ b/test_driver/test_driver.md @@ -0,0 +1,9 @@ +Trace actions +```console +flutter drive \ + --driver=test_driver/performance_driver.dart \ + --target=integration_test/widget_dialog_animated_test.dart \ + --profile \ + --flavor=dev \ + --no-dds +``` \ No newline at end of file