Unverified Commit dfaec11b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

migrate web integration tests to null safety (#106231)

parent adec8f23
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import '../integration.shard/test_data/stepping_project.dart'; import '../integration.shard/test_data/stepping_project.dart';
...@@ -12,8 +10,8 @@ import '../integration.shard/test_utils.dart'; ...@@ -12,8 +10,8 @@ import '../integration.shard/test_utils.dart';
import '../src/common.dart'; import '../src/common.dart';
void main() { void main() {
Directory tempDirectory; late Directory tempDirectory;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() { setUp(() {
tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.'); tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.');
...@@ -30,13 +28,13 @@ void main() { ...@@ -30,13 +28,13 @@ void main() {
additionalCommandArgs: <String>['--verbose', '--web-renderer=html']); additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine); await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint. await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
expect((await flutter.getSourceLocation()).line, equals(project.breakpointLine)); expect((await flutter.getSourceLocation())!.line, equals(project.breakpointLine));
// Issue 5 steps, ensuring that we end up on the annotated lines each time. // Issue 5 steps, ensuring that we end up on the annotated lines each time.
for (int i = 1; i <= project.numberOfSteps; i += 1) { for (int i = 1; i <= project.numberOfSteps; i += 1) {
await flutter.stepOverOrOverAsyncSuspension(); await flutter.stepOverOrOverAsyncSuspension();
final SourcePosition location = await flutter.getSourceLocation(); final SourcePosition? location = await flutter.getSourceLocation();
final int actualLine = location.line; final int actualLine = location!.line;
// Get the line we're expected to stop at by searching for the comment // Get the line we're expected to stop at by searching for the comment
// within the source code. // within the source code.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -16,8 +14,8 @@ import '../src/common.dart'; ...@@ -16,8 +14,8 @@ import '../src/common.dart';
void main() { void main() {
group('Flutter run for web', () { group('Flutter run for web', () {
final BasicProject project = BasicProject(); final BasicProject project = BasicProject();
Directory tempDir; late Directory tempDir;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.'); tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
...@@ -33,7 +31,7 @@ void main() { ...@@ -33,7 +31,7 @@ void main() {
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
Future<void> start({bool expressionEvaluation}) async { Future<void> start({required bool expressionEvaluation}) async {
// The non-test project has a loop around its breakpoints. // The non-test project has a loop around its breakpoints.
// No need to start paused as all breakpoint would be eventually reached. // No need to start paused as all breakpoint would be eventually reached.
await flutter.run( await flutter.run(
...@@ -116,8 +114,8 @@ void main() { ...@@ -116,8 +114,8 @@ void main() {
group('Flutter test for web', () { group('Flutter test for web', () {
final TestsProject project = TestsProject(); final TestsProject project = TestsProject();
Directory tempDir; late Directory tempDir;
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.'); tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
...@@ -130,7 +128,7 @@ void main() { ...@@ -130,7 +128,7 @@ void main() {
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
Future<Isolate> breakInMethod(FlutterTestDriver flutter) async { Future<Isolate?> breakInMethod(FlutterTestDriver flutter) async {
await flutter.addBreakpoint( await flutter.addBreakpoint(
project.breakpointAppUri, project.breakpointAppUri,
project.breakpointLine, project.breakpointLine,
...@@ -138,7 +136,7 @@ void main() { ...@@ -138,7 +136,7 @@ void main() {
return flutter.resume(waitForNextPause: true); return flutter.resume(waitForNextPause: true);
} }
Future<void> startPaused({bool expressionEvaluation}) { Future<void> startPaused({required bool expressionEvaluation}) {
// The test project does not have a loop around its breakpoints. // The test project does not have a loop around its breakpoints.
// Start paused so we can set a breakpoint before passing it // Start paused so we can set a breakpoint before passing it
// in the execution. // in the execution.
...@@ -224,19 +222,19 @@ Future<void> evaluateComplexExpressions(FlutterTestDriver flutter) async { ...@@ -224,19 +222,19 @@ Future<void> evaluateComplexExpressions(FlutterTestDriver flutter) async {
Future<void> evaluateTrivialExpressionsInLibrary(FlutterTestDriver flutter) async { Future<void> evaluateTrivialExpressionsInLibrary(FlutterTestDriver flutter) async {
final LibraryRef library = await getRootLibrary(flutter); final LibraryRef library = await getRootLibrary(flutter);
final ObjRef res = await flutter.evaluate(library.id, '"test"'); final ObjRef res = await flutter.evaluate(library.id!, '"test"');
expectInstance(res, InstanceKind.kString, 'test'); expectInstance(res, InstanceKind.kString, 'test');
} }
Future<void> evaluateComplexExpressionsInLibrary(FlutterTestDriver flutter) async { Future<void> evaluateComplexExpressionsInLibrary(FlutterTestDriver flutter) async {
final LibraryRef library = await getRootLibrary(flutter); final LibraryRef library = await getRootLibrary(flutter);
final ObjRef res = await flutter.evaluate(library.id, 'new DateTime.now().year'); final ObjRef res = await flutter.evaluate(library.id!, 'new DateTime.now().year');
expectInstance(res, InstanceKind.kDouble, DateTime.now().year.toString()); expectInstance(res, InstanceKind.kDouble, DateTime.now().year.toString());
} }
Future<void> evaluateWebLibraryBooleanFromEnvironmentInLibrary(FlutterTestDriver flutter) async { Future<void> evaluateWebLibraryBooleanFromEnvironmentInLibrary(FlutterTestDriver flutter) async {
final LibraryRef library = await getRootLibrary(flutter); final LibraryRef library = await getRootLibrary(flutter);
final ObjRef res = await flutter.evaluate(library.id, 'const bool.fromEnvironment("dart.library.html")'); final ObjRef res = await flutter.evaluate(library.id!, 'const bool.fromEnvironment("dart.library.html")');
expectInstance(res, InstanceKind.kBool, true.toString()); expectInstance(res, InstanceKind.kBool, true.toString());
} }
...@@ -246,8 +244,8 @@ Future<LibraryRef> getRootLibrary(FlutterTestDriver flutter) async { ...@@ -246,8 +244,8 @@ Future<LibraryRef> getRootLibrary(FlutterTestDriver flutter) async {
// //
// Issue: https://github.com/dart-lang/sdk/issues/44760 // Issue: https://github.com/dart-lang/sdk/issues/44760
final Isolate isolate = await flutter.getFlutterIsolate(); final Isolate isolate = await flutter.getFlutterIsolate();
return isolate.libraries return isolate.libraries!
.firstWhere((LibraryRef l) => l.uri.contains('org-dartlang-app')); .firstWhere((LibraryRef l) => l.uri!.contains('org-dartlang-app'));
} }
void expectInstance(ObjRef result, String kind, String message) { void expectInstance(ObjRef result, String kind, String message) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'dart:async'; import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -14,9 +12,9 @@ import '../integration.shard/test_utils.dart'; ...@@ -14,9 +12,9 @@ import '../integration.shard/test_utils.dart';
import '../src/common.dart'; import '../src/common.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
final HotReloadProject project = HotReloadProject(); final HotReloadProject project = HotReloadProject();
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('hot_reload_test.'); tempDir = createResolvedTempDirectorySync('hot_reload_test.');
...@@ -25,8 +23,8 @@ void main() { ...@@ -25,8 +23,8 @@ void main() {
}); });
tearDown(() async { tearDown(() async {
await flutter?.stop(); await flutter.stop();
await flutter?.done; await flutter.done;
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service.dart';
...@@ -15,15 +13,14 @@ import '../integration.shard/test_utils.dart'; ...@@ -15,15 +13,14 @@ import '../integration.shard/test_utils.dart';
import '../src/common.dart'; import '../src/common.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain(); final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.'); tempDir = createResolvedTempDirectorySync('run_test.');
await project.setUpIn(tempDir); await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir); flutter = FlutterRunTestDriver(tempDir);
//flutter.stdout.listen(print);
}); });
tearDown(() async { tearDown(() async {
...@@ -37,7 +34,6 @@ void main() { ...@@ -37,7 +34,6 @@ void main() {
await flutter.run( await flutter.run(
withDebugger: true, withDebugger: true,
chrome: true, chrome: true,
expressionEvaluation: true,
additionalCommandArgs: <String>[ additionalCommandArgs: <String>[
if (verbose) '--verbose', if (verbose) '--verbose',
'--web-renderer=html', '--web-renderer=html',
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'dart:async'; import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
...@@ -17,9 +15,9 @@ import '../integration.shard/test_utils.dart'; ...@@ -17,9 +15,9 @@ import '../integration.shard/test_utils.dart';
import '../src/common.dart'; import '../src/common.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain(); final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
group('Clients of flutter run on web with DDS enabled', () { group('Clients of flutter run on web with DDS enabled', () {
setUp(() async { setUp(() async {
...@@ -92,7 +90,7 @@ void main() { ...@@ -92,7 +90,7 @@ void main() {
} }
Future<void> validateFlutterVersion(VmService client) async { Future<void> validateFlutterVersion(VmService client) async {
String method; String? method;
final Future<dynamic> registration = expectLater( final Future<dynamic> registration = expectLater(
client.onEvent('Service'), client.onEvent('Service'),
...@@ -110,10 +108,10 @@ Future<void> validateFlutterVersion(VmService client) async { ...@@ -110,10 +108,10 @@ Future<void> validateFlutterVersion(VmService client) async {
await registration; await registration;
await client.streamCancel('Service'); await client.streamCancel('Service');
final dynamic version1 = await client.callServiceExtension(method); final dynamic version1 = await client.callServiceExtension(method!);
expect(version1, const TypeMatcher<Success>() expect(version1, const TypeMatcher<Success>()
.having((Success r) => r.type, 'type', 'Success') .having((Success r) => r.type, 'type', 'Success')
.having((Success r) => r.json['frameworkVersion'], 'frameworkVersion', isNotNull)); .having((Success r) => r.json!['frameworkVersion'], 'frameworkVersion', isNotNull));
await client.dispose(); await client.dispose();
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/process.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +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.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
...@@ -13,9 +11,9 @@ import '../integration.shard/test_utils.dart'; ...@@ -13,9 +11,9 @@ import '../integration.shard/test_utils.dart';
import '../src/common.dart'; import '../src/common.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain(); final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
FlutterRunTestDriver flutter; late FlutterRunTestDriver flutter;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.'); tempDir = createResolvedTempDirectorySync('run_test.');
......
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