use isA<Xxx>() matcher (#48482)

This commit is contained in:
Alexandre Ardhuin
2020-01-16 21:43:03 +01:00
committed by Flutter GitHub Bot
parent 5eb394e084
commit 003541499b
138 changed files with 433 additions and 450 deletions

View File

@@ -3,7 +3,6 @@
// 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';
@@ -53,7 +52,7 @@ void main() {
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
expect(commandRunner.run(<String>['assemble', 'debug_macos_bundle_flutter_assets']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
});
testbed.test('Throws ToolExit if called with non-existent rule', () async {
@@ -64,7 +63,7 @@ void main() {
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
expect(commandRunner.run(<String>['assemble', '-o Output', 'undefined']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
});
testbed.test('Does not log stack traces during build failure', () async {
@@ -78,7 +77,7 @@ void main() {
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
await expectLater(commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
expect(testLogger.errorText, contains('bar'));
expect(testLogger.errorText, isNot(contains(testStackTrace.toString())));
});

View File

@@ -240,7 +240,7 @@ void main() {
});
testDeviceManager.addDevice(device);
expect(createTestCommandRunner(AttachCommand()).run(<String>['attach']),
throwsA(isA<ToolExit>()));
throwsToolExit());
}, 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']),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
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']),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
expect(testLogger.statusText, contains('More than one device'));
expect(testLogger.statusText, contains('xx1'));

View File

@@ -5,7 +5,6 @@
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';
@@ -50,7 +49,7 @@ void main() {
expect(
createTestCommandRunner(command)
.run(const <String>['build', 'fuchsia']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => linuxPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -67,7 +66,7 @@ void main() {
expect(
createTestCommandRunner(command)
.run(const <String>['build', 'fuchsia']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => linuxPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -89,7 +88,7 @@ void main() {
expect(
createTestCommandRunner(command)
.run(const <String>['build', 'fuchsia']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => windowsPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -111,7 +110,7 @@ void main() {
expect(
createTestCommandRunner(command)
.run(const <String>['build', 'fuchsia']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => linuxPlatform,
FileSystem: () => MemoryFileSystem(),

View File

@@ -8,7 +8,6 @@ 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';
@@ -101,7 +100,7 @@ void main() {
expect(createTestCommandRunner(command).run(
const <String>['build', 'linux']
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => notLinuxPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -220,7 +219,7 @@ BINARY_NAME=fizz_bar
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(() => runner.run(<String>['build', 'linux']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
});

View File

@@ -6,7 +6,6 @@ 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';
@@ -127,7 +126,7 @@ void main() {
expect(createTestCommandRunner(command).run(
const <String>['build', 'macos']
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => notMacosPlatform,
FileSystem: () => MemoryFileSystem(),
@@ -206,7 +205,7 @@ void main() {
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(() => runner.run(<String>['build', 'macos']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
});

View File

@@ -5,7 +5,6 @@
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';
@@ -60,7 +59,7 @@ void main() {
false,
const <String>[],
false,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}));
test('Refuses to build using runner when missing index.html', () => testbed.run(() async {
@@ -82,7 +81,7 @@ void main() {
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(() => runner.run(<String>['build', 'web', '--debug']),
throwsA(isInstanceOf<UsageException>()));
throwsA(isA<UsageException>()));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
}));
@@ -91,7 +90,7 @@ void main() {
final CommandRunner<void> runner = createTestCommandRunner(BuildCommand());
expect(() => runner.run(<String>['build', 'web']),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
}));

View File

@@ -5,7 +5,6 @@
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';
@@ -77,7 +76,7 @@ void main() {
setUpMockProjectFilesForBuild();
expect(createTestCommandRunner(command).run(
const <String>['build', 'windows']
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => windowsPlatform,
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),
@@ -110,7 +109,7 @@ void main() {
expect(createTestCommandRunner(command).run(
const <String>['build', 'windows']
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => notWindowsPlatform,
FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows),

View File

@@ -7,7 +7,6 @@ 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';
@@ -102,7 +101,7 @@ void main() {
expect(() => commandRunner.run(<String>[
'config',
'--build-dir=/foo',
]), throwsA(isInstanceOf<ToolExit>()));
]), throwsToolExit());
verifyNoAnalytics();
}, overrides: <Type, Generator>{
Usage: () => mockUsage,

View File

@@ -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'] is String, true);
expect(response['result'], isA<String>());
await responses.close();
await commands.close();
});

View File

@@ -111,7 +111,7 @@ void main() {
]);
fail('Expect exception');
} catch (e) {
expect(e, isInstanceOf<ToolExit>());
expect(e, isA<ToolExit>());
}
final BufferLogger bufferLogger = globals.logger as BufferLogger;

View File

@@ -107,7 +107,7 @@ void main() {
'--no-pub',
version,
]),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
@@ -119,7 +119,7 @@ void main() {
await command.getTags();
fail('ToolExit expected');
} catch(e) {
expect(e, isInstanceOf<ToolExit>());
expect(e, isA<ToolExit>());
}
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(failGitTag: true),

View File

@@ -4,7 +4,6 @@
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';
@@ -109,7 +108,7 @@ void main() {
'bundle',
'--no-pub',
'--target-platform=windows-x64',
]), throwsA(isInstanceOf<ToolExit>()));
]), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -127,7 +126,7 @@ void main() {
'bundle',
'--no-pub',
'--target-platform=linux-x64',
]), throwsA(isInstanceOf<ToolExit>()));
]), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),
@@ -145,7 +144,7 @@ void main() {
'bundle',
'--no-pub',
'--target-platform=darwin-x64',
]), throwsA(isInstanceOf<ToolExit>()));
]), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => MemoryFileSystem(),
ProcessManager: () => FakeProcessManager.any(),

View File

@@ -2,7 +2,6 @@
// 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';
@@ -63,7 +62,7 @@ void main() {
const GitTagVersion.unknown(),
flutterVersion,
);
expect(result, throwsA(isInstanceOf<ToolExit>()));
expect(result, throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => fakePlatform,
});
@@ -89,7 +88,7 @@ void main() {
gitTagVersion,
flutterVersion,
);
expect(result, throwsA(isA<ToolExit>()));
expect(result, throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => fakePlatform,
});

View File

@@ -652,7 +652,7 @@ flutter:
when(mockProcessManager.run(argThat(contains('forward'))))
.thenAnswer((_) async => ProcessResult(0, 0, '123456', ''));
expect(forwarder.forward(123, hostPort: 456), throwsA(isInstanceOf<ProcessException>()));
expect(forwarder.forward(123, hostPort: 456), throwsA(isA<ProcessException>()));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
});

