Unverified Commit 980f14e0 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false on flutter_tools (#45153)

* implicit-casts:false on flutter_tools

* use castStringKeyedMap

* address review comments

* address review comments

* fix issues after rebase
parent 033b897b
......@@ -5,7 +5,7 @@ include: ../../analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: true
implicit-casts: false
implicit-dynamic: false
linter:
......
......@@ -208,12 +208,12 @@ class AndroidAot extends AotElfBase {
}
// AndroidAot instances used by the bundle rules below.
const Target androidArmProfile = AndroidAot(TargetPlatform.android_arm, BuildMode.profile);
const Target androidArm64Profile = AndroidAot(TargetPlatform.android_arm64, BuildMode.profile);
const Target androidx64Profile = AndroidAot(TargetPlatform.android_x64, BuildMode.profile);
const Target androidArmRelease = AndroidAot(TargetPlatform.android_arm, BuildMode.release);
const Target androidArm64Release = AndroidAot(TargetPlatform.android_arm64, BuildMode.release);
const Target androidx64Release = AndroidAot(TargetPlatform.android_x64, BuildMode.release);
const AndroidAot androidArmProfile = AndroidAot(TargetPlatform.android_arm, BuildMode.profile);
const AndroidAot androidArm64Profile = AndroidAot(TargetPlatform.android_arm64, BuildMode.profile);
const AndroidAot androidx64Profile = AndroidAot(TargetPlatform.android_x64, BuildMode.profile);
const AndroidAot androidArmRelease = AndroidAot(TargetPlatform.android_arm, BuildMode.release);
const AndroidAot androidArm64Release = AndroidAot(TargetPlatform.android_arm64, BuildMode.release);
const AndroidAot androidx64Release = AndroidAot(TargetPlatform.android_x64, BuildMode.release);
/// A rule paired with [AndroidAot] that copies the produced so files into the output directory.
class AndroidAotBundle extends Target {
......
......@@ -169,7 +169,7 @@ class AssembleCommand extends FlutterCommand {
final Target target = targets.length == 1 ? targets.single : _CompositeTarget(targets);
final BuildResult result = await buildSystem.build(target, environment, buildSystemConfig: BuildSystemConfig(
resourcePoolSize: argResults.wasParsed('resource-pool-size')
? int.tryParse(argResults['resource-pool-size'])
? int.tryParse(stringArg('resource-pool-size'))
: null,
));
if (!result.success) {
......
......@@ -223,7 +223,7 @@ class AttachCommand extends FlutterCommand {
FuchsiaIsolateDiscoveryProtocol isolateDiscoveryProtocol;
try {
isolateDiscoveryProtocol = device.getIsolateDiscoveryProtocol(module);
observatoryUri = Stream<Uri>.fromFuture(isolateDiscoveryProtocol.uri).asBroadcastStream();
observatoryUri = Stream<Uri>.value(await isolateDiscoveryProtocol.uri).asBroadcastStream();
} catch (_) {
isolateDiscoveryProtocol?.dispose();
final List<ForwardedPort> ports = device.portForwarder.forwardedPorts.toList();
......
......@@ -74,7 +74,7 @@ class BuildFuchsiaCommand extends BuildSubCommand {
await buildFuchsia(
fuchsiaProject: flutterProject.fuchsia,
target: targetFile,
targetPlatform: getTargetPlatformForName(argResults['target-platform']),
targetPlatform: getTargetPlatformForName(stringArg('target-platform')),
buildInfo: buildInfo,
runnerPackageSource: stringArg('runner-source'),
);
......
......@@ -204,10 +204,11 @@ class Plugin {
if (!(value is YamlMap)) {
return false;
}
if (value.containsKey('default_package')) {
final YamlMap yamlValue = value as YamlMap;
if (yamlValue.containsKey('default_package')) {
return false;
}
return !validate(value);
return !validate(yamlValue);
}
final List<String> errors = <String>[];
if (isInvalid(AndroidPlugin.kConfigKey, AndroidPlugin.validate)) {
......@@ -246,7 +247,7 @@ class Plugin {
if (!platformsYaml.containsKey(platformKey)) {
return false;
}
if (platformsYaml[platformKey].containsKey('default_package')) {
if ((platformsYaml[platformKey] as YamlMap).containsKey('default_package')) {
return false;
}
return true;
......@@ -276,13 +277,13 @@ Plugin _pluginFromPubspec(String name, Uri packageRoot) {
return null;
}
final String packageRootPath = fs.path.fromUri(packageRoot);
final YamlMap dependencies = pubspec['dependencies'];
final YamlMap dependencies = pubspec['dependencies'] as YamlMap;
printTrace('Found plugin $name at $packageRootPath');
return Plugin.fromYaml(
name,
packageRootPath,
flutterConfig['plugin'] as YamlMap,
dependencies == null ? <String>[] : <String>[...dependencies.keys],
dependencies == null ? <String>[] : <String>[...dependencies.keys.cast<String>()],
);
}
......
......@@ -5,14 +5,13 @@
import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/assemble.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/testbed.dart';
void main() {
......@@ -29,9 +28,8 @@ void main() {
});
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
await commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']);
final BufferLogger bufferLogger = logger;
expect(bufferLogger.traceText, contains('build succeeded.'));
expect(testLogger.traceText, contains('build succeeded.'));
});
testbed.test('Throws ToolExit if not provided with output', () async {
......@@ -57,7 +55,6 @@ void main() {
});
testbed.test('Does not log stack traces during build failure', () async {
final BufferLogger bufferLogger = logger;
final StackTrace testStackTrace = StackTrace.current;
when(buildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
.thenAnswer((Invocation invocation) async {
......@@ -69,8 +66,8 @@ void main() {
await expectLater(commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']),
throwsA(isInstanceOf<ToolExit>()));
expect(bufferLogger.errorText, contains('bar'));
expect(bufferLogger.errorText, isNot(contains(testStackTrace.toString())));
expect(testLogger.errorText, contains('bar'));
expect(testLogger.errorText, isNot(contains(testStackTrace.toString())));
});
testbed.test('Only writes input and output files when the values change', () async {
......
......@@ -306,7 +306,7 @@ void main() {
),
)..called(1);
final List<FlutterDevice> flutterDevices = verificationResult.captured.first;
final List<FlutterDevice> flutterDevices = verificationResult.captured.first as List<FlutterDevice>;
expect(flutterDevices, hasLength(1));
// Validate that the attach call built a flutter device with the right
......
......@@ -47,7 +47,7 @@ void main() {
'--no-pub',
]);
final Environment environment = verify(buildSystem.build(any, captureAny)).captured.single;
final Environment environment = verify(buildSystem.build(any, captureAny)).captured.single as Environment;
expect(environment.defines, <String, String>{
kTargetFile: fs.path.absolute(fs.path.join('lib', 'main.dart')),
kBuildMode: 'release',
......
......@@ -7,14 +7,12 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
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';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_linux.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/linux/makefile.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
......@@ -142,7 +140,6 @@ void main() {
});
testUsingContext('Linux build does not spew stdout to status logger', () async {
final BufferLogger bufferLogger = logger;
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
setUpMockProjectFilesForBuild();
......@@ -151,8 +148,8 @@ void main() {
await createTestCommandRunner(command).run(
const <String>['build', 'linux', '--debug']
);
expect(bufferLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(bufferLogger.traceText, contains('STDOUT STUFF'));
expect(testLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(testLogger.traceText, contains('STDOUT STUFF'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
......@@ -230,8 +227,7 @@ BINARY_NAME=fizz_bar
const <String>['build', 'linux']
);
final BufferLogger bufferLogger = logger;
expect(bufferLogger.statusText, contains('🚧'));
expect(testLogger.statusText, contains('🚧'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
......
......@@ -7,7 +7,6 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
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';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
......@@ -15,7 +14,6 @@ import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_macos.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
......@@ -128,7 +126,6 @@ void main() {
});
testUsingContext('macOS build does not spew stdout to status logger', () async {
final BufferLogger bufferLogger = logger;
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
createMinimalMockProjectFiles();
......@@ -137,8 +134,8 @@ void main() {
await createTestCommandRunner(command).run(
const <String>['build', 'macos', '--debug']
);
expect(bufferLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(bufferLogger.traceText, contains('STDOUT STUFF'));
expect(testLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(testLogger.traceText, contains('STDOUT STUFF'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => mockProcessManager,
......
......@@ -71,7 +71,7 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
stayResident: true,
dartDefines: const <String>[],
);
) as ResidentWebRunner;
expect(await runner.run(), 1);
}));
......
......@@ -6,14 +6,12 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart';
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';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
import 'package:flutter_tools/src/commands/build_windows.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/windows/visual_studio.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
......@@ -109,7 +107,6 @@ void main() {
});
testUsingContext('Windows build does not spew stdout to status logger', () async {
final BufferLogger bufferLogger = logger;
final BuildCommand command = BuildCommand();
applyMocksToCommand(command);
fs.file(solutionPath).createSync(recursive: true);
......@@ -130,8 +127,8 @@ void main() {
await createTestCommandRunner(command).run(
const <String>['build', 'windows']
);
expect(bufferLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(bufferLogger.traceText, contains('STDOUT STUFF'));
expect(testLogger.statusText, isNot(contains('STDOUT STUFF')));
expect(testLogger.traceText, contains('STDOUT STUFF'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
ProcessManager: () => mockProcessManager,
......@@ -199,8 +196,7 @@ void main() {
const <String>['build', 'windows']
);
final BufferLogger bufferLogger = logger;
expect(bufferLogger.statusText, contains('🚧'));
expect(testLogger.statusText, contains('🚧'));
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
ProcessManager: () => mockProcessManager,
......
......@@ -69,11 +69,10 @@ void main() {
final MockFile mockFile = MockFile();
when(mockFile.existsSync()).thenReturn(true);
final BufferLogger logger = context.get<Logger>();
when(mockFile.deleteSync(recursive: true)).thenThrow(const FileSystemException('Deletion failed'));
final CleanCommand command = CleanCommand();
command.deleteFile(mockFile);
expect(logger.errorText, contains('A program may still be using a file'));
expect(testLogger.errorText, contains('A program may still be using a file'));
verify(mockFile.deleteSync(recursive: true)).called(1);
}, overrides: <Type, Generator>{
Platform: () => windowsPlatform,
......@@ -88,10 +87,9 @@ void main() {
when(mockFile.existsSync()).thenThrow(const FileSystemException('OS error: Access Denied'));
when(mockFile.path).thenReturn('foo.dart');
final BufferLogger logger = context.get<Logger>();
final CleanCommand command = CleanCommand();
command.deleteFile(mockFile);
expect(logger.errorText, contains('Cannot clean foo.dart'));
expect(testLogger.errorText, contains('Cannot clean foo.dart'));
verifyNever(mockFile.deleteSync(recursive: true));
}, overrides: <Type, Generator>{
Platform: () => windowsPlatform,
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/config.dart';
......@@ -62,12 +61,11 @@ void main() {
group('config', () {
testUsingContext('machine flag', () async {
final BufferLogger logger = context.get<Logger>();
final ConfigCommand command = ConfigCommand();
await command.handleMachine();
expect(logger.statusText, isNotEmpty);
final dynamic jsonObject = json.decode(logger.statusText);
expect(testLogger.statusText, isNotEmpty);
final dynamic jsonObject = json.decode(testLogger.statusText);
expect(jsonObject, isMap);
expect(jsonObject.containsKey('android-studio-dir'), true);
......@@ -156,7 +154,6 @@ void main() {
});
testUsingContext('warns the user to reload IDE', () async {
final BufferLogger logger = context.get<Logger>();
final ConfigCommand configCommand = ConfigCommand();
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
......@@ -165,13 +162,12 @@ void main() {
'--enable-web'
]);
expect(logger.statusText, contains('You may need to restart any open editors'));
expect(testLogger.statusText, contains('You may need to restart any open editors'));
}, overrides: <Type, Generator>{
Usage: () => mockUsage,
});
testUsingContext('displays which config settings are available on stable', () async {
final BufferLogger logger = context.get<Logger>();
when(mockFlutterVersion.channel).thenReturn('stable');
final ConfigCommand configCommand = ConfigCommand();
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
......@@ -188,10 +184,10 @@ void main() {
'config',
]);
expect(logger.statusText, contains('enable-web: true (Unavailable)'));
expect(logger.statusText, contains('enable-linux-desktop: true (Unavailable)'));
expect(logger.statusText, contains('enable-windows-desktop: true (Unavailable)'));
expect(logger.statusText, contains('enable-macos-desktop: true (Unavailable)'));
expect(testLogger.statusText, contains('enable-web: true (Unavailable)'));
expect(testLogger.statusText, contains('enable-linux-desktop: true (Unavailable)'));
expect(testLogger.statusText, contains('enable-windows-desktop: true (Unavailable)'));
expect(testLogger.statusText, contains('enable-macos-desktop: true (Unavailable)'));
verifyNoAnalytics();
}, overrides: <Type, Generator>{
AndroidStudio: () => mockAndroidStudio,
......
......@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:flutter_tools/src/android/android_workflow.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart';
import 'package:flutter_tools/src/globals.dart';
......@@ -65,7 +66,7 @@ void main() {
});
expect(response['id'], isNull);
expect(response['event'], 'daemon.logMessage');
final Map<String, String> logMessage = response['params'].cast<String, String>();
final Map<String, String> logMessage = castStringKeyedMap(response['params']).cast<String, String>();
expect(logMessage['level'], 'error');
expect(logMessage['message'], 'daemon.logMessage test');
await responses.close();
......@@ -232,7 +233,7 @@ void main() {
expect(response['event'], 'device.added');
expect(response['params'], isMap);
final Map<String, dynamic> params = response['params'];
final Map<String, dynamic> params = castStringKeyedMap(response['params']);
expect(params['platform'], isNotEmpty); // the mock device has a platform of 'android-arm'
await responses.close();
......
......@@ -485,7 +485,7 @@ void main() {
platformArgs: anyNamed('platformArgs'),
prebuiltApplication: anyNamed('prebuiltApplication'),
)).thenAnswer((Invocation invocation) async {
debuggingOptions = invocation.namedArguments[#debuggingOptions];
debuggingOptions = invocation.namedArguments[#debuggingOptions] as DebuggingOptions;
return mockLaunchResult;
});
when(mockDevice.isAppInstalled(any))
......
......@@ -3,15 +3,14 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/codegen.dart';
import 'package:flutter_tools/src/commands/generate.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/mocks.dart';
import '../../src/testbed.dart';
......@@ -47,7 +46,6 @@ void main() {
test('Outputs error information from flutter generate', () => testbed.run(() async {
final GenerateCommand command = GenerateCommand();
final BufferLogger bufferLogger = logger;
applyMocksToCommand(command);
fs.file(fs.path.join('lib', 'main.dart'))
..createSync(recursive: true);
......@@ -71,10 +69,10 @@ void main() {
await createTestCommandRunner(command)
.run(const <String>['generate']);
expect(bufferLogger.errorText, contains('a'));
expect(bufferLogger.errorText, contains('b'));
expect(bufferLogger.errorText, contains('foo builder'));
expect(bufferLogger.errorText, isNot(contains('Error reading error')));
expect(testLogger.errorText, contains('a'));
expect(testLogger.errorText, contains('b'));
expect(testLogger.errorText, contains('foo builder'));
expect(testLogger.errorText, isNot(contains('Error reading error')));
}));
}
......
......@@ -27,7 +27,7 @@ void main() {
when(cache.isUpToDate()).thenReturn(false);
when(cache.updateAll(any)).thenAnswer((Invocation invocation) {
artifacts = invocation.positionalArguments.first;
artifacts = invocation.positionalArguments.first as Set<DevelopmentArtifact>;
return Future<void>.value(null);
});
flutterVersion = MockFlutterVersion();
......
......@@ -117,7 +117,7 @@ class MockProcessManager extends Mock implements ProcessManager {
return ProcessResult(0, 0, 'v10.0.0\r\nv20.0.0', '');
}
if (command[0] == 'git' && command[1] == 'checkout') {
version = command[2];
version = command[2] as String;
}
return ProcessResult(0, 0, '', '');
}
......
......@@ -211,7 +211,7 @@ void main() {
fs.file('.packages').createSync();
final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand());
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
final Environment environment = invocation.positionalArguments[1];
final Environment environment = invocation.positionalArguments[1] as Environment;
expect(environment.defines, <String, String>{
kTargetFile: fs.path.join('lib', 'main.dart'),
kBuildMode: 'debug',
......
......@@ -1379,7 +1379,7 @@ class LoggingProcessManager extends LocalProcessManager {
@override
Future<Process> start(
List<dynamic> command, {
List<String> command, {
String workingDirectory,
Map<String, String> environment,
bool includeParentEnvironment = true,
......
......@@ -81,7 +81,7 @@ void main() {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--name', 'inc.*de']);
if (!result.stdout.contains('+1: All tests passed')) {
if (!(result.stdout as String).contains('+1: All tests passed')) {
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
}
expect(result.exitCode, 0);
......@@ -91,7 +91,7 @@ void main() {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--plain-name', 'include']);
if (!result.stdout.contains('+1: All tests passed')) {
if (!(result.stdout as String).contains('+1: All tests passed')) {
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
}
expect(result.exitCode, 0);
......@@ -101,14 +101,15 @@ void main() {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('trivial', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--verbose']);
if ((!result.stdout.contains('+1: All tests passed')) ||
(!result.stdout.contains('test 0: starting shell process')) ||
(!result.stdout.contains('test 0: deleting temporary directory')) ||
(!result.stdout.contains('test 0: finished')) ||
(!result.stdout.contains('test package returned with exit code 0'))) {
final String stdout = result.stdout as String;
if ((!stdout.contains('+1: All tests passed')) ||
(!stdout.contains('test 0: starting shell process')) ||
(!stdout.contains('test 0: deleting temporary directory')) ||
(!stdout.contains('test 0: finished')) ||
(!stdout.contains('test package returned with exit code 0'))) {
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
}
if (result.stderr.isNotEmpty) {
if ((result.stderr as String).isNotEmpty) {
fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n');
}
expect(result.exitCode, 0);
......@@ -118,14 +119,15 @@ void main() {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest(null, automatedTestsDirectory, flutterTestDirectory + '/child_directory',
extraArguments: const <String>['--verbose']);
if ((!result.stdout.contains('+2: All tests passed')) ||
(!result.stdout.contains('test 0: starting shell process')) ||
(!result.stdout.contains('test 0: deleting temporary directory')) ||
(!result.stdout.contains('test 0: finished')) ||
(!result.stdout.contains('test package returned with exit code 0'))) {
final String stdout = result.stdout as String;
if ((!stdout.contains('+2: All tests passed')) ||
(!stdout.contains('test 0: starting shell process')) ||
(!stdout.contains('test 0: deleting temporary directory')) ||
(!stdout.contains('test 0: finished')) ||
(!stdout.contains('test package returned with exit code 0'))) {
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
}
if (result.stderr.isNotEmpty) {
if ((result.stderr as String).isNotEmpty) {
fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n');
}
expect(result.exitCode, 0);
......@@ -160,7 +162,7 @@ Future<void> _testFile(
);
expect(exec.exitCode, exitCode);
final List<String> output = exec.stdout.split('\n');
final List<String> output = (exec.stdout as String).split('\n');
if (output.first == 'Waiting for another flutter command to release the startup lock...') {
output.removeAt(0);
}
......@@ -168,7 +170,7 @@ Future<void> _testFile(
output.removeAt(0);
}
output.add('<<stderr>>');
output.addAll(exec.stderr.split('\n'));
output.addAll((exec.stderr as String).split('\n'));
final List<String> expectations = fs.file(fullTestExpectation).readAsLinesSync();
bool allowSkip = false;
int expectationLineNumber = 0;
......
......@@ -94,7 +94,7 @@ void main() {
});
testUsingContext('Usage records one feature in experiment setting', () async {
when<bool>(mockFlutterConfig.getValue(flutterWebFeature.configSetting))
when<bool>(mockFlutterConfig.getValue(flutterWebFeature.configSetting) as bool)
.thenReturn(true);
final Usage usage = Usage();
usage.sendCommand('test');
......@@ -112,11 +112,11 @@ void main() {
});
testUsingContext('Usage records multiple features in experiment setting', () async {
when<bool>(mockFlutterConfig.getValue(flutterWebFeature.configSetting))
when<bool>(mockFlutterConfig.getValue(flutterWebFeature.configSetting) as bool)
.thenReturn(true);
when<bool>(mockFlutterConfig.getValue(flutterLinuxDesktopFeature.configSetting))
when<bool>(mockFlutterConfig.getValue(flutterLinuxDesktopFeature.configSetting) as bool)
.thenReturn(true);
when<bool>(mockFlutterConfig.getValue(flutterMacOSDesktopFeature.configSetting))
when<bool>(mockFlutterConfig.getValue(flutterMacOSDesktopFeature.configSetting) as bool)
.thenReturn(true);
final Usage usage = Usage();
usage.sendCommand('test');
......@@ -201,7 +201,7 @@ void main() {
testUsingContext('compound command usage path', () async {
final BuildCommand buildCommand = BuildCommand();
final FlutterCommand buildApkCommand = buildCommand.subcommands['apk'];
final FlutterCommand buildApkCommand = buildCommand.subcommands['apk'] as FlutterCommand;
expect(await buildApkCommand.usagePath, 'build/apk');
}, overrides: <Type, Generator>{
Usage: () => mockUsage,
......
......@@ -3,13 +3,11 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/gradle_utils.dart';
import 'package:flutter_tools/src/android/gradle_errors.dart';
import 'package:flutter_tools/src/android/gradle_utils.dart';
import 'package:flutter_tools/src/base/context.dart';
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';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
......@@ -57,8 +55,7 @@ at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)''';
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -86,8 +83,7 @@ at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)''';
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -106,8 +102,7 @@ Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -142,8 +137,7 @@ Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host clos
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -170,8 +164,7 @@ Exception in thread "main" java.io.FileNotFoundException: https://downloads.grad
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -209,8 +202,7 @@ Exception in thread "main" java.net.SocketException: Connection reset
expect(testErrorMessage(errorMessage, networkErrorHandler), isTrue);
expect(await networkErrorHandler.handler(), equals(GradleBuildStatus.retry));
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText,
expect(testLogger.errorText,
contains(
'Gradle threw an error while trying to update itself. '
'Retrying the update...'
......@@ -228,13 +220,12 @@ Command: /home/android/gradlew assembleRelease
expect(testErrorMessage(errorMessage, permissionDeniedErrorHandler), isTrue);
expect(await permissionDeniedErrorHandler.handler(), equals(GradleBuildStatus.exit));
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains('Gradle does not have execution permission.'),
);
expect(
logger.statusText,
testLogger.statusText,
contains(
'You should change the ownership of the project directory to your user, '
'or move the project to a directory with execute permissions.'
......@@ -302,8 +293,7 @@ Command: /home/android/gradlew assembleRelease
usesAndroidX: false,
);
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText,
expect(testLogger.statusText,
contains(
'AndroidX incompatibilities may have caused this build to fail. '
'Please migrate your app to AndroidX. See https://goo.gl/CP92wY.'
......@@ -361,8 +351,7 @@ Command: /home/android/gradlew assembleRelease
shouldBuildPluginAsAar: false,
);
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText,
expect(testLogger.statusText,
contains(
'The built failed likely due to AndroidX incompatibilities in a plugin. '
'The tool is about to try using Jetfier to solve the incompatibility.'
......@@ -396,13 +385,12 @@ Command: /home/android/gradlew assembleRelease
testUsingContext('handler', () async {
expect(await permissionDeniedErrorHandler.handler(), equals(GradleBuildStatus.exit));
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains('Gradle does not have execution permission.'),
);
expect(
logger.statusText,
testLogger.statusText,
contains(
'You should change the ownership of the project directory to your user, '
'or move the project to a directory with execute permissions.'
......@@ -427,9 +415,8 @@ Command: /home/android/gradlew assembleRelease
project: FlutterProject.current(),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'Unable to download needed Android SDK components, as the '
'following licenses have not been accepted:\n'
......@@ -508,16 +495,15 @@ assembleFooTest
project: FlutterProject.current(),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'Gradle project does not define a task suitable '
'for the requested build.'
)
);
expect(
logger.statusText,
testLogger.statusText,
contains(
'The android/app/build.gradle file defines product '
'flavors: flavor1, flavor_2 '
......@@ -557,16 +543,15 @@ assembleProfile
project: FlutterProject.current(),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'Gradle project does not define a task suitable '
'for the requested build.'
)
);
expect(
logger.statusText,
testLogger.statusText,
contains(
'The android/app/build.gradle file does not define any custom product flavors. '
'You cannot use the --flavor option.'
......
......@@ -1604,9 +1604,8 @@ plugin2=${plugin2.path}
localGradleErrors: const <GradleHandledError>[],
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains('Built build/app/outputs/apk/release/app-release.apk (0.0MB)'),
);
......@@ -1652,13 +1651,12 @@ plugin2=${plugin2.path}
target: '',
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains('Built build/outputs/repo'),
);
expect(
logger.statusText.contains('Consuming the Module'),
testLogger.statusText.contains('Consuming the Module'),
isFalse,
);
......@@ -1745,7 +1743,7 @@ plugin2=${plugin2.path}
environment: anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory')
),
).captured.last;
).captured.last as List<String>;
expect(actualGradlewCall, contains('/android/gradlew'));
expect(actualGradlewCall, contains('-Plocal-engine-out=out/android_arm'));
......@@ -1821,7 +1819,7 @@ plugin2=${plugin2.path}
environment: anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory'),
),
).captured.last;
).captured.last as List<String>;
expect(actualGradlewCall, contains('/.android/gradlew'));
expect(actualGradlewCall, contains('-Plocal-engine-out=out/android_arm'));
......@@ -1847,9 +1845,8 @@ plugin2=${plugin2.path}
repoDirectory: fs.directory('build/'),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'\n'
'Consuming the Module\n'
......@@ -1900,9 +1897,8 @@ plugin2=${plugin2.path}
repoDirectory: fs.directory('build/'),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'\n'
'Consuming the Module\n'
......@@ -1940,9 +1936,8 @@ plugin2=${plugin2.path}
repoDirectory: fs.directory('build/'),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'\n'
'Consuming the Module\n'
......@@ -1980,9 +1975,8 @@ plugin2=${plugin2.path}
repoDirectory: fs.directory('build/'),
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
testLogger.statusText,
contains(
'\n'
'Consuming the Module\n'
......@@ -2047,7 +2041,7 @@ FlutterProject generateFakeAppBundle(String directoryName, String fileName) {
return project;
}
Platform fakePlatform(String name) {
FakePlatform fakePlatform(String name) {
return FakePlatform.fromPlatform(const LocalPlatform())
..operatingSystem = name
..stdoutSupportsAnsi = false;
......
......@@ -6,6 +6,7 @@ import 'dart:convert' show json;
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/fingerprint.dart';
......@@ -301,7 +302,7 @@ void main() {
fs.file('b.dart').writeAsStringSync('This is b');
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']);
final Map<String, dynamic> jsonObject = json.decode(fingerprint.toJson());
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['files'], hasLength(2));
expect(jsonObject['files']['a.dart'], '8a21a15fad560b799f6731d436c1b698');
expect(jsonObject['files']['b.dart'], '6f144e08b58cd0925328610fad7ac07c');
......@@ -313,14 +314,14 @@ void main() {
testUsingContext('includes framework version', () {
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>[]);
final Map<String, dynamic> jsonObject = json.decode(fingerprint.toJson());
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['version'], mockVersion.frameworkRevision);
}, overrides: <Type, Generator>{FlutterVersion: () => mockVersion});
testUsingContext('includes provided properties', () {
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{'a': 'A', 'b': 'B'}, <String>[]);
final Map<String, dynamic> jsonObject = json.decode(fingerprint.toJson());
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['properties'], hasLength(2));
expect(jsonObject['properties']['a'], 'A');
expect(jsonObject['properties']['b'], 'B');
......@@ -348,7 +349,7 @@ void main() {
},
});
final Fingerprint fingerprint = Fingerprint.fromJson(jsonString);
final Map<String, dynamic> content = json.decode(fingerprint.toJson());
final Map<String, dynamic> content = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(content, hasLength(3));
expect(content['version'], mockVersion.frameworkRevision);
expect(content['properties'], hasLength(3));
......
......@@ -705,10 +705,9 @@ void main() {
});
testUsingContext('sequential startProgress calls with BufferLogger', () async {
final BufferLogger logger = context.get<Logger>();
logger.startProgress('AAA', timeout: timeoutConfiguration.fastOperation)..stop();
logger.startProgress('BBB', timeout: timeoutConfiguration.fastOperation)..stop();
expect(logger.statusText, 'AAA\nBBB\n');
testLogger.startProgress('AAA', timeout: timeoutConfiguration.fastOperation)..stop();
testLogger.startProgress('BBB', timeout: timeoutConfiguration.fastOperation)..stop();
expect(testLogger.statusText, 'AAA\nBBB\n');
}, overrides: <Type, Generator>{
Logger: () => BufferLogger(),
Platform: _kNoAnsiPlatform,
......
......@@ -4,7 +4,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:file/file.dart';
import 'package:file/memory.dart';
......@@ -365,25 +364,25 @@ class FakeHttpClientResponse implements io.HttpClientResponse {
String get reasonPhrase => '<reason phrase>';
@override
StreamSubscription<Uint8List> listen(
void onData(Uint8List event), {
StreamSubscription<List<int>> listen(
void onData(List<int> event), {
Function onError,
void onDone(),
bool cancelOnError,
}) {
if (data == null) {
return Stream<Uint8List>.fromFuture(Future<Uint8List>.error(
return Stream<List<int>>.fromFuture(Future<List<int>>.error(
const io.SocketException('test'),
)).listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
} else {
return Stream<Uint8List>.fromFuture(Future<Uint8List>.value(
utf8.encode(data) as Uint8List,
return Stream<List<int>>.fromFuture(Future<List<int>>.value(
utf8.encode(data),
)).listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
}
@override
Future<dynamic> forEach(void Function(Uint8List element) action) async {
Future<dynamic> forEach(void Function(List<int> element) action) async {
if (data == null) {
return Future<void>.error(const io.SocketException('test'));
} else {
......
......@@ -4,6 +4,7 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/exceptions.dart';
import 'package:flutter_tools/src/cache.dart';
......@@ -133,7 +134,7 @@ void main() {
final File stampFile = fs.file(fs.path.join(environment.buildDir.path, 'foo.stamp'));
expect(stampFile.existsSync(), true);
final Map<String, Object> stampContents = json.decode(stampFile.readAsStringSync());
final Map<String, dynamic> stampContents = castStringKeyedMap(json.decode(stampFile.readAsStringSync()));
expect(stampContents['inputs'], <Object>['/foo.dart']);
}));
......
......@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:typed_data';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/file_hash_store.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/testbed.dart';
void main() {
......@@ -34,7 +35,7 @@ void main() {
expect(fs.file(fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true);
final List<int> buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
.readAsBytesSync();
final FileStorage fileStorage = FileStorage.fromBuffer(buffer);
......@@ -51,7 +52,7 @@ void main() {
await fileCache.hashFiles(<File>[file]);
fileCache.persist();
final String currentHash = fileCache.currentHashes[file.path];
final List<int> buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache'))
.readAsBytesSync();
FileStorage fileStorage = FileStorage.fromBuffer(buffer);
......@@ -97,7 +98,6 @@ void main() {
}));
test('handles failure to persist file cache', () => testbed.run(() async {
final BufferLogger bufferLogger = logger;
final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs);
final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem);
final String cacheFile = environment.buildDir.childFile('.filecache').path;
......@@ -109,11 +109,10 @@ void main() {
fakeForwardingFileSystem.files[cacheFile] = mockFile;
fileCache.persist();
expect(bufferLogger.errorText, contains('Out of space!'));
expect(testLogger.errorText, contains('Out of space!'));
}));
test('handles failure to restore file cache', () => testbed.run(() async {
final BufferLogger bufferLogger = logger;
final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs);
final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem);
final String cacheFile = environment.buildDir.childFile('.filecache').path;
......@@ -124,14 +123,14 @@ void main() {
fakeForwardingFileSystem.files[cacheFile] = mockFile;
fileCache.initialize();
expect(bufferLogger.errorText, contains('Out of space!'));
expect(testLogger.errorText, contains('Out of space!'));
}));
}
class FakeForwardingFileSystem extends ForwardingFileSystem {
FakeForwardingFileSystem(FileSystem fileSystem) : super(fileSystem);
final Map<String, FileSystemEntity> files = <String, FileSystemEntity>{};
final Map<String, File> files = <String, File>{};
@override
File file(dynamic path) => files[path] ?? super.file(path);
......
......@@ -115,7 +115,7 @@ void main() {
snapshotType: captureAnyNamed('snapshotType'),
darwinArch: anyNamed('darwinArch'),
additionalArgs: anyNamed('additionalArgs')
)).captured.single;
)).captured.single as SnapshotType;
expect(snapshotType.platform, TargetPlatform.android_arm64);
expect(snapshotType.mode, BuildMode.release);
......
......@@ -118,7 +118,7 @@ flutter_tools:lib/''');
}));
test('kernel_snapshot handles null result from kernel compilation', () => testbed.run(() async {
final FakeKernelCompilerFactory fakeKernelCompilerFactory = kernelCompilerFactory;
final FakeKernelCompilerFactory fakeKernelCompilerFactory = kernelCompilerFactory as FakeKernelCompilerFactory;
fakeKernelCompilerFactory.kernelCompiler = MockKernelCompiler();
when(fakeKernelCompilerFactory.kernelCompiler.compile(
sdkRoot: anyNamed('sdkRoot'),
......
......@@ -90,7 +90,7 @@ void main() {
.createSync(recursive: true);
when(processManager.run(any)).thenAnswer((Invocation invocation) async {
final List<String> arguments = invocation.positionalArguments.first;
final List<String> arguments = invocation.positionalArguments.first as List<String>;
final String sourcePath = arguments[arguments.length - 2];
final String targetPath = arguments.last;
final Directory source = fs.directory(sourcePath);
......
......@@ -25,7 +25,7 @@ void main() {
test('Copies assets to expected directory after building', () => testbed.run(() async {
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
final Environment environment = invocation.positionalArguments[1];
final Environment environment = invocation.positionalArguments[1] as Environment;
environment.outputDir.childFile('kernel_blob.bin').createSync(recursive: true);
environment.outputDir.childFile('isolate_snapshot_data').createSync();
environment.outputDir.childFile('vm_snapshot_data').createSync();
......
......@@ -332,7 +332,7 @@ void main() {
when(processManager.run(any, environment: captureAnyNamed('environment')))
.thenAnswer((Invocation invocation) {
final List<String> args = invocation.positionalArguments[0];
final List<String> args = invocation.positionalArguments[0] as List<String>;
expect(args.length, 6);
expect(args[1], '-b');
expect(args[2].endsWith('resolve_dependencies.gradle'), isTrue);
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/android/android_builder.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_apk.dart';
......@@ -362,9 +361,8 @@ flutter:
);
}, throwsToolExit());
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText, contains('Your app isn\'t using AndroidX'));
expect(logger.statusText, contains(
expect(testLogger.statusText, contains('Your app isn\'t using AndroidX'));
expect(testLogger.statusText, contains(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
)
......@@ -414,10 +412,9 @@ flutter:
);
}, throwsToolExit());
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText.contains('[!] Your app isn\'t using AndroidX'), isFalse);
expect(testLogger.statusText.contains('[!] Your app isn\'t using AndroidX'), isFalse);
expect(
logger.statusText.contains(
testLogger.statusText.contains(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
),
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/android/android_builder.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_appbundle.dart';
......@@ -348,9 +347,8 @@ flutter:
);
}, throwsToolExit());
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText, contains('Your app isn\'t using AndroidX'));
expect(logger.statusText, contains(
expect(testLogger.statusText, contains('Your app isn\'t using AndroidX'));
expect(testLogger.statusText, contains(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
)
......@@ -400,10 +398,9 @@ flutter:
);
}, throwsToolExit());
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText.contains('Your app isn\'t using AndroidX'), isFalse);
expect(testLogger.statusText.contains('Your app isn\'t using AndroidX'), isFalse);
expect(
logger.statusText.contains(
testLogger.statusText.contains(
'To avoid potential build failures, you can quickly migrate your app by '
'following the steps on https://goo.gl/CP92wY'
),
......
......@@ -5,13 +5,11 @@
import 'dart:async';
import 'package:flutter_tools/src/base/io.dart';
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/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
......@@ -41,14 +39,13 @@ void main() {
when(mockProcessManager.canRun(any)).thenReturn(true);
when(mockProcessManager.start(any)).thenAnswer(
(Invocation invocation) {
latestCommand = invocation.positionalArguments.first;
latestCommand = invocation.positionalArguments.first as List<String>;
return Future<Process>.value(mockFrontendServer);
});
when(mockFrontendServer.exitCode).thenAnswer((_) async => 0);
});
testUsingContext('batch compile single dart successful compilation', () async {
final BufferLogger bufferLogger = logger;
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
Future<List<int>>.value(utf8.encode(
......@@ -64,7 +61,7 @@ void main() {
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(bufferLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
......@@ -136,7 +133,6 @@ void main() {
});
testUsingContext('batch compile single dart failed compilation', () async {
final BufferLogger bufferLogger = logger;
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
Future<List<int>>.value(utf8.encode(
......@@ -152,7 +148,7 @@ void main() {
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(bufferLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(output, equals(null));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
......@@ -162,7 +158,6 @@ void main() {
testUsingContext('batch compile single dart abnormal compiler termination', () async {
when(mockFrontendServer.exitCode).thenAnswer((_) async => 255);
final BufferLogger bufferLogger = logger;
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
......@@ -179,7 +174,7 @@ void main() {
dartDefines: const <String>[],
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(bufferLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(output, equals(null));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
......
......@@ -12,7 +12,6 @@ import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
......@@ -59,8 +58,6 @@ void main() {
});
testUsingContext('compile expression can compile single expression', () async {
final BufferLogger bufferLogger = logger;
final Completer<List<int>> compileResponseCompleter =
Completer<List<int>>();
final Completer<List<int>> compileExpressionResponseCompleter =
......@@ -85,7 +82,7 @@ void main() {
expect(mockFrontendServerStdIn.getAndClear(),
'compile /path/to/main.dart\n');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(bufferLogger.errorText,
expect(testLogger.errorText,
equals('\nCompiler message:\nline1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
......@@ -111,7 +108,6 @@ void main() {
});
testUsingContext('compile expressions without awaiting', () async {
final BufferLogger bufferLogger = logger;
final Completer<List<int>> compileResponseCompleter = Completer<List<int>>();
final Completer<List<int>> compileExpressionResponseCompleter1 = Completer<List<int>>();
final Completer<List<int>> compileExpressionResponseCompleter2 = Completer<List<int>>();
......@@ -132,7 +128,7 @@ void main() {
null, /* invalidatedFiles */
outputPath: '/build/',
).then((CompilerOutput outputCompile) {
expect(bufferLogger.errorText,
expect(testLogger.errorText,
equals('\nCompiler message:\nline1\nline2\n'));
expect(outputCompile.outputFilename, equals('/path/to/main.dart.dill'));
......
......@@ -7,13 +7,11 @@ import 'dart:async';
import 'package:flutter_tools/src/base/async_guard.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
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/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
......@@ -53,8 +51,6 @@ void main() {
});
testUsingContext('incremental compile single dart compile', () async {
final BufferLogger bufferLogger = logger;
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
Future<List<int>>.value(utf8.encode(
......@@ -69,7 +65,7 @@ void main() {
);
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(bufferLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
......@@ -112,7 +108,6 @@ void main() {
});
testUsingContext('incremental compile and recompile', () async {
final BufferLogger bufferLogger = logger;
final StreamController<List<int>> streamController = StreamController<List<int>>();
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream);
......@@ -141,7 +136,7 @@ void main() {
'^reject\\n\$');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(bufferLogger.errorText, equals(
expect(testLogger.errorText, equals(
'\nCompiler message:\nline0\nline1\n'
'\nCompiler message:\nline1\nline2\n'
'\nCompiler message:\nline1\nline2\n'
......@@ -153,8 +148,6 @@ void main() {
});
testUsingContext('incremental compile and recompile twice', () async {
final BufferLogger bufferLogger = logger;
final StreamController<List<int>> streamController = StreamController<List<int>>();
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream);
......@@ -171,7 +164,7 @@ void main() {
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(bufferLogger.errorText, equals(
expect(testLogger.errorText, equals(
'\nCompiler message:\nline0\nline1\n'
'\nCompiler message:\nline1\nline2\n'
'\nCompiler message:\nline2\nline3\n'
......
......@@ -11,7 +11,6 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/runner.dart' as tools;
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/doctor.dart';
......@@ -181,8 +180,7 @@ void main() {
expect(method, null);
expect(uri, null);
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText, '');
expect(testLogger.statusText, '');
}, overrides: <Type, Generator>{
Stdio: () => const _NoStderr(),
});
......@@ -260,8 +258,7 @@ Future<void> verifyCrashReportSent(RequestInfo crashInfo, {
expect(crashInfo.fields['error_message'], 'Bad state: Test bad state error');
expect(crashInfo.fields['comments'], 'crash');
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText, 'Sending crash report to Google.\n'
expect(testLogger.statusText, 'Sending crash report to Google.\n'
'Crash report sent (report ID: test-report-id)\n');
// Verify that we've written the crash report to disk.
......@@ -295,11 +292,11 @@ class MockCrashReportSender extends MockClient {
})
.where((List<String> pair) => pair != null),
key: (dynamic key) {
final List<String> pair = key;
final List<String> pair = key as List<String>;
return pair[0];
},
value: (dynamic value) {
final List<String> pair = value;
final List<String> pair = value as List<String>;
return pair[1];
},
);
......
......@@ -34,7 +34,7 @@ void main() {
testUsingContext('pub get 69', () async {
String error;
final MockProcessManager processMock = context.get<ProcessManager>();
final MockProcessManager processMock = context.get<ProcessManager>() as MockProcessManager;
FakeAsync().run((FakeAsync time) {
expect(processMock.lastPubEnvironment, isNull);
......@@ -158,7 +158,7 @@ void main() {
testUsingContext('pub cache in environment is used', () async {
String error;
final MockProcessManager processMock = context.get<ProcessManager>();
final MockProcessManager processMock = context.get<ProcessManager>() as MockProcessManager;
FakeAsync().run((FakeAsync time) {
MockDirectory.findCache = true;
......@@ -410,7 +410,7 @@ class MockFileSystem extends ForwardingFileSystem {
@override
Directory directory(dynamic path) {
return MockDirectory(path);
return MockDirectory(path as String);
}
}
......
......@@ -5,19 +5,17 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/desktop_device.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import '../src/common.dart';
import '../src/context.dart';
......@@ -171,8 +169,7 @@ void main() {
final MockAppplicationPackage package = MockAppplicationPackage();
final LaunchResult result = await device.startApp(package, prebuiltApplication: true);
expect(result.started, false);
final BufferLogger logger = context.get<Logger>();
expect(logger.errorText, contains('Unable to find executable to run'));
expect(testLogger.errorText, contains('Unable to find executable to run'));
});
testUsingContext('stopApp kills process started by startApp', () async {
......
......@@ -129,7 +129,7 @@ void main() {
when(mockXcode.xcodeSelectPath).thenReturn('/fake/Xcode.app/Contents/Developer');
when(mockXcode.getSimulatorPath()).thenAnswer((_) => '/fake/simulator.app');
when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async {
final List<String> args = invocation.positionalArguments[0];
final List<String> args = invocation.positionalArguments[0] as List<String>;
if (args.length >= 3 && args[0] == 'open' && args[1] == '-a' && args[2] == '/fake/simulator.app') {
didAttemptToRunSimulator = true;
}
......@@ -206,9 +206,9 @@ class MockProcessManager extends Mock implements ProcessManager {
Encoding stdoutEncoding = systemEncoding,
Encoding stderrEncoding = systemEncoding,
}) {
final String program = command[0];
final List<String> args = command.sublist(1);
switch (command[0]) {
final String program = command[0] as String;
final List<String> args = command.sublist(1) as List<String>;
switch (program) {
case '/usr/bin/xcode-select':
throw ProcessException(program, args);
break;
......
......@@ -22,7 +22,7 @@ void main() {
mockFlutterVerion = MockFlutterVerion();
mockFlutterConfig = MockFlutterConfig();
mockPlatform = MockPlatform();
when<bool>(mockFlutterConfig.getValue(any)).thenReturn(false);
when<bool>(mockFlutterConfig.getValue(any) as bool).thenReturn(false);
when(mockPlatform.environment).thenReturn(const <String, String>{});
testbed = Testbed(overrides: <Type, Generator>{
FlutterVersion: () => mockFlutterVerion,
......@@ -117,7 +117,7 @@ void main() {
test('flutter web enabled with config on master', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-web')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, true);
}));
......@@ -137,7 +137,7 @@ void main() {
test('flutter web enabled with config on dev', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-web')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, true);
}));
......@@ -157,7 +157,7 @@ void main() {
test('flutter web not enabled with config on beta', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-web')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, false);
}));
......@@ -177,7 +177,7 @@ void main() {
test('flutter web not enabled with config on stable', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-web')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-web') as bool).thenReturn(true);
expect(featureFlags.isWebEnabled, false);
}));
......@@ -199,7 +199,7 @@ void main() {
test('flutter macos desktop enabled with config on master', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-macos-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-macos-desktop') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, true);
}));
......@@ -219,7 +219,7 @@ void main() {
test('flutter macos desktop not enabled with config on dev', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, false);
}));
......@@ -239,7 +239,7 @@ void main() {
test('fflutter macos desktop not enabled with config on beta', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, false);
}));
......@@ -259,7 +259,7 @@ void main() {
test('flutter macos desktop not enabled with config on stable', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('flutter-desktop-macos') as bool).thenReturn(true);
expect(featureFlags.isMacOSEnabled, false);
}));
......@@ -280,7 +280,7 @@ void main() {
test('flutter linux desktop enabled with config on master', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, true);
}));
......@@ -300,7 +300,7 @@ void main() {
test('flutter linux desktop not enabled with config on dev', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, false);
}));
......@@ -320,7 +320,7 @@ void main() {
test('fflutter linux desktop not enabled with config on beta', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, false);
}));
......@@ -340,7 +340,7 @@ void main() {
test('flutter linux desktop not enabled with config on stable', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-linux-desktop') as bool).thenReturn(true);
expect(featureFlags.isLinuxEnabled, false);
}));
......@@ -361,7 +361,7 @@ void main() {
test('flutter windows desktop enabled with config on master', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('master');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, true);
}));
......@@ -381,7 +381,7 @@ void main() {
test('flutter windows desktop not enabled with config on dev', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('dev');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, false);
}));
......@@ -401,7 +401,7 @@ void main() {
test('fflutter windows desktop not enabled with config on beta', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('beta');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, false);
}));
......@@ -421,7 +421,7 @@ void main() {
test('flutter windows desktop not enabled with config on stable', () => testbed.run(() {
when(mockFlutterVerion.channel).thenReturn('stable');
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop')).thenReturn(true);
when<bool>(mockFlutterConfig.getValue('enable-windows-desktop') as bool).thenReturn(true);
expect(featureFlags.isWindowsEnabled, false);
}));
......
......@@ -8,7 +8,6 @@ import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/flutter_manifest.dart';
......@@ -401,7 +400,6 @@ flutter:
});
testUsingContext('handles an invalid plugin declaration', () async {
final BufferLogger bufferLogger = context.get<Logger>();
const String manifest = '''
name: test
flutter:
......@@ -409,7 +407,7 @@ flutter:
''';
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(bufferLogger.errorText, contains('Expected "plugin" to be an object, but got null'));
expect(testLogger.errorText, contains('Expected "plugin" to be an object, but got null'));
});
......@@ -528,7 +526,6 @@ flutter:
// Regression test for https://github.com/flutter/flutter/issues/31764
testUsingContext('Returns proper error when font detail is malformed', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
......@@ -543,11 +540,10 @@ flutter:
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected "fonts" to either be null or a list.'));
expect(testLogger.errorText, contains('Expected "fonts" to either be null or a list.'));
});
testUsingContext('Returns proper error when font detail is not a list of maps', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
......@@ -562,11 +558,10 @@ flutter:
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected "fonts" to be a list of maps.'));
expect(testLogger.errorText, contains('Expected "fonts" to be a list of maps.'));
});
testUsingContext('Returns proper error when font is a map instead of a list', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
......@@ -581,11 +576,10 @@ flutter:
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected "fonts" to be a list'));
expect(testLogger.errorText, contains('Expected "fonts" to be a list'));
});
testUsingContext('Returns proper error when second font family is invalid', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
......@@ -601,11 +595,10 @@ flutter:
''';
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
expect(flutterManifest, null);
expect(logger.errorText, contains('Expected a map.'));
expect(testLogger.errorText, contains('Expected a map.'));
});
testUsingContext('Does not crash on empty entry', () async {
final BufferLogger logger = context.get<Logger>();
const String manifest = '''
name: test
dependencies:
......@@ -620,7 +613,7 @@ flutter:
final FlutterManifest flutterManifest = FlutterManifest.createFromString(manifest);
final List<Uri> assets = flutterManifest.assets;
expect(logger.errorText, contains('Asset manifest contains a null or empty uri.'));
expect(testLogger.errorText, contains('Asset manifest contains a null or empty uri.'));
expect(assets.length, 1);
});
});
......
......@@ -51,7 +51,7 @@ void main() {
final VerificationResult toVerify = verify(mockProcessManager.start(any, environment: captureAnyNamed('environment')));
expect(toVerify.captured, hasLength(1));
expect(toVerify.captured.first, isInstanceOf<Map<String, String>>());
return toVerify.captured.first;
return toVerify.captured.first as Map<String, String>;
}
testUsingContext('as true when not originally set', () async {
......
......@@ -135,4 +135,4 @@ void main() {
bool _isDartFile(FileSystemEntity entity) => entity is File && entity.path.endsWith('.dart');
File _asFile(FileSystemEntity entity) => entity;
File _asFile(FileSystemEntity entity) => entity as File;
......@@ -147,8 +147,8 @@ void main() {
)).thenAnswer((Invocation invocation) =>
Future<ProcessResult>.value(mockProcessResult));
when(mockProcessResult.exitCode).thenReturn(1);
when<String>(mockProcessResult.stdout).thenReturn('');
when<String>(mockProcessResult.stderr).thenReturn('');
when<String>(mockProcessResult.stdout as String).thenReturn('');
when<String>(mockProcessResult.stderr as String).thenReturn('');
when(mockFile.absolute).thenReturn(mockFile);
when(mockFile.path).thenReturn('');
......@@ -161,8 +161,8 @@ void main() {
)).thenAnswer((Invocation invocation) =>
Future<ProcessResult>.value(emptyStdoutProcessResult));
when(emptyStdoutProcessResult.exitCode).thenReturn(0);
when<String>(emptyStdoutProcessResult.stdout).thenReturn('');
when<String>(emptyStdoutProcessResult.stderr).thenReturn('');
when<String>(emptyStdoutProcessResult.stdout as String).thenReturn('');
when<String>(emptyStdoutProcessResult.stderr as String).thenReturn('');
});
testUsingContext('No vmservices found', () async {
......@@ -327,7 +327,7 @@ void main() {
when(vmService.vm).thenReturn(vm);
});
Future<Uri> findUri(List<MockFlutterView> views, String expectedIsolateName) {
Future<Uri> findUri(List<MockFlutterView> views, String expectedIsolateName) async {
when(vm.views).thenReturn(views);
for (MockFlutterView view in views) {
when(view.owner).thenReturn(vm);
......@@ -350,7 +350,7 @@ void main() {
when(vmService.refreshViews())
.thenAnswer((Invocation invocation) => Future<void>.value(null));
when(vmService.httpAddress).thenReturn(Uri.parse('example'));
return discoveryProtocol.uri;
return await discoveryProtocol.uri;
}
testUsingContext('can find flutter view with matching isolate name', () async {
......@@ -659,24 +659,24 @@ void main() {
when(mockSuccessProcessManager.run(any)).thenAnswer(
(Invocation invocation) => Future<ProcessResult>.value(mockSuccessProcessResult));
when(mockSuccessProcessResult.exitCode).thenReturn(0);
when<String>(mockSuccessProcessResult.stdout).thenReturn('version');
when<String>(mockSuccessProcessResult.stderr).thenReturn('');
when<String>(mockSuccessProcessResult.stdout as String).thenReturn('version');
when<String>(mockSuccessProcessResult.stderr as String).thenReturn('');
mockFailureProcessManager = MockProcessManager();
mockFailureProcessResult = MockProcessResult();
when(mockFailureProcessManager.run(any)).thenAnswer(
(Invocation invocation) => Future<ProcessResult>.value(mockFailureProcessResult));
when(mockFailureProcessResult.exitCode).thenReturn(1);
when<String>(mockFailureProcessResult.stdout).thenReturn('');
when<String>(mockFailureProcessResult.stderr).thenReturn('');
when<String>(mockFailureProcessResult.stdout as String).thenReturn('');
when<String>(mockFailureProcessResult.stderr as String).thenReturn('');
emptyStdoutProcessManager = MockProcessManager();
emptyStdoutProcessResult = MockProcessResult();
when(emptyStdoutProcessManager.run(any)).thenAnswer((Invocation invocation) =>
Future<ProcessResult>.value(emptyStdoutProcessResult));
when(emptyStdoutProcessResult.exitCode).thenReturn(0);
when<String>(emptyStdoutProcessResult.stdout).thenReturn('');
when<String>(emptyStdoutProcessResult.stderr).thenReturn('');
when<String>(emptyStdoutProcessResult.stdout as String).thenReturn('');
when<String>(emptyStdoutProcessResult.stderr as String).thenReturn('');
});
testUsingContext('returns what we get from the device on success', () async {
......
......@@ -455,7 +455,7 @@ void main() {
));
when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr);
when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future<int>.value(0));
when<String>(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Profile 3 (3333CCCC33)');
when<String>(mockConfig.getValue('ios-signing-cert') as String).thenReturn('iPhone Developer: Profile 3 (3333CCCC33)');
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
......@@ -535,7 +535,7 @@ void main() {
));
when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr);
when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future<int>.value(0));
when<String>(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Invalid Profile');
when<String>(mockConfig.getValue('ios-signing-cert') as String).thenReturn('iPhone Developer: Invalid Profile');
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
......
......@@ -111,7 +111,7 @@ void main() {
IOSDeviceLogReader createLogReader(
IOSDevice device,
ApplicationPackage appPackage,
IOSApp appPackage,
Process process) {
final IOSDeviceLogReader logReader = IOSDeviceLogReader(device, appPackage);
logReader.idevicesyslogProcess = process;
......@@ -436,7 +436,7 @@ void main() {
bundlePath: anyNamed('bundlePath'),
launchArguments: anyNamed('launchArguments'),
)).thenAnswer((Invocation inv) {
args = inv.namedArguments[const Symbol('launchArguments')];
args = inv.namedArguments[const Symbol('launchArguments')] as List<String>;
return Future<int>.value(0);
});
......
......@@ -193,7 +193,7 @@ void main() {
await simulator.sideloadUpdatedAssetsForInstalledApplicationBundle(BuildInfo.debug, 'lib/main.dart');
final VerificationResult result = verify(buildSystem.build(any, captureAny));
final Environment environment = result.captured.single;
final Environment environment = result.captured.single as Environment;
expect(environment.defines, <String, String>{
kTargetFile: 'lib/main.dart',
kTargetPlatform: 'ios',
......
......@@ -722,7 +722,7 @@ flutter:
});
}
Platform fakePlatform(String name) {
FakePlatform fakePlatform(String name) {
return FakePlatform.fromPlatform(const LocalPlatform())..operatingSystem = name;
}
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:typed_data';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
......@@ -31,7 +33,7 @@ void main() {
mockFile = MockFile();
when(mockFileSystem.path).thenReturn(fs.path);
when(mockFileSystem.file(any)).thenReturn(mockFile);
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(packagesContents));
when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(packagesContents) as Uint8List);
});
testUsingContext('Can map main.dart to correct package', () async {
......@@ -66,7 +68,7 @@ void main() {
when(mockFileSystem.path).thenReturn(fs.path);
when(mockFileSystem.file(any)).thenReturn(mockFile);
when(mockFile.readAsBytesSync())
.thenReturn(utf8.encode(multiRootPackagesContents));
.thenReturn(utf8.encode(multiRootPackagesContents) as Uint8List);
final PackageUriMapper packageUriMapper = PackageUriMapper(
'/example/lib/main.dart',
'.packages',
......
......@@ -18,13 +18,13 @@ void main() {
'iosPrefix: FLT\n'
'pluginClass: SamplePlugin\n';
final dynamic pluginYaml = loadYaml(pluginYamlRaw);
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
final Plugin plugin =
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]);
final AndroidPlugin androidPlugin =
plugin.platforms[AndroidPlugin.kConfigKey];
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey];
plugin.platforms[AndroidPlugin.kConfigKey] as AndroidPlugin;
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey] as IOSPlugin;
final String androidPluginClass = androidPlugin.pluginClass;
final String iosPluginClass = iosPlugin.pluginClass;
......@@ -51,20 +51,20 @@ void main() {
' windows:\n'
' pluginClass: WinSamplePlugin\n';
final dynamic pluginYaml = loadYaml(pluginYamlRaw);
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
final Plugin plugin =
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]);
final AndroidPlugin androidPlugin =
plugin.platforms[AndroidPlugin.kConfigKey];
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey];
plugin.platforms[AndroidPlugin.kConfigKey] as AndroidPlugin;
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey] as IOSPlugin;
final LinuxPlugin linuxPlugin =
plugin.platforms[LinuxPlugin.kConfigKey];
plugin.platforms[LinuxPlugin.kConfigKey] as LinuxPlugin;
final MacOSPlugin macOSPlugin =
plugin.platforms[MacOSPlugin.kConfigKey];
final WebPlugin webPlugin = plugin.platforms[WebPlugin.kConfigKey];
plugin.platforms[MacOSPlugin.kConfigKey] as MacOSPlugin;
final WebPlugin webPlugin = plugin.platforms[WebPlugin.kConfigKey] as WebPlugin;
final WindowsPlugin windowsPlugin =
plugin.platforms[WindowsPlugin.kConfigKey];
plugin.platforms[WindowsPlugin.kConfigKey] as WindowsPlugin;
final String androidPluginClass = androidPlugin.pluginClass;
final String iosPluginClass = iosPlugin.pluginClass;
......@@ -100,18 +100,14 @@ void main() {
final dynamic pluginYaml = loadYaml(pluginYamlRaw);
final Plugin plugin =
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]);
final AndroidPlugin androidPlugin =
plugin.platforms[AndroidPlugin.kConfigKey];
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey];
final LinuxPlugin linuxPlugin =
plugin.platforms[LinuxPlugin.kConfigKey];
final MacOSPlugin macOSPlugin =
plugin.platforms[MacOSPlugin.kConfigKey];
final WebPlugin webPlugin = plugin.platforms[WebPlugin.kConfigKey];
final WindowsPlugin windowsPlugin =
plugin.platforms[WindowsPlugin.kConfigKey];
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml as YamlMap, const <String>[]);
final AndroidPlugin androidPlugin = plugin.platforms[AndroidPlugin.kConfigKey] as AndroidPlugin;
final IOSPlugin iosPlugin = plugin.platforms[IOSPlugin.kConfigKey] as IOSPlugin;
final LinuxPlugin linuxPlugin = plugin.platforms[LinuxPlugin.kConfigKey] as LinuxPlugin;
final MacOSPlugin macOSPlugin = plugin.platforms[MacOSPlugin.kConfigKey] as MacOSPlugin;
final WebPlugin webPlugin = plugin.platforms[WebPlugin.kConfigKey] as WebPlugin;
final WindowsPlugin windowsPlugin = plugin.platforms[WindowsPlugin.kConfigKey] as WindowsPlugin;
final String androidPluginClass = androidPlugin.pluginClass;
final String iosPluginClass = iosPlugin.pluginClass;
......@@ -144,7 +140,7 @@ void main() {
final dynamic pluginYaml = loadYaml(pluginYamlRaw);
final Plugin plugin =
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml, const <String>[]);
Plugin.fromYaml(_kTestPluginName, _kTestPluginPath, pluginYaml as YamlMap, const <String>[]);
expect(plugin.platforms, <String, PluginPlatform> {});
});
......
......@@ -10,7 +10,6 @@ import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' as io;
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/devfs.dart';
......@@ -330,35 +329,33 @@ void main() {
when(mockDevice.supportsScreenshot).thenReturn(true);
residentRunner.printHelp(details: true);
final BufferLogger bufferLogger = context.get<Logger>();
// supports service protocol
expect(residentRunner.supportsServiceProtocol, true);
expect(bufferLogger.statusText, contains('"w"'));
expect(bufferLogger.statusText, contains('"t"'));
expect(bufferLogger.statusText, contains('"P"'));
expect(bufferLogger.statusText, contains('"a"'));
expect(testLogger.statusText, contains('"w"'));
expect(testLogger.statusText, contains('"t"'));
expect(testLogger.statusText, contains('"P"'));
expect(testLogger.statusText, contains('"a"'));
// isRunningDebug
expect(residentRunner.isRunningDebug, true);
expect(bufferLogger.statusText, contains('"L"'));
expect(bufferLogger.statusText, contains('"S"'));
expect(bufferLogger.statusText, contains('"U"'));
expect(bufferLogger.statusText, contains('"i"'));
expect(bufferLogger.statusText, contains('"p"'));
expect(bufferLogger.statusText, contains('"o"'));
expect(bufferLogger.statusText, contains('"z"'));
expect(testLogger.statusText, contains('"L"'));
expect(testLogger.statusText, contains('"S"'));
expect(testLogger.statusText, contains('"U"'));
expect(testLogger.statusText, contains('"i"'));
expect(testLogger.statusText, contains('"p"'));
expect(testLogger.statusText, contains('"o"'));
expect(testLogger.statusText, contains('"z"'));
// screenshot
expect(bufferLogger.statusText, contains('"s"'));
expect(testLogger.statusText, contains('"s"'));
}));
test('ResidentRunner can take screenshot on debug device', () => testbed.run(() async {
when(mockDevice.supportsScreenshot).thenReturn(true);
when(mockDevice.takeScreenshot(any))
.thenAnswer((Invocation invocation) async {
final File file = invocation.positionalArguments.first;
final File file = invocation.positionalArguments.first as File;
file.writeAsBytesSync(List<int>.generate(1024, (int i) => i));
});
final BufferLogger bufferLogger = context.get<Logger>();
await residentRunner.screenshot(mockFlutterDevice);
......@@ -366,37 +363,34 @@ void main() {
verify(mockIsolate.flutterDebugAllowBanner(false)).called(1);
// Enables debug banner.
verify(mockIsolate.flutterDebugAllowBanner(true)).called(1);
expect(bufferLogger.statusText, contains('1kB'));
expect(testLogger.statusText, contains('1kB'));
}));
test('ResidentRunner bails taking screenshot on debug device if debugAllowBanner throws pre', () => testbed.run(() async {
when(mockDevice.supportsScreenshot).thenReturn(true);
when(mockIsolate.flutterDebugAllowBanner(false)).thenThrow(Exception());
final BufferLogger bufferLogger = context.get<Logger>();
await residentRunner.screenshot(mockFlutterDevice);
expect(bufferLogger.errorText, contains('Error'));
expect(testLogger.errorText, contains('Error'));
}));
test('ResidentRunner bails taking screenshot on debug device if debugAllowBanner throws post', () => testbed.run(() async {
when(mockDevice.supportsScreenshot).thenReturn(true);
when(mockIsolate.flutterDebugAllowBanner(true)).thenThrow(Exception());
final BufferLogger bufferLogger = context.get<Logger>();
await residentRunner.screenshot(mockFlutterDevice);
expect(bufferLogger.errorText, contains('Error'));
expect(testLogger.errorText, contains('Error'));
}));
test('ResidentRunner bails taking screenshot on debug device if takeScreenshot throws', () => testbed.run(() async {
when(mockDevice.supportsScreenshot).thenReturn(true);
when(mockDevice.takeScreenshot(any)).thenThrow(Exception());
final BufferLogger bufferLogger = context.get<Logger>();
await residentRunner.screenshot(mockFlutterDevice);
expect(bufferLogger.errorText, contains('Error'));
expect(testLogger.errorText, contains('Error'));
}));
test('ResidentRunner can\'t take screenshot on device without support', () => testbed.run(() {
......@@ -417,10 +411,9 @@ void main() {
when(mockDevice.supportsScreenshot).thenReturn(true);
when(mockDevice.takeScreenshot(any))
.thenAnswer((Invocation invocation) async {
final File file = invocation.positionalArguments.first;
final File file = invocation.positionalArguments.first as File;
file.writeAsBytesSync(List<int>.generate(1024, (int i) => i));
});
final BufferLogger bufferLogger = context.get<Logger>();
await residentRunner.screenshot(mockFlutterDevice);
......@@ -428,7 +421,7 @@ void main() {
verifyNever(mockIsolate.flutterDebugAllowBanner(false));
// doesn't enable debug banner.
verifyNever(mockIsolate.flutterDebugAllowBanner(true));
expect(bufferLogger.statusText, contains('1kB'));
expect(testLogger.statusText, contains('1kB'));
}));
test('FlutterDevice will not exit a paused isolate', () => testbed.run(() async {
......@@ -560,7 +553,6 @@ void main() {
}));
test('HotRunner handles failure to write vmservice file', () => testbed.run(() async {
final BufferLogger bufferLogger = logger;
fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true);
residentRunner = HotRunner(
<FlutterDevice>[
......@@ -577,7 +569,7 @@ void main() {
});
await residentRunner.run();
expect(bufferLogger.errorText, contains('Failed to write vmservice-out-file at foo'));
expect(testLogger.errorText, contains('Failed to write vmservice-out-file at foo'));
}, overrides: <Type, Generator>{
FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem()),
}));
......@@ -615,7 +607,7 @@ void main() {
flutterProject: FlutterProject.current(),
target: null,
trackWidgetCreation: true,
)).generator;
)).generator as DefaultResidentCompiler;
expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot,
......
......@@ -42,7 +42,7 @@ void main() {
ipv6: true,
stayResident: true,
dartDefines: const <String>[],
);
) as ResidentWebRunner;
},
overrides: <Type, Generator>{
WebFsFactory: () => ({
......@@ -70,7 +70,7 @@ void main() {
test('Can successfully run and connect without vmservice', () => testbed.run(() async {
_setupMocks();
final DelegateLogger delegateLogger = logger;
final DelegateLogger delegateLogger = logger as DelegateLogger;
final MockStatus mockStatus = MockStatus();
delegateLogger.status = mockStatus;
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
......
......@@ -50,13 +50,13 @@ void main() {
version: '1 2 3 4 5',
);
runner = createTestCommandRunner(DummyFlutterCommand());
runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;
processManager = MockProcessManager();
});
group('run', () {
testUsingContext('checks that Flutter installation is up-to-date', () async {
final MockFlutterVersion version = FlutterVersion.instance;
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion;
bool versionChecked = false;
when(version.checkFlutterVersionFreshness()).thenAnswer((_) async {
versionChecked = true;
......@@ -72,7 +72,7 @@ void main() {
}, initializeFlutterRoot: false);
testUsingContext('throw tool exit if the version file cannot be written', () async {
final MockFlutterVersion version = FlutterVersion.instance;
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion;
when(version.ensureVersionFile()).thenThrow(const FileSystemException());
expect(() async => await runner.run(<String>['dummy']), throwsA(isA<ToolExit>()));
......
......@@ -58,7 +58,7 @@ void main() {
Cache: () => cache,
});
void testUsingCommandContext(String testName, Function testBody) {
void testUsingCommandContext(String testName, dynamic Function() testBody) {
testUsingContext(testName, testBody, overrides: <Type, Generator>{
ProcessInfo: () => mockProcessInfo,
SystemClock: () => clock,
......
......@@ -63,7 +63,7 @@ void main() {
// exception on the first attempt, the second attempt tries to report the
// *original* crash, and not the crash from the first crash report
// attempt.
final CrashingUsage crashingUsage = flutterUsage;
final CrashingUsage crashingUsage = flutterUsage as CrashingUsage;
expect(crashingUsage.sentException, 'runCommand');
}, overrides: <Type, Generator>{
Platform: () => FakePlatform(environment: <String, String>{
......
......@@ -3,11 +3,10 @@
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:mockito/mockito.dart';
......@@ -123,9 +122,7 @@ void main() {
await terminalHandler.processTerminalInput('l');
final BufferLogger bufferLogger = logger;
expect(bufferLogger.statusText, contains('Connected views:\n'));
expect(testLogger.statusText, contains('Connected views:\n'));
});
testUsingContext('L - debugDumpLayerTree with service protocol', () async {
......@@ -242,9 +239,7 @@ void main() {
verify(mockResidentRunner.restart(fullRestart: false)).called(1);
final BufferLogger bufferLogger = logger;
expect(bufferLogger.statusText, contains('Try again after fixing the above error(s).'));
expect(testLogger.statusText, contains('Try again after fixing the above error(s).'));
});
testUsingContext('r - hotReload supported and fails fatally', () async {
......@@ -287,9 +282,7 @@ void main() {
verify(mockResidentRunner.restart(fullRestart: true)).called(1);
final BufferLogger bufferLogger = logger;
expect(bufferLogger.statusText, contains('Try again after fixing the above error(s).'));
expect(testLogger.statusText, contains('Try again after fixing the above error(s).'));
});
testUsingContext('R - hotRestart supported and fails fatally', () async {
......
......@@ -153,13 +153,13 @@ baz=qux
'wrapped and indentation preserved.';
final FakeStdio fakeStdio = FakeStdio();
void testWrap(String description, Function body) {
void testWrap(String description, dynamic Function() body) {
testUsingContext(description, body, overrides: <Type, Generator>{
OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: _lineLength),
});
}
void testNoWrap(String description, Function body) {
void testNoWrap(String description, dynamic Function() body) {
testUsingContext(description, body, overrides: <Type, Generator>{
OutputPreferences: () => OutputPreferences(wrapText: false),
});
......
......@@ -5,15 +5,14 @@
import 'dart:convert';
import 'package:collection/collection.dart' show ListEquality;
import 'package:flutter_tools/src/base/time.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import '../src/common.dart';
import '../src/context.dart';
......@@ -414,9 +413,8 @@ void main() {
}
void _expectVersionMessage(String message) {
final BufferLogger logger = context.get<Logger>();
expect(logger.statusText.trim(), message.trim());
logger.clear();
expect(testLogger.statusText.trim(), message.trim());
testLogger.clear();
}
void fakeData(
......@@ -457,7 +455,7 @@ void fakeData(
expect(invocation.positionalArguments.first, VersionCheckStamp.flutterVersionCheckStampFile);
if (expectSetStamp) {
stamp = VersionCheckStamp.fromJson(json.decode(invocation.positionalArguments[1]));
stamp = VersionCheckStamp.fromJson(castStringKeyedMap(json.decode(invocation.positionalArguments[1] as String)));
return null;
}
......@@ -467,13 +465,13 @@ void fakeData(
final Answering<ProcessResult> syncAnswer = (Invocation invocation) {
bool argsAre(String a1, [ String a2, String a3, String a4, String a5, String a6, String a7, String a8, String a9 ]) {
const ListEquality<String> equality = ListEquality<String>();
final List<String> args = invocation.positionalArguments.single;
final List<String> args = invocation.positionalArguments.single as List<String>;
final List<String> expectedArgs = <String>[a1, a2, a3, a4, a5, a6, a7, a8, a9].where((String arg) => arg != null).toList();
return equality.equals(args, expectedArgs);
}
bool listArgsAre(List<String> a) {
return Function.apply(argsAre, a);
return Function.apply(argsAre, a) as bool;
}
if (listArgsAre(FlutterVersion.gitLog(<String>['-n', '1', '--pretty=format:%ad', '--date=iso']))) {
......
......@@ -85,7 +85,7 @@ void main() {
await chromeLauncher.launch('example_url', skipCheck: true, dataDir: dataDir);
final VerificationResult result = verify(processManager.start(captureAny));
final String arg = result.captured.single
final String arg = (result.captured.single as List<String>)
.firstWhere((String arg) => arg.startsWith('--user-data-dir='));
final Directory tempDirectory = fs.directory(arg.split('=')[1]);
final File tempFile = tempDirectory
......
......@@ -51,7 +51,7 @@ void main() {
headers = MockHttpHeaders();
closeCompleter = Completer<void>();
when(mockHttpServer.listen(any, onError: anyNamed('onError'))).thenAnswer((Invocation invocation) {
final Function callback = invocation.positionalArguments.first;
final void Function(HttpRequest) callback = invocation.positionalArguments.first as void Function(HttpRequest);
return requestController.stream.listen(callback);
});
when(request.response).thenReturn(response);
......
......@@ -48,7 +48,7 @@ void main() {
mockProcessUtils = MockProcessUtils();
when(mockBuildDaemonCreator.startBuildDaemon(any, release: anyNamed('release'), initializePlatform: anyNamed('initializePlatform')))
.thenAnswer((Invocation invocation) async {
lastInitializePlatform = invocation.namedArguments[#initializePlatform];
lastInitializePlatform = invocation.namedArguments[#initializePlatform] as bool;
return mockBuildDaemonClient;
});
when(mockOperatingSystemUtils.findFreePort()).thenAnswer((Invocation _) async {
......@@ -60,7 +60,7 @@ void main() {
mapFunction: anyNamed('mapFunction'),
environment: anyNamed('environment'),
)).thenAnswer((Invocation invocation) async {
final String workingDirectory = invocation.namedArguments[#workingDirectory];
final String workingDirectory = invocation.namedArguments[#workingDirectory] as String;
fs.file(fs.path.join(workingDirectory, '.packages')).createSync(recursive: true);
return 0;
});
......
......@@ -81,8 +81,8 @@ void main() {
final String finalResponse = responseOverride ??
json.encode(<Map<String, dynamic>>[response]);
when<String>(result.stdout).thenReturn(finalResponse);
when<String>(result.stderr).thenReturn('');
when<String>(result.stdout as String).thenReturn(finalResponse);
when<String>(result.stderr as String).thenReturn('');
final List<String> requirementArguments = requiredComponents == null
? <String>[]
: <String>['-requires', ...requiredComponents];
......@@ -180,8 +180,8 @@ void main() {
)).thenAnswer((Invocation invocation) {
return result;
});
when<String>(result.stdout).thenReturn('');
when<String>(result.stderr).thenReturn('');
when<String>(result.stdout as String).thenReturn('');
when<String>(result.stderr as String).thenReturn('');
visualStudio = VisualStudio();
expect(visualStudio.isInstalled, false);
......
......@@ -9,6 +9,7 @@ import 'package:file/file.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import 'package:vm_service/vm_service.dart';
......@@ -186,7 +187,7 @@ abstract class FlutterTestDriver {
}
Future<Isolate> _getFlutterIsolate() async {
final Isolate isolate = await _vmService.getIsolate(await _getFlutterIsolateId());
final Isolate isolate = await _vmService.getIsolate(await _getFlutterIsolateId()) as Isolate;
return isolate;
}
......@@ -236,7 +237,7 @@ abstract class FlutterTestDriver {
// But also check if the isolate was already paused (only after we've set
// up the subscription) to avoid races. If it was paused, we don't need to wait
// for the event.
final Isolate isolate = await _vmService.getIsolate(flutterIsolate);
final Isolate isolate = await _vmService.getIsolate(flutterIsolate) as Isolate;
if (isolate.pauseEvent.kind.startsWith('Pause')) {
_debugPrint('Isolate was already paused (${isolate.pauseEvent.kind}).');
} else {
......@@ -282,14 +283,14 @@ abstract class FlutterTestDriver {
Future<InstanceRef> evaluateInFrame(String expression) async {
return _timeoutWithMessages<InstanceRef>(
() async => await _vmService.evaluateInFrame(await _getFlutterIsolateId(), 0, expression),
() async => await _vmService.evaluateInFrame(await _getFlutterIsolateId(), 0, expression) as InstanceRef,
task: 'Evaluating expression ($expression)',
);
}
Future<InstanceRef> evaluate(String targetId, String expression) async {
return _timeoutWithMessages<InstanceRef>(
() async => await _vmService.evaluate(await _getFlutterIsolateId(), targetId, expression),
() async => await _vmService.evaluate(await _getFlutterIsolateId(), targetId, expression) as InstanceRef,
task: 'Evaluating expression ($expression for $targetId)',
);
}
......@@ -306,7 +307,7 @@ abstract class FlutterTestDriver {
Future<SourcePosition> getSourceLocation() async {
final String flutterIsolateId = await _getFlutterIsolateId();
final Frame frame = await getTopStackFrame();
final Script script = await _vmService.getObject(flutterIsolateId, frame.location.script.id);
final Script script = await _vmService.getObject(flutterIsolateId, frame.location.script.id) as Script;
return _lookupTokenPos(script.tokenPosTable, frame.location.tokenPos);
}
......@@ -338,7 +339,7 @@ abstract class FlutterTestDriver {
final Completer<Map<String, dynamic>> response = Completer<Map<String, dynamic>>();
StreamSubscription<String> subscription;
subscription = _stdout.stream.listen((String line) async {
final dynamic json = parseFlutterResponse(line);
final Map<String, dynamic> json = parseFlutterResponse(line);
_lastResponse = line;
if (json == null) {
return;
......@@ -504,7 +505,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
// _process.kill() (`flutter` is a shell script so _process itself is a
// shell, not the flutter tool's Dart process).
final Map<String, dynamic> connected = await _waitFor(event: 'daemon.connected');
_processPid = connected['params']['pid'];
_processPid = connected['params']['pid'] as int;
// Set this up now, but we don't wait it yet. We want to make sure we don't
// miss it while waiting for debugPort below.
......@@ -512,7 +513,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
if (withDebugger) {
final Map<String, dynamic> debugPort = await _waitFor(event: 'app.debugPort', timeout: appStartTimeout);
final String wsUriString = debugPort['params']['wsUri'];
final String wsUriString = debugPort['params']['wsUri'] as String;
_vmServiceWsUri = Uri.parse(wsUriString);
await connectToVmService(pauseOnExceptions: pauseOnExceptions);
if (!startPaused) {
......@@ -522,7 +523,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
// Now await the started event; if it had already happened the future will
// have already completed.
_currentRunningAppId = (await started)['params']['appId'];
_currentRunningAppId = (await started)['params']['appId'] as String;
prematureExitGuard.complete();
} catch(error, stackTrace) {
prematureExitGuard.completeError(error, stackTrace);
......@@ -677,11 +678,11 @@ class FlutterTestTestDriver extends FlutterTestDriver {
// _proc.kill() (because _proc is a shell, because `flutter` is a shell
// script).
final Map<String, dynamic> version = await _waitForJson();
_processPid = version['pid'];
_processPid = version['pid'] as int;
if (withDebugger) {
final Map<String, dynamic> startedProcess = await _waitFor(event: 'test.startedProcess', timeout: appStartTimeout);
final String vmServiceHttpString = startedProcess['params']['observatoryUri'];
final String vmServiceHttpString = startedProcess['params']['observatoryUri'] as String;
_vmServiceWsUri = Uri.parse(vmServiceHttpString).replace(scheme: 'ws', path: '/ws');
await connectToVmService(pauseOnExceptions: pauseOnExceptions);
// Allow us to run code before we start, eg. to set up breakpoints.
......@@ -706,7 +707,7 @@ class FlutterTestTestDriver extends FlutterTestDriver {
Map<String, dynamic> _parseJsonResponse(String line) {
try {
return json.decode(line);
return castStringKeyedMap(json.decode(line));
} catch (e) {
// Not valid JSON, so likely some other output.
return null;
......@@ -721,7 +722,7 @@ Stream<String> transformToLines(Stream<List<int>> byteStream) {
Map<String, dynamic> parseFlutterResponse(String line) {
if (line.startsWith('[') && line.endsWith(']')) {
try {
final Map<String, dynamic> response = json.decode(line)[0];
final Map<String, dynamic> response = castStringKeyedMap(json.decode(line)[0]);
return response;
} catch (e) {
// Not valid JSON, so likely some other output that was surrounded by [brackets]
......
......@@ -38,10 +38,10 @@ export 'package:flutter_tools/src/base/context.dart' show Generator;
export 'fake_process_manager.dart' show ProcessManager, FakeProcessManager, FakeCommand;
/// Return the test logger. This assumes that the current Logger is a BufferLogger.
BufferLogger get testLogger => context.get<Logger>();
BufferLogger get testLogger => context.get<Logger>() as BufferLogger;
FakeDeviceManager get testDeviceManager => context.get<DeviceManager>();
FakeDoctor get testDoctor => context.get<Doctor>();
FakeDeviceManager get testDeviceManager => context.get<DeviceManager>() as FakeDeviceManager;
FakeDoctor get testDoctor => context.get<Doctor>() as FakeDoctor;
typedef ContextInitializer = void Function(AppContext testContext);
......@@ -149,7 +149,7 @@ void testUsingContext(
void _printBufferedErrors(AppContext testContext) {
if (testContext.get<Logger>() is BufferLogger) {
final BufferLogger bufferLogger = testContext.get<Logger>();
final BufferLogger bufferLogger = testContext.get<Logger>() as BufferLogger;
if (bufferLogger.errorText.isNotEmpty) {
print(bufferLogger.errorText);
}
......
......@@ -212,7 +212,7 @@ abstract class FakeProcessManager implements ProcessManager {
bool includeParentEnvironment = true, // ignored
bool runInShell = false, // ignored
ProcessStartMode mode = ProcessStartMode.normal, // ignored
}) async => _runCommand(command, workingDirectory, environment);
}) async => _runCommand(command.cast<String>(), workingDirectory, environment);
@override
Future<ProcessResult> run(
......@@ -224,7 +224,7 @@ abstract class FakeProcessManager implements ProcessManager {
Encoding stdoutEncoding = systemEncoding,
Encoding stderrEncoding = systemEncoding,
}) async {
final _FakeProcess process = _runCommand(command, workingDirectory, environment);
final _FakeProcess process = _runCommand(command.cast<String>(), workingDirectory, environment);
await process.exitCode;
return ProcessResult(
process.pid,
......@@ -244,7 +244,7 @@ abstract class FakeProcessManager implements ProcessManager {
Encoding stdoutEncoding = systemEncoding, // actual encoder is ignored
Encoding stderrEncoding = systemEncoding, // actual encoder is ignored
}) {
final _FakeProcess process = _runCommand(command, workingDirectory, environment);
final _FakeProcess process = _runCommand(command.cast<String>(), workingDirectory, environment);
return ProcessResult(
process.pid,
process._exitCode,
......
......@@ -177,14 +177,15 @@ class MockProcessManager extends Mock implements ProcessManager {
bool runInShell = false,
ProcessStartMode mode = ProcessStartMode.normal,
}) {
final List<String> commands = command.cast<String>();
if (!runSucceeds) {
final String executable = command[0];
final List<String> arguments = command.length > 1 ? command.sublist(1) : <String>[];
final String executable = commands[0];
final List<String> arguments = commands.length > 1 ? commands.sublist(1) : <String>[];
throw ProcessException(executable, arguments);
}
commands = command;
return Future<Process>.value(processFactory(command));
this.commands = commands;
return Future<Process>.value(processFactory(commands));
}
}
......@@ -254,7 +255,7 @@ class MockProcess extends Mock implements Process {
this.stdout = const Stream<List<int>>.empty(),
this.stderr = const Stream<List<int>>.empty(),
}) : exitCode = exitCode ?? Future<int>.value(0),
stdin = stdin ?? MemoryIOSink();
stdin = stdin as IOSink ?? MemoryIOSink();
@override
final int pid;
......@@ -281,7 +282,7 @@ class FakeProcess implements Process {
this.stdout = const Stream<List<int>>.empty(),
this.stderr = const Stream<List<int>>.empty(),
}) : exitCode = exitCode ?? Future<int>.value(0),
stdin = stdin ?? MemoryIOSink();
stdin = stdin as IOSink ?? MemoryIOSink();
@override
final int pid;
......
......@@ -5,7 +5,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/context.dart';
......@@ -171,7 +170,7 @@ class NoOpUsage implements Usage {
bool get isFirstRun => false;
@override
Stream<Map<String, Object>> get onSend => const Stream<Object>.empty();
Stream<Map<String, Object>> get onSend => const Stream<Map<String, Object>>.empty();
@override
void printWelcome() {}
......@@ -373,7 +372,7 @@ class FakeHttpClientRequest implements HttpClientRequest {
}
class FakeHttpClientResponse implements HttpClientResponse {
final Stream<Uint8List> _delegate = Stream<Uint8List>.fromIterable(const Iterable<Uint8List>.empty());
final Stream<List<int>> _delegate = Stream<List<int>>.fromIterable(const Iterable<List<int>>.empty());
@override
final HttpHeaders headers = FakeHttpHeaders();
......@@ -404,8 +403,8 @@ class FakeHttpClientResponse implements HttpClientResponse {
bool get isRedirect => false;
@override
StreamSubscription<Uint8List> listen(void Function(Uint8List event) onData, { Function onError, void Function() onDone, bool cancelOnError }) {
return const Stream<Uint8List>.empty().listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
StreamSubscription<List<int>> listen(void Function(List<int> event) onData, { Function onError, void Function() onDone, bool cancelOnError }) {
return const Stream<List<int>>.empty().listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
@override
......@@ -426,25 +425,25 @@ class FakeHttpClientResponse implements HttpClientResponse {
int get statusCode => 400;
@override
Future<bool> any(bool Function(Uint8List element) test) {
Future<bool> any(bool Function(List<int> element) test) {
return _delegate.any(test);
}
@override
Stream<Uint8List> asBroadcastStream({
void Function(StreamSubscription<Uint8List> subscription) onListen,
void Function(StreamSubscription<Uint8List> subscription) onCancel,
Stream<List<int>> asBroadcastStream({
void Function(StreamSubscription<List<int>> subscription) onListen,
void Function(StreamSubscription<List<int>> subscription) onCancel,
}) {
return _delegate.asBroadcastStream(onListen: onListen, onCancel: onCancel);
}
@override
Stream<E> asyncExpand<E>(Stream<E> Function(Uint8List event) convert) {
Stream<E> asyncExpand<E>(Stream<E> Function(List<int> event) convert) {
return _delegate.asyncExpand<E>(convert);
}
@override
Stream<E> asyncMap<E>(FutureOr<E> Function(Uint8List event) convert) {
Stream<E> asyncMap<E>(FutureOr<E> Function(List<int> event) convert) {
return _delegate.asyncMap<E>(convert);
}
......@@ -459,7 +458,7 @@ class FakeHttpClientResponse implements HttpClientResponse {
}
@override
Stream<Uint8List> distinct([bool Function(Uint8List previous, Uint8List next) equals]) {
Stream<List<int>> distinct([bool Function(List<int> previous, List<int> next) equals]) {
return _delegate.distinct(equals);
}
......@@ -469,43 +468,43 @@ class FakeHttpClientResponse implements HttpClientResponse {
}
@override
Future<Uint8List> elementAt(int index) {
Future<List<int>> elementAt(int index) {
return _delegate.elementAt(index);
}
@override
Future<bool> every(bool Function(Uint8List element) test) {
Future<bool> every(bool Function(List<int> element) test) {
return _delegate.every(test);
}
@override
Stream<S> expand<S>(Iterable<S> Function(Uint8List element) convert) {
Stream<S> expand<S>(Iterable<S> Function(List<int> element) convert) {
return _delegate.expand(convert);
}
@override
Future<Uint8List> get first => _delegate.first;
Future<List<int>> get first => _delegate.first;
@override
Future<Uint8List> firstWhere(
bool Function(Uint8List element) test, {
Future<List<int>> firstWhere(
bool Function(List<int> element) test, {
List<int> Function() orElse,
}) {
return _delegate.firstWhere(test, orElse: orElse);
}
@override
Future<S> fold<S>(S initialValue, S Function(S previous, Uint8List element) combine) {
Future<S> fold<S>(S initialValue, S Function(S previous, List<int> element) combine) {
return _delegate.fold<S>(initialValue, combine);
}
@override
Future<dynamic> forEach(void Function(Uint8List element) action) {
Future<dynamic> forEach(void Function(List<int> element) action) {
return _delegate.forEach(action);
}
@override
Stream<Uint8List> handleError(
Stream<List<int>> handleError(
Function onError, {
bool Function(dynamic error) test,
}) {
......@@ -524,11 +523,11 @@ class FakeHttpClientResponse implements HttpClientResponse {
}
@override
Future<Uint8List> get last => _delegate.last;
Future<List<int>> get last => _delegate.last;
@override
Future<Uint8List> lastWhere(
bool Function(Uint8List element) test, {
Future<List<int>> lastWhere(
bool Function(List<int> element) test, {
List<int> Function() orElse,
}) {
return _delegate.lastWhere(test, orElse: orElse);
......@@ -538,7 +537,7 @@ class FakeHttpClientResponse implements HttpClientResponse {
Future<int> get length => _delegate.length;
@override
Stream<S> map<S>(S Function(Uint8List event) convert) {
Stream<S> map<S>(S Function(List<int> event) convert) {
return _delegate.map<S>(convert);
}
......@@ -548,53 +547,53 @@ class FakeHttpClientResponse implements HttpClientResponse {
}
@override
Future<Uint8List> reduce(List<int> Function(Uint8List previous, Uint8List element) combine) {
Future<List<int>> reduce(List<int> Function(List<int> previous, List<int> element) combine) {
return _delegate.reduce(combine);
}
@override
Future<Uint8List> get single => _delegate.single;
Future<List<int>> get single => _delegate.single;
@override
Future<Uint8List> singleWhere(bool Function(Uint8List element) test, {List<int> Function() orElse}) {
Future<List<int>> singleWhere(bool Function(List<int> element) test, {List<int> Function() orElse}) {
return _delegate.singleWhere(test, orElse: orElse);
}
@override
Stream<Uint8List> skip(int count) {
Stream<List<int>> skip(int count) {
return _delegate.skip(count);
}
@override
Stream<Uint8List> skipWhile(bool Function(Uint8List element) test) {
Stream<List<int>> skipWhile(bool Function(List<int> element) test) {
return _delegate.skipWhile(test);
}
@override
Stream<Uint8List> take(int count) {
Stream<List<int>> take(int count) {
return _delegate.take(count);
}
@override
Stream<Uint8List> takeWhile(bool Function(Uint8List element) test) {
Stream<List<int>> takeWhile(bool Function(List<int> element) test) {
return _delegate.takeWhile(test);
}
@override
Stream<Uint8List> timeout(
Stream<List<int>> timeout(
Duration timeLimit, {
void Function(EventSink<Uint8List> sink) onTimeout,
void Function(EventSink<List<int>> sink) onTimeout,
}) {
return _delegate.timeout(timeLimit, onTimeout: onTimeout);
}
@override
Future<List<Uint8List>> toList() {
Future<List<List<int>>> toList() {
return _delegate.toList();
}
@override
Future<Set<Uint8List>> toSet() {
Future<Set<List<int>>> toSet() {
return _delegate.toSet();
}
......@@ -604,7 +603,7 @@ class FakeHttpClientResponse implements HttpClientResponse {
}
@override
Stream<Uint8List> where(bool Function(Uint8List event) test) {
Stream<List<int>> where(bool Function(List<int> event) test) {
return _delegate.where(test);
}
}
......
......@@ -27,7 +27,7 @@ Future<void> main() async {
.transform<String>(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) => print('<== $line'));
daemon.stderr.listen((dynamic data) => stderr.add(data));
daemon.stderr.listen(stderr.add);
stdout.write('> ');
stdin.transform<String>(utf8.decoder).transform<String>(const LineSplitter()).listen((String line) {
......
......@@ -89,7 +89,7 @@ class VMPlatform extends PlatformPlugin {
_pending.remove(codePath);
}));
final ServiceProtocolInfo info = await Service.controlWebServer(enable: true);
final dynamic channel = IsolateChannel<Object>.connectReceive(receivePort)
final StreamChannel<Object> channel = IsolateChannel<Object>.connectReceive(receivePort)
.transformStream(StreamTransformer<Object, Object>.fromHandlers(
handleDone: (EventSink<Object> sink) async {
try {
......
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