use isA<Xxx>() matcher (#48482)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
5eb394e084
commit
003541499b
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_driver/src/common/error.dart';
|
||||
import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
|
||||
import 'package:test_api/test_api.dart' as test_package show TypeMatcher; // ignore: deprecated_member_use
|
||||
|
||||
@@ -13,7 +14,7 @@ export 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignor
|
||||
// TODO(ianh): Clean this up once https://github.com/dart-lang/matcher/issues/98 is fixed
|
||||
|
||||
/// A matcher that compares the type of the actual value to the type argument T.
|
||||
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
|
||||
@@ -25,3 +26,6 @@ void tryToDelete(Directory directory) {
|
||||
print('Failed to delete ${directory.path}: $error');
|
||||
}
|
||||
}
|
||||
|
||||
/// Matcher for functions that throw [DriverError].
|
||||
final Matcher throwsDriverError = throwsA(isA<DriverError>());
|
||||
|
||||
@@ -145,8 +145,7 @@ void main() {
|
||||
|
||||
group('ByValueKey', () {
|
||||
test('restricts value types', () async {
|
||||
expect(() => find.byValueKey(null),
|
||||
throwsA(isInstanceOf<DriverError>()));
|
||||
expect(() => find.byValueKey(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('finds by ValueKey', () async {
|
||||
@@ -195,7 +194,7 @@ void main() {
|
||||
|
||||
group('tap', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.tap(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.tap(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the tap command', () async {
|
||||
@@ -214,7 +213,7 @@ void main() {
|
||||
|
||||
group('getText', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getText(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getText(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the getText command', () async {
|
||||
@@ -256,7 +255,7 @@ void main() {
|
||||
|
||||
group('waitFor', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.waitFor(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.waitFor(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the waitFor command', () async {
|
||||
@@ -379,11 +378,11 @@ void main() {
|
||||
|
||||
group('getOffset', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getCenter(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getTopLeft(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getTopRight(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getBottomLeft(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getBottomRight(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getCenter(null), throwsDriverError);
|
||||
expect(driver.getTopLeft(null), throwsDriverError);
|
||||
expect(driver.getTopRight(null), throwsDriverError);
|
||||
expect(driver.getBottomLeft(null), throwsDriverError);
|
||||
expect(driver.getBottomRight(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the getCenter command', () async {
|
||||
@@ -646,7 +645,7 @@ void main() {
|
||||
await driver.waitFor(find.byTooltip('foo'));
|
||||
fail('expected an exception');
|
||||
} catch (error) {
|
||||
expect(error is DriverError, isTrue);
|
||||
expect(error, isA<DriverError>());
|
||||
expect(error.message, 'Error in Flutter application: {message: This is a failure}');
|
||||
}
|
||||
});
|
||||
@@ -705,7 +704,7 @@ void main() {
|
||||
group('ByValueKey', () {
|
||||
test('restricts value types', () async {
|
||||
expect(() => find.byValueKey(null),
|
||||
throwsA(isInstanceOf<DriverError>()));
|
||||
throwsDriverError);
|
||||
});
|
||||
|
||||
test('finds by ValueKey', () async {
|
||||
@@ -757,7 +756,7 @@ void main() {
|
||||
|
||||
group('tap', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.tap(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.tap(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the tap command', () async {
|
||||
@@ -777,7 +776,7 @@ void main() {
|
||||
|
||||
group('getText', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getText(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getText(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the getText command', () async {
|
||||
@@ -801,7 +800,7 @@ void main() {
|
||||
|
||||
group('waitFor', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.waitFor(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.waitFor(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the waitFor command', () async {
|
||||
@@ -880,11 +879,11 @@ void main() {
|
||||
|
||||
group('getOffset', () {
|
||||
test('requires a target reference', () async {
|
||||
expect(driver.getCenter(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getTopLeft(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getTopRight(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getBottomLeft(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getBottomRight(null), throwsA(isInstanceOf<DriverError>()));
|
||||
expect(driver.getCenter(null), throwsDriverError);
|
||||
expect(driver.getTopLeft(null), throwsDriverError);
|
||||
expect(driver.getTopRight(null), throwsDriverError);
|
||||
expect(driver.getBottomLeft(null), throwsDriverError);
|
||||
expect(driver.getBottomRight(null), throwsDriverError);
|
||||
});
|
||||
|
||||
test('sends the getCenter command', () async {
|
||||
@@ -1002,27 +1001,27 @@ void main() {
|
||||
group('WebFlutterDriver Unimplemented error', () {
|
||||
test('forceGC', () async {
|
||||
expect(driver.forceGC(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
});
|
||||
|
||||
test('getVmFlags', () async {
|
||||
expect(driver.getVmFlags(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
});
|
||||
|
||||
test('waitUntilFirstFrameRasterized', () async {
|
||||
expect(driver.waitUntilFirstFrameRasterized(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
});
|
||||
|
||||
test('appIsoloate', () async {
|
||||
expect(() => driver.appIsolate.invokeExtension('abc', <String, String>{'abc': '123'}),
|
||||
throwsA(isInstanceOf<UnsupportedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
});
|
||||
|
||||
test('serviceClient', () async {
|
||||
expect(() => driver.serviceClient.getVM(),
|
||||
throwsA(isInstanceOf<UnsupportedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1038,13 +1037,13 @@ void main() {
|
||||
|
||||
test('tracing', () async {
|
||||
expect(driver.traceAction(() async { return Future<dynamic>.value(); }),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.startTracing(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.stopTracingAndDownloadTimeline(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
expect(driver.clearTimeline(),
|
||||
throwsA(isInstanceOf<UnimplementedError>()));
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1054,7 +1053,7 @@ void main() {
|
||||
/// script will be in the following format:
|
||||
// window.flutterDriver('[actual script]')
|
||||
String _checkAndEncode(dynamic script) {
|
||||
expect(script is String, isTrue);
|
||||
expect(script, isA<String>());
|
||||
expect(script.startsWith(_kWebScriptPrefix), isTrue);
|
||||
expect(script.endsWith(_kWebScriptSuffix), isTrue);
|
||||
// Strip prefix and suffix
|
||||
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
|
||||
test('io_extension should throw exception', () {
|
||||
expect(() => registerWebServiceExtension(call),
|
||||
throwsA(isInstanceOf<UnsupportedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user