From 3749ff02e1e3d247f30797366d543e1ce9405b11 Mon Sep 17 00:00:00 2001 From: Abhishek Ghaskata Date: Mon, 7 Jun 2021 23:59:04 +0530 Subject: [PATCH] Migrate gallery test to null safety (#84065) --- .../test_driver/scroll_perf_test.dart | 5 +---- .../test_driver/scroll_perf_web.dart | 2 -- .../test_driver/scroll_perf_web_test.dart | 5 +---- .../test_driver/transitions_perf_e2e.dart | 1 - .../test_driver/transitions_perf_e2e_test.dart | 6 ++---- .../transitions_perf_e2e_with_semantics.dart | 1 - .../test_driver/transitions_perf_hybrid_test.dart | 2 -- .../test_driver/transitions_perf_test.dart | 13 +++++-------- .../transitions_perf_with_semantics_test.dart | 1 - 9 files changed, 9 insertions(+), 27 deletions(-) diff --git a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart index 196d146c74..19006e1fe4 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_test.dart @@ -2,14 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { group('scrolling performance test', () { - FlutterDriver driver; + late FlutterDriver driver; setUpAll(() async { driver = await FlutterDriver.connect(); @@ -18,7 +16,6 @@ void main() { }); tearDownAll(() async { - if (driver != null) driver.close(); }); diff --git a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web.dart b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web.dart index 3edebdd0dc..e8f26d02f6 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/material.dart'; import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_gallery/gallery/app.dart' show GalleryApp; diff --git a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart index 70234e7eec..fbd61d5024 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/scroll_perf_web_test.dart @@ -2,21 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { group('scrolling performance test', () { - FlutterDriver driver; + late FlutterDriver driver; setUpAll(() async { driver = await FlutterDriver.connect(); }); tearDownAll(() async { - if (driver != null) driver.close(); }); diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e.dart index 89a706eefd..0225af5723 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_gallery/demo_lists.dart'; diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart index f0a9277b87..e4936e8309 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_test.dart @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:integration_test/integration_test_driver.dart' as driver; Future main() => driver.integrationDriver( timeout: const Duration(minutes: 5), - responseDataCallback: (Map data) async { + responseDataCallback: (Map? data) async { await driver.writeResponseData( - data['performance'] as Map, + data!['performance'] as Map, testOutputFilename: 'e2e_perf_summary', ); } diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_with_semantics.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_with_semantics.dart index e30850d89a..1f26cbda38 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_with_semantics.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_e2e_with_semantics.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 import 'transitions_perf_e2e.dart' as transitions_perf; void main() { diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart index 8b758d838b..dc5ab42f02 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_hybrid_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'transitions_perf_test.dart' as transitions_perf_test; void main([List args = const []]) => transitions_perf_test.main( diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart index 104d8581c5..5d86c8079e 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:convert' show JsonEncoder, json; import 'package:file/file.dart'; @@ -27,8 +25,8 @@ List _allDemos = []; /// it into a histogram, and saves to a JSON file. Future saveDurationsHistogram(List> events, String outputPath) async { final Map> durations = >{}; - Map startEvent; - int frameStart; + Map? startEvent; + int? frameStart; // Save the duration of the first frame after each 'Start Transition' event. for (final Map event in events) { @@ -46,7 +44,7 @@ Future saveDurationsHistogram(List> events, String ou assert(phase == 'E'); final String routeName = startEvent['args']['to'] as String; durations[routeName] ??= []; - durations[routeName].add(timestamp - frameStart); + durations[routeName]!.add(timestamp - frameStart!); startEvent = null; frameStart = null; } @@ -105,7 +103,7 @@ Future saveDurationsHistogram(List> events, String ou /// home screen twice. Future runDemos(List demos, FlutterDriver driver) async { final SerializableFinder demoList = find.byValueKey('GalleryDemoList'); - String currentDemoCategory; + String? currentDemoCategory; for (final String demo in demos) { if (kSkippedDemos.contains(demo)) @@ -158,7 +156,7 @@ void main([List args = const []]) { final bool withSemantics = args.contains('--with_semantics'); final bool hybrid = args.contains('--hybrid'); group('flutter gallery transitions', () { - FlutterDriver driver; + late FlutterDriver driver; setUpAll(() async { driver = await FlutterDriver.connect(); @@ -176,7 +174,6 @@ void main([List args = const []]) { }); tearDownAll(() async { - if (driver != null) await driver.close(); }); diff --git a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_with_semantics_test.dart b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_with_semantics_test.dart index 40c924b215..eaa0ca226e 100644 --- a/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_with_semantics_test.dart +++ b/dev/integration_tests/flutter_gallery/test_driver/transitions_perf_with_semantics_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 import 'transitions_perf_test.dart' as transitions_perf_test; void main() {