[null-safety] opt driver tests into null safety (#70245)
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user