View File

@@ -1356,7 +1356,7 @@ plugin1=${plugin1.path}
localGradleErrors: const <GradleHandledError>[],
);
},
throwsA(isInstanceOf<ProcessException>()));
throwsA(isA<ProcessException>()));
}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,

View File

@@ -26,7 +26,7 @@ void main() {
});
testWithoutContext('Throws if accessing the Zone', () {
expect(() => context.get<Object>(), throwsA(isInstanceOf<UnsupportedError>()));
expect(() => context.get<Object>(), throwsA(isA<UnsupportedError>()));
});
});
}

View File

@@ -70,7 +70,7 @@ void main() {
});
test('exit throws a StateError if called without being overriden', () {
expect(() => exit(0), throwsA(isInstanceOf<AssertionError>()));
expect(() => exit(0), throwsAssertionError);
});
test('exit does not throw a StateError if overriden', () {

View File

@@ -144,8 +144,8 @@ void main() {
expect(lines.length, equals(1));
// Verify that stopping or canceling multiple times throws.
expect(ansiSpinner.stop, throwsA(isInstanceOf<AssertionError>()));
expect(ansiSpinner.cancel, throwsA(isInstanceOf<AssertionError>()));
expect(ansiSpinner.stop, throwsAssertionError);
expect(ansiSpinner.cancel, throwsAssertionError);
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(); }, throwsA(isInstanceOf<AssertionError>()));
expect(() { ansiStatus.stop(); }, throwsA(isInstanceOf<AssertionError>()));
expect(() { ansiStatus.cancel(); }, throwsAssertionError);
expect(() { ansiStatus.stop(); }, throwsAssertionError);
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, throwsA(isInstanceOf<AssertionError>()));
expect(ansiStatus.cancel, throwsA(isInstanceOf<AssertionError>()));
expect(ansiStatus.stop, throwsAssertionError);
expect(ansiStatus.cancel, throwsAssertionError);
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, throwsA(isInstanceOf<AssertionError>()));
expect(summaryStatus.stop, throwsA(isInstanceOf<AssertionError>()));
expect(summaryStatus.cancel, throwsAssertionError);
expect(summaryStatus.stop, throwsAssertionError);
});
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, throwsA(isInstanceOf<AssertionError>()));
expect(summaryStatus.cancel, throwsA(isInstanceOf<AssertionError>()));
expect(summaryStatus.stop, throwsAssertionError);
expect(summaryStatus.cancel, throwsAssertionError);
});
testWithoutContext('sequential startProgress calls with StdoutLogger', () async {

View File

@@ -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(isInstanceOf<ProcessException>()));
throwsA(isA<ProcessException>()));
});
});
@@ -236,7 +236,7 @@ void main() {
<String>['dummy'],
timeout: delay - const Duration(milliseconds: 500),
timeoutRetries: 0,
), throwsA(isInstanceOf<ProcessException>()));
), throwsA(isA<ProcessException>()));
});
});

View File

@@ -120,7 +120,7 @@ void main() {
<String>['a', 'b', 'c'],
prompt: 'Please choose something',
logger: null,
), throwsA(isInstanceOf<StateError>()));
), throwsStateError);
});
testWithoutContext('character prompt', () async {

View File

@@ -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'), throwsA(isInstanceOf<ArgumentError>()));
expect(() => BuildMode.fromName('foo'), throwsArgumentError);
});
});
}

View File

@@ -309,7 +309,7 @@ void main() {
barTarget.dependencies.add(fooTarget);
fooTarget.dependencies.add(barTarget);
expect(() => checkCycles(barTarget), throwsA(isInstanceOf<CycleException>()));
expect(() => checkCycles(barTarget), throwsA(isA<CycleException>()));
});
test('Target with depfile dependency will not run twice without invalidation', () => testbed.run(() async {

View File

@@ -141,14 +141,14 @@ void main() {
globals.fs.file('abcd.bar').createSync();
expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>()));
expect(() => fizzSource.accept(visitor), throwsA(isA<InvalidPatternException>()));
}));
test('can\'t substitute foo', () => testbed.run(() {
const Source invalidBase = Source.pattern('foo');
expect(() => invalidBase.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>()));
expect(() => invalidBase.accept(visitor), throwsA(isA<InvalidPatternException>()));
}));
test('can substitute optional files', () => testbed.run(() {

View File

@@ -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, isInstanceOf<MissingDefineException>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<Exception>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<MissingDefineException>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<MissingDefineException>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<MissingDefineException>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<MissingDefineException>());
expect(result.exceptions.values.single.exception, isA<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, isInstanceOf<Exception>());
expect(result.exceptions.values.single.exception, isA<Exception>());
}));
test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async {

View File

@@ -126,7 +126,7 @@ void main() {
..writeAsStringSync('testing');
expect(() async => await const DebugMacOSBundleFlutterAssets().build(environment),
throwsA(isInstanceOf<Exception>()));
throwsException);
}));
test('debug macOS application creates correctly structured framework', () => testbed.run(() async {

View File

@@ -2,7 +2,6 @@
// 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';
@@ -62,7 +61,7 @@ void main() {
targetPlatform: TargetPlatform.linux_x64,
depfilePath: 'example.d',
precompiled: false,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
}));
}

View File

@@ -12,7 +12,6 @@ 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';
@@ -72,7 +71,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(), throwsA(isA<ToolExit>()));
expect(() async => await Cache.lock(), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => mockFileSystem,
ProcessManager: () => FakeProcessManager.any(),
@@ -231,7 +230,7 @@ void main() {
'FLUTTER_STORAGE_BASE_URL': ' http://foo',
});
final Cache cache = Cache();
expect(() => cache.storageBaseUrl, throwsA(isInstanceOf<ToolExit>()));
expect(() => cache.storageBaseUrl, throwsToolExit());
}, overrides: <Type, Generator>{
Platform: () => MockPlatform(),
});

View File

@@ -5,7 +5,6 @@
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';
@@ -82,7 +81,7 @@ void main() {
'/path/to/main.dart',
null, /* invalidatedFiles */
outputPath: '/build/',
)), throwsA(isInstanceOf<ToolExit>()));
)), throwsToolExit());
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
OutputPreferences: () => OutputPreferences(showColor: false),
@@ -100,7 +99,7 @@ void main() {
'/path/to/main.dart',
null, /* invalidatedFiles */
outputPath: '/build/',
)), throwsA(isInstanceOf<ToolExit>()));
)), throwsToolExit());
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
OutputPreferences: () => OutputPreferences(showColor: false),

View File

@@ -2,7 +2,6 @@
// 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';
@@ -25,7 +24,7 @@ void main() {
final Future<CompilerOutput> output = stdoutHandler.compilerOutput.future;
stdoutHandler.handler('message with no result');
expect(output, throwsA(isInstanceOf<ToolExit>()));
expect(output, throwsToolExit());
});
test('TargetModel values', () {
@@ -41,6 +40,6 @@ void main() {
expect(TargetModel('dartdevc'), TargetModel.dartdevc);
expect(TargetModel.dartdevc.toString(), 'dartdevc');
expect(() => TargetModel('foobar'), throwsA(isInstanceOf<AssertionError>()));
expect(() => TargetModel('foobar'), throwsAssertionError);
});
}

View File

@@ -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, isInstanceOf<Exception>());
expect(error, isA<Exception>());
expect(error.message, '/: unexpected concurrent modification of pubspec.yaml while running pub.');
}
expect(testLogger.statusText, 'Running "flutter pub get" in /...\n');

View File

@@ -20,9 +20,9 @@ void main() {
test('doctor validators includes desktop when features are enabled', () => testbed.run(() {
expect(DoctorValidatorsProvider.defaultInstance.validators,
contains(isInstanceOf<LinuxDoctorValidator>()));
contains(isA<LinuxDoctorValidator>()));
expect(DoctorValidatorsProvider.defaultInstance.validators,
contains(isInstanceOf<VisualStudioValidator>()));
contains(isA<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(isInstanceOf<LinuxDoctorValidator>())));
isNot(contains(isA<LinuxDoctorValidator>())));
expect(DoctorValidatorsProvider.defaultInstance.validators,
isNot(contains(isInstanceOf<VisualStudioValidator>())));
isNot(contains(isA<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(isInstanceOf<WebValidator>()));
contains(isA<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(isInstanceOf<WebValidator>())));
isNot(contains(isA<WebValidator>())));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(
isWebEnabled: false,

View File

@@ -3,7 +3,6 @@
// 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';
@@ -21,13 +20,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()), throwsA(isA<ToolExit>()));
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit());
});
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()), throwsA(isA<ToolExit>()));
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit());
});
group('The FLUTTER_TEST environment variable is passed to the test process', () {
@@ -50,7 +49,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, isInstanceOf<Map<String, String>>());
expect(toVerify.captured.first, isA<Map<String, String>>());
return toVerify.captured.first as Map<String, String>;
}
@@ -91,7 +90,7 @@ void main() {
shellPath: 'abc',
enableObservatory: false,
startPaused: true,
), throwsA(isA<AssertionError>()));
), throwsAssertionError);
expect(() => installHook(
buildMode: BuildMode.debug,
@@ -99,7 +98,7 @@ void main() {
enableObservatory: false,
startPaused: false,
observatoryPort: 123,
), throwsA(isA<AssertionError>()));
), throwsAssertionError);
FlutterPlatform capturedPlatform;
final Map<String, String> expectedPrecompiledDillFiles = <String, String>{'Key': 'Value'};

View File

@@ -84,7 +84,7 @@ void main() {
testUsingContext('throws UnsupportedError exception if instantiated on ${platform.operatingSystem}', () {
expect(
() { IOSDevice('device-123'); },
throwsA(isInstanceOf<AssertionError>()),
throwsAssertionError,
);
}, overrides: <Type, Generator>{
Platform: () => platform,
@@ -788,7 +788,7 @@ void main() {
.thenAnswer((Invocation invocation) => Future<String>.value(''));
expect(
() async { await IOSDevice.getAttachedDevices(); },
throwsA(isInstanceOf<UnsupportedError>()),
throwsA(isA<UnsupportedError>()),
);
}, overrides: <Type, Generator>{
IMobileDevice: () => mockIMobileDevice,

View File

@@ -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(isInstanceOf<IOSDeviceNotFoundError>()));
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<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(isInstanceOf<IOSDeviceNotTrustedError>()));
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<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(isInstanceOf<IOSDeviceNotTrustedError>()));
expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA<IOSDeviceNotTrustedError>()));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
Cache: () => mockCache,

