Unverified Commit 28ecf056 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[null-safety] opt driver tests into null safety (#70245)

parent 425ae862
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -26,7 +25,7 @@ final List<String> kSkippedDemos = <String>[ ...@@ -26,7 +25,7 @@ final List<String> kSkippedDemos = <String>[
/// home screen twice. /// home screen twice.
Future<void> runDemos(List<String> demos, WidgetController controller) async { Future<void> runDemos(List<String> demos, WidgetController controller) async {
final Finder demoList = find.byType(Scrollable); final Finder demoList = find.byType(Scrollable);
String currentDemoCategory; String? currentDemoCategory;
for (final String demo in demos) { for (final String demo in demos) {
if (kSkippedDemos.contains(demo)) if (kSkippedDemos.contains(demo))
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp; import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9
import 'dart:convert' show JsonEncoder; import 'dart:convert' show JsonEncoder;
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
...@@ -25,20 +24,20 @@ List<String> _allDemos = kAllGalleryDemos.map( ...@@ -25,20 +24,20 @@ List<String> _allDemos = kAllGalleryDemos.map(
Set<String> _unTestedDemos = Set<String>.from(_allDemos); Set<String> _unTestedDemos = Set<String>.from(_allDemos);
class _MessageHandler { class _MessageHandler {
static LiveWidgetController controller; static LiveWidgetController? controller;
Future<String> call(String message) async { Future<String> call(String message) async {
switch(message) { switch(message) {
case 'demoNames': case 'demoNames':
return const JsonEncoder.withIndent(' ').convert(_allDemos); return const JsonEncoder.withIndent(' ').convert(_allDemos);
case 'profileDemos': case 'profileDemos':
controller ??= LiveWidgetController(WidgetsBinding.instance); controller ??= LiveWidgetController(WidgetsBinding.instance!);
await runDemos(kProfiledDemos, controller); await runDemos(kProfiledDemos, controller!);
_unTestedDemos.removeAll(kProfiledDemos); _unTestedDemos.removeAll(kProfiledDemos);
return const JsonEncoder.withIndent(' ').convert(kProfiledDemos); return const JsonEncoder.withIndent(' ').convert(kProfiledDemos);
case 'restDemos': case 'restDemos':
controller ??= LiveWidgetController(WidgetsBinding.instance); controller ??= LiveWidgetController(WidgetsBinding.instance!);
final List<String> restDemos = _unTestedDemos.toList(); final List<String> restDemos = _unTestedDemos.toList();
await runDemos(restDemos, controller); await runDemos(restDemos, controller!);
return const JsonEncoder.withIndent(' ').convert(restDemos); return const JsonEncoder.withIndent(' ').convert(restDemos);
default: default:
throw ArgumentError; throw ArgumentError;
...@@ -47,7 +46,7 @@ class _MessageHandler { ...@@ -47,7 +46,7 @@ class _MessageHandler {
} }
void main() { void main() {
enableFlutterDriverExtension(handler: _MessageHandler().call); enableFlutterDriverExtension(handler: (String? message) => _MessageHandler().call(message!));
// As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736 // As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736
// for better visual effect at the cost of performance. // for better visual effect at the cost of performance.
runApp(const GalleryApp(testMode: true)); runApp(const GalleryApp(testMode: true));
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart // See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
// @dart = 2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp; import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
...@@ -12,8 +11,8 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -12,8 +11,8 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async { Future<void> endOfAnimation() async {
do { do {
await SchedulerBinding.instance.endOfFrame; await SchedulerBinding.instance!.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame); } while (SchedulerBinding.instance!.hasScheduledFrame);
} }
int iteration = 0; int iteration = 0;
...@@ -31,5 +30,5 @@ Future<void> main() async { ...@@ -31,5 +30,5 @@ Future<void> main() async {
await endOfAnimation(); await endOfAnimation();
await Future<void>.delayed(const Duration(milliseconds: 50)); await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ===='); debugPrint('==== MEMORY BENCHMARK ==== READY ====');
WidgetsBinding.instance.addObserver(LifecycleObserver()); WidgetsBinding.instance!.addObserver(LifecycleObserver());
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart // See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart
// @dart = 2.9
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -39,7 +38,7 @@ Future<void> main() async { ...@@ -39,7 +38,7 @@ Future<void> main() async {
), ),
)); ));
await SchedulerBinding.instance.endOfFrame; await SchedulerBinding.instance!.endOfFrame;
// We are waiting for the GPU to rasterize a frame here. This makes this // We are waiting for the GPU to rasterize a frame here. This makes this
// flaky, we can rely on a more deterministic source such as // flaky, we can rely on a more deterministic source such as
...@@ -49,7 +48,7 @@ Future<void> main() async { ...@@ -49,7 +48,7 @@ Future<void> main() async {
debugPrint('==== MEMORY BENCHMARK ==== READY ===='); debugPrint('==== MEMORY BENCHMARK ==== READY ====');
final WidgetController controller = final WidgetController controller =
LiveWidgetController(WidgetsBinding.instance); LiveWidgetController(WidgetsBinding.instance!);
debugPrint('Scrolling...'); debugPrint('Scrolling...');
final Finder list = find.byKey(const Key('ImageList')); final Finder list = find.byKey(const Key('ImageList'));
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart // See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
// @dart = 2.9
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -14,8 +13,8 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -14,8 +13,8 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async { Future<void> endOfAnimation() async {
do { do {
await SchedulerBinding.instance.endOfFrame; await SchedulerBinding.instance!.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame); } while (SchedulerBinding.instance!.hasScheduledFrame);
} }
Rect boundsFor(WidgetController controller, Finder item) { Rect boundsFor(WidgetController controller, Finder item) {
...@@ -36,7 +35,7 @@ Future<void> main() async { ...@@ -36,7 +35,7 @@ Future<void> main() async {
child: GalleryApp(testMode: true), child: GalleryApp(testMode: true),
), ),
)); ));
await SchedulerBinding.instance.endOfFrame; await SchedulerBinding.instance!.endOfFrame;
await Future<void>.delayed(const Duration(milliseconds: 50)); await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ===='); debugPrint('==== MEMORY BENCHMARK ==== READY ====');
...@@ -50,9 +49,9 @@ Future<void> main() async { ...@@ -50,9 +49,9 @@ Future<void> main() async {
child: GalleryApp(testMode: true), child: GalleryApp(testMode: true),
), ),
)); ));
await SchedulerBinding.instance.endOfFrame; await SchedulerBinding.instance!.endOfFrame;
final WidgetController controller = LiveWidgetController(WidgetsBinding.instance); final WidgetController controller = LiveWidgetController(WidgetsBinding.instance!);
debugPrint('Navigating...'); debugPrint('Navigating...');
await controller.tap(find.text('Material')); await controller.tap(find.text('Material'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment