mirror of
https://github.com/flutter/flutter
synced 2024-10-12 19:23:02 +00:00
use throwsXxx instead of throwsA(isA<Xxx>()) (#82328)
This commit is contained in:
parent
ab2aa31944
commit
7d46d43635
|
@ -39,7 +39,7 @@ Future<void> main() async {
|
|||
),
|
||||
],
|
||||
)),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('items.length'),
|
||||
|
|
|
@ -94,7 +94,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('children.length'),
|
||||
|
@ -110,7 +110,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('children.length'),
|
||||
|
@ -220,7 +220,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('children'),
|
||||
|
|
|
@ -82,7 +82,7 @@ void main() {
|
|||
onValueChanged: defaultCallback,
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('children.length'),
|
||||
|
@ -97,7 +97,7 @@ void main() {
|
|||
onValueChanged: defaultCallback,
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('children.length'),
|
||||
|
@ -117,7 +117,7 @@ void main() {
|
|||
onValueChanged: defaultCallback,
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains('groupValue must be either null or one of the keys in the children map'),
|
||||
|
|
|
@ -588,7 +588,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains("There should be exactly one item with [DropdownButton]'s value"),
|
||||
|
@ -617,7 +617,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains("There should be exactly one item with [DropdownButton]'s value"),
|
||||
|
|
|
@ -457,7 +457,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains("There should be exactly one item with [DropdownButton]'s value"),
|
||||
|
@ -486,7 +486,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
contains("There should be exactly one item with [DropdownButton]'s value"),
|
||||
|
|
|
@ -185,7 +185,7 @@ void main() {
|
|||
),
|
||||
),
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.toString(),
|
||||
'.toString()',
|
||||
allOf(
|
||||
|
|
|
@ -980,7 +980,7 @@ void main() {
|
|||
},
|
||||
);
|
||||
},
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.message,
|
||||
'message',
|
||||
'paintTransform must be invertible.',
|
||||
|
@ -996,7 +996,7 @@ void main() {
|
|||
},
|
||||
);
|
||||
},
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.message,
|
||||
'message',
|
||||
'Exactly one transform or offset argument must be provided.',
|
||||
|
|
|
@ -183,7 +183,7 @@ void main() {
|
|||
// child1 is not given up before running finalizers.
|
||||
expect(
|
||||
() => manager.doSerialization(),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
equals(
|
||||
|
|
|
@ -768,7 +768,7 @@ void main() {
|
|||
child: GridView.extent(
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
),
|
||||
), throwsA(isA<AssertionError>()));
|
||||
), throwsAssertionError);
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void main() {
|
|||
itemExtent: 20.0,
|
||||
children: const <Widget>[],
|
||||
),
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.message,
|
||||
'message',
|
||||
contains("You can't set a diameterRatio of 0"),
|
||||
|
|
|
@ -758,7 +758,7 @@ void main() {
|
|||
final PageController controller = PageController();
|
||||
expect(
|
||||
() => controller.page,
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.message,
|
||||
'message',
|
||||
equals('PageController.page cannot be accessed before a PageView is built with it.'),
|
||||
|
@ -792,7 +792,7 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
() => controller.page,
|
||||
throwsA(isA<AssertionError>().having(
|
||||
throwsA(isAssertionError.having(
|
||||
(AssertionError error) => error.message,
|
||||
'message',
|
||||
equals('PageController.page cannot be accessed before a PageView is built with it.'),
|
||||
|
|
|
@ -632,11 +632,11 @@ void main() {
|
|||
|
||||
group('VMServiceFlutterDriver Unsupported error', () {
|
||||
test('enableAccessibility', () async {
|
||||
expect(driver.enableAccessibility(), throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.enableAccessibility(), throwsUnsupportedError);
|
||||
});
|
||||
|
||||
test('webDriver', () async {
|
||||
expect(() => driver.webDriver, throwsA(isA<UnsupportedError>()));
|
||||
expect(() => driver.webDriver, throwsUnsupportedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -913,28 +913,23 @@ void main() {
|
|||
|
||||
group('WebFlutterDriver Unimplemented/Unsupported error', () {
|
||||
test('forceGC', () async {
|
||||
expect(driver.forceGC(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.forceGC(), throwsUnimplementedError);
|
||||
});
|
||||
|
||||
test('getVmFlags', () async {
|
||||
expect(driver.getVmFlags(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.getVmFlags(), throwsUnimplementedError);
|
||||
});
|
||||
|
||||
test('waitUntilFirstFrameRasterized', () async {
|
||||
expect(driver.waitUntilFirstFrameRasterized(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.waitUntilFirstFrameRasterized(), throwsUnimplementedError);
|
||||
});
|
||||
|
||||
test('appIsoloate', () async {
|
||||
expect(() => driver.appIsolate.extensionRPCs,
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(() => driver.appIsolate.extensionRPCs, throwsUnsupportedError);
|
||||
});
|
||||
|
||||
test('serviceClient', () async {
|
||||
expect(() => driver.serviceClient.getVM(),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(() => driver.serviceClient.getVM(), throwsUnsupportedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -949,14 +944,10 @@ void main() {
|
|||
});
|
||||
|
||||
test('tracing', () async {
|
||||
expect(driver.traceAction(() async { return Future<dynamic>.value(); }),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.startTracing(),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.stopTracingAndDownloadTimeline(),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.clearTimeline(),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.traceAction(() async { return Future<dynamic>.value(); }), throwsUnsupportedError);
|
||||
expect(driver.startTracing(), throwsUnsupportedError);
|
||||
expect(driver.stopTracingAndDownloadTimeline(), throwsUnsupportedError);
|
||||
expect(driver.clearTimeline(), throwsUnsupportedError);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('io_extension should throw exception', () {
|
||||
expect(() => registerWebServiceExtension(call),
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(() => registerWebServiceExtension(call), throwsUnsupportedError);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ void main() {
|
|||
await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes);
|
||||
await expectLater(
|
||||
() => doComparison(),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
contains('% diff detected'),
|
||||
|
@ -216,7 +216,7 @@ void main() {
|
|||
..writeAsBytesSync(_kColorFailurePngBytes);
|
||||
await expectLater(
|
||||
() => doComparison('subdir/golden.png'),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
contains('% diff detected'),
|
||||
|
@ -255,7 +255,7 @@ void main() {
|
|||
await fs.file(fix('/golden.png')).writeAsBytes(_kSizeFailurePngBytes);
|
||||
await expectLater(
|
||||
() => doComparison(),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
contains('image sizes do not match'),
|
||||
|
@ -267,7 +267,7 @@ void main() {
|
|||
await fs.file(fix('/golden.png')).writeAsBytes(_kColorFailurePngBytes);
|
||||
await expectLater(
|
||||
() => doComparison(),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
contains('% diff detected'),
|
||||
|
@ -279,7 +279,7 @@ void main() {
|
|||
await fs.file(fix('/golden.png')).writeAsBytes(<int>[]);
|
||||
await expectLater(
|
||||
() => doComparison(),
|
||||
throwsA(isA<FlutterError>().having(
|
||||
throwsA(isFlutterError.having(
|
||||
(FlutterError error) => error.message,
|
||||
'message',
|
||||
contains('null image provided'),
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
// @dart = 2.8
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
|
@ -19,7 +19,7 @@ void main() {
|
|||
expect(() => commandRunner.run(<String>[
|
||||
'build',
|
||||
'--obfuscate',
|
||||
]), throwsA(isA<ToolExit>()));
|
||||
]), throwsToolExit());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
// @dart = 2.8
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/commands/generate_localizations.dart';
|
||||
import 'package:flutter_tools/src/runner/flutter_command.dart';
|
||||
|
||||
import '../../integration.shard/test_data/basic_project.dart';
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
import '../../src/test_flutter_command_runner.dart';
|
||||
|
||||
|
@ -100,7 +100,7 @@ void main() {
|
|||
'--header="some header',
|
||||
'--header-file="header.txt"',
|
||||
]),
|
||||
throwsA(isA<ToolExit>()),
|
||||
throwsToolExit(),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void main() {
|
|||
'--no-pub',
|
||||
'--show-test-device',
|
||||
]),
|
||||
throwsA(isA<Exception>().having(
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'toString',
|
||||
isNot(contains('--fast-start is not supported with --use-application-binary')),
|
||||
|
@ -102,7 +102,7 @@ void main() {
|
|||
'run',
|
||||
'--no-pub',
|
||||
]),
|
||||
throwsA(isA<ToolExit>()),
|
||||
throwsToolExit(),
|
||||
);
|
||||
final BufferLogger bufferLogger = globals.logger as BufferLogger;
|
||||
expect(
|
||||
|
@ -127,11 +127,7 @@ void main() {
|
|||
'run',
|
||||
'--no-pub',
|
||||
]),
|
||||
throwsA(isA<ToolExit>().having(
|
||||
(ToolExit error) => error.toString(),
|
||||
'toString()',
|
||||
contains('No pubspec.yaml file found'),
|
||||
)),
|
||||
throwsToolExit(message: 'No pubspec.yaml file found'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
|
@ -510,7 +506,7 @@ void main() {
|
|||
'run',
|
||||
'--no-pub',
|
||||
'--bundle-sksl-path=foo.json',
|
||||
]), throwsA(isA<ToolExit>().having((ToolExit exit) => exit.message, 'message', contains('No SkSL shader bundle found at foo.json'))));
|
||||
]), throwsToolExit(message: 'No SkSL shader bundle found at foo.json'));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ void main() {
|
|||
|
||||
await expectLater(() => createTestCommandRunner(ScreenshotCommand())
|
||||
.run(<String>['screenshot', '--type=skia', '--observatory-url=http://localhost:8181']),
|
||||
throwsA(isA<Exception>().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))),
|
||||
throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))),
|
||||
);
|
||||
|
||||
await expectLater(() => createTestCommandRunner(ScreenshotCommand())
|
||||
.run(<String>['screenshot', '--type=rasterizer', '--observatory-url=http://localhost:8181']),
|
||||
throwsA(isA<Exception>().having((dynamic exception) => exception.toString(), 'message', contains('dummy'))),
|
||||
throwsA(isException.having((Exception exception) => exception.toString(), 'message', contains('dummy'))),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -211,8 +211,7 @@ dev_dependencies:
|
|||
'--coverage',
|
||||
'--',
|
||||
'test/fake_test.dart',
|
||||
]), throwsA(isA<ToolExit>()
|
||||
.having((ToolExit toolExit) => toolExit.message, 'message', isNull)));
|
||||
]), throwsA(isA<ToolExit>().having((ToolExit toolExit) => toolExit.message, 'message', isNull)));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/android/android_device.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/device_port_forwarder.dart';
|
||||
|
||||
|
@ -78,7 +77,7 @@ void main() {
|
|||
logger: BufferLogger.test(),
|
||||
);
|
||||
|
||||
expect(forwarder.forward(123, hostPort: 456), throwsA(isA<ProcessException>()));
|
||||
expect(forwarder.forward(123, hostPort: 456), throwsProcessException());
|
||||
});
|
||||
|
||||
testWithoutContext('AndroidDevicePortForwarder forwardedPorts returns empty '
|
||||
|
@ -159,6 +158,6 @@ void main() {
|
|||
logger: BufferLogger.test(),
|
||||
);
|
||||
|
||||
expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsA(isA<ProcessException>()));
|
||||
expect(() => forwarder.unforward(ForwardedPort(456, 23)), throwsProcessException());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -358,7 +358,7 @@ void main() {
|
|||
..writeAsStringSync('apply from: irrelevant/flutter.gradle');
|
||||
|
||||
await expectLater(() async {
|
||||
await builder.buildGradleApp(
|
||||
await builder.buildGradleApp(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
androidBuildInfo: const AndroidBuildInfo(
|
||||
BuildInfo(
|
||||
|
@ -371,8 +371,7 @@ void main() {
|
|||
isBuildingBundle: false,
|
||||
localGradleErrors: const <GradleHandledError>[],
|
||||
);
|
||||
},
|
||||
throwsA(isA<ProcessException>()));
|
||||
}, throwsProcessException());
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
|
@ -288,7 +287,7 @@ void main() {
|
|||
'test message',
|
||||
Uri.parse('http://test.zip'),
|
||||
fileSystem.currentDirectory.childDirectory('out'),
|
||||
), throwsA(isA<ArgumentError>()));
|
||||
), throwsArgumentError);
|
||||
|
||||
expect(logger.statusText, contains('test message'));
|
||||
expect(fileSystem.file('out/test'), isNot(exists));
|
||||
|
@ -361,7 +360,7 @@ void main() {
|
|||
'test message',
|
||||
Uri.parse('http://test.zip'),
|
||||
fileSystem.currentDirectory.childDirectory('out'),
|
||||
), throwsA(isA<ToolExit>()));
|
||||
), throwsToolExit());
|
||||
expect(fileSystem.file('te,[/test'), isNot(exists));
|
||||
expect(fileSystem.file('out/test'), isNot(exists));
|
||||
});
|
||||
|
@ -385,7 +384,7 @@ void main() {
|
|||
'test message',
|
||||
Uri.parse('http://test.zip'),
|
||||
fileSystem.currentDirectory.childDirectory('out'),
|
||||
), throwsA(isA<ToolExit>()));
|
||||
), throwsToolExit());
|
||||
expect(fileSystem.file('te,[/test'), isNot(exists));
|
||||
expect(fileSystem.file('out/test'), isNot(exists));
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('Throws if accessing the Zone', () {
|
||||
expect(() => context.get<Object>(), throwsA(isA<UnsupportedError>()));
|
||||
expect(() => context.get<Object>(), throwsUnsupportedError);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ void main() {
|
|||
when(file.deleteSync(recursive: false))
|
||||
.thenThrow(const FileSystemException('', '', OSError('', 2)));
|
||||
|
||||
expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsA(isA<ToolExit>()));
|
||||
expect(() => ErrorHandlingFileSystem.deleteIfExists(file), throwsToolExit());
|
||||
});
|
||||
|
||||
testWithoutContext('deleteIfExists does not tool exit if file exists on read-only '
|
||||
|
@ -182,7 +182,7 @@ void main() {
|
|||
ErrorHandlingFileSystem.noExitOnFailure(() {
|
||||
ErrorHandlingFileSystem.deleteIfExists(file);
|
||||
});
|
||||
}, throwsA(isA<FileSystemException>()));
|
||||
}, throwsFileSystemException());
|
||||
});
|
||||
|
||||
group('throws ToolExit on Windows', () {
|
||||
|
@ -213,7 +213,7 @@ void main() {
|
|||
final File file = fs.file('file');
|
||||
|
||||
expect(() => ErrorHandlingFileSystem.noExitOnFailure(
|
||||
() => file.writeAsStringSync('')), throwsA(isA<Exception>()));
|
||||
() => file.writeAsStringSync('')), throwsException);
|
||||
|
||||
// nesting does not unconditionally re-enable errors.
|
||||
expect(() {
|
||||
|
@ -221,10 +221,10 @@ void main() {
|
|||
ErrorHandlingFileSystem.noExitOnFailure(() { });
|
||||
file.writeAsStringSync('');
|
||||
});
|
||||
}, throwsA(isA<Exception>()));
|
||||
}, throwsException);
|
||||
|
||||
// Check that state does not leak.
|
||||
expect(() => file.writeAsStringSync(''), throwsA(isA<ToolExit>()));
|
||||
expect(() => file.writeAsStringSync(''), throwsToolExit());
|
||||
});
|
||||
|
||||
testWithoutContext('when access is denied', () async {
|
||||
|
|
|
@ -227,7 +227,7 @@ void main() {
|
|||
|
||||
expect(
|
||||
() => asLogger<AppRunLogger>(notifyingLogger),
|
||||
throwsA(isA<StateError>()),
|
||||
throwsStateError,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -335,8 +335,8 @@ void main() {
|
|||
logger.printStatus('message');
|
||||
logger.printError('error message');
|
||||
|
||||
expect(() async => stdout.done, throwsA(isA<Exception>()));
|
||||
expect(() async => stderr.done, throwsA(isA<Exception>()));
|
||||
expect(() async => stdout.done, throwsException);
|
||||
expect(() async => stderr.done, throwsException);
|
||||
});
|
||||
|
||||
group('Spinners', () {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'package:file/file.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/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
|
@ -100,7 +99,7 @@ void main() {
|
|||
processManager: fakeProcessManager,
|
||||
);
|
||||
|
||||
expect(() => utils.which(kExecutable), throwsA(isA<ToolExit>()));
|
||||
expect(() => utils.which(kExecutable), throwsToolExit());
|
||||
});
|
||||
|
||||
testWithoutContext('returns null when executable does not exist', () async {
|
||||
|
|
|
@ -35,8 +35,7 @@ void main() {
|
|||
exitCode: 1,
|
||||
));
|
||||
|
||||
expect(() async => processUtils.run(<String>['false'], throwOnError: true),
|
||||
throwsA(isA<ProcessException>()));
|
||||
expect(() async => processUtils.run(<String>['false'], throwOnError: true), throwsProcessException());
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -124,8 +123,7 @@ void main() {
|
|||
],
|
||||
exitCode: 1,
|
||||
));
|
||||
expect(() => processUtils.run(<String>['kaboom'], throwOnError: true),
|
||||
throwsA(isA<ProcessException>()));
|
||||
expect(() => processUtils.run(<String>['kaboom'], throwOnError: true), throwsProcessException());
|
||||
});
|
||||
|
||||
testWithoutContext(' does not throw on allowed Failures', () async {
|
||||
|
@ -158,7 +156,7 @@ void main() {
|
|||
throwOnError: true,
|
||||
allowedFailures: (int c) => c == 1,
|
||||
),
|
||||
throwsA(isA<ProcessException>()),
|
||||
throwsProcessException(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -269,7 +267,8 @@ void main() {
|
|||
throwOnError: true,
|
||||
allowedFailures: (int c) => c == 1,
|
||||
),
|
||||
throwsA(isA<ProcessException>()));
|
||||
throwsProcessException(),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext(' prints stdout and stderr to trace on success', () async {
|
||||
|
@ -294,8 +293,7 @@ void main() {
|
|||
stdout: 'stdout',
|
||||
stderr: 'stderr',
|
||||
));
|
||||
expect(() => processUtils.runSync(<String>['kaboom'], throwOnError: true),
|
||||
throwsA(isA<ProcessException>()));
|
||||
expect(() => processUtils.runSync(<String>['kaboom'], throwOnError: true), throwsProcessException());
|
||||
expect(testLogger.statusText, contains('stdout'));
|
||||
expect(testLogger.errorText, contains('stderr'));
|
||||
});
|
||||
|
|
|
@ -110,8 +110,7 @@ flutter:
|
|||
|
||||
''');
|
||||
|
||||
expect(() async => const CopyAssets().build(environment),
|
||||
throwsA(isA<Exception>()));
|
||||
expect(() async => const CopyAssets().build(environment), throwsException);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
|
@ -138,7 +137,7 @@ flutter:
|
|||
fileSystem: MemoryFileSystem.test(),
|
||||
logger: BufferLogger.test(),
|
||||
engineVersion: null,
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
});
|
||||
|
||||
testWithoutContext('processSkSLBundle throws exception if the bundle is not '
|
||||
|
@ -154,7 +153,7 @@ flutter:
|
|||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
engineVersion: null,
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
expect(logger.errorText, contains('was not a JSON object'));
|
||||
});
|
||||
|
||||
|
@ -171,7 +170,7 @@ flutter:
|
|||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
engineVersion: null,
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
expect(logger.errorText, contains('was not a JSON object'));
|
||||
});
|
||||
|
||||
|
@ -192,7 +191,7 @@ flutter:
|
|||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
engineVersion: '2',
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
expect(logger.errorText, contains('Expected Flutter 1, but found 2'));
|
||||
});
|
||||
|
||||
|
|
|
@ -104,8 +104,7 @@ void main() {
|
|||
], exitCode: 1),
|
||||
]);
|
||||
|
||||
await expectLater(() => const KernelSnapshot().build(androidEnvironment),
|
||||
throwsA(isA<Exception>()));
|
||||
await expectLater(() => const KernelSnapshot().build(androidEnvironment), throwsException);
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
|
@ -434,8 +433,7 @@ void main() {
|
|||
});
|
||||
|
||||
testUsingContext('AotAssemblyProfile throws error if built for non-iOS platform', () async {
|
||||
expect(const AotAssemblyProfile().build(androidEnvironment),
|
||||
throwsA(isA<Exception>()));
|
||||
expect(const AotAssemblyProfile().build(androidEnvironment), throwsException);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => macPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
|
|
|
@ -64,7 +64,7 @@ void main() {
|
|||
'a.txt',
|
||||
],
|
||||
clientSourcePaths: <String>['foo'],
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
});
|
||||
|
||||
testWithoutContext('unpackDesktopArtifacts throws when attempting to copy missing directory', () async {
|
||||
|
@ -79,7 +79,7 @@ void main() {
|
|||
'a.txt',
|
||||
],
|
||||
clientSourcePaths: <String>['foo'],
|
||||
), throwsA(isA<Exception>()));
|
||||
), throwsException);
|
||||
});
|
||||
|
||||
testWithoutContext('unpackDesktopArtifacts does not require a client source path', () async {
|
||||
|
|
|
@ -225,7 +225,7 @@ void main() {
|
|||
fileSystem: fileSystem,
|
||||
);
|
||||
|
||||
expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>()
|
||||
expect(const AotAssemblyRelease().build(environment), throwsA(isException
|
||||
.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
|
@ -254,13 +254,11 @@ void main() {
|
|||
environment.defines[kBuildMode] = 'release';
|
||||
environment.defines[kIosArchs] = 'x86_64';
|
||||
|
||||
expect(const AotAssemblyRelease().build(environment), throwsA(isA<Exception>()
|
||||
.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
expect(const AotAssemblyRelease().build(environment), throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('required define SdkRoot but it was not provided'),
|
||||
)
|
||||
));
|
||||
)));
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
|
@ -371,7 +369,7 @@ void main() {
|
|||
processManager.addCommand(copyPhysicalFrameworkCommand);
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Flutter.framework/Flutter does not exist, cannot thin'),
|
||||
|
@ -412,12 +410,13 @@ void main() {
|
|||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'),
|
||||
)));
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('does not contain arm64 armv7. Running lipo -info:\nArchitectures in the fat file:'),
|
||||
)),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('fails when lipo extract fails', () async {
|
||||
|
@ -466,11 +465,12 @@ void main() {
|
|||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to extract arm64 armv7 for output/Flutter.framework/Flutter.\nlipo error\nRunning lipo -info:\nArchitectures in the fat file:'),
|
||||
)));
|
||||
)),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('skips thin framework', () async {
|
||||
|
@ -581,12 +581,13 @@ void main() {
|
|||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'),
|
||||
)));
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to strip bitcode for output/Flutter.framework/Flutter.\nbitcode_strip error'),
|
||||
)),
|
||||
);
|
||||
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
@ -653,12 +654,13 @@ void main() {
|
|||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'),
|
||||
)));
|
||||
const DebugUnpackIOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('Failed to codesign output/Flutter.framework/Flutter with identity ABC123.\ncodesign error'),
|
||||
)),
|
||||
);
|
||||
|
||||
expect(processManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
|
|
@ -96,7 +96,7 @@ use-deferred-loading: string
|
|||
file: configFile,
|
||||
logger: BufferLogger.test(),
|
||||
),
|
||||
throwsA(isA<Exception>()),
|
||||
throwsException,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -105,12 +105,13 @@ void main() {
|
|||
testUsingContext('thinning fails when framework missing', () async {
|
||||
processManager.addCommand(copyFrameworkCommand);
|
||||
await expectLater(
|
||||
const DebugUnpackMacOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'),
|
||||
)));
|
||||
const DebugUnpackMacOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('FlutterMacOS.framework/FlutterMacOS does not exist, cannot thin'),
|
||||
)),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
|
@ -132,12 +133,13 @@ void main() {
|
|||
]);
|
||||
|
||||
await expectLater(
|
||||
const DebugUnpackMacOS().build(environment),
|
||||
throwsA(isA<Exception>().having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'),
|
||||
)));
|
||||
const DebugUnpackMacOS().build(environment),
|
||||
throwsA(isException.having(
|
||||
(Exception exception) => exception.toString(),
|
||||
'description',
|
||||
contains('does not contain arm64 x86_64. Running lipo -info:\nArchitectures in the fat file:'),
|
||||
)),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
|
|
|
@ -290,7 +290,7 @@ void main() {
|
|||
);
|
||||
await expectLater(
|
||||
() => cache.updateAll(<DevelopmentArtifact>{null}),
|
||||
throwsA(isA<Exception>()),
|
||||
throwsException,
|
||||
);
|
||||
verify(artifact1.update(any, any, any, any));
|
||||
// Don't continue when retrieval fails.
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
|
@ -336,7 +335,7 @@ void main() {
|
|||
);
|
||||
await expectLater(
|
||||
() async => deviceManager.findTargetDevices(FakeFlutterProject()),
|
||||
throwsA(isA<ToolExit>())
|
||||
throwsToolExit(),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -516,8 +516,8 @@ void main() {
|
|||
);
|
||||
when(mockXcdevice.isInstalled).thenReturn(false);
|
||||
expect(
|
||||
() async { await iosDevices.pollingGetDevices(); },
|
||||
throwsA(isA<UnsupportedError>()),
|
||||
() async { await iosDevices.pollingGetDevices(); },
|
||||
throwsUnsupportedError,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
() async => portDiscovery.query(),
|
||||
throwsA(isA<Exception>()),
|
||||
throwsException,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void main() {
|
|||
usage: TestUsage(),
|
||||
);
|
||||
|
||||
expect(() async => residentWebRunner.run(), throwsA(isA<Exception>()));
|
||||
expect(() async => residentWebRunner.run(), throwsException);
|
||||
expect(await residentWebRunner.waitForAppToFinish(), 1);
|
||||
}, overrides: <Type, Generator>{
|
||||
BuildSystem: () => TestBuildSystem.error(Exception('foo')),
|
||||
|
|
|
@ -212,7 +212,7 @@ void main() {
|
|||
);
|
||||
await expectLater(
|
||||
() => flutterCommand.run(),
|
||||
throwsA(isA<ToolExit>()),
|
||||
throwsToolExit(),
|
||||
);
|
||||
expect(usage.events, <TestUsageEvent>[
|
||||
const TestUsageEvent(
|
||||
|
@ -436,7 +436,7 @@ void main() {
|
|||
|
||||
await expectLater(
|
||||
() => flutterCommand.run(),
|
||||
throwsA(isA<ToolExit>()),
|
||||
throwsToolExit(),
|
||||
);
|
||||
expect(usage.timings, contains(
|
||||
const TestTimingEvent(
|
||||
|
|
|
@ -96,7 +96,7 @@ void main() {
|
|||
ProcessUtils: () => null,
|
||||
});
|
||||
|
||||
expect(() => testbed.run(() {}), throwsA(isA<StateError>()));
|
||||
expect(() => testbed.run(() {}), throwsStateError);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue