Unverified Commit ec75399b authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Null safety migration of packages/flutter_tools/test/general.shard, part 1/2 (#110711)

* Migrate packages/flutter_tools/test/general.shard, part 1/2

* Fix most of the tests

* Fix analysis

* Fix analysis

* Fix test

* Fix analysis

* Fix analysis

* Fix nit
parent 6f9bcec4
......@@ -80,7 +80,7 @@ class CleanCommand extends FlutterCommand {
try {
final XcodeProjectInterpreter xcodeProjectInterpreter = globals.xcodeProjectInterpreter!;
final Directory xcodeWorkspace = xcodeProject.xcodeWorkspace;
final XcodeProjectInfo projectInfo = await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path);
final XcodeProjectInfo projectInfo = (await xcodeProjectInterpreter.getInfo(xcodeWorkspace.parent.path))!;
for (final String scheme in projectInfo.schemes) {
await xcodeProjectInterpreter.cleanWorkspace(xcodeWorkspace.path, scheme, verbose: _verbose);
}
......
......@@ -96,15 +96,15 @@ class WebDriverService extends DriverService {
);
bool isAppStarted = false;
await Future.any<Object>(<Future<Object>>[
await Future.any(<Future<Object?>>[
runFuture.then((int? result) {
_runResult = result;
return null;
} as FutureOr<Object> Function(int?)),
}),
appStartedCompleter.future.then((_) {
isAppStarted = true;
return null;
} as FutureOr<Object> Function(void)),
}),
]);
if (_runResult != null) {
......
......@@ -306,7 +306,7 @@ class XcodeProjectInterpreter {
], workingDirectory: _fileSystem.currentDirectory.path);
}
Future<XcodeProjectInfo> getInfo(String projectPath, {String? projectFilename}) async {
Future<XcodeProjectInfo?> getInfo(String projectPath, {String? projectFilename}) async {
// The exit code returned by 'xcodebuild -list' when either:
// * -project is passed and the given project isn't there, or
// * no -project is passed and there isn't a project.
......
......@@ -84,15 +84,15 @@ Future<void> buildMacOS({
// other Xcode projects in the macos/ directory. Otherwise pass no name, which will work
// regardless of the project name so long as there is exactly one project.
final String? xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null;
final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter!.getInfo(
final XcodeProjectInfo? projectInfo = await globals.xcodeProjectInterpreter?.getInfo(
xcodeProject.parent.path,
projectFilename: xcodeProjectName,
);
final String? scheme = projectInfo.schemeFor(buildInfo);
final String? scheme = projectInfo?.schemeFor(buildInfo);
if (scheme == null) {
projectInfo.reportFlavorNotFoundAndExit();
projectInfo!.reportFlavorNotFoundAndExit();
}
final String? configuration = projectInfo.buildConfigurationFor(buildInfo, scheme);
final String? configuration = projectInfo?.buildConfigurationFor(buildInfo, scheme);
if (configuration == null) {
throwToolExit('Unable to find expected configuration in Xcode project.');
}
......
......@@ -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:fake_async/fake_async.dart';
......@@ -13,7 +11,6 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
......@@ -232,7 +229,7 @@ void main() {
});
group('AppContext', () {
FakeStopwatch fakeStopWatch;
late FakeStopwatch fakeStopWatch;
setUp(() {
fakeStopWatch = FakeStopwatch();
......@@ -365,10 +362,10 @@ void main() {
});
group('Spinners', () {
FakeStdio mockStdio;
FakeStopwatch mockStopwatch;
FakeStopwatchFactory stopwatchFactory;
int called;
late FakeStdio mockStdio;
late FakeStopwatch mockStopwatch;
late FakeStopwatchFactory stopwatchFactory;
late int called;
final List<Platform> testPlatforms = <Platform>[
FakePlatform(
environment: <String, String>{},
......@@ -404,8 +401,8 @@ void main() {
stopwatchFactory = FakeStopwatchFactory(stopwatch: mockStopwatch);
});
List<String> outputStdout() => mockStdio.writtenToStdout.join('').split('\n');
List<String> outputStderr() => mockStdio.writtenToStderr.join('').split('\n');
List<String> outputStdout() => mockStdio.writtenToStdout.join().split('\n');
List<String> outputStderr() => mockStdio.writtenToStderr.join().split('\n');
void doWhileAsync(FakeAsync time, bool Function() doThis) {
do {
......@@ -416,11 +413,11 @@ void main() {
for (final Platform testPlatform in testPlatforms) {
group('(${testPlatform.operatingSystem})', () {
Platform platform;
Platform ansiPlatform;
AnsiTerminal terminal;
AnsiTerminal coloredTerminal;
SpinnerStatus spinnerStatus;
late Platform platform;
late Platform ansiPlatform;
late AnsiTerminal terminal;
late AnsiTerminal coloredTerminal;
late SpinnerStatus spinnerStatus;
setUp(() {
platform = FakePlatform();
......@@ -517,7 +514,6 @@ void main() {
);
final Status status = logger.startProgress(
'Hello',
progressId: null,
progressIndicatorPadding: 20, // this minus the "Hello" equals the 15 below.
);
expect(outputStderr().length, equals(1));
......@@ -679,7 +675,7 @@ void main() {
expect(times, hasLength(1));
final Match match = times.single;
expect(lines[0], endsWith(match.group(0)));
expect(lines[0], endsWith(match.group(0)!));
expect(called, equals(1));
expect(lines.length, equals(2));
expect(lines[1], equals(''));
......@@ -696,9 +692,9 @@ void main() {
});
group('Output format', () {
FakeStdio fakeStdio;
SummaryStatus summaryStatus;
int called;
late FakeStdio fakeStdio;
late SummaryStatus summaryStatus;
late int called;
setUp(() {
fakeStdio = FakeStdio();
......@@ -712,8 +708,8 @@ void main() {
);
});
List<String> outputStdout() => fakeStdio.writtenToStdout.join('').split('\n');
List<String> outputStderr() => fakeStdio.writtenToStderr.join('').split('\n');
List<String> outputStdout() => fakeStdio.writtenToStdout.join().split('\n');
List<String> outputStderr() => fakeStdio.writtenToStderr.join().split('\n');
testWithoutContext('Error logs are wrapped', () async {
final Logger logger = StdoutLogger(
......@@ -739,7 +735,7 @@ void main() {
final BufferLogger buffer = BufferLogger.test();
final AppRunLogger logger = AppRunLogger(parent: buffer);
logger.startProgress('Test status...', timeout: null).stop();
logger.startProgress('Test status...').stop();
expect(buffer.statusText.trim(), equals('Test status...'));
});
......@@ -936,51 +932,6 @@ void main() {
expect(lines[0], equals('All good.'));
});
testWithoutContext('Stdout printStatus handle null inputs on colored terminal', () async {
final Logger logger = StdoutLogger(
terminal: AnsiTerminal(
stdio: fakeStdio,
platform: FakePlatform(),
),
stdio: fakeStdio,
outputPreferences: OutputPreferences.test(showColor: true),
);
logger.printStatus(
null,
emphasis: null,
color: null,
newline: null,
indent: null,
);
final List<String> lines = outputStdout();
expect(outputStderr().length, equals(1));
expect(outputStderr().first, isEmpty);
expect(lines[0], equals(''));
});
testWithoutContext('Stdout printStatus handle null inputs on non-color terminal', () async {
final Logger logger = StdoutLogger(
terminal: AnsiTerminal(
stdio: fakeStdio,
platform: _kNoAnsiPlatform,
),
stdio: fakeStdio,
outputPreferences: OutputPreferences.test(),
);
logger.printStatus(
null,
emphasis: null,
color: null,
newline: null,
indent: null,
);
final List<String> lines = outputStdout();
expect(outputStderr().length, equals(1));
expect(outputStderr().first, isEmpty);
expect(lines[0], equals(''));
});
testWithoutContext('Stdout printBox puts content inside a box', () {
final Logger logger = StdoutLogger(
terminal: AnsiTerminal(
......@@ -991,7 +942,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true),
);
logger.printBox('Hello world', title: 'Test title');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
expect(stdout,
contains(
'\n'
......@@ -1012,7 +963,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true),
);
logger.printBox('Hello world');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
expect(stdout,
contains(
'\n'
......@@ -1033,7 +984,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true),
);
logger.printBox('Hello world\nThis is a new line', title: 'Test title');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
expect(stdout,
contains(
'\n'
......@@ -1057,7 +1008,7 @@ void main() {
const String bold = '\u001B[1m';
const String clear = '\u001B[2J\u001B[H';
logger.printBox('${bold}Hello world$clear', title: 'Test title');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
expect(stdout,
contains(
'\n'
......@@ -1079,7 +1030,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true, wrapColumn: columnLimit),
);
logger.printBox('This line is longer than $columnLimit characters', title: 'Test');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
final List<String> stdoutLines = stdout.split('\n');
expect(stdoutLines.length, greaterThan(1));
......@@ -1108,7 +1059,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true, wrapColumn: columnLimit),
);
logger.printBox('This\nline is longer than\n\n$columnLimit characters', title: 'Test');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
final List<String> stdoutLines = stdout.split('\n');
expect(stdoutLines.length, greaterThan(1));
......@@ -1140,7 +1091,7 @@ void main() {
outputPreferences: OutputPreferences.test(showColor: true, wrapColumn: columnLimit),
);
logger.printBox('Thiswordislongerthan${columnLimit}characters', title: 'Test');
final String stdout = fakeStdio.writtenToStdout.join('');
final String stdout = fakeStdio.writtenToStdout.join();
final List<String> stdoutLines = stdout.split('\n');
expect(stdoutLines.length, greaterThan(1));
......@@ -1172,7 +1123,6 @@ void main() {
);
final Status status = logger.startProgress(
'Hello',
progressId: null,
progressIndicatorPadding: 20, // this minus the "Hello" equals the 15 below.
);
expect(outputStderr().length, equals(1));
......@@ -1328,14 +1278,14 @@ Matcher _throwsInvocationFor(dynamic Function() fakeCall) =>
throwsA(_matchesInvocation(_invocationFor(fakeCall)));
class FakeStdout extends Fake implements Stdout {
FakeStdout({@required this.syncError, this.completeWithError = false});
FakeStdout({required this.syncError, this.completeWithError = false});
final bool syncError;
final bool completeWithError;
final Completer<void> _completer = Completer<void>();
@override
void write(Object object) {
void write(Object? object) {
if (syncError) {
throw Exception('Error!');
}
......
......@@ -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:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/build_info.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/src/interface/file_system.dart';
......@@ -282,7 +280,7 @@ class FakeWebRunnerFactory implements WebRunnerFactory {
final bool doResolveToError;
@override
ResidentRunner createWebRunner(FlutterDevice device, {String target, bool stayResident, FlutterProject flutterProject, bool ipv6, DebuggingOptions debuggingOptions, UrlTunneller urlTunneller, Logger logger, FileSystem fileSystem, SystemClock systemClock, Usage usage, bool machine = false}) {
ResidentRunner createWebRunner(FlutterDevice device, {String? target, bool? stayResident, FlutterProject? flutterProject, bool? ipv6, DebuggingOptions? debuggingOptions, UrlTunneller? urlTunneller, Logger? logger, FileSystem? fileSystem, SystemClock? systemClock, Usage? usage, bool machine = false}) {
expect(stayResident, isTrue);
return FakeResidentRunner(
doResolveToError: doResolveToError,
......@@ -292,12 +290,12 @@ class FakeWebRunnerFactory implements WebRunnerFactory {
class FakeResidentRunner extends Fake implements ResidentRunner {
FakeResidentRunner({
this.doResolveToError,
required this.doResolveToError,
}) {
instance = this;
}
static FakeResidentRunner instance;
static late FakeResidentRunner instance;
final bool doResolveToError;
final Completer<int> _exitCompleter = Completer<int>();
......@@ -308,10 +306,10 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
@override
Future<int> run({
Completer<DebugConnectionInfo> connectionInfoCompleter,
Completer<void> appStartedCompleter,
Completer<DebugConnectionInfo>? connectionInfoCompleter,
Completer<void>? appStartedCompleter,
bool enableDevTools = false,
String route,
String? route,
}) async {
callLog.add('run');
......@@ -319,7 +317,7 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
return Future<int>.error('This is a test error');
}
appStartedCompleter.complete();
appStartedCompleter?.complete();
// Emulate stayResident by completing after exitApp is called.
return _exitCompleter.future;
}
......@@ -327,7 +325,7 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
@override
Future<void> exitApp() async {
callLog.add('exitApp');
_exitCompleter.complete();
_exitCompleter.complete(0);
}
@override
......
......@@ -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';
......@@ -24,7 +22,6 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
import 'package:flutter_tools/src/fuchsia/pkgctl.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
......@@ -33,14 +30,14 @@ import '../../src/fakes.dart';
void main() {
group('Fuchsia app start and stop: ', () {
MemoryFileSystem memoryFileSystem;
FakeOperatingSystemUtils osUtils;
FakeFuchsiaDeviceTools fuchsiaDeviceTools;
FakeFuchsiaSdk fuchsiaSdk;
Artifacts artifacts;
FakeProcessManager fakeSuccessfulProcessManager;
FakeProcessManager fakeFailedProcessManagerForHostAddress;
File sshConfig;
late MemoryFileSystem memoryFileSystem;
late FakeOperatingSystemUtils osUtils;
late FakeFuchsiaDeviceTools fuchsiaDeviceTools;
late FakeFuchsiaSdk fuchsiaSdk;
late Artifacts artifacts;
late FakeProcessManager fakeSuccessfulProcessManager;
late FakeProcessManager fakeFailedProcessManagerForHostAddress;
late File sshConfig;
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
......@@ -113,8 +110,8 @@ void main() {
});
Future<LaunchResult> setupAndStartApp({
@required bool prebuilt,
@required BuildMode mode,
required bool prebuilt,
required BuildMode mode,
}) async {
const String appName = 'app_name';
final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123');
......@@ -122,7 +119,7 @@ void main() {
final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync('name: $appName');
FuchsiaApp app;
FuchsiaApp? app;
if (prebuilt) {
final File far = globals.fs.file('app_name-0.far')..createSync();
app = FuchsiaApp.fromPrebuiltApp(far);
......@@ -143,7 +140,7 @@ void main() {
final DebuggingOptions debuggingOptions = DebuggingOptions.disabled(
BuildInfo(mode, null, treeShakeIcons: false));
return device.startApp(
app,
app!,
prebuiltApplication: prebuilt,
debuggingOptions: debuggingOptions,
);
......@@ -191,7 +188,7 @@ void main() {
pubspecFile.writeAsStringSync('name: $appName');
final File far = globals.fs.file('app_name-0.far')..createSync();
final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far);
final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far)!;
final DebuggingOptions debuggingOptions = DebuggingOptions.disabled(
const BuildInfo(BuildMode.release, null, treeShakeIcons: false));
final LaunchResult launchResult = await device.startApp(app,
......@@ -217,7 +214,7 @@ void main() {
pubspecFile.writeAsStringSync('name: $appName');
final File far = globals.fs.file('app_name-0.far')..createSync();
final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far);
final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far)!;
final DebuggingOptions debuggingOptions = DebuggingOptions.disabled(
const BuildInfo(BuildMode.release, null, treeShakeIcons: false));
final LaunchResult launchResult = await device.startApp(app,
......@@ -470,8 +467,7 @@ Process _createFakeProcess({
}
class FuchsiaDeviceWithFakeDiscovery extends FuchsiaDevice {
FuchsiaDeviceWithFakeDiscovery(String id, {String name})
: super(id, name: name);
FuchsiaDeviceWithFakeDiscovery(super.id, {super.name = ''});
@override
FuchsiaIsolateDiscoveryProtocol getIsolateDiscoveryProtocol(
......@@ -533,8 +529,8 @@ class FailingPkgctl implements FuchsiaPkgctl {
class FakeFuchsiaDeviceTools implements FuchsiaDeviceTools {
FakeFuchsiaDeviceTools({
FuchsiaPkgctl pkgctl,
FuchsiaFfx ffx,
FuchsiaPkgctl? pkgctl,
FuchsiaFfx? ffx,
}) : pkgctl = pkgctl ?? FakeFuchsiaPkgctl(),
ffx = ffx ?? FakeFuchsiaFfx();
......@@ -546,7 +542,7 @@ class FakeFuchsiaDeviceTools implements FuchsiaDeviceTools {
}
class FakeFuchsiaPM implements FuchsiaPM {
String _appName;
String? _appName;
@override
Future<bool> init(String buildPath, String appName) async {
......@@ -651,8 +647,8 @@ class FailingPM implements FuchsiaPM {
class FakeFuchsiaKernelCompiler implements FuchsiaKernelCompiler {
@override
Future<void> build({
@required FuchsiaProject fuchsiaProject,
@required String target, // E.g., lib/main.dart
required FuchsiaProject fuchsiaProject,
required String target, // E.g., lib/main.dart
BuildInfo buildInfo = BuildInfo.debug,
}) async {
final String outDir = getFuchsiaBuildDirectory();
......@@ -665,7 +661,7 @@ class FakeFuchsiaKernelCompiler implements FuchsiaKernelCompiler {
class FakeFuchsiaFfx implements FuchsiaFfx {
@override
Future<List<String>> list({Duration timeout}) async {
Future<List<String>> list({Duration? timeout}) async {
return <String>['192.168.42.172 scare-cable-skip-ffx'];
}
......@@ -675,7 +671,7 @@ class FakeFuchsiaFfx implements FuchsiaFfx {
}
@override
Future<String> sessionShow() async {
Future<String?> sessionShow() async {
return null;
}
......@@ -687,7 +683,7 @@ class FakeFuchsiaFfx implements FuchsiaFfx {
class FakeFuchsiaFfxWithSession implements FuchsiaFfx {
@override
Future<List<String>> list({Duration timeout}) async {
Future<List<String>> list({Duration? timeout}) async {
return <String>['192.168.42.172 scare-cable-skip-ffx'];
}
......@@ -709,9 +705,9 @@ class FakeFuchsiaFfxWithSession implements FuchsiaFfx {
class FakeFuchsiaSdk extends Fake implements FuchsiaSdk {
FakeFuchsiaSdk({
FuchsiaPM pm,
FuchsiaKernelCompiler compiler,
FuchsiaFfx ffx,
FuchsiaPM? pm,
FuchsiaKernelCompiler? compiler,
FuchsiaFfx? ffx,
}) : fuchsiaPM = pm ?? FakeFuchsiaPM(),
fuchsiaKernelCompiler = compiler ?? FakeFuchsiaKernelCompiler(),
fuchsiaFfx = ffx ?? FakeFuchsiaFfx();
......
......@@ -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/memory.dart';
......@@ -28,7 +26,6 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
......@@ -56,9 +53,9 @@ final vm_service.Isolate fakeIsolate = vm_service.Isolate(
void main() {
group('fuchsia device', () {
MemoryFileSystem memoryFileSystem;
File sshConfig;
FakeProcessManager processManager;
late MemoryFileSystem memoryFileSystem;
late File sshConfig;
late FakeProcessManager processManager;
setUp(() {
memoryFileSystem = MemoryFileSystem.test();
......@@ -306,8 +303,8 @@ void main() {
});
group('displays friendly error when', () {
File artifactFile;
FakeProcessManager processManager;
late File artifactFile;
late FakeProcessManager processManager;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -350,9 +347,9 @@ void main() {
[2018-11-09 01:30:12][52580][52983][log] INFO: example_app.cm(flutter): Did thing this time
''';
FakeProcessManager processManager;
File ffx;
File sshConfig;
late FakeProcessManager processManager;
late File ffx;
late File sshConfig;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -475,7 +472,7 @@ void main() {
});
group('screenshot', () {
FakeProcessManager processManager;
late FakeProcessManager processManager;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -681,8 +678,8 @@ void main() {
});
group('portForwarder', () {
FakeProcessManager processManager;
File sshConfig;
late FakeProcessManager processManager;
late File sshConfig;
setUp(() {
processManager = FakeProcessManager.empty();
......@@ -746,7 +743,7 @@ void main() {
fuchsiaDevice,
expectedIsolateName,
(Uri uri) async => fakeVmServiceHost.vmService,
(Device device, Uri uri, bool enableServiceAuthCodes) => null,
(Device device, Uri uri, bool enableServiceAuthCodes) async {},
true, // only poll once.
);
return discoveryProtocol.uri;
......@@ -789,7 +786,7 @@ void main() {
// wrong name.
FlutterView(
id: '2',
uiIsolate: vm_service.Isolate.parse(<String, Object>{
uiIsolate: vm_service.Isolate.parse(<String, Object?>{
...fakeIsolate.toJson(),
'name': 'wrong name',
})),
......@@ -854,8 +851,8 @@ void main() {
});
group('sdkNameAndVersion: ', () {
File sshConfig;
FakeProcessManager processManager;
late File sshConfig;
late FakeProcessManager processManager;
setUp(() {
sshConfig = MemoryFileSystem.test().file('ssh_config')
......@@ -934,7 +931,7 @@ void main() {
}
class FuchsiaModulePackage extends ApplicationPackage {
FuchsiaModulePackage({@required this.name}) : super(id: name);
FuchsiaModulePackage({required this.name}) : super(id: name);
@override
final String name;
......@@ -982,7 +979,7 @@ class FakePortForwarder extends Fake implements DevicePortForwarder {
class FakeFuchsiaFfx implements FuchsiaFfx {
@override
Future<List<String>> list({Duration timeout}) async {
Future<List<String>> list({Duration? timeout}) async {
return <String>['192.168.42.172 scare-cable-skip-ffx'];
}
......@@ -992,7 +989,7 @@ class FakeFuchsiaFfx implements FuchsiaFfx {
}
@override
Future<String> sessionShow() async {
Future<String?> sessionShow() async {
return null;
}
......@@ -1002,14 +999,18 @@ class FakeFuchsiaFfx implements FuchsiaFfx {
}
}
class FakeFuchsiaPM extends Fake implements FuchsiaPM {}
class FakeFuchsiaKernelCompiler extends Fake implements FuchsiaKernelCompiler {}
class FakeFuchsiaSdk extends Fake implements FuchsiaSdk {
FakeFuchsiaSdk({
FuchsiaPM pm,
FuchsiaKernelCompiler compiler,
FuchsiaFfx ffx,
String devices,
}) : fuchsiaPM = pm,
fuchsiaKernelCompiler = compiler,
FuchsiaPM? pm,
FuchsiaKernelCompiler? compiler,
FuchsiaFfx? ffx,
String? devices,
}) : fuchsiaPM = pm ?? FakeFuchsiaPM(),
fuchsiaKernelCompiler = compiler ?? FakeFuchsiaKernelCompiler(),
fuchsiaFfx = ffx ?? FakeFuchsiaFfx(),
_devices = devices;
......@@ -1022,10 +1023,10 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk {
@override
final FuchsiaFfx fuchsiaFfx;
final String _devices;
final String? _devices;
@override
Future<String> listDevices({Duration timeout}) async {
Future<String?> listDevices({Duration? timeout}) async {
return _devices;
}
}
......@@ -1035,10 +1036,10 @@ class FakeDartDevelopmentService extends Fake
@override
Future<void> startDartDevelopmentService(
Uri observatoryUri, {
@required Logger logger,
int hostPort,
bool ipv6,
bool disableServiceAuthCodes,
required Logger logger,
int? hostPort,
bool? ipv6,
bool? disableServiceAuthCodes,
bool cacheStartupProfile = false,
}) async {}
......
......@@ -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:fake_async/fake_async.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
......@@ -23,7 +21,6 @@ import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
......@@ -76,8 +73,8 @@ final FakePlatform macPlatform = FakePlatform(
);
void main() {
Artifacts artifacts;
String iosDeployPath;
late Artifacts artifacts;
late String iosDeployPath;
setUp(() {
artifacts = Artifacts.test();
......@@ -85,12 +82,12 @@ void main() {
});
group('IOSDevice.startApp succeeds in release mode', () {
FileSystem fileSystem;
FakeProcessManager processManager;
BufferLogger logger;
Xcode xcode;
FakeXcodeProjectInterpreter fakeXcodeProjectInterpreter;
XcodeProjectInfo projectInfo;
late FileSystem fileSystem;
late FakeProcessManager processManager;
late BufferLogger logger;
late Xcode xcode;
late FakeXcodeProjectInterpreter fakeXcodeProjectInterpreter;
late XcodeProjectInfo projectInfo;
setUp(() {
logger = BufferLogger.test();
......@@ -168,7 +165,7 @@ void main() {
FileSystem: () => fileSystem,
Logger: () => logger,
Platform: () => macPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(projectInfo: null),
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(),
Xcode: () => xcode,
});
......@@ -305,10 +302,10 @@ void setUpIOSProject(FileSystem fileSystem) {
IOSDevice setUpIOSDevice({
String sdkVersion = '13.0.1',
FileSystem fileSystem,
Logger logger,
ProcessManager processManager,
Artifacts artifacts,
FileSystem? fileSystem,
Logger? logger,
ProcessManager? processManager,
Artifacts? artifacts,
}) {
artifacts ??= Artifacts.test();
final Cache cache = Cache.test(
......@@ -347,7 +344,7 @@ IOSDevice setUpIOSDevice({
class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterpreter {
FakeXcodeProjectInterpreter({
@required this.projectInfo,
this.projectInfo,
this.buildSettings = const <String, String>{
'TARGET_BUILD_DIR': 'build/ios/Release-iphoneos',
'WRAPPER_NAME': 'My Super Awesome App.app',
......@@ -356,7 +353,7 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
});
final Map<String, String> buildSettings;
final XcodeProjectInfo projectInfo;
final XcodeProjectInfo? projectInfo;
@override
final bool isInstalled = true;
......@@ -371,15 +368,15 @@ class FakeXcodeProjectInterpreter extends Fake implements XcodeProjectInterprete
List<String> xcrunCommand() => <String>['xcrun'];
@override
Future<XcodeProjectInfo> getInfo(
Future<XcodeProjectInfo?> getInfo(
String projectPath, {
String projectFilename,
String? projectFilename,
}) async => projectInfo;
@override
Future<Map<String, String>> getBuildSettings(
String projectPath, {
@required XcodeProjectBuildContext buildContext,
required XcodeProjectBuildContext buildContext,
Duration timeout = const Duration(minutes: 1),
}) async => buildSettings;
}
......@@ -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/memory.dart';
import 'package:flutter_tools/src/base/bot_detector.dart';
import 'package:flutter_tools/src/base/file_system.dart';
......@@ -26,8 +24,8 @@ const String _kProjectRoot = '/project';
void main() {
group('FlutterCommandRunner', () {
MemoryFileSystem fileSystem;
Platform platform;
late MemoryFileSystem fileSystem;
late Platform platform;
setUpAll(() {
Cache.disableLocking();
......@@ -173,7 +171,7 @@ void main() {
});
group('getRepoPackages', () {
String oldFlutterRoot;
late String? oldFlutterRoot;
setUp(() {
oldFlutterRoot = Cache.flutterRoot;
......@@ -270,7 +268,7 @@ void main() {
}
class FakeFlutterCommand extends FlutterCommand {
OutputPreferences preferences;
late OutputPreferences preferences;
@override
Future<FlutterCommandResult> runCommand() {
......@@ -279,14 +277,14 @@ class FakeFlutterCommand extends FlutterCommand {
}
@override
String get description => null;
String get description => '';
@override
String get name => 'fake';
}
class FakeStdio extends Stdio {
FakeStdio({this.hasFakeTerminal});
FakeStdio({required this.hasFakeTerminal});
final bool hasFakeTerminal;
......@@ -294,10 +292,10 @@ class FakeStdio extends Stdio {
bool get hasTerminal => hasFakeTerminal;
@override
int get terminalColumns => hasFakeTerminal ? 80 : null;
int? get terminalColumns => hasFakeTerminal ? 80 : null;
@override
int get terminalLines => hasFakeTerminal ? 24 : null;
int? get terminalLines => hasFakeTerminal ? 24 : null;
@override
bool get supportsAnsiEscapes => hasFakeTerminal;
}
......@@ -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:io' as io;
......@@ -32,13 +30,13 @@ import 'utils.dart';
void main() {
group('Flutter Command', () {
FakeCache cache;
TestUsage usage;
FakeClock clock;
FakeProcessInfo processInfo;
MemoryFileSystem fileSystem;
FakeProcessManager processManager;
PreRunValidator preRunValidator;
late FakeCache cache;
late TestUsage usage;
late FakeClock clock;
late FakeProcessInfo processInfo;
late MemoryFileSystem fileSystem;
late FakeProcessManager processManager;
late PreRunValidator preRunValidator;
setUpAll(() {
Cache.flutterRoot = '/path/to/sdk/flutter';
......@@ -246,7 +244,7 @@ void main() {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand(
commandFunction: () async {
throwToolExit('fail');
}
},
);
await expectLater(
() => flutterCommand.run(),
......@@ -324,9 +322,9 @@ void main() {
});
group('signals tests', () {
FakeIoProcessSignal mockSignal;
ProcessSignal signalUnderTest;
StreamController<io.ProcessSignal> signalController;
late FakeIoProcessSignal mockSignal;
late ProcessSignal signalUnderTest;
late StreamController<io.ProcessSignal> signalController;
setUp(() {
mockSignal = FakeIoProcessSignal();
......@@ -350,7 +348,7 @@ void main() {
commandFunction: () async {
final Completer<void> c = Completer<void>();
await c.future;
return null; // unreachable
throw UnsupportedError('Unreachable');
}
);
......@@ -398,7 +396,7 @@ void main() {
checkLockCompleter.complete();
final Completer<void> c = Completer<void>();
await c.future;
return null; // unreachable
throw UnsupportedError('Unreachable');
});
unawaited(flutterCommand.run());
......@@ -454,7 +452,7 @@ void main() {
final FlutterCommandResult commandResult = FlutterCommandResult(
ExitStatus.success,
// nulls should be cleaned up.
timingLabelParts: <String> ['blah1', 'blah2', null, 'blah3'],
timingLabelParts: <String?> ['blah1', 'blah2', null, 'blah3'],
endTimeOverride: DateTime.fromMillisecondsSinceEpoch(1500),
);
......@@ -701,7 +699,7 @@ class FakeTargetCommand extends FlutterCommand {
return FlutterCommandResult.success();
}
String cachedTargetFile;
String? cachedTargetFile;
@override
String get description => '';
......@@ -759,7 +757,7 @@ class FakeProcessInfo extends Fake implements ProcessInfo {
}
class FakeIoProcessSignal extends Fake implements io.ProcessSignal {
Stream<io.ProcessSignal> stream;
late Stream<io.ProcessSignal> stream;
@override
Stream<io.ProcessSignal> watch() => stream;
......@@ -779,8 +777,8 @@ class FakeCache extends Fake implements Cache {
class FakeSignals implements Signals {
FakeSignals({
this.subForSigTerm,
List<ProcessSignal> exitSignals,
required this.subForSigTerm,
required List<ProcessSignal> exitSignals,
}) : delegate = Signals.test(exitSignals: exitSignals);
final ProcessSignal subForSigTerm;
......@@ -814,14 +812,12 @@ class FakeClock extends Fake implements SystemClock {
class FakePub extends Fake implements Pub {
@override
Future<void> get({
PubContext context,
FlutterProject project,
required PubContext context,
required FlutterProject project,
bool skipIfAbsent = false,
bool upgrade = false,
bool offline = false,
bool generateSyntheticPackage = false,
bool generateSyntheticPackageForExample = false,
String flutterRootOverride,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
bool printProgress = 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/memory.dart';
......@@ -28,7 +26,7 @@ import '../../src/fake_http_client.dart';
const String kCustomBugInstructions = 'These are instructions to report with a custom bug tracker.';
void main() {
int firstExitCode;
int? firstExitCode;
group('runner', () {
setUp(() {
......@@ -59,7 +57,7 @@ void main() {
final Completer<void> completer = Completer<void>();
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(runZoned<Future<void>>(
unawaited(runZoned<Future<void>?>(
() {
unawaited(runner.run(
<String>['crash'],
......@@ -112,7 +110,7 @@ void main() {
final Completer<void> completer = Completer<void>();
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(runZoned<Future<void>>(
unawaited(runZoned<Future<void>?>(
() {
unawaited(runner.run(
<String>['crash'],
......@@ -160,7 +158,7 @@ void main() {
final Completer<void> completer = Completer<void>();
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(runZoned<Future<void>>(
unawaited(runZoned<Future<void>?>(
() {
unawaited(runner.run(
<String>['crash'],
......@@ -197,7 +195,7 @@ void main() {
expect(logContents, contains('CrashingFlutterCommand.runCommand'));
expect(logContents, contains('[!] Flutter'));
final CrashDetails sentDetails = (globals.crashReporter as WaitingCrashReporter)._details;
final CrashDetails sentDetails = (globals.crashReporter! as WaitingCrashReporter)._details;
expect(sentDetails.command, 'flutter crash');
expect(sentDetails.error.toString(), 'Exception: an exception % --');
expect(sentDetails.stackTrace.toString(), contains('CrashingFlutterCommand.runCommand'));
......@@ -222,15 +220,15 @@ void main() {
class CrashingFlutterCommand extends FlutterCommand {
CrashingFlutterCommand({
bool asyncCrash = false,
Completer<void> completer,
Completer<void>? completer,
}) : _asyncCrash = asyncCrash,
_completer = completer;
final bool _asyncCrash;
final Completer<void> _completer;
final Completer<void>? _completer;
@override
String get description => null;
String get description => '';
@override
String get name => 'crash';
......@@ -249,7 +247,7 @@ class CrashingFlutterCommand extends FlutterCommand {
});
await completer.future;
_completer.complete();
_completer!.complete();
return FlutterCommandResult.success();
}
......@@ -298,16 +296,16 @@ class CrashingUsage implements Usage {
String get clientId => _impl.clientId;
@override
void sendCommand(String command, {CustomDimensions parameters}) =>
void sendCommand(String command, {CustomDimensions? parameters}) =>
_impl.sendCommand(command, parameters: parameters);
@override
void sendEvent(
String category,
String parameter, {
String label,
int value,
CustomDimensions parameters,
String? label,
int? value,
CustomDimensions? parameters,
}) => _impl.sendEvent(
category,
parameter,
......@@ -321,7 +319,7 @@ class CrashingUsage implements Usage {
String category,
String variableName,
Duration duration, {
String label,
String? label,
}) => _impl.sendTiming(category, variableName, duration, label: label);
@override
......@@ -347,7 +345,7 @@ class WaitingCrashReporter implements CrashReporter {
WaitingCrashReporter(Future<void> future) : _future = future;
final Future<void> _future;
CrashDetails _details;
late CrashDetails _details;
@override
Future<void> informUser(CrashDetails details, File crashFile) {
......
......@@ -2,12 +2,11 @@
// 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';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
......@@ -15,6 +14,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/tester/flutter_tester.dart';
import 'package:test/fake.dart';
import '../../src/common.dart';
import '../../src/context.dart';
......@@ -23,7 +23,7 @@ import '../../src/fakes.dart';
import '../../src/test_build_system.dart';
void main() {
MemoryFileSystem fileSystem;
late MemoryFileSystem fileSystem;
setUp(() {
fileSystem = MemoryFileSystem.test();
......@@ -74,12 +74,12 @@ void main() {
});
group('startApp', () {
FlutterTesterDevice device;
List<String> logLines;
String mainPath;
late FlutterTesterDevice device;
late List<String> logLines;
String? mainPath;
FakeProcessManager fakeProcessManager;
TestBuildSystem buildSystem;
late FakeProcessManager fakeProcessManager;
late TestBuildSystem buildSystem;
final Map<Type, Generator> startOverrides = <Type, Generator>{
Platform: () => FakePlatform(),
......@@ -111,24 +111,24 @@ void main() {
expect(device.portForwarder, isNot(isNull));
expect(await device.targetPlatform, TargetPlatform.tester);
expect(await device.installApp(null), isTrue);
expect(await device.isAppInstalled(null), isFalse);
expect(await device.isLatestBuildInstalled(null), isFalse);
expect(await device.uninstallApp(null), isTrue);
expect(await device.installApp(FakeApplicationPackage()), isTrue);
expect(await device.isAppInstalled(FakeApplicationPackage()), isFalse);
expect(await device.isLatestBuildInstalled(FakeApplicationPackage()), isFalse);
expect(await device.uninstallApp(FakeApplicationPackage()), isTrue);
expect(device.isSupported(), isTrue);
});
testWithoutContext('does not accept profile, release, or jit-release builds', () async {
final LaunchResult releaseResult = await device.startApp(null,
final LaunchResult releaseResult = await device.startApp(FakeApplicationPackage(),
mainPath: mainPath,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.release),
);
final LaunchResult profileResult = await device.startApp(null,
final LaunchResult profileResult = await device.startApp(FakeApplicationPackage(),
mainPath: mainPath,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.profile),
);
final LaunchResult jitReleaseResult = await device.startApp(null,
final LaunchResult jitReleaseResult = await device.startApp(FakeApplicationPackage(),
mainPath: mainPath,
debuggingOptions: DebuggingOptions.disabled(BuildInfo.jitRelease),
);
......@@ -216,3 +216,5 @@ FlutterTesterDevices setUpFlutterTesterDevices() {
operatingSystemUtils: FakeOperatingSystemUtils(),
);
}
class FakeApplicationPackage extends Fake implements ApplicationPackage {}
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