[flutter_tools] migrate some integration tests to null safety (#103560)
This commit is contained in:
parent
42b6fbad26
commit
9f28b83c19
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' hide Directory;
|
||||
@ -17,8 +15,8 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
Process daemonProcess;
|
||||
late Directory tempDir;
|
||||
late Process daemonProcess;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('daemon_mode_test.');
|
||||
@ -26,7 +24,7 @@ void main() {
|
||||
|
||||
tearDown(() async {
|
||||
tryToDelete(tempDir);
|
||||
daemonProcess?.kill();
|
||||
daemonProcess.kill();
|
||||
});
|
||||
|
||||
testWithoutContext('device.getDevices', () async {
|
||||
@ -43,12 +41,12 @@ void main() {
|
||||
|
||||
final StreamController<String> stdout = StreamController<String>.broadcast();
|
||||
transformToLines(daemonProcess.stdout).listen((String line) => stdout.add(line));
|
||||
final Stream<Map<String, dynamic>> stream = stdout
|
||||
final Stream<Map<String, Object?>?> stream = stdout
|
||||
.stream
|
||||
.map<Map<String, dynamic>>(parseFlutterResponse)
|
||||
.where((Map<String, dynamic> value) => value != null);
|
||||
.map<Map<String, Object?>?>(parseFlutterResponse)
|
||||
.where((Map<String, Object?>? value) => value != null);
|
||||
|
||||
Map<String, dynamic> response = await stream.first;
|
||||
Map<String, Object?> response = (await stream.first)!;
|
||||
expect(response['event'], 'daemon.connected');
|
||||
|
||||
// start listening for devices
|
||||
@ -56,13 +54,13 @@ void main() {
|
||||
'id': 1,
|
||||
'method': 'device.enable',
|
||||
})}]');
|
||||
response = await stream.firstWhere((Map<String, Object> json) => json['id'] == 1);
|
||||
response = (await stream.firstWhere((Map<String, Object?>? json) => json!['id'] == 1))!;
|
||||
expect(response['id'], 1);
|
||||
expect(response['error'], isNull);
|
||||
|
||||
// [{"event":"device.added","params":{"id":"flutter-tester","name":
|
||||
// "Flutter test device","platform":"flutter-tester","emulator":false}}]
|
||||
response = await stream.first;
|
||||
response = (await stream.first)!;
|
||||
expect(response['event'], 'device.added');
|
||||
|
||||
// get the list of all devices
|
||||
@ -71,7 +69,7 @@ void main() {
|
||||
'method': 'device.getDevices',
|
||||
})}]');
|
||||
// Skip other device.added events that may fire (desktop/web devices).
|
||||
response = await stream.firstWhere((Map<String, dynamic> response) => response['event'] != 'device.added');
|
||||
response = (await stream.firstWhere((Map<String, Object?>? response) => response!['event'] != 'device.added'))!;
|
||||
expect(response['id'], 2);
|
||||
expect(response['error'], isNull);
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
@ -29,7 +27,7 @@ final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', platform
|
||||
|
||||
/// A test for flutter upgrade & downgrade that checks out a parallel flutter repo.
|
||||
void main() {
|
||||
Directory parentDirectory;
|
||||
late Directory parentDirectory;
|
||||
|
||||
setUp(() {
|
||||
parentDirectory = fileSystem.systemTempDirectory
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
@ -12,7 +10,7 @@ import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
final String dartBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'dart');
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
tempDir = createResolvedTempDirectorySync('exit_code_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:vm_service/vm_service.dart';
|
||||
|
||||
@ -13,9 +11,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
FlutterRunTestDriver flutterRun, flutterAttach;
|
||||
late FlutterRunTestDriver flutterRun, flutterAttach;
|
||||
final BasicProject project = BasicProject();
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('attach_test.');
|
||||
@ -39,28 +37,28 @@ void main() {
|
||||
|
||||
testWithoutContext('can hot reload', () async {
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort!);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
testWithoutContext('can detach, reattach, hot reload', () async {
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort!);
|
||||
await flutterAttach.detach();
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort!);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
testWithoutContext('killing process behaves the same as detach ', () async {
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort!);
|
||||
await flutterAttach.quit();
|
||||
flutterAttach = FlutterRunTestDriver(
|
||||
tempDir,
|
||||
logPrefix: 'ATTACH-2',
|
||||
spawnDdsInstance: false,
|
||||
);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort!);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
@ -85,11 +83,11 @@ void main() {
|
||||
);
|
||||
|
||||
final Response response = await flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri');
|
||||
final String vmServiceUri = response.json['value'] as String;
|
||||
final String vmServiceUri = response.json!['value'] as String;
|
||||
|
||||
// Attach with a different DevTools server address.
|
||||
await flutterAttach.attach(
|
||||
flutterRun.vmServicePort,
|
||||
flutterRun.vmServicePort!,
|
||||
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9110'],
|
||||
);
|
||||
await pollForServiceExtensionValue<String>(
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
|
||||
@ -17,9 +15,9 @@ import 'test_utils.dart';
|
||||
// `flutter build` command inside the `example` directory, so we create a plugin
|
||||
// project in the test.
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
String flutterBin;
|
||||
Directory exampleAppDir;
|
||||
late Directory tempDir;
|
||||
late String flutterBin;
|
||||
late Directory exampleAppDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
@ -11,9 +9,9 @@ import '../src/common.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
Directory projectRoot;
|
||||
String flutterBin;
|
||||
late Directory tempDir;
|
||||
late Directory projectRoot;
|
||||
late String flutterBin;
|
||||
final List<String> targetPlatforms = <String>[
|
||||
'apk',
|
||||
'web',
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
@ -11,9 +9,9 @@ import '../src/common.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
Directory projectRoot;
|
||||
String flutterBin;
|
||||
late Directory tempDir;
|
||||
late Directory projectRoot;
|
||||
late String flutterBin;
|
||||
final List<String> targetPlatforms = <String>[
|
||||
'apk',
|
||||
'web',
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -14,9 +12,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final BasicProjectWithFlutterGen project = BasicProjectWithFlutterGen();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:process/process.dart';
|
||||
@ -14,9 +12,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final BasicProject project = BasicProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -17,10 +15,10 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final ProjectWithEarlyError project = ProjectWithEarlyError();
|
||||
const String exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════';
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
@ -56,14 +54,14 @@ void main() {
|
||||
|
||||
if (line.startsWith('An Observatory debugger')) {
|
||||
final RegExp exp = RegExp(r'http://127.0.0.1:(\d+)/');
|
||||
final RegExpMatch match = exp.firstMatch(line);
|
||||
final String port = match.group(1);
|
||||
final RegExpMatch match = exp.firstMatch(line)!;
|
||||
final String port = match.group(1)!;
|
||||
if (port != null) {
|
||||
final VmService vmService =
|
||||
await vmServiceConnectUri('ws://localhost:$port/ws');
|
||||
final VM vm = await vmService.getVM();
|
||||
for (final IsolateRef isolate in vm.isolates) {
|
||||
await vmService.resume(isolate.id);
|
||||
for (final IsolateRef isolate in vm.isolates!) {
|
||||
await vmService.resume(isolate.id!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -19,8 +17,8 @@ final GenL10nProject project = GenL10nProject();
|
||||
// It can fail if gen_l10n produces a lib/l10n/app_localizations.dart that
|
||||
// does not analyze cleanly.
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver flutter;
|
||||
late Directory tempDir;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('gen_l10n_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
|
||||
@ -11,7 +9,7 @@ import '../src/common.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
@ -12,9 +10,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final HotReloadConstProject project = HotReloadConstProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
@ -23,7 +21,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -15,9 +13,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final HotReloadProject project = HotReloadProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
@ -26,7 +24,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
@ -123,7 +121,7 @@ void main() {
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
await flutter.hotReload(); // reload triggers code which eventually hits the breakpoint
|
||||
isolate = await flutter.waitForPause();
|
||||
expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint));
|
||||
expect(isolate.pauseEvent?.kind, equals(EventKind.kPauseBreakpoint));
|
||||
await flutter.resume();
|
||||
await flutter.addBreakpoint(
|
||||
project.buildBreakpointUri,
|
||||
@ -133,7 +131,7 @@ void main() {
|
||||
final Future<void> reloadFuture = flutter.hotReload().then((void value) { reloaded = true; });
|
||||
printOnFailure('waiting for pause...');
|
||||
isolate = await flutter.waitForPause();
|
||||
expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint));
|
||||
expect(isolate.pauseEvent?.kind, equals(EventKind.kPauseBreakpoint));
|
||||
printOnFailure('waiting for debugger message...');
|
||||
await sawDebuggerPausedMessage.future;
|
||||
expect(reloaded, isFalse);
|
||||
@ -179,7 +177,7 @@ void main() {
|
||||
await Future<void>.delayed(const Duration(seconds: 1));
|
||||
final Future<void> reloadFuture = flutter.hotReload().then((void value) { reloaded = true; });
|
||||
final Isolate isolate = await flutter.waitForPause();
|
||||
expect(isolate.pauseEvent.kind, equals(EventKind.kPauseBreakpoint));
|
||||
expect(isolate.pauseEvent?.kind, equals(EventKind.kPauseBreakpoint));
|
||||
expect(reloaded, isFalse);
|
||||
await sawDebuggerPausedMessage1.future; // this is the one where it say "uh, you broke into the debugger while reloading"
|
||||
await reloadFuture; // this is the one where it times out because you're in the debugger
|
||||
@ -191,10 +189,10 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
bool _isHotReloadCompletionEvent(Map<String, dynamic> event) {
|
||||
bool _isHotReloadCompletionEvent(Map<String, Object?>? event) {
|
||||
return event != null &&
|
||||
event['event'] == 'app.progress' &&
|
||||
event['params'] != null &&
|
||||
(event['params'] as Map<String, dynamic>)['progressId'] == 'hot.reload' &&
|
||||
(event['params'] as Map<String, dynamic>)['finished'] == true;
|
||||
(event['params'] as Map<String, Object?>?)!['progressId'] == 'hot.reload' &&
|
||||
(event['params'] as Map<String, Object?>?)!['finished'] == true;
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -14,9 +12,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final HotReloadWithAssetProject project = HotReloadWithAssetProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
@ -25,7 +23,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
@ -18,8 +16,8 @@ const Duration requiredLifespan = Duration(seconds: 5);
|
||||
|
||||
void main() {
|
||||
final BasicProject project = BasicProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
Directory tempDir;
|
||||
late FlutterRunTestDriver flutter;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('lifetime_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
@ -14,12 +12,12 @@ import 'package:flutter_tools/src/migrate/migrate_utils.dart';
|
||||
import '../src/common.dart';
|
||||
|
||||
void main() {
|
||||
BufferLogger logger;
|
||||
FileSystem fileSystem;
|
||||
Directory projectRoot;
|
||||
String projectRootPath;
|
||||
MigrateUtils utils;
|
||||
ProcessUtils processUtils;
|
||||
late BufferLogger logger;
|
||||
late FileSystem fileSystem;
|
||||
late Directory projectRoot;
|
||||
late String projectRootPath;
|
||||
late MigrateUtils utils;
|
||||
late ProcessUtils processUtils;
|
||||
|
||||
setUpAll(() async {
|
||||
fileSystem = globals.localFileSystem;
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
@ -13,8 +11,8 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver flutter;
|
||||
late Directory tempDir;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -43,7 +41,7 @@ Future<void> waitForObservatoryMessage(Process process, int port) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final BasicProject project = BasicProject();
|
||||
|
||||
setUp(() async {
|
||||
|
@ -22,9 +22,6 @@
|
||||
// To aid in debugging, consider passing the `debug: true` argument
|
||||
// to the runFlutter function.
|
||||
|
||||
// @dart = 2.8
|
||||
// This file is ready to transition, just uncomment /*?*/, /*!*/, and /*late*/.
|
||||
|
||||
// This file intentionally assumes the tests run in order.
|
||||
@Tags(<String>['no-shuffle'])
|
||||
|
||||
@ -49,7 +46,7 @@ void debugPrint(String message) {
|
||||
print(message);
|
||||
}
|
||||
|
||||
typedef LineHandler = String/*?*/ Function(String line);
|
||||
typedef LineHandler = String? Function(String line);
|
||||
|
||||
abstract class Transition {
|
||||
const Transition({this.handler, this.logging});
|
||||
@ -59,12 +56,12 @@ abstract class Transition {
|
||||
/// This should not throw, even if the test is failing. (For example, don't use "expect"
|
||||
/// in these callbacks.) Throwing here would prevent the [runFlutter] function from running
|
||||
/// to completion, which would leave zombie `flutter` processes around.
|
||||
final LineHandler/*?*/ handler;
|
||||
final LineHandler? handler;
|
||||
|
||||
/// Whether to enable or disable logging when this transition is matched.
|
||||
///
|
||||
/// The default value, null, leaves the logging state unaffected.
|
||||
final bool/*?*/ logging;
|
||||
final bool? logging;
|
||||
|
||||
bool matches(String line);
|
||||
|
||||
@ -89,7 +86,7 @@ abstract class Transition {
|
||||
}
|
||||
|
||||
class Barrier extends Transition {
|
||||
const Barrier(this.pattern, {LineHandler/*?*/ handler, bool/*?*/ logging}) : super(handler: handler, logging: logging);
|
||||
const Barrier(this.pattern, {super.handler, super.logging});
|
||||
final Pattern pattern;
|
||||
|
||||
@override
|
||||
@ -101,11 +98,10 @@ class Barrier extends Transition {
|
||||
|
||||
class Multiple extends Transition {
|
||||
Multiple(List<Pattern> patterns, {
|
||||
LineHandler/*?*/ handler,
|
||||
bool/*?*/ logging,
|
||||
super.handler,
|
||||
super.logging,
|
||||
}) : _originalPatterns = patterns,
|
||||
patterns = patterns.toList(),
|
||||
super(handler: handler, logging: logging);
|
||||
patterns = patterns.toList();
|
||||
|
||||
final List<Pattern> _originalPatterns;
|
||||
final List<Pattern> patterns;
|
||||
@ -159,7 +155,7 @@ class LogLine {
|
||||
case 0x0D: return '<CR>';
|
||||
}
|
||||
return '<${rune.toRadixString(16).padLeft(rune <= 0xFF ? 2 : rune <= 0xFFFF ? 4 : 5, '0')}>';
|
||||
}).join('');
|
||||
}).join();
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,7 +218,7 @@ Future<ProcessTestResult> runFlutter(
|
||||
}
|
||||
}
|
||||
bool streamingLogs = false;
|
||||
Timer/*?*/ timeout;
|
||||
Timer? timeout;
|
||||
void processTimeout() {
|
||||
if (!streamingLogs) {
|
||||
streamingLogs = true;
|
||||
@ -235,7 +231,7 @@ Future<ProcessTestResult> runFlutter(
|
||||
debugPrint('(taking a long time...)');
|
||||
}
|
||||
}
|
||||
String stamp() => '[${(clock.elapsed.inMilliseconds / 1000.0).toStringAsFixed(1).padLeft(5, " ")}s]';
|
||||
String stamp() => '[${(clock.elapsed.inMilliseconds / 1000.0).toStringAsFixed(1).padLeft(5)}s]';
|
||||
void processStdout(String line) {
|
||||
final LogLine log = LogLine('stdout', stamp(), line);
|
||||
if (logging) {
|
||||
@ -249,10 +245,10 @@ Future<ProcessTestResult> runFlutter(
|
||||
debugPrint('(matched ${transitions[nextTransition]})');
|
||||
}
|
||||
if (transitions[nextTransition].logging != null) {
|
||||
if (!logging && transitions[nextTransition].logging/*!*/) {
|
||||
if (!logging && transitions[nextTransition].logging!) {
|
||||
logs.add(log);
|
||||
}
|
||||
logging = transitions[nextTransition].logging/*!*/;
|
||||
logging = transitions[nextTransition].logging!;
|
||||
if (streamingLogs) {
|
||||
if (logging) {
|
||||
debugPrint('(enabled logging)');
|
||||
@ -262,7 +258,7 @@ Future<ProcessTestResult> runFlutter(
|
||||
}
|
||||
}
|
||||
if (transitions[nextTransition].handler != null) {
|
||||
final String/*?*/ command = transitions[nextTransition].handler/*!*/(line);
|
||||
final String? command = transitions[nextTransition].handler!(line);
|
||||
if (command != null) {
|
||||
final LogLine inLog = LogLine('stdin', stamp(), command);
|
||||
logs.add(inLog);
|
||||
@ -333,7 +329,7 @@ void main() {
|
||||
final String tempDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_overall_experience_test.').resolveSymbolicLinksSync();
|
||||
final String pidFile = fileSystem.path.join(tempDirectory, 'flutter.pid');
|
||||
final String testDirectory = fileSystem.path.join(flutterRoot, 'examples', 'hello_world');
|
||||
bool/*?*/ existsDuringTest;
|
||||
bool? existsDuringTest;
|
||||
try {
|
||||
expect(fileSystem.file(pidFile).existsSync(), isFalse);
|
||||
final ProcessTestResult result = await runFlutter(
|
||||
@ -367,7 +363,7 @@ void main() {
|
||||
final String pidFile = fileSystem.path.join(tempDirectory, 'flutter.pid');
|
||||
final String testDirectory = fileSystem.path.join(flutterRoot, 'dev', 'integration_tests', 'ui');
|
||||
final String testScript = fileSystem.path.join('lib', 'commands.dart');
|
||||
/*late*/ int pid;
|
||||
late int pid;
|
||||
try {
|
||||
final ProcessTestResult result = await runFlutter(
|
||||
<String>['run', '-dflutter-tester', '--report-ready', '--pid-file', pidFile, '--no-devtools', testScript],
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -52,9 +50,9 @@ void main() {
|
||||
// `ProcessManager` because doing so wouldn't actually test what we want to
|
||||
// test, which is that the underlying tool we're using to parse Plist files
|
||||
// works with the way we're calling it.
|
||||
File file;
|
||||
PlistParser parser;
|
||||
BufferLogger logger;
|
||||
late File file;
|
||||
late PlistParser parser;
|
||||
late BufferLogger logger;
|
||||
|
||||
setUp(() {
|
||||
logger = BufferLogger(
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -14,9 +12,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final SingleWidgetReloadProject project = SingleWidgetReloadProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
@ -25,7 +23,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -16,9 +14,9 @@ import 'test_utils.dart';
|
||||
// This test verifies that we can hot reload a stateless widget into a
|
||||
// stateful one and back.
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
final HotReloadProject project = HotReloadProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
@ -27,7 +25,7 @@ void main() {
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import '../src/common.dart';
|
||||
@ -12,11 +10,11 @@ import 'test_utils.dart';
|
||||
/// Checks that all active template files are defined in the template_manifest.json file.
|
||||
void main() {
|
||||
testWithoutContext('Check template manifest is up to date', () {
|
||||
final Map<String, Object> manifest = json.decode(
|
||||
final Map<String, Object?> manifest = json.decode(
|
||||
fileSystem.file('templates/template_manifest.json').readAsStringSync(),
|
||||
) as Map<String, Object>;
|
||||
) as Map<String, Object?>;
|
||||
final Set<Uri> declaredFileList = Set<Uri>.from(
|
||||
(manifest['files'] as List<Object>).cast<String>().map<Uri>(fileSystem.path.toUri));
|
||||
(manifest['files'] as List<Object?>?)!.cast<String>().map<Uri>(fileSystem.path.toUri));
|
||||
|
||||
final Set<Uri> activeTemplateList = fileSystem.directory('templates')
|
||||
.listSync(recursive: true)
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
// TODO(gspencergoog): Remove this tag once this test's state leaks/test
|
||||
// dependencies have been fixed.
|
||||
// https://github.com/flutter/flutter/issues/85160
|
||||
@ -205,7 +203,7 @@ Future<void> _testFile(
|
||||
String testName,
|
||||
String workingDirectory,
|
||||
String testDirectory, {
|
||||
Matcher exitCode,
|
||||
Matcher? exitCode,
|
||||
List<String> extraArguments = const <String>[],
|
||||
}) async {
|
||||
exitCode ??= isNonZero;
|
||||
@ -287,7 +285,7 @@ Future<void> _testFile(
|
||||
}
|
||||
|
||||
Future<ProcessResult> _runFlutterTest(
|
||||
String testName,
|
||||
String? testName,
|
||||
String workingDirectory,
|
||||
String testDirectory, {
|
||||
List<String> extraArguments = const <String>[],
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
@ -16,9 +14,9 @@ import 'test_driver.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver flutter;
|
||||
VmService vmService;
|
||||
late Directory tempDir;
|
||||
late FlutterRunTestDriver flutter;
|
||||
late VmService vmService;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('vmservice_integration_test.');
|
||||
@ -28,12 +26,12 @@ void main() {
|
||||
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
await flutter.run(withDebugger: true);
|
||||
final int port = flutter.vmServicePort;
|
||||
final int? port = flutter.vmServicePort;
|
||||
vmService = await vmServiceConnectUri('ws://localhost:$port/ws');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await flutter?.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
@ -78,16 +76,16 @@ void main() {
|
||||
'ext.flutter.brightnessOverride',
|
||||
isolateId: isolate.id,
|
||||
);
|
||||
expect(response.json['value'], 'Brightness.light');
|
||||
expect(response.json!['value'], 'Brightness.light');
|
||||
}
|
||||
timer.cancel();
|
||||
|
||||
// Verify that all duration events on the timeline are properly nested.
|
||||
final Response response = await vmService.callServiceExtension('getVMTimeline');
|
||||
final List<TimelineEvent> events = (response as Timeline).traceEvents;
|
||||
final List<TimelineEvent>? events = (response as Timeline).traceEvents;
|
||||
final Map<int, List<String>> threadDurationEventStack = <int, List<String>>{};
|
||||
for (final TimelineEvent e in events) {
|
||||
final Map<String, dynamic> event = e.json;
|
||||
for (final TimelineEvent e in events!) {
|
||||
final Map<String, dynamic> event = e.json!;
|
||||
final String phase = event['ph'] as String;
|
||||
final int tid = event['tid'] as int;
|
||||
final String name = event['name'] as String;
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:process/process.dart';
|
||||
@ -12,7 +10,7 @@ import '../src/common.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
late Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('unit_coverage_test.');
|
||||
|
@ -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.8
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@ -69,8 +67,8 @@ void main() {
|
||||
}, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
|
||||
|
||||
group('observatory Bonjour service keys', () {
|
||||
Directory buildDirectory;
|
||||
File infoPlist;
|
||||
late Directory buildDirectory;
|
||||
late File infoPlist;
|
||||
|
||||
setUp(() {
|
||||
buildDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_tools_xcode_backend_test.');
|
||||
|
Loading…
x
Reference in New Issue
Block a user