[a11y] Make sure RenderFractionalTranslation updates its semantics after the translation field is set (#48985)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
fcf341e4f3
commit
b67d5ec6e9
@@ -8,12 +8,8 @@ import 'package:meta/meta.dart';
|
||||
|
||||
import '../android/android_sdk.dart';
|
||||
import '../android/android_workflow.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/process.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../convert.dart';
|
||||
import '../device.dart';
|
||||
import '../emulator.dart';
|
||||
import '../globals.dart' as globals;
|
||||
@@ -54,59 +50,18 @@ class AndroidEmulator extends Emulator {
|
||||
|
||||
@override
|
||||
Future<void> launch() async {
|
||||
final Process process = await processUtils.start(
|
||||
<String>[getEmulatorPath(androidSdk), '-avd', id],
|
||||
final Future<void> launchResult = processUtils.run(
|
||||
<String>[getEmulatorPath(), '-avd', id],
|
||||
throwOnError: true,
|
||||
);
|
||||
|
||||
// Record output from the emulator process.
|
||||
final List<String> stdoutList = <String>[];
|
||||
final List<String> stderrList = <String>[];
|
||||
final StreamSubscription<String> stdoutSubscription = process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(stdoutList.add);
|
||||
final StreamSubscription<String> stderrSubscription = process.stderr
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen(stderrList.add);
|
||||
final Future<void> stdioFuture = waitGroup<void>(<Future<void>>[
|
||||
stdoutSubscription.asFuture<void>(),
|
||||
stderrSubscription.asFuture<void>(),
|
||||
// The emulator continues running on a successful launch, so if it hasn't
|
||||
// quit within 3 seconds we assume that's a success and just return. This
|
||||
// means that on a slow machine, a failure that takes more than three
|
||||
// seconds won't be recognized as such... :-/
|
||||
return Future.any<void>(<Future<void>>[
|
||||
launchResult,
|
||||
Future<void>.delayed(const Duration(seconds: 3)),
|
||||
]);
|
||||
|
||||
// The emulator continues running on success, so we don't wait for the
|
||||
// process to complete before continuing. However, if the process fails
|
||||
// after the startup phase (3 seconds), then we only echo its output if
|
||||
// its error code is non-zero and its stderr is non-empty.
|
||||
bool earlyFailure = true;
|
||||
unawaited(process.exitCode.then((int status) async {
|
||||
if (status == 0) {
|
||||
globals.printTrace('The Android emulator exited successfully');
|
||||
return;
|
||||
}
|
||||
// Make sure the process' stdout and stderr are drained.
|
||||
await stdioFuture;
|
||||
unawaited(stdoutSubscription.cancel());
|
||||
unawaited(stderrSubscription.cancel());
|
||||
if (stdoutList.isNotEmpty) {
|
||||
globals.printTrace('Android emulator stdout:');
|
||||
stdoutList.forEach(globals.printTrace);
|
||||
}
|
||||
if (!earlyFailure && stderrList.isEmpty) {
|
||||
globals.printStatus('The Android emulator exited with code $status');
|
||||
return;
|
||||
}
|
||||
final String when = earlyFailure ? 'during startup' : 'after startup';
|
||||
globals.printError('The Android emulator exited with code $status $when');
|
||||
globals.printError('Android emulator stderr:');
|
||||
stderrList.forEach(globals.printError);
|
||||
globals.printError('Address these issues and try again.');
|
||||
}));
|
||||
|
||||
// Wait a few seconds for the emulator to start.
|
||||
await Future<void>.delayed(const Duration(seconds: 3));
|
||||
earlyFailure = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,11 @@ import '../base/os.dart';
|
||||
import '../base/terminal.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
import '../compile.dart';
|
||||
import '../convert.dart';
|
||||
import '../devfs.dart';
|
||||
import '../device.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../platform_plugins.dart';
|
||||
import '../plugins.dart';
|
||||
import '../project.dart';
|
||||
import '../reporting/reporting.dart';
|
||||
import '../resident_runner.dart';
|
||||
@@ -101,10 +98,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
|
||||
final List<String> dartDefines;
|
||||
DateTime firstBuildTime;
|
||||
|
||||
// Used with the new compiler to generate a bootstrap file containing plugins
|
||||
// and platform initialization.
|
||||
Directory _generatedEntrypointDirectory;
|
||||
|
||||
// Only the debug builds of the web support the service protocol.
|
||||
@override
|
||||
bool get supportsServiceProtocol => isRunningDebug && deviceIsDebuggable;
|
||||
@@ -158,7 +151,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
|
||||
await _stdOutSub?.cancel();
|
||||
await _webFs?.stop();
|
||||
await device.device.stopApp(null);
|
||||
_generatedEntrypointDirectory?.deleteSync(recursive: true);
|
||||
if (ChromeLauncher.hasChromeInstance) {
|
||||
final Chrome chrome = await ChromeLauncher.connectedInstance;
|
||||
await chrome.close();
|
||||
@@ -486,46 +478,6 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
|
||||
return OperationResult.ok;
|
||||
}
|
||||
|
||||
// Flutter web projects need to include a generated main entrypoint to call the
|
||||
// appropriate bootstrap method and inject plugins.
|
||||
// Keep this in sync with build_system/targets/web.dart.
|
||||
Future<String> _generateEntrypoint(String main, String packagesPath) async {
|
||||
File result = _generatedEntrypointDirectory?.childFile('web_entrypoint.dart');
|
||||
if (_generatedEntrypointDirectory == null) {
|
||||
_generatedEntrypointDirectory ??= globals.fs.systemTempDirectory.createTempSync('flutter_tools.')
|
||||
..createSync();
|
||||
result = _generatedEntrypointDirectory.childFile('web_entrypoint.dart');
|
||||
|
||||
final bool hasWebPlugins = findPlugins(flutterProject)
|
||||
.any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
|
||||
await injectPlugins(flutterProject, checkProjects: true);
|
||||
|
||||
final PackageUriMapper packageUriMapper = PackageUriMapper(main, packagesPath, null, null);
|
||||
final String generatedPath = globals.fs.currentDirectory
|
||||
.childDirectory('lib')
|
||||
.childFile('generated_plugin_registrant.dart')
|
||||
.absolute.path;
|
||||
final Uri generatedImport = packageUriMapper.map(generatedPath);
|
||||
|
||||
final String entrypoint = <String>[
|
||||
'import "${packageUriMapper.map(main)}" as entrypoint;',
|
||||
'import "dart:ui" as ui;',
|
||||
if (hasWebPlugins)
|
||||
'import "package:flutter_web_plugins/flutter_web_plugins.dart";',
|
||||
if (hasWebPlugins)
|
||||
'import "$generatedImport";',
|
||||
'Future<void> main() async {',
|
||||
if (hasWebPlugins)
|
||||
' registerPlugins(webPluginRegistry);'
|
||||
' await ui.webOnlyInitializePlatform();',
|
||||
' entrypoint.main();',
|
||||
'}',
|
||||
].join('\n');
|
||||
result.writeAsStringSync(entrypoint);
|
||||
}
|
||||
return result.path;
|
||||
}
|
||||
|
||||
Future<UpdateFSReport> _updateDevFS({bool fullRestart = false}) async {
|
||||
final bool isFirstUpload = !assetBundle.wasBuiltOnce();
|
||||
final bool rebuildBundle = assetBundle.needsBuild();
|
||||
@@ -547,7 +499,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
|
||||
timeout: timeoutConfiguration.fastOperation,
|
||||
);
|
||||
final UpdateFSReport report = await device.devFS.update(
|
||||
mainPath: await _generateEntrypoint(mainPath, packagesFilePath),
|
||||
mainPath: mainPath,
|
||||
target: target,
|
||||
bundle: assetBundle,
|
||||
firstBuildTime: firstBuildTime,
|
||||
|
||||
@@ -32,7 +32,6 @@ const String kDart2jsOptimization = 'Dart2jsOptimization';
|
||||
const String kCspMode = 'cspMode';
|
||||
|
||||
/// Generates an entry point for a web target.
|
||||
// Keep this in sync with build_runner/resident_web_runner.dart
|
||||
class WebEntrypointTarget extends Target {
|
||||
const WebEntrypointTarget();
|
||||
|
||||
|
||||
@@ -69,7 +69,16 @@ class EmulatorsCommand extends FlutterCommand {
|
||||
"More than one emulator matches '$id':",
|
||||
);
|
||||
} else {
|
||||
await emulators.first.launch();
|
||||
try {
|
||||
await emulators.first.launch();
|
||||
}
|
||||
catch (e) {
|
||||
if (e is String) {
|
||||
globals.printError(e);
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,7 @@ window.\$hotReloadHook = function(modules) {
|
||||
// once we've reloaded every module, trigger the hot reload.
|
||||
if (reloadCount == modules.length) {
|
||||
require(["$entrypoint", "dart_sdk"], function(app, dart_sdk) {
|
||||
// See L81 below for an explanation.
|
||||
window.\$mainEntrypoint = app[Object.keys(app)[0]].main;
|
||||
window.\$mainEntrypoint = app.main.main;
|
||||
window.\$hotReload(resolve);
|
||||
});
|
||||
}
|
||||
@@ -79,23 +78,22 @@ define("main_module", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) {
|
||||
let voidToNull = () => (voidToNull = dart_sdk.dart.constFn(dart_sdk.dart.fnType(dart_sdk.core.Null, [dart_sdk.dart.void])))();
|
||||
|
||||
// Attach the main entrypoint and hot reload functionality to the window.
|
||||
// The app module will have a single property which contains the actual application
|
||||
// code. The property name is based off of the entrypoint that is generated, for example
|
||||
// the file `foo/bar/baz.dart` will generate a property named approximately
|
||||
// `foo__bar__baz`. Rather than attempt to guess, we assume the first property of
|
||||
// this object is the module.
|
||||
window.\$mainEntrypoint = app[Object.keys(app)[0]].main;
|
||||
window.\$mainEntrypoint = app.main.main;
|
||||
if (window.\$hotReload == null) {
|
||||
window.\$hotReload = function(cb) {
|
||||
dart_sdk.developer.invokeExtension("ext.flutter.disassemble", "{}").then((_) => {
|
||||
dart_sdk.dart.hotRestart();
|
||||
window.\$mainEntrypoint();
|
||||
window.requestAnimationFrame(cb);
|
||||
dart_sdk.ui.webOnlyInitializePlatform().then(dart_sdk.core.Null, dart_sdk.dart.fn(_ => {
|
||||
window.\$mainEntrypoint();
|
||||
window.requestAnimationFrame(cb);
|
||||
}, voidToNull()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
window.\$mainEntrypoint();
|
||||
dart_sdk.ui.webOnlyInitializePlatform().then(dart_sdk.core.Null, dart_sdk.dart.fn(_ => {
|
||||
app.main.main();
|
||||
}, voidToNull()));
|
||||
});
|
||||
|
||||
// Require JS configuration.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
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/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@@ -52,7 +53,7 @@ void main() {
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
|
||||
expect(commandRunner.run(<String>['assemble', 'debug_macos_bundle_flutter_assets']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
testbed.test('Throws ToolExit if called with non-existent rule', () async {
|
||||
@@ -63,7 +64,7 @@ void main() {
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
|
||||
expect(commandRunner.run(<String>['assemble', '-o Output', 'undefined']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
testbed.test('Does not log stack traces during build failure', () async {
|
||||
@@ -77,7 +78,7 @@ void main() {
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
|
||||
await expectLater(commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
expect(testLogger.errorText, contains('bar'));
|
||||
expect(testLogger.errorText, isNot(contains(testStackTrace.toString())));
|
||||
});
|
||||
|
||||
@@ -240,7 +240,7 @@ void main() {
|
||||
});
|
||||
testDeviceManager.addDevice(device);
|
||||
expect(createTestCommandRunner(AttachCommand()).run(<String>['attach']),
|
||||
throwsToolExit());
|
||||
throwsA(isA<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => testFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
@@ -619,7 +619,7 @@ void main() {
|
||||
final AttachCommand command = AttachCommand();
|
||||
await expectLater(
|
||||
createTestCommandRunner(command).run(<String>['attach']),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
expect(testLogger.statusText, contains('No supported devices connected'));
|
||||
}, overrides: <Type, Generator>{
|
||||
@@ -642,7 +642,7 @@ void main() {
|
||||
testDeviceManager.addDevice(aDeviceWithId('yy2'));
|
||||
await expectLater(
|
||||
createTestCommandRunner(command).run(<String>['attach']),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
expect(testLogger.statusText, contains('More than one device'));
|
||||
expect(testLogger.statusText, contains('xx1'));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@@ -49,7 +50,7 @@ void main() {
|
||||
expect(
|
||||
createTestCommandRunner(command)
|
||||
.run(const <String>['build', 'fuchsia']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => linuxPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
@@ -66,7 +67,7 @@ void main() {
|
||||
expect(
|
||||
createTestCommandRunner(command)
|
||||
.run(const <String>['build', 'fuchsia']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => linuxPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
@@ -88,7 +89,7 @@ void main() {
|
||||
expect(
|
||||
createTestCommandRunner(command)
|
||||
.run(const <String>['build', 'fuchsia']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => windowsPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
@@ -110,7 +111,7 @@ void main() {
|
||||
expect(
|
||||
createTestCommandRunner(command)
|
||||
.run(const <String>['build', 'fuchsia']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => linuxPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:platform/platform.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.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/cache.dart';
|
||||
@@ -100,7 +101,7 @@ void main() {
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'linux']
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notLinuxPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
@@ -219,7 +220,7 @@ BINARY_NAME=fizz_bar
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
|
||||
|
||||
expect(() => runner.run(<String>['build', 'linux']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:platform/platform.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/build_info.dart';
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'macos']
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notMacosPlatform,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
@@ -205,7 +206,7 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
|
||||
|
||||
expect(() => runner.run(<String>['build', 'macos']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@@ -59,7 +60,7 @@ void main() {
|
||||
false,
|
||||
const <String>[],
|
||||
false,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}));
|
||||
|
||||
test('Refuses to build using runner when missing index.html', () => testbed.run(() async {
|
||||
@@ -81,7 +82,7 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
|
||||
|
||||
expect(() => runner.run(<String>['build', 'web', '--debug']),
|
||||
throwsA(isA<UsageException>()));
|
||||
throwsA(isInstanceOf<UsageException>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
|
||||
}));
|
||||
@@ -90,7 +91,7 @@ void main() {
|
||||
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
|
||||
|
||||
expect(() => runner.run(<String>['build', 'web']),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
|
||||
}));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:platform/platform.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/cache.dart';
|
||||
@@ -76,7 +77,7 @@ void main() {
|
||||
setUpMockProjectFilesForBuild();
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'windows']
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => windowsPlatform,
|
||||
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
|
||||
@@ -109,7 +110,7 @@ void main() {
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'windows']
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notWindowsPlatform,
|
||||
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:convert';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/android/android_studio.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@@ -101,7 +102,7 @@ void main() {
|
||||
expect(() => commandRunner.run(<String>[
|
||||
'config',
|
||||
'--build-dir=/foo',
|
||||
]), throwsToolExit());
|
||||
]), throwsA(isInstanceOf<ToolExit>()));
|
||||
verifyNoAnalytics();
|
||||
}, overrides: <Type, Generator>{
|
||||
Usage: () => mockUsage,
|
||||
|
||||
@@ -47,7 +47,7 @@ void main() {
|
||||
final Map<String, dynamic> response = await responses.stream.firstWhere(_notEvent);
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isNotEmpty);
|
||||
expect(response['result'], isA<String>());
|
||||
expect(response['result'] is String, true);
|
||||
await responses.close();
|
||||
await commands.close();
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ void main() {
|
||||
]);
|
||||
fail('Expect exception');
|
||||
} catch (e) {
|
||||
expect(e, isA<ToolExit>());
|
||||
expect(e, isInstanceOf<ToolExit>());
|
||||
}
|
||||
|
||||
final BufferLogger bufferLogger = globals.logger as BufferLogger;
|
||||
|
||||
@@ -107,7 +107,7 @@ void main() {
|
||||
'--no-pub',
|
||||
version,
|
||||
]),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => MockProcessManager(),
|
||||
@@ -119,7 +119,7 @@ void main() {
|
||||
await command.getTags();
|
||||
fail('ToolExit expected');
|
||||
} catch(e) {
|
||||
expect(e, isA<ToolExit>());
|
||||
expect(e, isInstanceOf<ToolExit>());
|
||||
}
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => MockProcessManager(failGitTag: true),
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
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/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/dart.dart';
|
||||
@@ -108,7 +109,7 @@ void main() {
|
||||
'bundle',
|
||||
'--no-pub',
|
||||
'--target-platform=windows-x64',
|
||||
]), throwsToolExit());
|
||||
]), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
'bundle',
|
||||
'--no-pub',
|
||||
'--target-platform=linux-x64',
|
||||
]), throwsToolExit());
|
||||
]), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
@@ -144,7 +145,7 @@ void main() {
|
||||
'bundle',
|
||||
'--no-pub',
|
||||
'--target-platform=darwin-x64',
|
||||
]), throwsToolExit());
|
||||
]), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
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';
|
||||
|
||||
@@ -62,7 +63,7 @@ void main() {
|
||||
const GitTagVersion.unknown(),
|
||||
flutterVersion,
|
||||
);
|
||||
expect(result, throwsToolExit());
|
||||
expect(result, throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
});
|
||||
@@ -88,7 +89,7 @@ void main() {
|
||||
gitTagVersion,
|
||||
flutterVersion,
|
||||
);
|
||||
expect(result, throwsToolExit());
|
||||
expect(result, throwsA(isA<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/android/android_sdk.dart';
|
||||
import 'package:flutter_tools/src/application_package.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
@@ -43,6 +44,45 @@ class MockAndroidApk extends Mock implements AndroidApk {
|
||||
File get file => MockFile();
|
||||
}
|
||||
|
||||
class MockProcessUtils extends Mock implements ProcessUtils {
|
||||
@override
|
||||
Future<RunResult> run(
|
||||
List<String> cmd, {
|
||||
bool throwOnError = false,
|
||||
RunResultChecker whiteListFailures,
|
||||
String workingDirectory,
|
||||
bool allowReentrantFlutter = false,
|
||||
Map<String, String> environment,
|
||||
Duration timeout,
|
||||
int timeoutRetries = 0,
|
||||
}) async {
|
||||
if (cmd.contains('version')) {
|
||||
return RunResult(ProcessResult(0, 0, 'Android Debug Bridge version 1.0.41', ''), cmd);
|
||||
}
|
||||
if (cmd.contains('android.intent.action.RUN')) {
|
||||
_runCmd = cmd;
|
||||
}
|
||||
return RunResult(ProcessResult(0, 0, '', ''), cmd);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> stream(
|
||||
List<String> cmd, {
|
||||
String workingDirectory,
|
||||
bool allowReentrantFlutter = false,
|
||||
String prefix = '',
|
||||
bool trace = false,
|
||||
RegExp filter,
|
||||
StringConverter mapFunction,
|
||||
Map<String, String> environment,
|
||||
}) async {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<String> _runCmd;
|
||||
List<String> get runCmd => _runCmd;
|
||||
}
|
||||
|
||||
class MockAndroidSdkVersion extends Mock implements AndroidSdkVersion {}
|
||||
|
||||
void main() {
|
||||
@@ -57,11 +97,13 @@ void main() {
|
||||
MockAndroidApk mockApk;
|
||||
MockProcessManager mockProcessManager;
|
||||
MockAndroidSdk mockAndroidSdk;
|
||||
MockProcessUtils mockProcessUtils;
|
||||
|
||||
setUp(() {
|
||||
mockApk = MockAndroidApk();
|
||||
mockProcessManager = MockProcessManager();
|
||||
mockAndroidSdk = MockAndroidSdk();
|
||||
mockProcessUtils = MockProcessUtils();
|
||||
});
|
||||
|
||||
testUsingContext('succeeds with --cache-sksl', () async {
|
||||
@@ -82,20 +124,6 @@ void main() {
|
||||
)).thenAnswer((_) async {
|
||||
return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', '');
|
||||
});
|
||||
when(mockProcessManager.run(
|
||||
any,
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment')
|
||||
)).thenAnswer((_) async {
|
||||
return ProcessResult(0, 0, '', '');
|
||||
});
|
||||
when(mockProcessManager.start(
|
||||
any,
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment')
|
||||
)).thenAnswer((_) async {
|
||||
return FakeProcess();
|
||||
});
|
||||
|
||||
final LaunchResult launchResult = await device.startApp(
|
||||
mockApk,
|
||||
@@ -106,14 +134,18 @@ void main() {
|
||||
),
|
||||
platformArgs: <String, dynamic>{},
|
||||
);
|
||||
|
||||
expect(launchResult.started, isTrue);
|
||||
expect(verify(mockProcessManager.run(captureAny)).captured.last.join(','),
|
||||
contains(<String>['--ez', 'cache-sksl', 'true'].join(',')));
|
||||
|
||||
final int cmdIndex = mockProcessUtils.runCmd.indexOf('cache-sksl');
|
||||
expect(
|
||||
mockProcessUtils.runCmd.sublist(cmdIndex - 1, cmdIndex + 2),
|
||||
equals(<String>['--ez', 'cache-sksl', 'true']),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
ProcessUtils: () => mockProcessUtils,
|
||||
});
|
||||
|
||||
testUsingContext('can run a release build on x64', () async {
|
||||
@@ -134,20 +166,6 @@ void main() {
|
||||
)).thenAnswer((_) async {
|
||||
return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]\n[ro.product.cpu.abi]: [x86_64]', '');
|
||||
});
|
||||
when(mockProcessManager.run(
|
||||
any,
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment')
|
||||
)).thenAnswer((_) async {
|
||||
return ProcessResult(0, 0, '', '');
|
||||
});
|
||||
when(mockProcessManager.start(
|
||||
any,
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment')
|
||||
)).thenAnswer((_) async {
|
||||
return FakeProcess();
|
||||
});
|
||||
|
||||
final LaunchResult launchResult = await device.startApp(
|
||||
mockApk,
|
||||
@@ -162,6 +180,7 @@ void main() {
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
FileSystem: () => MemoryFileSystem(),
|
||||
ProcessManager: () => mockProcessManager,
|
||||
ProcessUtils: () => mockProcessUtils,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -633,7 +652,7 @@ flutter:
|
||||
when(mockProcessManager.run(argThat(contains('forward'))))
|
||||
.thenAnswer((_) async => ProcessResult(0, 0, '123456', ''));
|
||||
|
||||
expect(forwarder.forward(123, hostPort: 456), throwsA(isA<ProcessException>()));
|
||||
expect(forwarder.forward(123, hostPort: 456), throwsA(isInstanceOf<ProcessException>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
});
|
||||
|
||||
@@ -2,22 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/android/android_sdk.dart'
|
||||
show getEmulatorPath, AndroidSdk, androidSdk;
|
||||
import 'package:flutter_tools/src/android/android_emulator.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:quiver/testing/async.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/fake_process_manager.dart';
|
||||
import '../../src/mocks.dart' show MockAndroidSdk;
|
||||
|
||||
void main() {
|
||||
group('android_emulator', () {
|
||||
@@ -29,10 +18,8 @@ void main() {
|
||||
});
|
||||
testUsingContext('flags emulators with config', () {
|
||||
const String emulatorID = '1234';
|
||||
final AndroidEmulator emulator = AndroidEmulator(
|
||||
emulatorID,
|
||||
<String, String>{'name': 'test'},
|
||||
);
|
||||
final AndroidEmulator emulator =
|
||||
AndroidEmulator(emulatorID, <String, String>{'name': 'test'});
|
||||
expect(emulator.id, emulatorID);
|
||||
expect(emulator.hasConfig, true);
|
||||
});
|
||||
@@ -44,7 +31,8 @@ void main() {
|
||||
'hw.device.manufacturer': manufacturer,
|
||||
'avd.ini.displayname': displayName,
|
||||
};
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties);
|
||||
final AndroidEmulator emulator =
|
||||
AndroidEmulator(emulatorID, properties);
|
||||
expect(emulator.id, emulatorID);
|
||||
expect(emulator.name, displayName);
|
||||
expect(emulator.manufacturer, manufacturer);
|
||||
@@ -57,7 +45,8 @@ void main() {
|
||||
final Map<String, String> properties = <String, String>{
|
||||
'avd.ini.displayname': displayName,
|
||||
};
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties);
|
||||
final AndroidEmulator emulator =
|
||||
AndroidEmulator(emulatorID, properties);
|
||||
expect(emulator.name, displayName);
|
||||
});
|
||||
testUsingContext('uses cleaned up ID if no displayname is set', () {
|
||||
@@ -67,7 +56,8 @@ void main() {
|
||||
final Map<String, String> properties = <String, String>{
|
||||
'avd.ini.notadisplayname': 'this is not a display name',
|
||||
};
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties);
|
||||
final AndroidEmulator emulator =
|
||||
AndroidEmulator(emulatorID, properties);
|
||||
expect(emulator.name, 'This is my ID');
|
||||
});
|
||||
testUsingContext('parses ini files', () {
|
||||
@@ -84,98 +74,4 @@ void main() {
|
||||
expect(results['avd.ini.displayname'], 'dispName');
|
||||
});
|
||||
});
|
||||
|
||||
group('Android emulator launch ', () {
|
||||
const String emulatorID = 'i1234';
|
||||
const String errorText = '[Android emulator test error]';
|
||||
MockAndroidSdk mockSdk;
|
||||
FakeProcessManager successProcessManager;
|
||||
FakeProcessManager errorProcessManager;
|
||||
FakeProcessManager lateFailureProcessManager;
|
||||
MemoryFileSystem fs;
|
||||
|
||||
setUp(() {
|
||||
fs = MemoryFileSystem();
|
||||
mockSdk = MockAndroidSdk();
|
||||
when(mockSdk.emulatorPath).thenReturn('emulator');
|
||||
|
||||
const List<String> command = <String>[
|
||||
'emulator', '-avd', emulatorID,
|
||||
];
|
||||
|
||||
successProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(command: command),
|
||||
]);
|
||||
|
||||
errorProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: command,
|
||||
exitCode: 1,
|
||||
stderr: errorText,
|
||||
stdout: 'dummy text',
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
]);
|
||||
|
||||
lateFailureProcessManager = FakeProcessManager.list(<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: command,
|
||||
exitCode: 1,
|
||||
stderr: '',
|
||||
stdout: 'dummy text',
|
||||
duration: Duration(seconds: 4),
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
testUsingContext('succeeds', () async {
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID);
|
||||
expect(getEmulatorPath(androidSdk), mockSdk.emulatorPath);
|
||||
final Completer<void> completer = Completer<void>();
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
unawaited(emulator.launch().whenComplete(completer.complete));
|
||||
time.elapse(const Duration(seconds: 5));
|
||||
time.flushMicrotasks();
|
||||
});
|
||||
await completer.future;
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => successProcessManager,
|
||||
AndroidSdk: () => mockSdk,
|
||||
FileSystem: () => fs,
|
||||
});
|
||||
|
||||
testUsingContext('prints error on failure', () async {
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID);
|
||||
final Completer<void> completer = Completer<void>();
|
||||
FakeAsync().run((FakeAsync time) {
|
||||
unawaited(emulator.launch().whenComplete(completer.complete));
|
||||
time.elapse(const Duration(seconds: 5));
|
||||
time.flushMicrotasks();
|
||||
});
|
||||
await completer.future;
|
||||
|
||||
expect(testLogger.errorText, contains(errorText));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => errorProcessManager,
|
||||
AndroidSdk: () => mockSdk,
|
||||
FileSystem: () => fs,
|
||||
});
|
||||
|
||||
testUsingContext('prints nothing on late failure with empty stderr', () async {
|
||||
final AndroidEmulator emulator = AndroidEmulator(emulatorID);
|
||||
final Completer<void> completer = Completer<void>();
|
||||
FakeAsync().run((FakeAsync time) async {
|
||||
unawaited(emulator.launch().whenComplete(completer.complete));
|
||||
time.elapse(const Duration(seconds: 5));
|
||||
time.flushMicrotasks();
|
||||
});
|
||||
await completer.future;
|
||||
expect(testLogger.errorText, isEmpty);
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => lateFailureProcessManager,
|
||||
AndroidSdk: () => mockSdk,
|
||||
FileSystem: () => fs,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1356,7 +1356,7 @@ plugin1=${plugin1.path}
|
||||
localGradleErrors: const <GradleHandledError>[],
|
||||
);
|
||||
},
|
||||
throwsA(isA<ProcessException>()));
|
||||
throwsA(isInstanceOf<ProcessException>()));
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
AndroidSdk: () => mockAndroidSdk,
|
||||
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWithoutContext('Throws if accessing the Zone', () {
|
||||
expect(() => context.get<Object>(), throwsA(isA<UnsupportedError>()));
|
||||
expect(() => context.get<Object>(), throwsA(isInstanceOf<UnsupportedError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('exit throws a StateError if called without being overriden', () {
|
||||
expect(() => exit(0), throwsAssertionError);
|
||||
expect(() => exit(0), throwsA(isInstanceOf<AssertionError>()));
|
||||
});
|
||||
|
||||
test('exit does not throw a StateError if overriden', () {
|
||||
|
||||
@@ -144,8 +144,8 @@ void main() {
|
||||
expect(lines.length, equals(1));
|
||||
|
||||
// Verify that stopping or canceling multiple times throws.
|
||||
expect(ansiSpinner.stop, throwsAssertionError);
|
||||
expect(ansiSpinner.cancel, throwsAssertionError);
|
||||
expect(ansiSpinner.stop, throwsA(isInstanceOf<AssertionError>()));
|
||||
expect(ansiSpinner.cancel, throwsA(isInstanceOf<AssertionError>()));
|
||||
done = true;
|
||||
});
|
||||
expect(done, isTrue);
|
||||
@@ -323,8 +323,8 @@ void main() {
|
||||
expect(lines[1], equals(''));
|
||||
|
||||
// Verify that stopping or canceling multiple times throws.
|
||||
expect(() { ansiStatus.cancel(); }, throwsAssertionError);
|
||||
expect(() { ansiStatus.stop(); }, throwsAssertionError);
|
||||
expect(() { ansiStatus.cancel(); }, throwsA(isInstanceOf<AssertionError>()));
|
||||
expect(() { ansiStatus.stop(); }, throwsA(isInstanceOf<AssertionError>()));
|
||||
done = true;
|
||||
});
|
||||
expect(done, isTrue);
|
||||
@@ -367,8 +367,8 @@ void main() {
|
||||
expect(lines[1], equals(''));
|
||||
|
||||
// Verify that stopping or canceling multiple times throws.
|
||||
expect(ansiStatus.stop, throwsAssertionError);
|
||||
expect(ansiStatus.cancel, throwsAssertionError);
|
||||
expect(ansiStatus.stop, throwsA(isInstanceOf<AssertionError>()));
|
||||
expect(ansiStatus.cancel, throwsA(isInstanceOf<AssertionError>()));
|
||||
done = true;
|
||||
});
|
||||
expect(done, isTrue);
|
||||
@@ -736,8 +736,8 @@ void main() {
|
||||
expect(lines[1], equals(''));
|
||||
|
||||
// Verify that stopping or canceling multiple times throws.
|
||||
expect(summaryStatus.cancel, throwsAssertionError);
|
||||
expect(summaryStatus.stop, throwsAssertionError);
|
||||
expect(summaryStatus.cancel, throwsA(isInstanceOf<AssertionError>()));
|
||||
expect(summaryStatus.stop, throwsA(isInstanceOf<AssertionError>()));
|
||||
});
|
||||
|
||||
testWithoutContext('SummaryStatus works when stopped', () async {
|
||||
@@ -759,8 +759,8 @@ void main() {
|
||||
expect(lines[1], equals(''));
|
||||
|
||||
// Verify that stopping or canceling multiple times throws.
|
||||
expect(summaryStatus.stop, throwsAssertionError);
|
||||
expect(summaryStatus.cancel, throwsAssertionError);
|
||||
expect(summaryStatus.stop, throwsA(isInstanceOf<AssertionError>()));
|
||||
expect(summaryStatus.cancel, throwsA(isInstanceOf<AssertionError>()));
|
||||
});
|
||||
|
||||
testWithoutContext('sequential startProgress calls with StdoutLogger', () async {
|
||||
|
||||
@@ -38,7 +38,7 @@ void main() {
|
||||
when(mockProcessManager.run(<String>['false'])).thenAnswer(
|
||||
(Invocation invocation) => Future<ProcessResult>.value(ProcessResult(0, 1, '', '')));
|
||||
expect(() async => await processUtils.run(<String>['false'], throwOnError: true),
|
||||
throwsA(isA<ProcessException>()));
|
||||
throwsA(isInstanceOf<ProcessException>()));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -236,7 +236,7 @@ void main() {
|
||||
<String>['dummy'],
|
||||
timeout: delay - const Duration(milliseconds: 500),
|
||||
timeoutRetries: 0,
|
||||
), throwsA(isA<ProcessException>()));
|
||||
), throwsA(isInstanceOf<ProcessException>()));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ void main() {
|
||||
<String>['a', 'b', 'c'],
|
||||
prompt: 'Please choose something',
|
||||
logger: null,
|
||||
), throwsStateError);
|
||||
), throwsA(isInstanceOf<StateError>()));
|
||||
});
|
||||
|
||||
testWithoutContext('character prompt', () async {
|
||||
|
||||
@@ -75,7 +75,7 @@ void main() {
|
||||
expect(BuildMode.fromName('profile'), BuildMode.profile);
|
||||
expect(BuildMode.fromName('jit_release'), BuildMode.jitRelease);
|
||||
expect(BuildMode.fromName('release'), BuildMode.release);
|
||||
expect(() => BuildMode.fromName('foo'), throwsArgumentError);
|
||||
expect(() => BuildMode.fromName('foo'), throwsA(isInstanceOf<ArgumentError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ void main() {
|
||||
barTarget.dependencies.add(fooTarget);
|
||||
fooTarget.dependencies.add(barTarget);
|
||||
|
||||
expect(() => checkCycles(barTarget), throwsA(isA<CycleException>()));
|
||||
expect(() => checkCycles(barTarget), throwsA(isInstanceOf<CycleException>()));
|
||||
});
|
||||
|
||||
test('Target with depfile dependency will not run twice without invalidation', () => testbed.run(() async {
|
||||
|
||||
@@ -141,14 +141,14 @@ void main() {
|
||||
|
||||
globals.fs.file('abcd.bar').createSync();
|
||||
|
||||
expect(() => fizzSource.accept(visitor), throwsA(isA<InvalidPatternException>()));
|
||||
expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>()));
|
||||
}));
|
||||
|
||||
|
||||
test('can\'t substitute foo', () => testbed.run(() {
|
||||
const Source invalidBase = Source.pattern('foo');
|
||||
|
||||
expect(() => invalidBase.accept(visitor), throwsA(isA<InvalidPatternException>()));
|
||||
expect(() => invalidBase.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>()));
|
||||
}));
|
||||
|
||||
test('can substitute optional files', () => testbed.run(() {
|
||||
|
||||
@@ -113,7 +113,7 @@ flutter_tools:lib/''');
|
||||
final BuildResult result = await buildSystem.build(const KernelSnapshot(),
|
||||
androidEnvironment..defines.remove(kBuildMode));
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<MissingDefineException>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('kernel_snapshot handles null result from kernel compilation', () => testbed.run(() async {
|
||||
@@ -141,7 +141,7 @@ flutter_tools:lib/''');
|
||||
});
|
||||
final BuildResult result = await buildSystem.build(const KernelSnapshot(), androidEnvironment);
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<Exception>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<Exception>());
|
||||
}));
|
||||
|
||||
test('kernel_snapshot does not use track widget creation on profile builds', () => testbed.run(() async {
|
||||
@@ -283,35 +283,35 @@ flutter_tools:lib/''');
|
||||
final BuildResult result = await buildSystem.build(const AotElfProfile(),
|
||||
androidEnvironment..defines.remove(kBuildMode));
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<MissingDefineException>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('aot_elf_profile throws error if missing target platform', () => testbed.run(() async {
|
||||
final BuildResult result = await buildSystem.build(const AotElfProfile(),
|
||||
androidEnvironment..defines.remove(kTargetPlatform));
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<MissingDefineException>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('aot_assembly_profile throws error if missing build mode', () => testbed.run(() async {
|
||||
final BuildResult result = await buildSystem.build(const AotAssemblyProfile(),
|
||||
iosEnvironment..defines.remove(kBuildMode));
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<MissingDefineException>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('aot_assembly_profile throws error if missing target platform', () => testbed.run(() async {
|
||||
final BuildResult result = await buildSystem.build(const AotAssemblyProfile(),
|
||||
iosEnvironment..defines.remove(kTargetPlatform));
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<MissingDefineException>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<MissingDefineException>());
|
||||
}));
|
||||
|
||||
test('aot_assembly_profile throws error if built for non-iOS platform', () => testbed.run(() async {
|
||||
final BuildResult result = await buildSystem
|
||||
.build(const AotAssemblyProfile(), androidEnvironment);
|
||||
|
||||
expect(result.exceptions.values.single.exception, isA<Exception>());
|
||||
expect(result.exceptions.values.single.exception, isInstanceOf<Exception>());
|
||||
}));
|
||||
|
||||
test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async {
|
||||
|
||||
@@ -126,7 +126,7 @@ void main() {
|
||||
..writeAsStringSync('testing');
|
||||
|
||||
expect(() async => await const DebugMacOSBundleFlutterAssets().build(environment),
|
||||
throwsException);
|
||||
throwsA(isInstanceOf<Exception>()));
|
||||
}));
|
||||
|
||||
test('debug macOS application creates correctly structured framework', () => testbed.run(() async {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/bundle.dart';
|
||||
@@ -61,7 +62,7 @@ void main() {
|
||||
targetPlatform: TargetPlatform.linux_x64,
|
||||
depfilePath: 'example.d',
|
||||
precompiled: false,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:platform/platform.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import 'package:flutter_tools/src/android/gradle_utils.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@@ -71,7 +72,7 @@ void main() {
|
||||
testUsingContext('throws tool exit when lockfile open fails', () async {
|
||||
when(mockFileSystem.file(argThat(endsWith('lockfile')))).thenReturn(mockFile);
|
||||
when(mockFile.openSync(mode: anyNamed('mode'))).thenThrow(const FileSystemException());
|
||||
expect(() async => await Cache.lock(), throwsToolExit());
|
||||
expect(() async => await Cache.lock(), throwsA(isA<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => mockFileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
@@ -230,7 +231,7 @@ void main() {
|
||||
'FLUTTER_STORAGE_BASE_URL': ' http://foo',
|
||||
});
|
||||
final Cache cache = Cache();
|
||||
expect(() => cache.storageBaseUrl, throwsToolExit());
|
||||
expect(() => cache.storageBaseUrl, throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => MockPlatform(),
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
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/terminal.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
@@ -81,7 +82,7 @@ void main() {
|
||||
'/path/to/main.dart',
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
)), throwsToolExit());
|
||||
)), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
OutputPreferences: () => OutputPreferences(showColor: false),
|
||||
@@ -99,7 +100,7 @@ void main() {
|
||||
'/path/to/main.dart',
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
)), throwsToolExit());
|
||||
)), throwsA(isInstanceOf<ToolExit>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
OutputPreferences: () => OutputPreferences(showColor: false),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/compile.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
@@ -24,7 +25,7 @@ void main() {
|
||||
final Future<CompilerOutput> output = stdoutHandler.compilerOutput.future;
|
||||
stdoutHandler.handler('message with no result');
|
||||
|
||||
expect(output, throwsToolExit());
|
||||
expect(output, throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
test('TargetModel values', () {
|
||||
@@ -40,6 +41,6 @@ void main() {
|
||||
expect(TargetModel('dartdevc'), TargetModel.dartdevc);
|
||||
expect(TargetModel.dartdevc.toString(), 'dartdevc');
|
||||
|
||||
expect(() => TargetModel('foobar'), throwsAssertionError);
|
||||
expect(() => TargetModel('foobar'), throwsA(isInstanceOf<AssertionError>()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ void main() {
|
||||
await pub.get(context: PubContext.flutterTests, checkLastModified: true);
|
||||
expect(true, isFalse, reason: 'pub.get did not throw');
|
||||
} catch (error) {
|
||||
expect(error, isA<Exception>());
|
||||
expect(error, isInstanceOf<Exception>());
|
||||
expect(error.message, '/: unexpected concurrent modification of pubspec.yaml while running pub.');
|
||||
}
|
||||
expect(testLogger.statusText, 'Running "flutter pub get" in /...\n');
|
||||
|
||||
@@ -20,9 +20,9 @@ void main() {
|
||||
|
||||
test('doctor validators includes desktop when features are enabled', () => testbed.run(() {
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
contains(isA<LinuxDoctorValidator>()));
|
||||
contains(isInstanceOf<LinuxDoctorValidator>()));
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
contains(isA<VisualStudioValidator>()));
|
||||
contains(isInstanceOf<VisualStudioValidator>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(
|
||||
isLinuxEnabled: true,
|
||||
@@ -32,9 +32,9 @@ void main() {
|
||||
|
||||
test('doctor validators does not include desktop when features are enabled', () => testbed.run(() {
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
isNot(contains(isA<LinuxDoctorValidator>())));
|
||||
isNot(contains(isInstanceOf<LinuxDoctorValidator>())));
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
isNot(contains(isA<VisualStudioValidator>())));
|
||||
isNot(contains(isInstanceOf<VisualStudioValidator>())));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(
|
||||
isLinuxEnabled: false,
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
|
||||
test('doctor validators includes web when feature is enabled', () => testbed.run(() {
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
contains(isA<WebValidator>()));
|
||||
contains(isInstanceOf<WebValidator>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(
|
||||
isWebEnabled: true,
|
||||
@@ -53,7 +53,7 @@ void main() {
|
||||
|
||||
test('doctor validators does not include web when feature is disabled', () => testbed.run(() {
|
||||
expect(DoctorValidatorsProvider.defaultInstance.validators,
|
||||
isNot(contains(isA<WebValidator>())));
|
||||
isNot(contains(isInstanceOf<WebValidator>())));
|
||||
}, overrides: <Type, Generator>{
|
||||
FeatureFlags: () => TestFeatureFlags(
|
||||
isWebEnabled: false,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/test/flutter_platform.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
@@ -20,13 +21,13 @@ void main() {
|
||||
testUsingContext('ensureConfiguration throws an error if an explicitObservatoryPort is specified and more than one test file', () async {
|
||||
final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', explicitObservatoryPort: 1234);
|
||||
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
|
||||
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit());
|
||||
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
|
||||
});
|
||||
|
||||
testUsingContext('ensureConfiguration throws an error if a precompiled entrypoint is specified and more that one test file', () {
|
||||
final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', precompiledDillPath: 'example.dill');
|
||||
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
|
||||
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit());
|
||||
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
|
||||
});
|
||||
|
||||
group('The FLUTTER_TEST environment variable is passed to the test process', () {
|
||||
@@ -49,7 +50,7 @@ void main() {
|
||||
await untilCalled(mockProcessManager.start(any, environment: anyNamed('environment')));
|
||||
final VerificationResult toVerify = verify(mockProcessManager.start(any, environment: captureAnyNamed('environment')));
|
||||
expect(toVerify.captured, hasLength(1));
|
||||
expect(toVerify.captured.first, isA<Map<String, String>>());
|
||||
expect(toVerify.captured.first, isInstanceOf<Map<String, String>>());
|
||||
return toVerify.captured.first as Map<String, String>;
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ void main() {
|
||||
shellPath: 'abc',
|
||||
enableObservatory: false,
|
||||
startPaused: true,
|
||||
), throwsAssertionError);
|
||||
), throwsA(isA<AssertionError>()));
|
||||
|
||||
expect(() => installHook(
|
||||
buildMode: BuildMode.debug,
|
||||
@@ -98,7 +99,7 @@ void main() {
|
||||
enableObservatory: false,
|
||||
startPaused: false,
|
||||
observatoryPort: 123,
|
||||
), throwsAssertionError);
|
||||
), throwsA(isA<AssertionError>()));
|
||||
|
||||
FlutterPlatform capturedPlatform;
|
||||
final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'};
|
||||
|
||||
@@ -12,6 +12,7 @@ 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';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
@@ -29,8 +30,8 @@ import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:process/process.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
@@ -39,10 +40,11 @@ void main() {
|
||||
group('fuchsia device', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
MockFile sshConfig;
|
||||
|
||||
MockProcessUtils mockProcessUtils;
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem();
|
||||
sshConfig = MockFile();
|
||||
mockProcessUtils = MockProcessUtils();
|
||||
when(sshConfig.absolute).thenReturn(sshConfig);
|
||||
});
|
||||
|
||||
@@ -116,27 +118,27 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('targetPlatform arm64 works', () async {
|
||||
when(globals.processManager.run(any)).thenAnswer((Invocation _) async {
|
||||
return ProcessResult(1, 0, 'aarch64', '');
|
||||
when(mockProcessUtils.run(any)).thenAnswer((Invocation _) {
|
||||
return Future<RunResult>.value(RunResult(ProcessResult(1, 0, 'aarch64', ''), <String>['']));
|
||||
});
|
||||
final FuchsiaDevice device = FuchsiaDevice('123');
|
||||
expect(await device.targetPlatform, TargetPlatform.fuchsia_arm64);
|
||||
}, overrides: <Type, Generator>{
|
||||
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
|
||||
FuchsiaSdk: () => MockFuchsiaSdk(),
|
||||
ProcessManager: () => MockProcessManager(),
|
||||
ProcessUtils: () => mockProcessUtils,
|
||||
});
|
||||
|
||||
testUsingContext('targetPlatform x64 works', () async {
|
||||
when(globals.processManager.run(any)).thenAnswer((Invocation _) async {
|
||||
return ProcessResult(1, 0, 'x86_64', '');
|
||||
when(mockProcessUtils.run(any)).thenAnswer((Invocation _) {
|
||||
return Future<RunResult>.value(RunResult(ProcessResult(1, 0, 'x86_64', ''), <String>['']));
|
||||
});
|
||||
final FuchsiaDevice device = FuchsiaDevice('123');
|
||||
expect(await device.targetPlatform, TargetPlatform.fuchsia_x64);
|
||||
}, overrides: <Type, Generator>{
|
||||
FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig),
|
||||
FuchsiaSdk: () => MockFuchsiaSdk(),
|
||||
ProcessManager: () => MockProcessManager(),
|
||||
ProcessUtils: () => mockProcessUtils,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -324,8 +326,8 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('screenshot', () {
|
||||
MockProcessManager mockProcessManager;
|
||||
group('screenshot', () {
|
||||
MockProcessManager mockProcessManager;
|
||||
|
||||
setUp(() {
|
||||
mockProcessManager = MockProcessManager();
|
||||
@@ -548,7 +550,6 @@ void main() {
|
||||
}, testOn: 'posix');
|
||||
});
|
||||
|
||||
|
||||
group(FuchsiaIsolateDiscoveryProtocol, () {
|
||||
MockPortForwarder portForwarder;
|
||||
MockVMService vmService;
|
||||
@@ -959,6 +960,8 @@ class MockProcessManager extends Mock implements ProcessManager {}
|
||||
|
||||
class MockProcessResult extends Mock implements ProcessResult {}
|
||||
|
||||
class MockProcessUtils extends Mock implements ProcessUtils {}
|
||||
|
||||
class MockFile extends Mock implements File {}
|
||||
|
||||
class MockProcess extends Mock implements Process {}
|
||||
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
testUsingContext('throws UnsupportedError exception if instantiated on ${platform.operatingSystem}', () {
|
||||
expect(
|
||||
() { IOSDevice('device-123'); },
|
||||
throwsAssertionError,
|
||||
throwsA(isInstanceOf<AssertionError>()),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => platform,
|
||||
@@ -788,7 +788,7 @@ void main() {
|
||||
.thenAnswer((Invocation invocation) => Future<String>.value(''));
|
||||
expect(
|
||||
() async { await IOSDevice.getAttachedDevices(); },
|
||||
throwsA(isA<UnsupportedError>()),
|
||||
throwsA(isInstanceOf<UnsupportedError>()),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
IMobileDevice: () => mockIMobileDevice,
|
||||
|
||||
@@ -108,7 +108,7 @@ void main() {
|
||||
<String>[ideviceInfoPath, '-u', 'foo', '-k', 'bar'],
|
||||
environment: <String, String>{'DYLD_LIBRARY_PATH': libimobiledevicePath},
|
||||
)).thenAnswer((_) => Future<ProcessResult>.value(ProcessResult(1, 255, 'No device found with udid foo, is it plugged in?', '')));
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<IOSDeviceNotFoundError>()));
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf<IOSDeviceNotFoundError>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Cache: () => mockCache,
|
||||
@@ -129,7 +129,7 @@ void main() {
|
||||
);
|
||||
return Future<ProcessResult>.value(result);
|
||||
});
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<IOSDeviceNotTrustedError>()));
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf<IOSDeviceNotTrustedError>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Cache: () => mockCache,
|
||||
@@ -171,7 +171,7 @@ void main() {
|
||||
);
|
||||
return Future<ProcessResult>.value(result);
|
||||
});
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<IOSDeviceNotTrustedError>()));
|
||||
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf<IOSDeviceNotTrustedError>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => mockProcessManager,
|
||||
Cache: () => mockCache,
|
||||
|
||||
@@ -345,7 +345,7 @@ void main() {
|
||||
);
|
||||
fail('ToolExit expected');
|
||||
} catch(e) {
|
||||
expect(e, isA<ToolExit>());
|
||||
expect(e, isInstanceOf<ToolExit>());
|
||||
verifyNever(mockProcessManager.run(
|
||||
argThat(containsAllInOrder(<String>['pod', 'install'])),
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
@@ -394,7 +394,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
|
||||
);
|
||||
fail('ToolExit expected');
|
||||
} catch (e) {
|
||||
expect(e, isA<ToolExit>());
|
||||
expect(e, isInstanceOf<ToolExit>());
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
contains("CocoaPods's specs repository is too out-of-date to satisfy dependencies"),
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
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/cache.dart';
|
||||
@@ -28,7 +29,7 @@ void main() {
|
||||
testInMemory('fails on null directory', () async {
|
||||
expect(
|
||||
() => FlutterProject.fromDirectory(null),
|
||||
throwsAssertionError,
|
||||
throwsA(isInstanceOf<AssertionError>()),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -40,7 +41,7 @@ void main() {
|
||||
|
||||
expect(
|
||||
() => FlutterProject.fromDirectory(directory),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -52,7 +53,7 @@ void main() {
|
||||
|
||||
expect(
|
||||
() => FlutterProject.fromDirectory(directory),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -64,7 +65,7 @@ void main() {
|
||||
|
||||
expect(
|
||||
() => FlutterProject.fromDirectory(directory),
|
||||
throwsToolExit(),
|
||||
throwsA(isInstanceOf<ToolExit>()),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -109,7 +110,7 @@ void main() {
|
||||
final FlutterProject project = await someProject();
|
||||
await expectLater(
|
||||
project.android.makeHostAppEditable(),
|
||||
throwsAssertionError,
|
||||
throwsA(isInstanceOf<AssertionError>()),
|
||||
);
|
||||
});
|
||||
testInMemory('exits on already editable module', () async {
|
||||
|
||||
@@ -445,7 +445,7 @@ void main() {
|
||||
when(mockDevice.supportsScreenshot).thenReturn(false);
|
||||
|
||||
expect(() => residentRunner.screenshot(mockFlutterDevice),
|
||||
throwsAssertionError);
|
||||
throwsA(isInstanceOf<AssertionError>()));
|
||||
}));
|
||||
|
||||
test('ResidentRunner does not toggle banner in non-debug mode', () => testbed.run(() async {
|
||||
@@ -725,7 +725,7 @@ void main() {
|
||||
expect(nextPlatform('iOS', TestFeatureFlags()), 'fuchsia');
|
||||
expect(nextPlatform('fuchsia', TestFeatureFlags()), 'android');
|
||||
expect(nextPlatform('fuchsia', TestFeatureFlags(isMacOSEnabled: true)), 'macOS');
|
||||
expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsAssertionError);
|
||||
expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsA(isInstanceOf<AssertionError>()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,6 @@ void main() {
|
||||
dartDefines: const <String>[],
|
||||
urlTunneller: null,
|
||||
) as ResidentWebRunner;
|
||||
globals.fs.currentDirectory.childFile('.packages')
|
||||
..writeAsStringSync('\n');
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
WebFsFactory: () => ({
|
||||
@@ -380,8 +378,6 @@ void main() {
|
||||
pathToReload: anyNamed('pathToReload'),
|
||||
invalidatedFiles: anyNamed('invalidatedFiles'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
// Generated entrypoint file in temp dir.
|
||||
expect(invocation.namedArguments[#mainPath], contains('entrypoint.dart'));
|
||||
return UpdateFSReport(success: true)
|
||||
..invalidatedModules = <String>['example'];
|
||||
});
|
||||
@@ -930,7 +926,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -949,7 +945,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -968,7 +964,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -987,7 +983,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -1006,7 +1002,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -1025,7 +1021,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -1045,7 +1041,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsException);
|
||||
), throwsA(isInstanceOf<Exception>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -1064,7 +1060,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsToolExit());
|
||||
), throwsA(isInstanceOf<ToolExit>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
@@ -1086,7 +1082,7 @@ void main() {
|
||||
|
||||
final Future<void> expectation = expectLater(() => residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
), throwsStateError);
|
||||
), throwsA(isInstanceOf<StateError>()));
|
||||
|
||||
unhandledErrorCompleter.complete();
|
||||
await expectation;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
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';
|
||||
@@ -75,7 +76,7 @@ void main() {
|
||||
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion;
|
||||
when(version.ensureVersionFile()).thenThrow(const FileSystemException());
|
||||
|
||||
expect(() async => await runner.run(<String>['dummy']), throwsToolExit());
|
||||
expect(() async => await runner.run(<String>['dummy']), throwsA(isA<ToolExit>()));
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
@@ -248,7 +249,7 @@ void main() {
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return OperationResult(1, 'fail', fatal: true);
|
||||
});
|
||||
expect(terminalHandler.processTerminalInput('r'), throwsToolExit());
|
||||
expect(terminalHandler.processTerminalInput('r'), throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
testUsingContext('r - hotReload unsupported', () async {
|
||||
@@ -291,7 +292,7 @@ void main() {
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return OperationResult(1, 'fail', fatal: true);
|
||||
});
|
||||
expect(() => terminalHandler.processTerminalInput('R'), throwsToolExit());
|
||||
expect(() => terminalHandler.processTerminalInput('R'), throwsA(isInstanceOf<ToolExit>()));
|
||||
});
|
||||
|
||||
testUsingContext('R - hot restart unsupported', () async {
|
||||
|
||||
@@ -10,11 +10,9 @@ 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/error_handling_file_system.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
import '../src/testbed.dart';
|
||||
|
||||
void main() {
|
||||
@@ -78,7 +76,7 @@ void main() {
|
||||
|
||||
expect(testbed.run(() async {
|
||||
Timer.periodic(const Duration(seconds: 1), (Timer timer) { });
|
||||
}), throwsStateError);
|
||||
}), throwsA(isInstanceOf<StateError>()));
|
||||
});
|
||||
|
||||
test('Doesnt throw a StateError if Timer is left cleaned up', () async {
|
||||
@@ -89,14 +87,6 @@ void main() {
|
||||
timer.cancel();
|
||||
});
|
||||
});
|
||||
|
||||
test('Throws if ProcessUtils is injected',() {
|
||||
final Testbed testbed = Testbed(overrides: <Type, Generator>{
|
||||
ProcessUtils: () => null,
|
||||
});
|
||||
|
||||
expect(() => testbed.run(() {}), throwsA(isInstanceOf<StateError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void main() {
|
||||
expect(devices, hasLength(1));
|
||||
|
||||
final Device device = devices.single;
|
||||
expect(device, isA<FlutterTesterDevice>());
|
||||
expect(device, isInstanceOf<FlutterTesterDevice>());
|
||||
expect(device.id, 'flutter-tester');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
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/convert.dart';
|
||||
@@ -79,7 +80,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Throws a tool exit if bind fails with a SocketException', () => testbed.run(() async {
|
||||
expect(WebAssetServer.start('hello', 1234), throwsToolExit());
|
||||
expect(WebAssetServer.start('hello', 1234), throwsA(isInstanceOf<ToolExit>()));
|
||||
}));
|
||||
|
||||
test('Can catch exceptions through the onError callback', () => testbed.run(() async {
|
||||
@@ -91,7 +92,7 @@ void main() {
|
||||
when(request.uri).thenReturn(Uri.parse('http://foobar/foo.js'));
|
||||
requestController.add(request);
|
||||
|
||||
expect(closeCompleter.future, throwsStateError);
|
||||
expect(closeCompleter.future, throwsA(isInstanceOf<StateError>()));
|
||||
}));
|
||||
|
||||
test('Handles against malformed manifest', () => testbed.run(() async {
|
||||
|
||||
@@ -41,8 +41,8 @@ void main() {
|
||||
expect(chromeDevice.supportsFlutterExit, true);
|
||||
expect(chromeDevice.supportsScreenshot, false);
|
||||
expect(await chromeDevice.isLocalEmulator, false);
|
||||
expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isA<NoOpDeviceLogReader>());
|
||||
expect(chromeDevice.getLogReader(), isA<NoOpDeviceLogReader>());
|
||||
expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isInstanceOf<NoOpDeviceLogReader>());
|
||||
expect(chromeDevice.getLogReader(), isInstanceOf<NoOpDeviceLogReader>());
|
||||
expect(await chromeDevice.portForwarder.forward(1), 1);
|
||||
});
|
||||
|
||||
@@ -57,8 +57,8 @@ void main() {
|
||||
expect(device.supportsFlutterExit, true);
|
||||
expect(device.supportsScreenshot, false);
|
||||
expect(await device.isLocalEmulator, false);
|
||||
expect(device.getLogReader(app: mockWebApplicationPackage), isA<NoOpDeviceLogReader>());
|
||||
expect(device.getLogReader(), isA<NoOpDeviceLogReader>());
|
||||
expect(device.getLogReader(app: mockWebApplicationPackage), isInstanceOf<NoOpDeviceLogReader>());
|
||||
expect(device.getLogReader(), isInstanceOf<NoOpDeviceLogReader>());
|
||||
expect(await device.portForwarder.forward(1), 1);
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ void main() {
|
||||
|
||||
final WebDevices deviceDiscoverer = WebDevices();
|
||||
final List<Device> devices = await deviceDiscoverer.pollingGetDevices();
|
||||
expect(devices, contains(isA<ChromeDevice>()));
|
||||
expect(devices, contains(isInstanceOf<ChromeDevice>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ChromeLauncher: () => mockChromeLauncher,
|
||||
});
|
||||
@@ -77,7 +77,7 @@ void main() {
|
||||
|
||||
final WebDevices deviceDiscoverer = WebDevices();
|
||||
final List<Device> devices = await deviceDiscoverer.pollingGetDevices();
|
||||
expect(devices, isNot(contains(isA<ChromeDevice>())));
|
||||
expect(devices, isNot(contains(isInstanceOf<ChromeDevice>())));
|
||||
}, overrides: <Type, Generator>{
|
||||
ChromeLauncher: () => mockChromeLauncher,
|
||||
});
|
||||
@@ -87,7 +87,7 @@ void main() {
|
||||
|
||||
final WebDevices deviceDiscoverer = WebDevices();
|
||||
final List<Device> devices = await deviceDiscoverer.pollingGetDevices();
|
||||
expect(devices, contains(isA<WebServerDevice>()));
|
||||
expect(devices, contains(isInstanceOf<WebServerDevice>()));
|
||||
}, overrides: <Type, Generator>{
|
||||
ChromeLauncher: () => mockChromeLauncher,
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:built_collection/built_collection.dart';
|
||||
import 'package:dwds/asset_handler.dart';
|
||||
import 'package:dwds/dwds.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/dart/pub.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
@@ -17,10 +18,8 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:http_multi_server/http_multi_server.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/mocks.dart';
|
||||
import '../../src/testbed.dart';
|
||||
|
||||
void main() {
|
||||
@@ -31,7 +30,7 @@ void main() {
|
||||
MockHttpMultiServer mockHttpMultiServer;
|
||||
MockBuildDaemonClient mockBuildDaemonClient;
|
||||
MockOperatingSystemUtils mockOperatingSystemUtils;
|
||||
MockProcessManager mockProcessManager;
|
||||
MockProcessUtils mockProcessUtils;
|
||||
bool lastInitializePlatform;
|
||||
dynamic lastAddress;
|
||||
int lastPort;
|
||||
@@ -46,7 +45,7 @@ void main() {
|
||||
mockBuildDaemonClient = MockBuildDaemonClient();
|
||||
mockOperatingSystemUtils = MockOperatingSystemUtils();
|
||||
mockDwds = MockDwds();
|
||||
mockProcessManager = MockProcessManager();
|
||||
mockProcessUtils = MockProcessUtils();
|
||||
when(mockBuildDaemonCreator.startBuildDaemon(any, release: anyNamed('release'), initializePlatform: anyNamed('initializePlatform')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
lastInitializePlatform = invocation.namedArguments[#initializePlatform] as bool;
|
||||
@@ -55,14 +54,15 @@ void main() {
|
||||
when(mockOperatingSystemUtils.findFreePort()).thenAnswer((Invocation _) async {
|
||||
return 1234;
|
||||
});
|
||||
when(mockProcessManager.start(
|
||||
when(mockProcessUtils.stream(
|
||||
any,
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
mapFunction: anyNamed('mapFunction'),
|
||||
environment: anyNamed('environment'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
final String workingDirectory = invocation.namedArguments[#workingDirectory] as String;
|
||||
globals.fs.file(globals.fs.path.join(workingDirectory, '.packages')).createSync(recursive: true);
|
||||
return FakeProcess();
|
||||
return 0;
|
||||
});
|
||||
when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) {
|
||||
return Stream<BuildResults>.fromFuture(Future<BuildResults>.value(
|
||||
@@ -93,7 +93,7 @@ void main() {
|
||||
OperatingSystemUtils: () => mockOperatingSystemUtils,
|
||||
BuildDaemonCreator: () => mockBuildDaemonCreator,
|
||||
ChromeLauncher: () => mockChromeLauncher,
|
||||
ProcessManager: () => mockProcessManager,
|
||||
ProcessUtils: () => mockProcessUtils,
|
||||
HttpMultiServerFactory: () => (dynamic address, int port) async {
|
||||
lastAddress = address;
|
||||
lastPort = port;
|
||||
@@ -216,7 +216,7 @@ void main() {
|
||||
port: '1234',
|
||||
urlTunneller: null,
|
||||
dartDefines: const <String>[],
|
||||
), throwsException);
|
||||
), throwsA(isInstanceOf<Exception>()));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -226,5 +226,5 @@ class MockDwds extends Mock implements Dwds {}
|
||||
class MockHttpMultiServer extends Mock implements HttpMultiServer {}
|
||||
class MockChromeLauncher extends Mock implements ChromeLauncher {}
|
||||
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {}
|
||||
class MockProcessUtils extends Mock implements ProcessUtils {}
|
||||
class MockPub extends Mock implements Pub {}
|
||||
class MockProcessManager extends Mock implements ProcessManager {}
|
||||
|
||||
@@ -22,7 +22,7 @@ export 'package:test_core/test_core.dart' hide TypeMatcher, isInstanceOf; // Def
|
||||
|
||||
/// A matcher that compares the type of the actual value to the type argument T.
|
||||
// TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed
|
||||
test_package.TypeMatcher<T> isInstanceOf<T>() => isA<T>();
|
||||
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>();
|
||||
|
||||
void tryToDelete(Directory directory) {
|
||||
// This should not be necessary, but it turns out that
|
||||
@@ -91,9 +91,6 @@ void updateFileModificationTime(
|
||||
globals.fs.file(path).setLastModifiedSync(modificationTime);
|
||||
}
|
||||
|
||||
/// Matcher for functions that throw [AssertionError].
|
||||
final Matcher throwsAssertionError = throwsA(isA<AssertionError>());
|
||||
|
||||
/// Matcher for functions that throw [ToolExit].
|
||||
Matcher throwsToolExit({ int exitCode, Pattern message }) {
|
||||
Matcher matcher = isToolExit;
|
||||
@@ -107,7 +104,7 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) {
|
||||
}
|
||||
|
||||
/// Matcher for [ToolExit]s.
|
||||
final test_package.TypeMatcher<ToolExit> isToolExit = isA<ToolExit>();
|
||||
final Matcher isToolExit = isInstanceOf<ToolExit>();
|
||||
|
||||
/// Matcher for functions that throw [ProcessExit].
|
||||
Matcher throwsProcessExit([ dynamic exitCode ]) {
|
||||
@@ -117,7 +114,7 @@ Matcher throwsProcessExit([ dynamic exitCode ]) {
|
||||
}
|
||||
|
||||
/// Matcher for [ProcessExit]s.
|
||||
final test_package.TypeMatcher<ProcessExit> isProcessExit = isA<ProcessExit>();
|
||||
final Matcher isProcessExit = isInstanceOf<ProcessExit>();
|
||||
|
||||
/// Creates a flutter project in the [temp] directory using the
|
||||
/// [arguments] list if specified, or `--no-pub` if not.
|
||||
|
||||
@@ -12,7 +12,6 @@ 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/os.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/signals.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
@@ -64,9 +63,6 @@ void testUsingContext(
|
||||
'that you are dealing with in your test.'
|
||||
);
|
||||
}
|
||||
if (overrides.containsKey(ProcessUtils)) {
|
||||
throw StateError('Do not inject ProcessUtils for testing, use ProcessManager instead.');
|
||||
}
|
||||
|
||||
// Ensure we don't rely on the default [Config] constructor which will
|
||||
// leak a sticky $HOME/.flutter_settings behind!
|
||||
|
||||
@@ -12,7 +12,6 @@ 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/os.dart';
|
||||
import 'package:flutter_tools/src/base/process.dart';
|
||||
|
||||
import 'package:flutter_tools/src/base/signals.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
@@ -114,9 +113,6 @@ class Testbed {
|
||||
// Add the test-specific overrides
|
||||
...?overrides,
|
||||
};
|
||||
if (testOverrides.containsKey(ProcessUtils)) {
|
||||
throw StateError('Do not inject ProcessUtils for testing, use ProcessManager instead.');
|
||||
}
|
||||
// Cache the original flutter root to restore after the test case.
|
||||
final String originalFlutterRoot = Cache.flutterRoot;
|
||||
// Track pending timers to verify that they were correctly cleaned up.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/template.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
@@ -23,7 +24,7 @@ void main() {
|
||||
when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());
|
||||
|
||||
expect(() => template.render(mockDirectory, <String, Object>{}),
|
||||
throwsToolExit());
|
||||
throwsA(isInstanceOf<ToolExit>()));
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user