Unverified Commit 942de678 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Make remaining DAP tests null-safe (#97368)

parent dcce0db1
...@@ -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:dds/src/dap/protocol_generated.dart'; import 'package:dds/src/dap/protocol_generated.dart';
...@@ -18,8 +16,8 @@ import 'test_client.dart'; ...@@ -18,8 +16,8 @@ import 'test_client.dart';
import 'test_support.dart'; import 'test_support.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
/*late*/ DapTestSession dap; late DapTestSession dap;
final String relativeMainPath = 'lib${fileSystem.path.separator}main.dart'; final String relativeMainPath = 'lib${fileSystem.path.separator}main.dart';
setUpAll(() { setUpAll(() {
...@@ -119,7 +117,7 @@ void main() { ...@@ -119,7 +117,7 @@ void main() {
await project.setUpIn(tempDir); await project.setUpIn(tempDir);
// Launch the app and wait for it to print "topLevelFunction". // Launch the app and wait for it to print "topLevelFunction".
await Future.wait(<Future<Object>>[ await Future.wait(<Future<void>>[
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')), dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
dap.client.start( dap.client.start(
launch: () => dap.client.launch( launch: () => dap.client.launch(
...@@ -156,7 +154,7 @@ void main() { ...@@ -156,7 +154,7 @@ void main() {
await project.setUpIn(tempDir); await project.setUpIn(tempDir);
// Launch the app and wait for it to print "topLevelFunction". // Launch the app and wait for it to print "topLevelFunction".
await Future.wait(<Future<Object>>[ await Future.wait(<Future<void>>[
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')), dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
dap.client.start( dap.client.start(
launch: () => dap.client.launch( launch: () => dap.client.launch(
...@@ -193,10 +191,10 @@ void main() { ...@@ -193,10 +191,10 @@ void main() {
await project.setUpIn(tempDir); await project.setUpIn(tempDir);
// Launch the app and wait for it to stop at an exception. // Launch the app and wait for it to stop at an exception.
int originalThreadId, newThreadId; late int originalThreadId, newThreadId;
await Future.wait(<Future<Object>>[ await Future.wait(<Future<void>>[
// Capture the thread ID of the stopped thread. // Capture the thread ID of the stopped thread.
dap.client.stoppedEvents.first.then((StoppedEventBody event) => originalThreadId = event.threadId), dap.client.stoppedEvents.first.then((StoppedEventBody event) => originalThreadId = event.threadId!),
dap.client.start( dap.client.start(
exceptionPauseMode: 'All', // Ensure we stop on all exceptions exceptionPauseMode: 'All', // Ensure we stop on all exceptions
launch: () => dap.client.launch( launch: () => dap.client.launch(
...@@ -208,9 +206,9 @@ void main() { ...@@ -208,9 +206,9 @@ void main() {
// Hot restart, ensuring it completes and capturing the ID of the new thread // Hot restart, ensuring it completes and capturing the ID of the new thread
// to pause. // to pause.
await Future.wait(<Future<Object>>[ await Future.wait(<Future<void>>[
// Capture the thread ID of the newly stopped thread. // Capture the thread ID of the newly stopped thread.
dap.client.stoppedEvents.first.then((StoppedEventBody event) => newThreadId = event.threadId), dap.client.stoppedEvents.first.then((StoppedEventBody event) => newThreadId = event.threadId!),
dap.client.hotRestart(), dap.client.hotRestart(),
], eagerError: true); ], eagerError: true);
...@@ -230,11 +228,11 @@ void main() { ...@@ -230,11 +228,11 @@ void main() {
// extension loads, as we'll need that to call it later. // extension loads, as we'll need that to call it later.
final Future<String> isolateIdForDebugPaint = dap.client final Future<String> isolateIdForDebugPaint = dap.client
.serviceExtensionAdded(debugPaintRpc) .serviceExtensionAdded(debugPaintRpc)
.then((Map<String, Object/*?*/> body) => body['isolateId'] as String); .then((Map<String, Object?> body) => body['isolateId']! as String);
// Launch the app and wait for it to print "topLevelFunction" so we know // Launch the app and wait for it to print "topLevelFunction" so we know
// it's up and running. // it's up and running.
await Future.wait(<Future<Object>>[ await Future.wait(<Future<void>>[
dap.client.outputEvents.firstWhere((OutputEventBody output) => dap.client.outputEvents.firstWhere((OutputEventBody output) =>
output.output.startsWith('topLevelFunction')), output.output.startsWith('topLevelFunction')),
dap.client.start( dap.client.start(
...@@ -247,15 +245,15 @@ void main() { ...@@ -247,15 +245,15 @@ void main() {
// Capture the next relevant state-change event (which should occur as a // Capture the next relevant state-change event (which should occur as a
// result of the call below). // result of the call below).
final Future<Map<String, Object/*?*/>> stateChangeEventFuture = final Future<Map<String, Object?>> stateChangeEventFuture =
dap.client.serviceExtensionStateChanged(debugPaintRpc); dap.client.serviceExtensionStateChanged(debugPaintRpc);
// Enable debug paint to trigger the state change. // Enable debug paint to trigger the state change.
await dap.client.custom( await dap.client.custom(
'callService', 'callService',
<String, Object/*?*/>{ <String, Object?>{
'method': debugPaintRpc, 'method': debugPaintRpc,
'params': <String, Object/*?*/>{ 'params': <String, Object?>{
'enabled': true, 'enabled': true,
'isolateId': await isolateIdForDebugPaint, 'isolateId': await isolateIdForDebugPaint,
}, },
...@@ -263,7 +261,7 @@ void main() { ...@@ -263,7 +261,7 @@ void main() {
); );
// Ensure the event occurred, and its value was as expected. // Ensure the event occurred, and its value was as expected.
final Map<String, Object/*?*/> stateChangeEvent = await stateChangeEventFuture; final Map<String, Object?> stateChangeEvent = await stateChangeEventFuture;
expect(stateChangeEvent['value'], 'true'); // extension state change values are always strings expect(stateChangeEvent['value'], 'true'); // extension state change values are always strings
await dap.client.terminate(); await dap.client.terminate();
...@@ -273,7 +271,7 @@ void main() { ...@@ -273,7 +271,7 @@ void main() {
/// Extracts the output from a set of [OutputEventBody], removing any /// Extracts the output from a set of [OutputEventBody], removing any
/// adjacent duplicates and combining into a single string. /// adjacent duplicates and combining into a single string.
String _uniqueOutputLines(List<OutputEventBody> outputEvents) { String _uniqueOutputLines(List<OutputEventBody> outputEvents) {
String/*?*/ lastItem; String? lastItem;
return outputEvents return outputEvents
.map((OutputEventBody e) => e.output) .map((OutputEventBody e) => e.output)
.where((String output) { .where((String output) {
......
...@@ -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:dds/src/dap/protocol_generated.dart'; import 'package:dds/src/dap/protocol_generated.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
...@@ -15,8 +13,8 @@ import 'test_client.dart'; ...@@ -15,8 +13,8 @@ import 'test_client.dart';
import 'test_support.dart'; import 'test_support.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
/*late*/ DapTestSession dap; late DapTestSession dap;
setUpAll(() { setUpAll(() {
Cache.flutterRoot = getFlutterRoot(); Cache.flutterRoot = getFlutterRoot();
...@@ -107,8 +105,8 @@ void main() { ...@@ -107,8 +105,8 @@ void main() {
); );
final List<Object> testsNames = outputEvents.testNotifications final List<Object> testsNames = outputEvents.testNotifications
.where((Map<String, Object>/*?*/ e) => e['type'] == 'testStart') .where((Map<String, Object?> e) => e['type'] == 'testStart')
.map((Map<String, Object>/*?*/ e) => (e['test'] as Map<String, Object/*?*/>)['name']) .map((Map<String, Object?> e) => (e['test']! as Map<String, Object?>)['name']!)
.toList(); .toList();
expect(testsNames, contains('Flutter tests can pass')); expect(testsNames, contains('Flutter tests can pass'));
...@@ -140,7 +138,7 @@ void _expectStandardTestsProjectResults(TestEvents events) { ...@@ -140,7 +138,7 @@ void _expectStandardTestsProjectResults(TestEvents events) {
// Check we recieved all expected test events passed through from // Check we recieved all expected test events passed through from
// package:test. // package:test.
final List<Object> eventNames = final List<Object> eventNames =
events.testNotifications.map((Map<String, Object/*?*/> e) => e['type']).toList(); events.testNotifications.map((Map<String, Object?> e) => e['type']!).toList();
// start/done should always be first/last. // start/done should always be first/last.
expect(eventNames.first, equals('start')); expect(eventNames.first, equals('start'));
......
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