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 @@
// 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:ui';
import 'package:flutter/cupertino.dart';
......@@ -26,7 +25,7 @@ final List<String> kSkippedDemos = <String>[
/// home screen twice.
Future<void> runDemos(List<String> demos, WidgetController controller) async {
final Finder demoList = find.byType(Scrollable);
String currentDemoCategory;
String? currentDemoCategory;
for (final String demo in demos) {
if (kSkippedDemos.contains(demo))
......
......@@ -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_driver/driver_extension.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter/material.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 'dart:convert' show JsonEncoder;
import 'package:flutter_driver/driver_extension.dart';
......@@ -25,20 +24,20 @@ List<String> _allDemos = kAllGalleryDemos.map(
Set<String> _unTestedDemos = Set<String>.from(_allDemos);
class _MessageHandler {
static LiveWidgetController controller;
static LiveWidgetController? controller;
Future<String> call(String message) async {
switch(message) {
case 'demoNames':
return const JsonEncoder.withIndent(' ').convert(_allDemos);
case 'profileDemos':
controller ??= LiveWidgetController(WidgetsBinding.instance);
await runDemos(kProfiledDemos, controller);
controller ??= LiveWidgetController(WidgetsBinding.instance!);
await runDemos(kProfiledDemos, controller!);
_unTestedDemos.removeAll(kProfiledDemos);
return const JsonEncoder.withIndent(' ').convert(kProfiledDemos);
case 'restDemos':
controller ??= LiveWidgetController(WidgetsBinding.instance);
controller ??= LiveWidgetController(WidgetsBinding.instance!);
final List<String> restDemos = _unTestedDemos.toList();
await runDemos(restDemos, controller);
await runDemos(restDemos, controller!);
return const JsonEncoder.withIndent(' ').convert(restDemos);
default:
throw ArgumentError;
......@@ -47,7 +46,7 @@ class _MessageHandler {
}
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
// for better visual effect at the cost of performance.
runApp(const GalleryApp(testMode: true));
......
......@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
// @dart = 2.9
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
......@@ -12,8 +11,8 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async {
do {
await SchedulerBinding.instance.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame);
await SchedulerBinding.instance!.endOfFrame;
} while (SchedulerBinding.instance!.hasScheduledFrame);
}
int iteration = 0;
......@@ -31,5 +30,5 @@ Future<void> main() async {
await endOfAnimation();
await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
WidgetsBinding.instance.addObserver(LifecycleObserver());
WidgetsBinding.instance!.addObserver(LifecycleObserver());
}
......@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__image_cache_memory.dart
// @dart = 2.9
import 'package:flutter/widgets.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -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
// flaky, we can rely on a more deterministic source such as
......@@ -49,7 +48,7 @@ Future<void> main() async {
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
final WidgetController controller =
LiveWidgetController(WidgetsBinding.instance);
LiveWidgetController(WidgetsBinding.instance!);
debugPrint('Scrolling...');
final Finder list = find.byKey(const Key('ImageList'));
......
......@@ -4,7 +4,6 @@
// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart
// @dart = 2.9
import 'dart:async';
import 'package:flutter/material.dart';
......@@ -14,8 +13,8 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> endOfAnimation() async {
do {
await SchedulerBinding.instance.endOfFrame;
} while (SchedulerBinding.instance.hasScheduledFrame);
await SchedulerBinding.instance!.endOfFrame;
} while (SchedulerBinding.instance!.hasScheduledFrame);
}
Rect boundsFor(WidgetController controller, Finder item) {
......@@ -36,7 +35,7 @@ Future<void> main() async {
child: GalleryApp(testMode: true),
),
));
await SchedulerBinding.instance.endOfFrame;
await SchedulerBinding.instance!.endOfFrame;
await Future<void>.delayed(const Duration(milliseconds: 50));
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
......@@ -50,9 +49,9 @@ Future<void> main() async {
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...');
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