View File

@@ -345,7 +345,7 @@ void main() {
);
fail('ToolExit expected');
} catch(e) {
expect(e, isInstanceOf<ToolExit>());
expect(e, isA<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, isInstanceOf<ToolExit>());
expect(e, isA<ToolExit>());
expect(
testLogger.errorText,
contains("CocoaPods's specs repository is too out-of-date to satisfy dependencies"),

View File

@@ -6,7 +6,6 @@ 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';
@@ -29,7 +28,7 @@ void main() {
testInMemory('fails on null directory', () async {
expect(
() => FlutterProject.fromDirectory(null),
throwsA(isInstanceOf<AssertionError>()),
throwsAssertionError,
);
});
@@ -41,7 +40,7 @@ void main() {
expect(
() => FlutterProject.fromDirectory(directory),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
});
@@ -53,7 +52,7 @@ void main() {
expect(
() => FlutterProject.fromDirectory(directory),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
});
@@ -65,7 +64,7 @@ void main() {
expect(
() => FlutterProject.fromDirectory(directory),
throwsA(isInstanceOf<ToolExit>()),
throwsToolExit(),
);
});
@@ -110,7 +109,7 @@ void main() {
final FlutterProject project = await someProject();
await expectLater(
project.android.makeHostAppEditable(),
throwsA(isInstanceOf<AssertionError>()),
throwsAssertionError,
);
});
testInMemory('exits on already editable module', () async {

View File

@@ -445,7 +445,7 @@ void main() {
when(mockDevice.supportsScreenshot).thenReturn(false);
expect(() => residentRunner.screenshot(mockFlutterDevice),
throwsA(isInstanceOf<AssertionError>()));
throwsAssertionError);
}));
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()), throwsA(isInstanceOf<AssertionError>()));
expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsAssertionError);
});
}

View File

@@ -926,7 +926,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -945,7 +945,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -964,7 +964,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -983,7 +983,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -1002,7 +1002,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -1021,7 +1021,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -1041,7 +1041,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<Exception>()));
), throwsException);
unhandledErrorCompleter.complete();
await expectation;
@@ -1060,7 +1060,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<ToolExit>()));
), throwsToolExit());
unhandledErrorCompleter.complete();
await expectation;
@@ -1082,7 +1082,7 @@ void main() {
final Future<void> expectation = expectLater(() => residentWebRunner.run(
connectionInfoCompleter: connectionInfoCompleter,
), throwsA(isInstanceOf<StateError>()));
), throwsStateError);
unhandledErrorCompleter.complete();
await expectation;

View File

@@ -3,7 +3,6 @@
// 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';
@@ -76,7 +75,7 @@ void main() {
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion;
when(version.ensureVersionFile()).thenThrow(const FileSystemException());
expect(() async => await runner.run(<String>['dummy']), throwsA(isA<ToolExit>()));
expect(() async => await runner.run(<String>['dummy']), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => fs,

View File

@@ -4,7 +4,6 @@
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';
@@ -249,7 +248,7 @@ void main() {
.thenAnswer((Invocation invocation) async {
return OperationResult(1, 'fail', fatal: true);
});
expect(terminalHandler.processTerminalInput('r'), throwsA(isInstanceOf<ToolExit>()));
expect(terminalHandler.processTerminalInput('r'), throwsToolExit());
});
testUsingContext('r - hotReload unsupported', () async {
@@ -292,7 +291,7 @@ void main() {
.thenAnswer((Invocation invocation) async {
return OperationResult(1, 'fail', fatal: true);
});
expect(() => terminalHandler.processTerminalInput('R'), throwsA(isInstanceOf<ToolExit>()));
expect(() => terminalHandler.processTerminalInput('R'), throwsToolExit());
});
testUsingContext('R - hot restart unsupported', () async {

View File

@@ -76,7 +76,7 @@ void main() {
expect(testbed.run(() async {
Timer.periodic(const Duration(seconds: 1), (Timer timer) { });
}), throwsA(isInstanceOf<StateError>()));
}), throwsStateError);
});
test('Doesnt throw a StateError if Timer is left cleaned up', () async {

View File

@@ -61,7 +61,7 @@ void main() {
expect(devices, hasLength(1));
final Device device = devices.single;
expect(device, isInstanceOf<FlutterTesterDevice>());
expect(device, isA<FlutterTesterDevice>());
expect(device.id, 'flutter-tester');
});
});

