Skip to content

Commit dfaec11

Browse files
author
Jonah Williams
authored
migrate web integration tests to null safety (#106231)
1 parent adec8f2 commit dfaec11

File tree

7 files changed

+30
-46
lines changed

7 files changed

+30
-46
lines changed

packages/flutter_tools/test/web.shard/debugger_stepping_web_test.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'package:file/file.dart';
86

97
import '../integration.shard/test_data/stepping_project.dart';
@@ -12,8 +10,8 @@ import '../integration.shard/test_utils.dart';
1210
import '../src/common.dart';
1311

1412
void main() {
15-
Directory tempDirectory;
16-
FlutterRunTestDriver flutter;
13+
late Directory tempDirectory;
14+
late FlutterRunTestDriver flutter;
1715

1816
setUp(() {
1917
tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.');
@@ -30,13 +28,13 @@ void main() {
3028
additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
3129
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
3230
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
33-
expect((await flutter.getSourceLocation()).line, equals(project.breakpointLine));
31+
expect((await flutter.getSourceLocation())!.line, equals(project.breakpointLine));
3432

3533
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
3634
for (int i = 1; i <= project.numberOfSteps; i += 1) {
3735
await flutter.stepOverOrOverAsyncSuspension();
38-
final SourcePosition location = await flutter.getSourceLocation();
39-
final int actualLine = location.line;
36+
final SourcePosition? location = await flutter.getSourceLocation();
37+
final int actualLine = location!.line;
4038

4139
// Get the line we're expected to stop at by searching for the comment
4240
// within the source code.

packages/flutter_tools/test/web.shard/expression_evaluation_web_test.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'package:file/file.dart';
86
import 'package:vm_service/vm_service.dart';
97

@@ -16,8 +14,8 @@ import '../src/common.dart';
1614
void main() {
1715
group('Flutter run for web', () {
1816
final BasicProject project = BasicProject();
19-
Directory tempDir;
20-
FlutterRunTestDriver flutter;
17+
late Directory tempDir;
18+
late FlutterRunTestDriver flutter;
2119

2220
setUp(() async {
2321
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
@@ -33,7 +31,7 @@ void main() {
3331
tryToDelete(tempDir);
3432
});
3533

36-
Future<void> start({bool expressionEvaluation}) async {
34+
Future<void> start({required bool expressionEvaluation}) async {
3735
// The non-test project has a loop around its breakpoints.
3836
// No need to start paused as all breakpoint would be eventually reached.
3937
await flutter.run(
@@ -116,8 +114,8 @@ void main() {
116114

117115
group('Flutter test for web', () {
118116
final TestsProject project = TestsProject();
119-
Directory tempDir;
120-
FlutterRunTestDriver flutter;
117+
late Directory tempDir;
118+
late FlutterRunTestDriver flutter;
121119

122120
setUp(() async {
123121
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
@@ -130,15 +128,15 @@ void main() {
130128
tryToDelete(tempDir);
131129
});
132130

133-
Future<Isolate> breakInMethod(FlutterTestDriver flutter) async {
131+
Future<Isolate?> breakInMethod(FlutterTestDriver flutter) async {
134132
await flutter.addBreakpoint(
135133
project.breakpointAppUri,
136134
project.breakpointLine,
137135
);
138136
return flutter.resume(waitForNextPause: true);
139137
}
140138

141-
Future<void> startPaused({bool expressionEvaluation}) {
139+
Future<void> startPaused({required bool expressionEvaluation}) {
142140
// The test project does not have a loop around its breakpoints.
143141
// Start paused so we can set a breakpoint before passing it
144142
// in the execution.
@@ -224,19 +222,19 @@ Future<void> evaluateComplexExpressions(FlutterTestDriver flutter) async {
224222

225223
Future<void> evaluateTrivialExpressionsInLibrary(FlutterTestDriver flutter) async {
226224
final LibraryRef library = await getRootLibrary(flutter);
227-
final ObjRef res = await flutter.evaluate(library.id, '"test"');
225+
final ObjRef res = await flutter.evaluate(library.id!, '"test"');
228226
expectInstance(res, InstanceKind.kString, 'test');
229227
}
230228

231229
Future<void> evaluateComplexExpressionsInLibrary(FlutterTestDriver flutter) async {
232230
final LibraryRef library = await getRootLibrary(flutter);
233-
final ObjRef res = await flutter.evaluate(library.id, 'new DateTime.now().year');
231+
final ObjRef res = await flutter.evaluate(library.id!, 'new DateTime.now().year');
234232
expectInstance(res, InstanceKind.kDouble, DateTime.now().year.toString());
235233
}
236234

237235
Future<void> evaluateWebLibraryBooleanFromEnvironmentInLibrary(FlutterTestDriver flutter) async {
238236
final LibraryRef library = await getRootLibrary(flutter);
239-
final ObjRef res = await flutter.evaluate(library.id, 'const bool.fromEnvironment("dart.library.html")');
237+
final ObjRef res = await flutter.evaluate(library.id!, 'const bool.fromEnvironment("dart.library.html")');
240238
expectInstance(res, InstanceKind.kBool, true.toString());
241239
}
242240

@@ -246,8 +244,8 @@ Future<LibraryRef> getRootLibrary(FlutterTestDriver flutter) async {
246244
//
247245
// Issue: https://github.com/dart-lang/sdk/issues/44760
248246
final Isolate isolate = await flutter.getFlutterIsolate();
249-
return isolate.libraries
250-
.firstWhere((LibraryRef l) => l.uri.contains('org-dartlang-app'));
247+
return isolate.libraries!
248+
.firstWhere((LibraryRef l) => l.uri!.contains('org-dartlang-app'));
251249
}
252250

253251
void expectInstance(ObjRef result, String kind, String message) {

packages/flutter_tools/test/web.shard/hot_reload_web_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'dart:async';
86

97
import 'package:file/file.dart';
@@ -14,9 +12,9 @@ import '../integration.shard/test_utils.dart';
1412
import '../src/common.dart';
1513

1614
void main() {
17-
Directory tempDir;
15+
late Directory tempDir;
1816
final HotReloadProject project = HotReloadProject();
19-
FlutterRunTestDriver flutter;
17+
late FlutterRunTestDriver flutter;
2018

2119
setUp(() async {
2220
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
@@ -25,8 +23,8 @@ void main() {
2523
});
2624

2725
tearDown(() async {
28-
await flutter?.stop();
29-
await flutter?.done;
26+
await flutter.stop();
27+
await flutter.done;
3028
tryToDelete(tempDir);
3129
});
3230

packages/flutter_tools/test/web.shard/output_web_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'package:file/file.dart';
86
import 'package:flutter_tools/src/base/file_system.dart';
97
import 'package:vm_service/vm_service.dart';
@@ -15,15 +13,14 @@ import '../integration.shard/test_utils.dart';
1513
import '../src/common.dart';
1614

1715
void main() {
18-
Directory tempDir;
16+
late Directory tempDir;
1917
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
20-
FlutterRunTestDriver flutter;
18+
late FlutterRunTestDriver flutter;
2119

2220
setUp(() async {
2321
tempDir = createResolvedTempDirectorySync('run_test.');
2422
await project.setUpIn(tempDir);
2523
flutter = FlutterRunTestDriver(tempDir);
26-
//flutter.stdout.listen(print);
2724
});
2825

2926
tearDown(() async {
@@ -37,7 +34,6 @@ void main() {
3734
await flutter.run(
3835
withDebugger: true,
3936
chrome: true,
40-
expressionEvaluation: true,
4137
additionalCommandArgs: <String>[
4238
if (verbose) '--verbose',
4339
'--web-renderer=html',

packages/flutter_tools/test/web.shard/vm_service_web_test.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'dart:async';
86

97
import 'package:file/file.dart';
@@ -17,9 +15,9 @@ import '../integration.shard/test_utils.dart';
1715
import '../src/common.dart';
1816

1917
void main() {
20-
Directory tempDir;
18+
late Directory tempDir;
2119
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
22-
FlutterRunTestDriver flutter;
20+
late FlutterRunTestDriver flutter;
2321

2422
group('Clients of flutter run on web with DDS enabled', () {
2523
setUp(() async {
@@ -92,7 +90,7 @@ void main() {
9290
}
9391

9492
Future<void> validateFlutterVersion(VmService client) async {
95-
String method;
93+
String? method;
9694

9795
final Future<dynamic> registration = expectLater(
9896
client.onEvent('Service'),
@@ -110,10 +108,10 @@ Future<void> validateFlutterVersion(VmService client) async {
110108
await registration;
111109
await client.streamCancel('Service');
112110

113-
final dynamic version1 = await client.callServiceExtension(method);
111+
final dynamic version1 = await client.callServiceExtension(method!);
114112
expect(version1, const TypeMatcher<Success>()
115113
.having((Success r) => r.type, 'type', 'Success')
116-
.having((Success r) => r.json['frameworkVersion'], 'frameworkVersion', isNotNull));
114+
.having((Success r) => r.json!['frameworkVersion'], 'frameworkVersion', isNotNull));
117115

118116
await client.dispose();
119117
}

packages/flutter_tools/test/web.shard/web_driver_service_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'package:flutter_tools/src/base/common.dart';
86
import 'package:flutter_tools/src/base/logger.dart';
97
import 'package:flutter_tools/src/base/process.dart';

packages/flutter_tools/test/web.shard/web_run_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.8
6-
75
import 'package:file/file.dart';
86
import 'package:flutter_tools/src/base/file_system.dart';
97

@@ -13,9 +11,9 @@ import '../integration.shard/test_utils.dart';
1311
import '../src/common.dart';
1412

1513
void main() {
16-
Directory tempDir;
14+
late Directory tempDir;
1715
final BasicProjectWithUnaryMain project = BasicProjectWithUnaryMain();
18-
FlutterRunTestDriver flutter;
16+
late FlutterRunTestDriver flutter;
1917

2018
setUp(() async {
2119
tempDir = createResolvedTempDirectorySync('run_test.');

0 commit comments

Comments
 (0)