View File

@@ -5,7 +5,6 @@
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';
@@ -80,7 +79,7 @@ void main() {
});
test('Throws a tool exit if bind fails with a SocketException', () => testbed.run(() async {
expect(WebAssetServer.start('hello', 1234), throwsA(isInstanceOf<ToolExit>()));
expect(WebAssetServer.start('hello', 1234), throwsToolExit());
}));
test('Can catch exceptions through the onError callback', () => testbed.run(() async {
@@ -92,7 +91,7 @@ void main() {
when(request.uri).thenReturn(Uri.parse('http://foobar/foo.js'));
requestController.add(request);
expect(closeCompleter.future, throwsA(isInstanceOf<StateError>()));
expect(closeCompleter.future, throwsStateError);
}));
test('Handles against malformed manifest', () => testbed.run(() async {

View File

@@ -41,8 +41,8 @@ void main() {
expect(chromeDevice.supportsFlutterExit, true);
expect(chromeDevice.supportsScreenshot, false);
expect(await chromeDevice.isLocalEmulator, false);
expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isInstanceOf<NoOpDeviceLogReader>());
expect(chromeDevice.getLogReader(), isInstanceOf<NoOpDeviceLogReader>());
expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isA<NoOpDeviceLogReader>());
expect(chromeDevice.getLogReader(), isA<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), isInstanceOf<NoOpDeviceLogReader>());
expect(device.getLogReader(), isInstanceOf<NoOpDeviceLogReader>());
expect(device.getLogReader(app: mockWebApplicationPackage), isA<NoOpDeviceLogReader>());
expect(device.getLogReader(), isA<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(isInstanceOf<ChromeDevice>()));
expect(devices, contains(isA<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(isInstanceOf<ChromeDevice>())));
expect(devices, isNot(contains(isA<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(isInstanceOf<WebServerDevice>()));
expect(devices, contains(isA<WebServerDevice>()));
}, overrides: <Type, Generator>{
ChromeLauncher: () => mockChromeLauncher,
});

View File

@@ -216,7 +216,7 @@ void main() {
port: '1234',
urlTunneller: null,
dartDefines: const <String>[],
), throwsA(isInstanceOf<Exception>()));
), throwsException);
}));
}

View File

@@ -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
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>();
test_package.TypeMatcher<T> isInstanceOf<T>() => isA<T>();
void tryToDelete(Directory directory) {
// This should not be necessary, but it turns out that
@@ -91,6 +91,9 @@ 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;
@@ -104,7 +107,7 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) {
}
/// Matcher for [ToolExit]s.
final Matcher isToolExit = isInstanceOf<ToolExit>();
final test_package.TypeMatcher<ToolExit> isToolExit = isA<ToolExit>();
/// Matcher for functions that throw [ProcessExit].
Matcher throwsProcessExit([ dynamic exitCode ]) {
@@ -114,7 +117,7 @@ Matcher throwsProcessExit([ dynamic exitCode ]) {
}
/// Matcher for [ProcessExit]s.
final Matcher isProcessExit = isInstanceOf<ProcessExit>();
final test_package.TypeMatcher<ProcessExit> isProcessExit = isA<ProcessExit>();
/// Creates a flutter project in the [temp] directory using the
/// [arguments] list if specified, or `--no-pub` if not.

View File

@@ -2,7 +2,6 @@
// 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;
@@ -24,7 +23,7 @@ void main() {
when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());
expect(() => template.render(mockDirectory, <String, Object>{}),
throwsA(isInstanceOf<ToolExit>()));
throwsToolExit());
}));
}