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

@ -13,7 +13,7 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
// TODO(ianh): Remove this file 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

View File

@ -25,7 +25,7 @@ void main() {
expectAsync1((List<String> commandLine) async {
return processRunner.runProcess(commandLine);
})(<String>['this_executable_better_not_exist_2857632534321']),
throwsA(isInstanceOf<PreparePackageException>()));
throwsA(isA<PreparePackageException>()));
try {
await processRunner.runProcess(<String>['this_executable_better_not_exist_2857632534321']);
} on PreparePackageException catch (e) {
@ -64,7 +64,7 @@ void main() {
expectAsync1((List<String> commandLine) async {
return processRunner.runProcess(commandLine);
})(<String>['echo', 'test']),
throwsA(isInstanceOf<PreparePackageException>()));
throwsA(isA<PreparePackageException>()));
});
});
group('ArchiveCreator for $platformName', () {
@ -185,8 +185,7 @@ void main() {
'git reset --hard $testRef': <ProcessResult>[ProcessResult(0, -1, 'output2', '')],
};
processManager.fakeResults = calls;
expect(expectAsync0(creator.initializeRepo),
throwsA(isInstanceOf<PreparePackageException>()));
expect(expectAsync0(creator.initializeRepo), throwsA(isA<PreparePackageException>()));
});
test('non-strict mode calls the right commands', () async {

View File

@ -11,4 +11,4 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
// TODO(ianh): Remove this file 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>();

View File

@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher;
export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
/// 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>();

View File

@ -13,7 +13,7 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
// TODO(ianh): Remove this file 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

View File

@ -17,7 +17,7 @@ void main() {
test('parsePixels', () {
expect(parsePixels('23px'), 23);
expect(parsePixels('9px'), 9);
expect(() { parsePixels('9pt'); }, throwsA(isInstanceOf<ArgumentError>()));
expect(() { parsePixels('9pt'); }, throwsArgumentError);
});
test('parsePoints', () {

View File

@ -172,10 +172,10 @@ void main() {
final TickerFuture f = controller1.forward();
await tester.pump(); // start ticker
await tester.pump(const Duration(milliseconds: 200)); // end ticker
expect(f.asStream().single, isInstanceOf<Future<void>>());
expect(f.asStream().single, isA<Future<void>>());
await f.catchError((dynamic e) { throw 'do not reach'; });
expect(await f.then<bool>((_) => true), isTrue);
expect(f.whenComplete(() => false), isInstanceOf<Future<void>>());
expect(f.timeout(const Duration(seconds: 5)), isInstanceOf<Future<void>>());
expect(f.whenComplete(() => false), isA<Future<void>>());
expect(f.timeout(const Duration(seconds: 5)), isA<Future<void>>());
});
}

View File

@ -11,7 +11,7 @@ import 'package:test_api/test_api.dart' as test_package show TypeMatcher; // ign
export 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use
/// 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>();
/// Whether we are running in a web browser.
const bool isBrowser = identical(0, 0.0);

View File

@ -110,8 +110,7 @@ void main() {
});
when(response.contentLength).thenReturn(-1);
expect(consolidateHttpClientResponseBytes(response),
throwsA(isInstanceOf<Exception>()));
expect(consolidateHttpClientResponseBytes(response), throwsException);
});
test('Propagates error to Future return value if onBytesReceived throws', () async {

View File

@ -27,9 +27,9 @@ Future<int> test2Async(int value) async {
void main() {
test('compute()', () async {
expect(await compute(test1, 0), 1);
expect(compute(test2, 0), throwsA(isInstanceOf<Exception>()));
expect(compute(test2, 0), throwsException);
expect(await compute(test1Async, 0), 1);
expect(compute(test2Async, 0), throwsA(isInstanceOf<Exception>()));
expect(compute(test2Async, 0), throwsException);
});
}

View File

@ -17,7 +17,7 @@ void main() {
log.add('build');
expect(Theme.of(context).primaryColor, Colors.green);
expect(Directionality.of(context), TextDirection.ltr);
expect(child, isInstanceOf<Navigator>());
expect(child, isA<Navigator>());
return const Placeholder();
},
);

View File

@ -322,7 +322,7 @@ void main() {
),
);
final dynamic exception = tester.takeException();
expect(exception is String, isTrue);
expect(exception, isA<String>());
expect(exception.startsWith('Could not navigate to initial route.'), isTrue);
expect(find.text('route "/"'), findsOneWidget);
expect(find.text('route "/a"'), findsNothing);
@ -474,7 +474,7 @@ void main() {
color: const Color(0xFF112233),
home: const Placeholder(),
));
expect(key.currentState, isInstanceOf<NavigatorState>());
expect(key.currentState, isA<NavigatorState>());
await tester.pumpWidget(const MaterialApp(
color: Color(0xFF112233),
home: Placeholder(),
@ -485,7 +485,7 @@ void main() {
color: const Color(0xFF112233),
home: const Placeholder(),
));
expect(key.currentState, isInstanceOf<NavigatorState>());
expect(key.currentState, isA<NavigatorState>());
});
testWidgets('Has default material and cupertino localizations', (WidgetTester tester) async {

View File

@ -1449,7 +1449,7 @@ void main() {
),
),
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsAssertionError);
});
testWidgets(

View File

@ -184,7 +184,7 @@ void main() {
expect(lightTheme.secondarySelectedColor, equals(customColor1.withAlpha(0x3d)));
expect(lightTheme.labelPadding, equals(const EdgeInsets.symmetric(horizontal: 8.0)));
expect(lightTheme.padding, equals(const EdgeInsets.all(4.0)));
expect(lightTheme.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lightTheme.shape, isA<StadiumBorder>());
expect(lightTheme.labelStyle.color, equals(Colors.black.withAlpha(0xde)));
expect(lightTheme.secondaryLabelStyle.color, equals(customColor1.withAlpha(0xde)));
expect(lightTheme.brightness, equals(Brightness.light));
@ -202,7 +202,7 @@ void main() {
expect(darkTheme.secondarySelectedColor, equals(customColor1.withAlpha(0x3d)));
expect(darkTheme.labelPadding, equals(const EdgeInsets.symmetric(horizontal: 8.0)));
expect(darkTheme.padding, equals(const EdgeInsets.all(4.0)));
expect(darkTheme.shape, equals(isInstanceOf<StadiumBorder>()));
expect(darkTheme.shape, isA<StadiumBorder>());
expect(darkTheme.labelStyle.color, equals(Colors.white.withAlpha(0xde)));
expect(darkTheme.secondaryLabelStyle.color, equals(customColor1.withAlpha(0xde)));
expect(darkTheme.brightness, equals(Brightness.dark));
@ -220,7 +220,7 @@ void main() {
expect(customTheme.secondarySelectedColor, equals(customColor2.withAlpha(0x3d)));
expect(customTheme.labelPadding, equals(const EdgeInsets.symmetric(horizontal: 8.0)));
expect(customTheme.padding, equals(const EdgeInsets.all(4.0)));
expect(customTheme.shape, equals(isInstanceOf<StadiumBorder>()));
expect(customTheme.shape, isA<StadiumBorder>());
expect(customTheme.labelStyle.color, equals(customColor1.withAlpha(0xde)));
expect(customTheme.secondaryLabelStyle.color, equals(customColor2.withAlpha(0xde)));
expect(customTheme.brightness, equals(Brightness.light));
@ -263,7 +263,7 @@ void main() {
expect(lerp.selectedShadowColor, equals(middleGrey));
expect(lerp.labelPadding, equals(const EdgeInsets.all(4.0)));
expect(lerp.padding, equals(const EdgeInsets.all(3.0)));
expect(lerp.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lerp.shape, isA<StadiumBorder>());
expect(lerp.labelStyle.color, equals(middleGrey.withAlpha(0xde)));
expect(lerp.secondaryLabelStyle.color, equals(middleGrey.withAlpha(0xde)));
expect(lerp.brightness, equals(Brightness.light));
@ -283,7 +283,7 @@ void main() {
expect(lerpANull25.selectedShadowColor, equals(Colors.white.withAlpha(0x40)));
expect(lerpANull25.labelPadding, equals(const EdgeInsets.only(left: 0.0, top: 2.0, right: 0.0, bottom: 2.0)));
expect(lerpANull25.padding, equals(const EdgeInsets.all(0.5)));
expect(lerpANull25.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lerpANull25.shape, isA<StadiumBorder>());
expect(lerpANull25.labelStyle.color, equals(Colors.black.withAlpha(0x38)));
expect(lerpANull25.secondaryLabelStyle.color, equals(Colors.white.withAlpha(0x38)));
expect(lerpANull25.brightness, equals(Brightness.light));
@ -301,7 +301,7 @@ void main() {
expect(lerpANull75.selectedShadowColor, equals(Colors.white.withAlpha(0xbf)));
expect(lerpANull75.labelPadding, equals(const EdgeInsets.only(left: 0.0, top: 6.0, right: 0.0, bottom: 6.0)));
expect(lerpANull75.padding, equals(const EdgeInsets.all(1.5)));
expect(lerpANull75.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lerpANull75.shape, isA<StadiumBorder>());
expect(lerpANull75.labelStyle.color, equals(Colors.black.withAlpha(0xa7)));
expect(lerpANull75.secondaryLabelStyle.color, equals(Colors.white.withAlpha(0xa7)));
expect(lerpANull75.brightness, equals(Brightness.light));
@ -319,7 +319,7 @@ void main() {
expect(lerpBNull25.selectedShadowColor, equals(Colors.black.withAlpha(0xbf)));
expect(lerpBNull25.labelPadding, equals(const EdgeInsets.only(left: 6.0, top: 0.0, right: 6.0, bottom: 0.0)));
expect(lerpBNull25.padding, equals(const EdgeInsets.all(3.0)));
expect(lerpBNull25.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lerpBNull25.shape, isA<StadiumBorder>());
expect(lerpBNull25.labelStyle.color, equals(Colors.white.withAlpha(0xa7)));
expect(lerpBNull25.secondaryLabelStyle.color, equals(Colors.black.withAlpha(0xa7)));
expect(lerpBNull25.brightness, equals(Brightness.dark));
@ -337,7 +337,7 @@ void main() {
expect(lerpBNull75.selectedShadowColor, equals(Colors.black.withAlpha(0x40)));
expect(lerpBNull75.labelPadding, equals(const EdgeInsets.only(left: 2.0, top: 0.0, right: 2.0, bottom: 0.0)));
expect(lerpBNull75.padding, equals(const EdgeInsets.all(1.0)));
expect(lerpBNull75.shape, equals(isInstanceOf<StadiumBorder>()));
expect(lerpBNull75.shape, isA<StadiumBorder>());
expect(lerpBNull75.labelStyle.color, equals(Colors.white.withAlpha(0x38)));
expect(lerpBNull75.secondaryLabelStyle.color, equals(Colors.black.withAlpha(0x38)));
expect(lerpBNull75.brightness, equals(Brightness.light));

View File

@ -22,8 +22,8 @@ void main() {
'Card, Dialog, Drawer, or Scaffold.\n',
),
);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isInstanceOf<DiagnosticsBlock>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isA<DiagnosticsBlock>());
expect(error.toStringDeep(),
'FlutterError\n'
' No Material widget found.\n'
@ -60,8 +60,8 @@ void main() {
'add a Localization widget with a MaterialLocalizations delegate.\n',
),
);
expect(error.diagnostics[4], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[5], isInstanceOf<DiagnosticsBlock>());
expect(error.diagnostics[4], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics[5], isA<DiagnosticsBlock>());
expect(error.toStringDeep(),
'FlutterError\n'
' No MaterialLocalizations found.\n'
@ -97,8 +97,8 @@ void main() {
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
expect(error.diagnostics.length, 5);
expect(error.diagnostics[2], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[3], isInstanceOf<DiagnosticsBlock>());
expect(error.diagnostics[2], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics[3], isA<DiagnosticsBlock>());
expect(error.diagnostics[4].level, DiagnosticLevel.hint);
expect(
error.diagnostics[4].toStringDeep(),

View File

@ -1047,7 +1047,7 @@ PhysicalModelLayer _findPhysicalLayer(Element element) {
object = object.parent as RenderObject;
}
expect(object.debugLayer, isNotNull);
expect(object.debugLayer.firstChild, isInstanceOf<PhysicalModelLayer>());
expect(object.debugLayer.firstChild, isA<PhysicalModelLayer>());
final PhysicalModelLayer layer = object.debugLayer.firstChild as PhysicalModelLayer;
final Layer child = layer.firstChild;
return child is PhysicalModelLayer ? child : layer;

View File

@ -470,7 +470,7 @@ void main() {
await tester.pumpAndSettle();
// An exception should've been thrown because the `builder` returned null.
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.toStringDeep(), equalsIgnoringHashCodes(
'FlutterError\n'
' The builder for route "broken" returned null.\n'

View File

@ -164,7 +164,7 @@ void main() {
// the column overflows because we're forcing it to 600 pixels high
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), startsWith('A RenderFlex overflowed by '));
@ -252,7 +252,7 @@ void main() {
));
// the column overflows because we're forcing it to 600 pixels high
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), contains('A RenderFlex overflowed by'));

View File

@ -345,7 +345,7 @@ void main() {
icon: const Icon(Icons.view_carousel),
itemBuilder: simplePopupMenuItemBuilder,
);
}, throwsA(isInstanceOf<AssertionError>()));
}, throwsAssertionError);
});
testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async {

View File

@ -1824,7 +1824,7 @@ void main() {
'the ScaffoldState rather than using the Scaffold.of() function.\n',
),
);
expect(error.diagnostics[4], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isA<DiagnosticsProperty<Element>>());
expect(error.toStringDeep(),
'FlutterError\n'
' Scaffold.of() called with a context that does not contain a\n'
@ -1893,7 +1893,7 @@ void main() {
'Scaffold.geometryOf().\n',
),
);
expect(error.diagnostics[4], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isA<DiagnosticsProperty<Element>>());
expect(error.toStringDeep(),
'FlutterError\n'
' Scaffold.geometryOf() called with a context that does not contain\n'

View File

@ -502,7 +502,7 @@ void main() {
);
expect(
const BorderDirectional(start: magenta3) + const BorderDirectional(start: yellow2),
isNot(isInstanceOf<BorderDirectional>()), // see shape_border_test.dart for better tests of this case
isNot(isA<BorderDirectional>()), // see shape_border_test.dart for better tests of this case
);
const BorderDirectional b3 = BorderDirectional(top: magenta3);
const BorderDirectional b6 = BorderDirectional(top: magenta6);

View File

@ -97,7 +97,7 @@ void main() {
);
expect(
const Border(left: magenta3) + const Border(left: yellow2),
isNot(isInstanceOf<Border>()), // see shape_border_test.dart for better tests of this case
isNot(isA<Border>()), // see shape_border_test.dart for better tests of this case
);
const Border b3 = Border(top: magenta3);
const Border b6 = Border(top: magenta6);

View File

@ -223,10 +223,10 @@ void main() {
final Invocation call = canvas.invocations.singleWhere((Invocation call) => call.memberName == #drawImageNine);
expect(call.isMethod, isTrue);
expect(call.positionalArguments, hasLength(4));
expect(call.positionalArguments[0], isInstanceOf<TestImage>());
expect(call.positionalArguments[0], isA<TestImage>());
expect(call.positionalArguments[1], const Rect.fromLTRB(10.0, 20.0, 40.0, 60.0));
expect(call.positionalArguments[2], const Rect.fromLTRB(0.0, 0.0, 100.0, 100.0));
expect(call.positionalArguments[3], isInstanceOf<Paint>());
expect(call.positionalArguments[3], isA<Paint>());
expect(call.positionalArguments[3].isAntiAlias, false);
expect(call.positionalArguments[3].colorFilter, colorFilter);
expect(call.positionalArguments[3].filterQuality, FilterQuality.low);
@ -253,8 +253,8 @@ void main() {
}
expect(error, isNotNull);
expect(error.diagnostics.length, 4);
expect(error.diagnostics[2], isInstanceOf<DiagnosticsProperty<DecorationImage>>());
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<ImageConfiguration>>());
expect(error.diagnostics[2], isA<DiagnosticsProperty<DecorationImage>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<ImageConfiguration>>());
expect(error.toStringDeep(),
'FlutterError\n'
' DecorationImage.matchTextDirection can only be used when a\n'
@ -375,10 +375,10 @@ void main() {
});
test('Decoration.lerp with unrelated decorations', () {
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.0), isInstanceOf<FlutterLogoDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.25), isInstanceOf<FlutterLogoDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.75), isInstanceOf<BoxDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 1.0), isInstanceOf<BoxDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.0), isA<FlutterLogoDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.25), isA<FlutterLogoDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.75), isA<BoxDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 1.0), isA<BoxDecoration>()); // ignore: CONST_EVAL_THROWS_EXCEPTION
});
test('paintImage BoxFit.none scale test', () {
@ -406,7 +406,7 @@ void main() {
expect(call.isMethod, isTrue);
expect(call.positionalArguments, hasLength(4));
expect(call.positionalArguments[0], isInstanceOf<TestImage>());
expect(call.positionalArguments[0], isA<TestImage>());
// sourceRect should contain all pixels of the source image
expect(call.positionalArguments[1], Offset.zero & imageSize);
@ -420,7 +420,7 @@ void main() {
);
expect(call.positionalArguments[2], expectedTileRect);
expect(call.positionalArguments[3], isInstanceOf<Paint>());
expect(call.positionalArguments[3], isA<Paint>());
}
});
@ -450,7 +450,7 @@ void main() {
expect(call.isMethod, isTrue);
expect(call.positionalArguments, hasLength(4));
expect(call.positionalArguments[0], isInstanceOf<TestImage>());
expect(call.positionalArguments[0], isA<TestImage>());
// sourceRect should contain all pixels of the source image
expect(call.positionalArguments[1], Offset.zero & imageSize);
@ -464,7 +464,7 @@ void main() {
);
expect(call.positionalArguments[2], expectedTileRect);
expect(call.positionalArguments[3], isInstanceOf<Paint>());
expect(call.positionalArguments[3], isA<Paint>());
}
});
@ -493,7 +493,7 @@ void main() {
expect(call.isMethod, isTrue);
expect(call.positionalArguments, hasLength(4));
expect(call.positionalArguments[0], isInstanceOf<TestImage>());
expect(call.positionalArguments[0], isA<TestImage>());
// sourceRect should contain all pixels of the source image
expect(call.positionalArguments[1], Offset.zero & imageSize);
@ -507,7 +507,7 @@ void main() {
);
expect(call.positionalArguments[2], expectedTileRect);
expect(call.positionalArguments[3], isInstanceOf<Paint>());
expect(call.positionalArguments[3], isA<Paint>());
});
test('paintImage boxFit, scale and alignment test', () {

View File

@ -175,7 +175,7 @@ void main() {
test('EdgeInsetsGeometry operators', () {
final EdgeInsetsGeometry a = const EdgeInsetsDirectional.fromSTEB(1.0, 2.0, 3.0, 5.0).add(EdgeInsets.zero);
expect(a, isNot(isInstanceOf<EdgeInsetsDirectional>()));
expect(a, isNot(isA<EdgeInsetsDirectional>()));
expect(a * 2.0, const EdgeInsetsDirectional.fromSTEB(2.0, 4.0, 6.0, 10.0));
expect(a / 2.0, const EdgeInsetsDirectional.fromSTEB(0.5, 1.0, 1.5, 2.5));
expect(a % 2.0, const EdgeInsetsDirectional.fromSTEB(1.0, 0.0, 1.0, 1.0));

View File

@ -133,7 +133,7 @@ void main() {
test('Returns null if an error is caught resolving an image', () {
final ErrorImageProvider errorImage = ErrorImageProvider();
expect(() => imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null)), throwsA(isInstanceOf<Error>()));
expect(() => imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null)), throwsA(isA<Error>()));
bool caughtError = false;
final ImageStreamCompleter result = imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null), onError: (dynamic error, StackTrace stackTrace) {
caughtError = true;

View File

@ -11,7 +11,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:test_api/test_api.dart' show TypeMatcher; // ignore: deprecated_member_use
import '../rendering/rendering_tester.dart';
import 'image_data.dart';
@ -182,7 +181,7 @@ void main() {
final dynamic err = await caughtError.future;
expect(
err,
const TypeMatcher<NetworkImageLoadException>()
isA<NetworkImageLoadException>()
.having((NetworkImageLoadException e) => e.statusCode, 'statusCode', errorStatusCode)
.having((NetworkImageLoadException e) => e.uri, 'uri', Uri.base.resolve(requestUrl)),
);

View File

@ -4,7 +4,8 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart';
import 'package:flutter_test/flutter_test.dart';
import 'rendering_tester.dart';
void main() {
@ -113,7 +114,7 @@ void main() {
errors.addAll(renderer.takeAllFlutterErrorDetails());
});
expect(errors, hasLength(2));
expect(errors.first.exception, isA<FlutterError>());
expect(errors.first.exception, isFlutterError);
expect(errors.first.exception.toStringDeep(),
'FlutterError\n'
' RenderAspectRatio has unbounded constraints.\n'

View File

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'package:flutter/rendering.dart';
import '../flutter_test_alternative.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('BoxConstraints toString', () {
@ -153,9 +153,9 @@ void main() {
minHeight: 20.0,
maxHeight: 30.0,
);
expect(() => BoxConstraints.lerp(constraints1, constraints2, 0.5), throwsA(isInstanceOf<AssertionError>()));
expect(() => BoxConstraints.lerp(constraints1, constraints3, 0.5), throwsA(isInstanceOf<AssertionError>()));
expect(() => BoxConstraints.lerp(constraints2, constraints3, 0.5), throwsA(isInstanceOf<AssertionError>()));
expect(() => BoxConstraints.lerp(constraints1, constraints2, 0.5), throwsAssertionError);
expect(() => BoxConstraints.lerp(constraints1, constraints3, 0.5), throwsAssertionError);
expect(() => BoxConstraints.lerp(constraints2, constraints3, 0.5), throwsAssertionError);
});
test('BoxConstraints normalize', () {

View File

@ -34,7 +34,7 @@ void main() {
);
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), startsWith('A RenderUnconstrainedBox overflowed by '));
expect(find.byType(UnconstrainedBox), paints..rect());

View File

@ -388,7 +388,7 @@ void main() {
exceptions.addAll(renderer.takeAllFlutterExceptions());
});
expect(exceptions, isNotEmpty);
expect(exceptions.first, isInstanceOf<FlutterError>());
expect(exceptions.first, isFlutterError);
});
test('MainAxisSize.min inside unconstrained', () {
@ -416,7 +416,7 @@ void main() {
exceptions.addAll(renderer.takeAllFlutterExceptions());
});
expect(exceptions, isNotEmpty);
expect(exceptions.first, isInstanceOf<FlutterError>());
expect(exceptions.first, isFlutterError);
});
test('MainAxisSize.min inside tightly constrained', () {

View File

@ -148,7 +148,7 @@ void _testPaintingContextLayerReuse<L extends Layer>(_LayerTestPaintCallback pai
box.markNeedsPaint();
pumpFrame(phase: EnginePhase.paint);
expect(box.paintedLayers, hasLength(2));
expect(box.paintedLayers[0], isInstanceOf<L>());
expect(box.paintedLayers[0], isA<L>());
expect(box.paintedLayers[0], same(box.paintedLayers[1]));
}

View File

@ -490,7 +490,7 @@ void _testLayerReuse<L extends Layer>(RenderBox renderObject) {
expect(renderObject.debugLayer, null);
layout(renderObject, phase: EnginePhase.paint, constraints: BoxConstraints.tight(const Size(10, 10)));
final Layer layer = renderObject.debugLayer;
expect(layer, isInstanceOf<L>());
expect(layer, isA<L>());
expect(layer, isNotNull);
// Mark for repaint otherwise pumpFrame is a noop.

View File

@ -60,7 +60,7 @@ void main() {
child: repaintBoundary,
);
layout(opacity, phase: EnginePhase.flushSemantics);
expect(repaintBoundary.debugLayer, isInstanceOf<OffsetLayer>());
expect(repaintBoundary.debugLayer, isA<OffsetLayer>());
});
test('Framework does not create an OffsetLayer for a non-repaint boundary', () {
@ -80,7 +80,7 @@ void main() {
child: compositedBox,
);
layout(opacity, phase: EnginePhase.flushSemantics);
expect(compositedBox.debugLayer, isInstanceOf<OpacityLayer>());
expect(compositedBox.debugLayer, isA<OpacityLayer>());
});
test('Framework ensures repaint boundary layer is not overwritten', () {

View File

@ -33,7 +33,7 @@ void main() {
}
expect(error, isNotNull);
expect(error.diagnostics.length, 3);
expect(error.diagnostics.last, isInstanceOf<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics.last, isA<DiagnosticsProperty<Ticker>>());
expect(
error.toStringDeep(),
startsWith(

View File

@ -68,7 +68,7 @@ void main() {
}
expect(error, isNotNull);
expect(error.diagnostics.length, 2);
expect(error.diagnostics.last, isInstanceOf<IntProperty>());
expect(error.diagnostics.last, isA<IntProperty>());
expect(
error.toStringDeep(),
'FlutterError\n'

View File

@ -70,7 +70,7 @@ void main() {
}
},
);
expect(channel.invokeMethod<List<String>>('sayHello', 'hello'), throwsA(isInstanceOf<CastError>()));
expect(channel.invokeMethod<List<String>>('sayHello', 'hello'), throwsA(isCastError));
expect(await channel.invokeListMethod<String>('sayHello', 'hello'), <String>['hello', 'world']);
});
@ -102,7 +102,7 @@ void main() {
}
},
);
expect(channel.invokeMethod<Map<String, String>>('sayHello', 'hello'), throwsA(isInstanceOf<CastError>()));
expect(channel.invokeMethod<Map<String, String>>('sayHello', 'hello'), throwsA(isCastError));
expect(await channel.invokeMapMethod<String, String>('sayHello', 'hello'), <String, String>{'hello': 'world'});
});
@ -292,7 +292,7 @@ void main() {
await Future<void>.delayed(Duration.zero);
expect(events, isEmpty);
expect(errors, hasLength(1));
expect(errors[0], isInstanceOf<PlatformException>());
expect(errors[0], isA<PlatformException>());
final PlatformException error = errors[0] as PlatformException;
expect(error.code, '404');
expect(error.message, 'Not Found.');

View File

@ -27,7 +27,7 @@ void main() {
layoutDirection: TextDirection.ltr,
).setSize(const Size(100.0, 100.0));
},
throwsA(isInstanceOf<PlatformException>()),
throwsA(isA<PlatformException>()),
);
});
@ -55,7 +55,7 @@ void main() {
expect(
() => PlatformViewsService.initAndroidView(
id: 0, viewType: 'web', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)),
throwsA(isInstanceOf<PlatformException>()));
throwsA(isA<PlatformException>()));
});
test('dispose Android view', () async {
@ -170,7 +170,7 @@ void main() {
layoutDirection: TextDirection.ltr,
);
},
throwsA(isInstanceOf<PlatformException>()),
throwsA(isA<PlatformException>()),
);
});
@ -199,7 +199,7 @@ void main() {
expect(
() => PlatformViewsService.initUiKitView(
id: 0, viewType: 'web', layoutDirection: TextDirection.ltr),
throwsA(isInstanceOf<PlatformException>()),
throwsA(isA<PlatformException>()),
);
});
@ -228,7 +228,7 @@ void main() {
() async {
await viewController.dispose();
},
throwsA(isInstanceOf<PlatformException>()),
throwsA(isA<PlatformException>()),
);
});
});

View File

@ -344,7 +344,7 @@ void main() {
'https://api.flutter.dev/flutter/widgets/AnimatedListState-class.html\n'
),
);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Element>>());
expect(
error.toStringDeep(),
equalsIgnoringHashCodes(

View File

@ -262,7 +262,7 @@ void main() {
expect(find.byType(Column), findsOneWidget);
for (final Widget child in foundChildren) {
expect(child, isInstanceOf<KeyedSubtree>());
expect(child, isA<KeyedSubtree>());
}
await tester.pumpWidget(
@ -280,7 +280,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 50));
for (final Widget child in foundChildren) {
expect(child, isInstanceOf<KeyedSubtree>());
expect(child, isA<KeyedSubtree>());
expect(
find.descendant(of: find.byWidget(child), matching: find.byType(SizeTransition)),
findsOneWidget,
@ -430,7 +430,7 @@ void main() {
expect(foundChildren.length, equals(3));
for (final Widget child in foundChildren) {
expect(child, isInstanceOf<KeyedSubtree>());
expect(child, isA<KeyedSubtree>());
expect(
find.descendant(of: find.byWidget(child), matching: find.byType(FadeTransition)),
findsOneWidget,
@ -460,7 +460,7 @@ void main() {
expect(foundChildren.length, equals(3));
for (final Widget child in foundChildren) {
expect(child, isInstanceOf<KeyedSubtree>());
expect(child, isA<KeyedSubtree>());
expect(
find.descendant(of: find.byWidget(child), matching: find.byType(ScaleTransition)),
findsOneWidget,

View File

@ -20,7 +20,7 @@ void main() {
color: const Color(0xFF112233),
onGenerateRoute: generateRoute,
));
expect(key.currentState, isInstanceOf<NavigatorState>());
expect(key.currentState, isA<NavigatorState>());
await tester.pumpWidget(WidgetsApp(
color: const Color(0xFF112233),
onGenerateRoute: generateRoute,
@ -31,6 +31,6 @@ void main() {
color: const Color(0xFF112233),
onGenerateRoute: generateRoute,
));
expect(key.currentState, isInstanceOf<NavigatorState>());
expect(key.currentState, isA<NavigatorState>());
});
}

View File

@ -74,7 +74,7 @@ void main() {
} finally {
expect(error, isNotNull);
expect(error.diagnostics.length, 4);
expect(error.diagnostics[2], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[2], isA<DiagnosticsProperty<Element>>());
expect(
error.toStringDeep(),
equalsIgnoringHashCodes(
@ -106,7 +106,7 @@ void main() {
} finally {
expect(error, isNotNull);
expect(error.diagnostics.length, 5);
expect(error.diagnostics[2], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[2], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics.last.level, DiagnosticLevel.hint);
expect(
error.diagnostics.last.toStringDeep(),
@ -147,7 +147,7 @@ void main() {
} finally {
expect(error, isNotNull);
expect(error.diagnostics.length, 4);
expect(error.diagnostics[1], isInstanceOf<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[1], isA<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[1].style, DiagnosticsTreeStyle.errorProperty);
expect(
error.diagnostics[1].toStringDeep(),
@ -190,7 +190,7 @@ void main() {
} finally {
expect(error, isNotNull);
expect(error.diagnostics.length, 3);
expect(error.diagnostics[1], isInstanceOf<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[1], isA<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[1].style, DiagnosticsTreeStyle.errorProperty);
expect(
error.diagnostics[1].toStringDeep(),

View File

@ -150,9 +150,9 @@ void main() {
ContainerLayer layer = RendererBinding.instance.renderView.debugLayer;
while (layer != null && layer is! OpacityLayer)
layer = layer.firstChild as ContainerLayer;
expect(layer, isInstanceOf<OpacityLayer>());
expect(layer, isA<OpacityLayer>());
final OpacityLayer opacityLayer = layer as OpacityLayer;
expect(opacityLayer.alpha, equals(opacity * 255));
expect(layer.firstChild, isInstanceOf<TransformLayer>());
expect(layer.firstChild, isA<TransformLayer>());
});
}

View File

@ -543,7 +543,7 @@ Future<void> main() async {
final FlutterError error = exception as FlutterError;
expect(error.diagnostics.length, 3);
final DiagnosticsNode last = error.diagnostics.last;
expect(last, isInstanceOf<DiagnosticsProperty<StatefulElement>>());
expect(last, isA<DiagnosticsProperty<StatefulElement>>());
expect(
last.toStringDeep(),
equalsIgnoringHashCodes(

View File

@ -1101,14 +1101,14 @@ void main() {
expect(find.byType(Center), findsOneWidget);
expect(find.byType(Padding), findsOneWidget);
expect(find.byType(RawImage), findsOneWidget);
expect(tester.widget<Padding>(find.byType(Padding)).child, isInstanceOf<RawImage>());
expect(tester.widget<Padding>(find.byType(Padding)).child, isA<RawImage>());
streamCompleter.setData(chunkEvent: const ImageChunkEvent(cumulativeBytesLoaded: 10, expectedTotalBytes: 100));
await tester.pump();
expect(find.byType(Center), findsOneWidget);
expect(find.byType(Padding), findsOneWidget);
expect(find.byType(RawImage), findsOneWidget);
expect(tester.widget<Center>(find.byType(Center)).child, isInstanceOf<Padding>());
expect(tester.widget<Padding>(find.byType(Padding)).child, isInstanceOf<RawImage>());
expect(tester.widget<Center>(find.byType(Center)).child, isA<Padding>());
expect(tester.widget<Padding>(find.byType(Padding)).child, isA<RawImage>());
}, skip: isBrowser);
testWidgets('Image state handles loadingBuilder update from null to non-null', (WidgetTester tester) async {

View File

@ -25,7 +25,7 @@ void main() {
expect(exception ,isFlutterError);
final FlutterError error = exception as FlutterError;
expect(error.diagnostics.length, 3);
expect(error.diagnostics.last, isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics.last, isA<DiagnosticsProperty<Element>>());
expect(
error.toStringDeep(),
equalsIgnoringHashCodes(

View File

@ -13,12 +13,12 @@ void checkTree(WidgetTester tester, List<BoxDecoration> expectedDecorations) {
(Element element) => element is MultiChildRenderObjectElement
));
expect(element, isNotNull);
expect(element.renderObject is RenderStack, isTrue);
expect(element.renderObject, isA<RenderStack>());
final RenderStack renderObject = element.renderObject as RenderStack;
try {
RenderObject child = renderObject.firstChild;
for (final BoxDecoration decoration in expectedDecorations) {
expect(child is RenderDecoratedBox, isTrue);
expect(child, isA<RenderDecoratedBox>());
final RenderDecoratedBox decoratedBox = child as RenderDecoratedBox;
expect(decoratedBox.decoration, equals(decoration));
final StackParentData decoratedBoxParentData = decoratedBox.parentData as StackParentData;

View File

@ -155,7 +155,7 @@ void main() {
);
await tester.pumpWidget(widget);
await tester.tap(find.byKey(targetKey));
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect('$exception', startsWith('Navigator operation requested with a context'));
});
@ -1027,7 +1027,7 @@ void main() {
);
final dynamic exception = tester.takeException();
expect(exception is String, isTrue);
expect(exception, isA<String>());
expect(exception.startsWith('Could not navigate to initial route.'), isTrue);
// Only the root route should've been pushed.
@ -1048,7 +1048,7 @@ void main() {
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
expect(error, isNotNull);
expect(error.diagnostics.last, isInstanceOf<DiagnosticsProperty<NavigatorState>>());
expect(error.diagnostics.last, isA<DiagnosticsProperty<NavigatorState>>());
expect(
error.toStringDeep(),
equalsIgnoringHashCodes(
@ -1075,7 +1075,7 @@ void main() {
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
expect(error, isNotNull);
expect(error.diagnostics.last, isInstanceOf<DiagnosticsProperty<NavigatorState>>());
expect(error.diagnostics.last, isA<DiagnosticsProperty<NavigatorState>>());
expect(
error.toStringDeep(),
equalsIgnoringHashCodes(

View File

@ -634,9 +634,9 @@ void main() {
'The most common way to add an Overlay to an application is to\n'
'include a MaterialApp or Navigator widget in the runApp() call.\n',
));
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Widget>>());
expect(error.diagnostics[3].value, debugRequiredFor);
expect(error.diagnostics[4], isInstanceOf<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isA<DiagnosticsProperty<Element>>());
expect(error.toStringDeep(), equalsIgnoringHashCodes(
'FlutterError\n'
' No Overlay widget found.\n'

View File

@ -22,14 +22,14 @@ void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) {
find.byElementPredicate((Element element) => element is MultiChildRenderObjectElement)
);
expect(element, isNotNull);
expect(element.renderObject is RenderStack, isTrue);
expect(element.renderObject, isA<RenderStack>());
final RenderStack renderObject = element.renderObject as RenderStack;
try {
RenderObject child = renderObject.firstChild;
for (final TestParentData expected in expectedParentData) {
expect(child is RenderDecoratedBox, isTrue);
expect(child, isA<RenderDecoratedBox>());
final RenderDecoratedBox decoratedBox = child as RenderDecoratedBox;
expect(decoratedBox.parentData is StackParentData, isTrue);
expect(decoratedBox.parentData, isA<StackParentData>());
final StackParentData parentData = decoratedBox.parentData as StackParentData;
expect(parentData.top, equals(expected.top));
expect(parentData.right, equals(expected.right));

View File

@ -105,7 +105,7 @@ void main() {
);
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), startsWith('A RenderFlex overflowed by '));
await expectLater(

View File

@ -128,7 +128,7 @@ void main() {
);
final Layer textureParentLayer = tester.layers[tester.layers.length - 2];
expect(textureParentLayer, isInstanceOf<ClipRectLayer>());
expect(textureParentLayer, isA<ClipRectLayer>());
final ClipRectLayer clipRect = textureParentLayer as ClipRectLayer;
expect(clipRect.clipRect, const Rect.fromLTWH(0.0, 0.0, 100.0, 50.0));
expect(

View File

@ -52,7 +52,7 @@ void main() {
SingleChildRenderObjectElement element =
tester.element(find.byElementType(SingleChildRenderObjectElement));
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox;
expect(renderObject.decoration, equals(kBoxDecorationA));
expect(renderObject.position, equals(DecorationPosition.background));
@ -60,7 +60,7 @@ void main() {
await tester.pumpWidget(DecoratedBox(decoration: kBoxDecorationB));
element = tester.element(find.byElementType(SingleChildRenderObjectElement));
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
renderObject = element.renderObject as RenderDecoratedBox;
expect(renderObject.decoration, equals(kBoxDecorationB));
expect(renderObject.position, equals(DecorationPosition.background));
@ -72,12 +72,12 @@ void main() {
final SingleChildRenderObjectElement element =
tester.firstElement(find.byElementType(SingleChildRenderObjectElement));
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
final RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox;
expect(renderObject.decoration, equals(kBoxDecorationA));
expect(renderObject.position, equals(DecorationPosition.background));
expect(renderObject.child, isNotNull);
expect(renderObject.child is RenderDecoratedBox, isTrue);
expect(renderObject.child, isA<RenderDecoratedBox>());
final RenderDecoratedBox child = renderObject.child as RenderDecoratedBox;
expect(child.decoration, equals(kBoxDecorationB));
expect(child.position, equals(DecorationPosition.background));
@ -88,7 +88,7 @@ void main() {
final SingleChildRenderObjectElement element =
tester.element(find.byElementType(SingleChildRenderObjectElement));
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
final RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox;
expect(renderObject.decoration, equals(kBoxDecorationA));
expect(renderObject.position, equals(DecorationPosition.background));
@ -164,12 +164,12 @@ void main() {
SingleChildRenderObjectElement element =
tester.firstElement(find.byElementType(SingleChildRenderObjectElement));
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
final RenderDecoratedBox parent = element.renderObject as RenderDecoratedBox;
expect(parent.child is RenderDecoratedBox, isTrue);
expect(parent.child, isA<RenderDecoratedBox>());
final RenderDecoratedBox child = parent.child as RenderDecoratedBox;
expect(child.decoration, equals(kBoxDecorationB));
expect(child.child is RenderDecoratedBox, isTrue);
expect(child.child, isA<RenderDecoratedBox>());
final RenderDecoratedBox grandChild = child.child as RenderDecoratedBox;
expect(grandChild.decoration, equals(kBoxDecorationC));
expect(grandChild.child, isNull);
@ -180,7 +180,7 @@ void main() {
element =
tester.element(find.byElementType(SingleChildRenderObjectElement));
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
expect(element.renderObject, equals(parent));
expect(parent.child, isNull);

View File

@ -48,7 +48,7 @@ class TestRoute extends Route<String> with LocalHistoryRoute<String> {
@override
void didReplace(Route<dynamic> oldRoute) {
expect(oldRoute, isInstanceOf<TestRoute>());
expect(oldRoute, isA<TestRoute>());
final TestRoute castRoute = oldRoute as TestRoute;
log('didReplace ${castRoute.name}');
super.didReplace(castRoute);
@ -65,7 +65,7 @@ class TestRoute extends Route<String> with LocalHistoryRoute<String> {
@override
void didPopNext(Route<dynamic> nextRoute) {
expect(nextRoute, isInstanceOf<TestRoute>());
expect(nextRoute, isA<TestRoute>());
final TestRoute castRoute = nextRoute as TestRoute;
log('didPopNext ${castRoute.name}');
super.didPopNext(castRoute);
@ -73,7 +73,7 @@ class TestRoute extends Route<String> with LocalHistoryRoute<String> {
@override
void didChangeNext(Route<dynamic> nextRoute) {
expect(nextRoute, anyOf(isNull, isInstanceOf<TestRoute>()));
expect(nextRoute, anyOf(isNull, isA<TestRoute>()));
final TestRoute castRoute = nextRoute as TestRoute;
log('didChangeNext ${castRoute?.name}');
super.didChangeNext(castRoute);

View File

@ -47,7 +47,7 @@ void main() {
expect(behavior, isNotNull);
expect(behavior.flag, isTrue);
expect(position.physics, isInstanceOf<ClampingScrollPhysics>());
expect(position.physics, isA<ClampingScrollPhysics>());
ScrollMetrics metrics = position.copyWith();
expect(metrics.extentAfter, equals(400.0));
expect(metrics.viewportDimension, equals(600.0));
@ -62,7 +62,7 @@ void main() {
expect(behavior, isNotNull);
expect(behavior.flag, isFalse);
expect(position.physics, isInstanceOf<BouncingScrollPhysics>());
expect(position.physics, isA<BouncingScrollPhysics>());
// Regression test for https://github.com/flutter/flutter/issues/5856
metrics = position.copyWith();
expect(metrics.extentAfter, equals(400.0));

View File

@ -24,7 +24,7 @@ void main() {
final TestGesture gesture = await tester.startGesture(const Offset(100.0, 100.0));
await tester.pump(const Duration(seconds: 1));
expect(notification, isInstanceOf<ScrollStartNotification>());
expect(notification, isA<ScrollStartNotification>());
expect(notification.depth, equals(0));
final ScrollStartNotification start = notification as ScrollStartNotification;
expect(start.dragDetails, isNotNull);
@ -32,7 +32,7 @@ void main() {
await gesture.moveBy(const Offset(-10.0, -10.0));
await tester.pump(const Duration(seconds: 1));
expect(notification, isInstanceOf<ScrollUpdateNotification>());
expect(notification, isA<ScrollUpdateNotification>());
expect(notification.depth, equals(0));
final ScrollUpdateNotification update = notification as ScrollUpdateNotification;
expect(update.dragDetails, isNotNull);
@ -41,7 +41,7 @@ void main() {
await gesture.up();
await tester.pump(const Duration(seconds: 1));
expect(notification, isInstanceOf<ScrollEndNotification>());
expect(notification, isA<ScrollEndNotification>());
expect(notification.depth, equals(0));
final ScrollEndNotification end = notification as ScrollEndNotification;
expect(end.dragDetails, isNotNull);

View File

@ -239,10 +239,10 @@ void main() {
} finally {
expect(error, isNotNull);
expect(error.diagnostics.length, 4);
expect(error.diagnostics[2], isInstanceOf<DiagnosticsProperty<ScrollPhysics>>());
expect(error.diagnostics[2], isA<DiagnosticsProperty<ScrollPhysics>>());
expect(error.diagnostics[2].style, DiagnosticsTreeStyle.errorProperty);
expect(error.diagnostics[2].value, physics);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<ScrollMetrics>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<ScrollMetrics>>());
expect(error.diagnostics[3].style, DiagnosticsTreeStyle.errorProperty);
expect(error.diagnostics[3].value, position);
// RegExp matcher is required here due to flutter web and flutter mobile generating

View File

@ -326,22 +326,22 @@ void main() {
testWidgets('Primary ListViews are always scrollable', (WidgetTester tester) async {
final ListView view = ListView(primary: true);
expect(view.physics, isInstanceOf<AlwaysScrollableScrollPhysics>());
expect(view.physics, isA<AlwaysScrollableScrollPhysics>());
});
testWidgets('Non-primary ListViews are not always scrollable', (WidgetTester tester) async {
final ListView view = ListView(primary: false);
expect(view.physics, isNot(isInstanceOf<AlwaysScrollableScrollPhysics>()));
expect(view.physics, isNot(isA<AlwaysScrollableScrollPhysics>()));
});
testWidgets('Defaulting-to-primary ListViews are always scrollable', (WidgetTester tester) async {
final ListView view = ListView(scrollDirection: Axis.vertical);
expect(view.physics, isInstanceOf<AlwaysScrollableScrollPhysics>());
expect(view.physics, isA<AlwaysScrollableScrollPhysics>());
});
testWidgets('Defaulting-to-not-primary ListViews are not always scrollable', (WidgetTester tester) async {
final ListView view = ListView(scrollDirection: Axis.horizontal);
expect(view.physics, isNot(isInstanceOf<AlwaysScrollableScrollPhysics>()));
expect(view.physics, isNot(isA<AlwaysScrollableScrollPhysics>()));
});
testWidgets('primary:true leads to scrolling', (WidgetTester tester) async {
@ -459,7 +459,7 @@ void main() {
// A separatorBuilder that returns null throws a FlutterError
await tester.pumpWidget(buildFrame(null));
expect(tester.takeException(), isInstanceOf<FlutterError>());
expect(tester.takeException(), isFlutterError);
expect(find.byType(ErrorWidget), findsOneWidget);
});
@ -520,7 +520,7 @@ void main() {
// When it does throw, one error widget is rendered in the item's place
await tester.pumpWidget(buildFrame(true));
expect(tester.takeException(), isInstanceOf<Exception>());
expect(tester.takeException(), isA<Exception>());
expect(finder, findsOneWidget);
});
@ -556,7 +556,7 @@ void main() {
// When it does throw, one error widget is rendered in the separator's place
await tester.pumpWidget(buildFrame(true));
expect(tester.takeException(), isInstanceOf<Exception>());
expect(tester.takeException(), isA<Exception>());
expect(finder, findsOneWidget);
});
@ -566,7 +566,7 @@ void main() {
return const SizedBox();
},
itemCount: -1,
), throwsA(isInstanceOf<AssertionError>()));
), throwsAssertionError);
});
testWidgets('ListView.builder asserts on negative semanticChildCount', (WidgetTester tester) async {
@ -576,7 +576,7 @@ void main() {
},
itemCount: 1,
semanticChildCount: -1,
), throwsA(isInstanceOf<AssertionError>()));
), throwsAssertionError);
});
testWidgets('ListView.builder asserts on nonsensical childCount/semanticChildCount', (WidgetTester tester) async {
@ -586,6 +586,6 @@ void main() {
},
itemCount: 1,
semanticChildCount: 4,
), throwsA(isInstanceOf<AssertionError>()));
), throwsAssertionError);
});
}

View File

@ -40,7 +40,7 @@ void main() {
));
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), contains('overflowed'));
@ -102,7 +102,7 @@ void main() {
));
final dynamic exception = tester.takeException();
expect(exception, isInstanceOf<FlutterError>());
expect(exception, isFlutterError);
expect(exception.diagnostics.first.level, DiagnosticLevel.summary);
expect(exception.diagnostics.first.toString(), contains('overflowed'));

View File

@ -29,6 +29,6 @@ class BadWidgetState extends State<BadWidget> {
void main() {
testWidgets('setState() catches being used inside a constructor', (WidgetTester tester) async {
await tester.pumpWidget(const BadWidget());
expect(tester.takeException(), isInstanceOf<FlutterError>());
expect(tester.takeException(), isFlutterError);
});
}

View File

@ -66,7 +66,7 @@ Future<void> main() async {
shape: BorderDirectional(start: BorderSide(color: Colors.red, width: 3)),
);
expect(decoration.padding, isInstanceOf<EdgeInsetsDirectional>());
expect(decoration.padding, isA<EdgeInsetsDirectional>());
});
testWidgets('TestBorder and Directionality - 1', (WidgetTester tester) async {

View File

@ -72,7 +72,7 @@ void main() {
));
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
expect(scrollable.position, isInstanceOf<TestScrollPosition>());
expect(scrollable.position, isA<TestScrollPosition>());
});
testWidgets('Sets PrimaryScrollController when primary', (WidgetTester tester) async {

View File

@ -29,7 +29,7 @@ void main() {
Center(
child: NotificationListener<LayoutChangedNotification>(
onNotification: (LayoutChangedNotification notification) {
expect(notification, isInstanceOf<SizeChangedLayoutNotification>());
expect(notification, isA<SizeChangedLayoutNotification>());
notified = true;
return true;
},

View File

@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
final RenderSliver target = key.currentContext.findRenderObject() as RenderSliver;
expect(target.parent, isInstanceOf<RenderViewport>());
expect(target.parent, isA<RenderViewport>());
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
final Offset actual = parentData.paintOffset;
expect(actual, ideal);

View File

@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
final RenderSliver target = key.currentContext.findRenderObject() as RenderSliver;
expect(target.parent, isInstanceOf<RenderViewport>());
expect(target.parent, isA<RenderViewport>());
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
final Offset actual = parentData.paintOffset;
expect(actual, ideal);

View File

@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
void verifyPaintPosition(GlobalKey key, Offset ideal) {
final RenderObject target = key.currentContext.findRenderObject();
expect(target.parent, isInstanceOf<RenderViewport>());
expect(target.parent, isA<RenderViewport>());
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
final Offset actual = parentData.paintOffset;
expect(actual, ideal);

View File

@ -168,11 +168,11 @@ void main() {
result = tester.hitTestOnBinding(const Offset(10.0, 10.0));
expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
result = tester.hitTestOnBinding(const Offset(10.0, 60.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(100.0, 100.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
result = tester.hitTestOnBinding(const Offset(100.0, 490.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(10.0, 520.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
});
@ -190,11 +190,11 @@ void main() {
result = tester.hitTestOnBinding(const Offset(10.0, 600.0-10.0));
expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
result = tester.hitTestOnBinding(const Offset(10.0, 600.0-60.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(100.0, 600.0-100.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
result = tester.hitTestOnBinding(const Offset(100.0, 600.0-490.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(10.0, 600.0-520.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
});
@ -212,11 +212,11 @@ void main() {
result = tester.hitTestOnBinding(const Offset(800.0-10.0, 10.0));
expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
result = tester.hitTestOnBinding(const Offset(800.0-60.0, 10.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(800.0-100.0, 100.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
result = tester.hitTestOnBinding(const Offset(800.0-490.0, 100.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(800.0-520.0, 10.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
});
@ -234,11 +234,11 @@ void main() {
result = tester.hitTestOnBinding(const Offset(10.0, 10.0));
expect(result.path.first.target, tester.firstRenderObject<RenderObject>(find.byType(Text)));
result = tester.hitTestOnBinding(const Offset(60.0, 10.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(100.0, 100.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).skip(1).first);
result = tester.hitTestOnBinding(const Offset(490.0, 100.0));
expect(result.path.first.target, isInstanceOf<RenderView>());
expect(result.path.first.target, isA<RenderView>());
result = tester.hitTestOnBinding(const Offset(520.0, 10.0));
expect(result.path.first.target, tester.renderObjectList<RenderObject>(find.byType(Text)).last);
});

View File

@ -10,7 +10,7 @@ import 'package:flutter/widgets.dart';
void verifyPaintPosition(GlobalKey key, Offset ideal) {
final RenderObject target = key.currentContext.findRenderObject();
expect(target.parent, isInstanceOf<RenderViewport>());
expect(target.parent, isA<RenderViewport>());
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
final Offset actual = parentData.paintOffset;
expect(actual, ideal);

View File

@ -16,7 +16,7 @@ void main() {
find.byElementPredicate((Element element) => element is SingleChildRenderObjectElement)
);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, isA<RenderDecoratedBox>());
final RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox;
expect(renderObject.decoration, equals(expectedDecoration));
}

View File

@ -118,7 +118,7 @@ void main() {
'calling dispose() on the AnimationController itself. Otherwise,\n'
'the ticker will leak.\n'
);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Ticker>>());
expect(error.toStringDeep().split('\n').take(14).join('\n'), equalsIgnoringHashCodes(
'FlutterError\n'
' _SingleTickerTestState#00000(ticker active) was disposed with an\n'
@ -161,7 +161,7 @@ void main() {
'calling dispose() on the AnimationController itself. Otherwise,\n'
'the ticker will leak.\n'
);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Ticker>>());
expect(error.toStringDeep().split('\n').take(14).join('\n'), equalsIgnoringHashCodes(
'FlutterError\n'
' _SingleTickerTestState#00000(ticker active) was disposed with an\n'
@ -204,7 +204,7 @@ void main() {
'calling dispose() on the AnimationController itself. Otherwise,\n'
'the ticker will leak.\n'
);
expect(error.diagnostics[3], isInstanceOf<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics[3], isA<DiagnosticsProperty<Ticker>>());
expect(error.toStringDeep().split('\n').take(14).join('\n'), equalsIgnoringHashCodes(
'FlutterError\n'
' _MultipleTickerTestState#00000(tickers: tracking 2 tickers) was\n'

View File

@ -80,7 +80,7 @@ void main() {
actualDecoration = actualBox.decoration as BoxDecoration;
expect(actualDecoration.color, const Color(0xFF7F7F7F));
expect(actualDecoration.border, isInstanceOf<Border>());
expect(actualDecoration.border, isA<Border>());
final Border border = actualDecoration.border as Border;
expect(border.left.width, 2.5);
expect(border.left.style, BorderStyle.solid);
@ -137,7 +137,7 @@ void main() {
// Same as the test above but the values should be much closer to the
// tween's end values given the easeOut curve.
expect(actualDecoration.color, const Color(0xFF505050));
expect(actualDecoration.border, isInstanceOf<Border>());
expect(actualDecoration.border, isA<Border>());
final Border border = actualDecoration.border as Border;
expect(border.left.width, closeTo(1.9, 0.1));
expect(border.left.style, BorderStyle.solid);

View File

@ -728,7 +728,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(chainNode['node'], isMap);
final Map<String, Object> jsonNode = chainNode['node'] as Map<String, Object>;
expect(service.toObject(jsonNode['valueId'] as String), equals(element));
expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(jsonNode['objectId'] as String), isA<DiagnosticsNode>());
expect(chainNode['children'], isList);
final List<Object> jsonChildren = chainNode['children'] as List<Object>;
@ -744,7 +744,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(jsonChildren[j], isMap);
final Map<String, Object> childJson = jsonChildren[j] as Map<String, Object>;
expect(service.toObject(childJson['valueId'] as String), equals(childrenElements[j]));
expect(service.toObject(childJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(childJson['objectId'] as String), isA<DiagnosticsNode>());
}
}
});
@ -761,7 +761,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < propertiesJson.length; ++i) {
final Map<String, Object> propertyJson = propertiesJson[i] as Map<String, Object>;
expect(service.toObject(propertyJson['valueId'] as String), equals(properties[i].value));
expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(propertyJson['objectId'] as String), isA<DiagnosticsNode>());
}
});
@ -790,7 +790,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < propertiesJson.length; ++i) {
final Map<String, Object> propertyJson = propertiesJson[i] as Map<String, Object>;
expect(service.toObject(propertyJson['valueId'] as String), equals(children[i].value));
expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(propertyJson['objectId'] as String), isA<DiagnosticsNode>());
}
});
@ -1168,7 +1168,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(chainNode['node'], isMap);
final Map<String, Object> jsonNode = chainNode['node'] as Map<String, Object>;
expect(service.toObject(jsonNode['valueId'] as String), equals(element));
expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(jsonNode['objectId'] as String), isA<DiagnosticsNode>());
expect(chainNode['children'], isList);
final List<Object> jsonChildren = chainNode['children'] as List<Object>;
@ -1184,7 +1184,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(jsonChildren[j], isMap);
final Map<String, Object> childJson = jsonChildren[j] as Map<String, Object>;
expect(service.toObject(childJson['valueId'] as String), equals(childrenElements[j]));
expect(service.toObject(childJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(childJson['objectId'] as String), isA<DiagnosticsNode>());
}
}
});
@ -1200,7 +1200,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < propertiesJson.length; ++i) {
final Map<String, Object> propertyJson = propertiesJson[i] as Map<String, Object>;
expect(service.toObject(propertyJson['valueId'] as String), equals(properties[i].value));
expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(propertyJson['objectId'] as String), isA<DiagnosticsNode>());
}
});
@ -1228,7 +1228,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < propertiesJson.length; ++i) {
final Map<String, Object> propertyJson = propertiesJson[i] as Map<String, Object>;
expect(service.toObject(propertyJson['valueId'] as String), equals(children[i].value));
expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(propertyJson['objectId'] as String), isA<DiagnosticsNode>());
}
});
@ -1256,13 +1256,13 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < childrenJson.length; ++i) {
final Map<String, Object> childJson = childrenJson[i] as Map<String, Object>;
expect(service.toObject(childJson['valueId'] as String), equals(children[i].value));
expect(service.toObject(childJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(childJson['objectId'] as String), isA<DiagnosticsNode>());
final List<Object> propertiesJson = childJson['properties'] as List<Object>;
final DiagnosticsNode diagnosticsNode = service.toObject(childJson['objectId'] as String) as DiagnosticsNode;
final List<DiagnosticsNode> expectedProperties = diagnosticsNode.getProperties();
for (final Map<String, Object> propertyJson in propertiesJson.cast<Map<String, Object>>()) {
final Object property = service.toObject(propertyJson['objectId'] as String);
expect(property, isInstanceOf<DiagnosticsNode>());
expect(property, isA<DiagnosticsNode>());
expect(expectedProperties, contains(property));
}
}
@ -1294,7 +1294,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
for (int i = 0; i < childrenJson.length; ++i) {
final Map<String, Object> childJson = childrenJson[i] as Map<String, Object>;
expect(service.toObject(childJson['valueId'] as String), equals(children[i].value));
expect(service.toObject(childJson['objectId'] as String), isInstanceOf<DiagnosticsNode>());
expect(service.toObject(childJson['objectId'] as String), isA<DiagnosticsNode>());
final List<Object> propertiesJson = childJson['properties'] as List<Object>;
for (final Map<String, Object> propertyJson in propertiesJson.cast<Map<String, Object>>()) {
expect(propertyJson, isNot(contains('children')));
@ -1303,7 +1303,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
final List<DiagnosticsNode> expectedProperties = diagnosticsNode.getProperties();
for (final Map<String, Object> propertyJson in propertiesJson.cast<Map<String, Object>>()) {
final Object property = service.toObject(propertyJson['objectId'] as String);
expect(property, isInstanceOf<DiagnosticsNode>());
expect(property, isA<DiagnosticsNode>());
expect(expectedProperties, contains(property));
}
}
@ -1670,7 +1670,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(rebuildEvents.length, equals(1));
Map<Object, Object> event = rebuildEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
List<int> data = event['events'] as List<int>;
expect(data.length, equals(14));
final int numDataEntries = data.length ~/ 2;
@ -1712,7 +1712,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
await tester.pump();
expect(rebuildEvents.length, equals(1));
event = rebuildEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
data = event['events'] as List<int>;
// No new locations were rebuilt.
expect(event, isNot(contains('newLocations')));
@ -1748,7 +1748,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
await tester.pump();
expect(rebuildEvents.length, equals(1));
event = rebuildEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
data = event['events'] as List<int>;
// No new locations were rebuilt.
expect(event, isNot(contains('newLocations')));
@ -1782,7 +1782,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
await tester.pump();
expect(rebuildEvents.length, equals(1));
event = rebuildEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
data = event['events'] as List<int>;
// No new locations were rebuilt.
expect(event, isNot(contains('newLocations')));
@ -1799,7 +1799,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
await tester.pump();
expect(rebuildEvents.length, equals(1));
event = rebuildEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
data = event['events'] as List<int>;
newLocations = event['newLocations'] as Map<String, List<int>>;
@ -1872,7 +1872,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
expect(repaintEvents.length, equals(1));
Map<Object, Object> event = repaintEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
List<int> data = event['events'] as List<int>;
expect(data.length, equals(18));
final int numDataEntries = data.length ~/ 2;
@ -1914,7 +1914,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
await tester.pump();
expect(repaintEvents.length, equals(1));
event = repaintEvents.removeLast();
expect(event['startTime'], isInstanceOf<int>());
expect(event['startTime'], isA<int>());
data = event['events'] as List<int>;
// No new locations were rebuilt.
expect(event, isNot(contains('newLocations')));

View File

@ -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>());

View File

@ -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

View File

@ -18,7 +18,7 @@ void main() {
test('io_extension should throw exception', () {
expect(() => registerWebServiceExtension(call),
throwsA(isInstanceOf<UnsupportedError>()));
throwsA(isA<UnsupportedError>()));
});
});
}

View File

@ -93,7 +93,7 @@ void main() {
const Locale locale = Locale('fr');
expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue);
final CupertinoLocalizations localizations = await GlobalCupertinoLocalizations.delegate.load(locale);
expect(localizations is CupertinoLocalizationFr, true);
expect(localizations, isA<CupertinoLocalizationFr>());
expect(localizations.alertDialogLabel, 'Alerte');
expect(localizations.datePickerHourSemanticsLabel(1), '1 heure');
expect(localizations.datePickerHourSemanticsLabel(12), '12 heures');
@ -108,7 +108,7 @@ void main() {
const Locale locale = Locale('zh');
expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue);
final CupertinoLocalizations localizations = await GlobalCupertinoLocalizations.delegate.load(locale);
expect(localizations is CupertinoLocalizationZh, true);
expect(localizations, isA<CupertinoLocalizationZh>());
expect(localizations.alertDialogLabel, '提醒');
expect(localizations.datePickerHourSemanticsLabel(1), '1 点');
expect(localizations.datePickerHourSemanticsLabel(12), '12 点');

View File

@ -159,268 +159,268 @@ void main() {
Locale locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale('zh', 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHantTw, true);
expect(localizations, isA<MaterialLocalizationZhHantTw>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'HK');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHantHk, true);
expect(localizations, isA<MaterialLocalizationZhHantHk>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHantTw, true);
expect(localizations, isA<MaterialLocalizationZhHantTw>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHans, true);
expect(localizations, isA<MaterialLocalizationZhHans>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHant, true);
expect(localizations, isA<MaterialLocalizationZhHant>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHans, true);
expect(localizations, isA<MaterialLocalizationZhHans>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHans, true);
expect(localizations, isA<MaterialLocalizationZhHans>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHans, true);
expect(localizations, isA<MaterialLocalizationZhHans>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'CN');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHant, true);
expect(localizations, isA<MaterialLocalizationZhHant>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHant, true);
expect(localizations, isA<MaterialLocalizationZhHant>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Latn', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Latn', countryCode: 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Cyrl', countryCode: 'RU');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'RU');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Cyrl', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
});
testWidgets('Serbian resolution', (WidgetTester tester) async {
Locale locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSr, true);
expect(localizations, isA<MaterialLocalizationSr>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrCyrl, true);
expect(localizations, isA<MaterialLocalizationSrCyrl>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrLatn, true);
expect(localizations, isA<MaterialLocalizationSrLatn>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: null, countryCode: 'SR');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSr, true);
expect(localizations, isA<MaterialLocalizationSr>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: 'SR');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrCyrl, true);
expect(localizations, isA<MaterialLocalizationSrCyrl>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: 'SR');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrLatn, true);
expect(localizations, isA<MaterialLocalizationSrLatn>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrCyrl, true);
expect(localizations, isA<MaterialLocalizationSrCyrl>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSrLatn, true);
expect(localizations, isA<MaterialLocalizationSrLatn>());
locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: null, countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationSr, true);
expect(localizations, isA<MaterialLocalizationSr>());
});
testWidgets('Misc resolution', (WidgetTester tester) async {
Locale locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Cyrl', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'AU');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEnAu, true);
expect(localizations, isA<MaterialLocalizationEnAu>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'GB');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEnGb, true);
expect(localizations, isA<MaterialLocalizationEnGb>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'SG');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEnSg, true);
expect(localizations, isA<MaterialLocalizationEnSg>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'MX');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hant', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hant', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hans', countryCode: 'CN');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEn, true);
expect(localizations, isA<MaterialLocalizationEn>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEs, true);
expect(localizations, isA<MaterialLocalizationEs>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: '419');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEs419, true);
expect(localizations, isA<MaterialLocalizationEs419>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'MX');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEsMx, true);
expect(localizations, isA<MaterialLocalizationEsMx>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEsUs, true);
expect(localizations, isA<MaterialLocalizationEsUs>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'AR');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEsAr, true);
expect(localizations, isA<MaterialLocalizationEsAr>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'ES');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEs, true);
expect(localizations, isA<MaterialLocalizationEs>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: 'Latn', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEs, true);
expect(localizations, isA<MaterialLocalizationEs>());
locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: 'Latn', countryCode: 'US');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationEsUs, true);
expect(localizations, isA<MaterialLocalizationEsUs>());
locale = const Locale.fromSubtags(languageCode: 'fr', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationFr, true);
expect(localizations, isA<MaterialLocalizationFr>());
locale = const Locale.fromSubtags(languageCode: 'fr', scriptCode: null, countryCode: 'CA');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationFrCa, true);
expect(localizations, isA<MaterialLocalizationFrCa>());
locale = const Locale.fromSubtags(languageCode: 'de', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationDe, true);
expect(localizations, isA<MaterialLocalizationDe>());
locale = const Locale.fromSubtags(languageCode: 'de', scriptCode: null, countryCode: 'CH');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationDeCh, true);
expect(localizations, isA<MaterialLocalizationDeCh>());
locale = const Locale.fromSubtags(languageCode: 'th', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationTh, true);
expect(localizations, isA<MaterialLocalizationTh>());
locale = const Locale.fromSubtags(languageCode: 'ru', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationRu, true);
expect(localizations, isA<MaterialLocalizationRu>());
});
testWidgets('Chinese translations spot check', (WidgetTester tester) async {
Locale locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZh, true);
expect(localizations, isA<MaterialLocalizationZh>());
expect(localizations.alertDialogLabel, '提醒');
expect(localizations.anteMeridiemAbbreviation, '上午');
expect(localizations.closeButtonLabel, '关闭');
@ -429,7 +429,7 @@ void main() {
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHans, true);
expect(localizations, isA<MaterialLocalizationZhHans>());
expect(localizations.alertDialogLabel, '提醒');
expect(localizations.anteMeridiemAbbreviation, '上午');
expect(localizations.closeButtonLabel, '关闭');
@ -438,7 +438,7 @@ void main() {
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: null);
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHant, true);
expect(localizations, isA<MaterialLocalizationZhHant>());
expect(localizations.alertDialogLabel, '通知');
expect(localizations.anteMeridiemAbbreviation, '上午');
expect(localizations.closeButtonLabel, '關閉');
@ -447,7 +447,7 @@ void main() {
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'TW');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHantTw, true);
expect(localizations, isA<MaterialLocalizationZhHantTw>());
expect(localizations.alertDialogLabel, '快訊');
expect(localizations.anteMeridiemAbbreviation, '上午');
expect(localizations.closeButtonLabel, '關閉');
@ -456,7 +456,7 @@ void main() {
locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'HK');
expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue);
localizations = await GlobalMaterialLocalizations.delegate.load(locale);
expect(localizations is MaterialLocalizationZhHantHk, true);
expect(localizations, isA<MaterialLocalizationZhHantHk>());
expect(localizations.alertDialogLabel, '通知');
expect(localizations.anteMeridiemAbbreviation, '上午');
expect(localizations.closeButtonLabel, '關閉');

View File

@ -162,7 +162,7 @@ const Matcher hasAGoodToStringDeep = _HasGoodToStringDeep();
/// A matcher for functions that throw [FlutterError].
///
/// This is equivalent to `throwsA(isInstanceOf<FlutterError>())`.
/// This is equivalent to `throwsA(isA<FlutterError>())`.
///
/// If you are trying to test whether a call to [WidgetTester.pumpWidget]
/// results in a [FlutterError], see [TestWidgetsFlutterBinding.takeException].
@ -176,7 +176,7 @@ final Matcher throwsFlutterError = throwsA(isFlutterError);
/// A matcher for functions that throw [AssertionError].
///
/// This is equivalent to `throwsA(isInstanceOf<AssertionError>())`.
/// This is equivalent to `throwsA(isA<AssertionError>())`.
///
/// If you are trying to test whether a call to [WidgetTester.pumpWidget]
/// results in an [AssertionError], see
@ -197,7 +197,7 @@ final Matcher throwsAssertionError = throwsA(isAssertionError);
///
/// * [throwsFlutterError], to test if a function throws a [FlutterError].
/// * [isAssertionError], to test if any object is any kind of [AssertionError].
final Matcher isFlutterError = isInstanceOf<FlutterError>();
final test_package.TypeMatcher<FlutterError> isFlutterError = isA<FlutterError>();
/// A matcher for [AssertionError].
///
@ -207,11 +207,11 @@ final Matcher isFlutterError = isInstanceOf<FlutterError>();
///
/// * [throwsAssertionError], to test if a function throws any [AssertionError].
/// * [isFlutterError], to test if any object is a [FlutterError].
final Matcher isAssertionError = isInstanceOf<AssertionError>();
final test_package.TypeMatcher<AssertionError> isAssertionError = isA<AssertionError>();
/// 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>();
/// Asserts that two [double]s are equal, within some tolerated error.
///

View File

@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('$WidgetsBinding initializes with $LiveTestWidgetsFlutterBinding when FLUTTER_TEST = "false"', () {
TestWidgetsFlutterBinding.ensureInitialized(<String, String>{'FLUTTER_TEST': 'false'});
expect(WidgetsBinding.instance, isInstanceOf<LiveTestWidgetsFlutterBinding>());
expect(WidgetsBinding.instance, isA<LiveTestWidgetsFlutterBinding>());
}, onPlatform: const <String, dynamic>{
'browser': <Skip>[Skip('Browser will not use the live binding')]
});

View File

@ -9,6 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('$WidgetsBinding initializes with $AutomatedTestWidgetsFlutterBinding when FLUTTER_TEST has a value that is not "true" or "false"', () {
TestWidgetsFlutterBinding.ensureInitialized(<String, String>{'FLUTTER_TEST': 'value that is neither "true" nor "false"'});
expect(WidgetsBinding.instance, isInstanceOf<AutomatedTestWidgetsFlutterBinding>());
expect(WidgetsBinding.instance, isA<AutomatedTestWidgetsFlutterBinding>());
});
}

View File

@ -9,6 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('$WidgetsBinding initializes with $AutomatedTestWidgetsFlutterBinding when FLUTTER_TEST is defined but null', () {
TestWidgetsFlutterBinding.ensureInitialized(<String, String>{'FLUTTER_TEST': null});
expect(WidgetsBinding.instance, isInstanceOf<AutomatedTestWidgetsFlutterBinding>());
expect(WidgetsBinding.instance, isA<AutomatedTestWidgetsFlutterBinding>());
});
}

View File

@ -9,6 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('$WidgetsBinding initializes with $AutomatedTestWidgetsFlutterBinding when FLUTTER_TEST = "true"', () {
TestWidgetsFlutterBinding.ensureInitialized(<String, String>{'FLUTTER_TEST': 'true'});
expect(WidgetsBinding.instance, isInstanceOf<AutomatedTestWidgetsFlutterBinding>());
expect(WidgetsBinding.instance, isA<AutomatedTestWidgetsFlutterBinding>());
});
}

View File

@ -9,6 +9,6 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('$WidgetsBinding initializes with $LiveTestWidgetsFlutterBinding when the environment does not contain FLUTTER_TEST', () {
TestWidgetsFlutterBinding.ensureInitialized(<String, String>{});
expect(WidgetsBinding.instance, isInstanceOf<LiveTestWidgetsFlutterBinding>());
expect(WidgetsBinding.instance, isA<LiveTestWidgetsFlutterBinding>());
});
}

View File

@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> main(FutureOr<void> testMain()) async {
reportTestException = (FlutterErrorDetails details, String testDescription) {
expect(details.exception, isInstanceOf<StateError>());
expect(details.exception, isA<StateError>());
expect(details.exception.message, 'foo');
expect(testDescription, 'custom exception reporter');
};

View File

@ -76,7 +76,7 @@ void main() {
group('goldenFileComparator', () {
test('is initialized by test framework', () {
expect(goldenFileComparator, isNotNull);
expect(goldenFileComparator, isInstanceOf<LocalFileComparator>());
expect(goldenFileComparator, isA<LocalFileComparator>());
final LocalFileComparator comparator = goldenFileComparator as LocalFileComparator;
expect(comparator.basedir.path, contains('flutter_test'));
});

View File

@ -153,15 +153,15 @@ void main() {
real_test.expect(information[3].level, DiagnosticLevel.info);
real_test.expect(information[4].level, DiagnosticLevel.info);
real_test.expect(information[5].level, DiagnosticLevel.info);
real_test.expect(information[0], isInstanceOf<DiagnosticsProperty<void>>());
real_test.expect(information[1], isInstanceOf<DiagnosticsProperty<void>>());
real_test.expect(information[2], isInstanceOf<DiagnosticsProperty<void>>());
real_test.expect(information[3], isInstanceOf<DiagnosticsProperty<void>>());
real_test.expect(information[4], isInstanceOf<DiagnosticsProperty<void>>());
real_test.expect(information[5], isInstanceOf<DiagnosticsStackTrace>());
real_test.expect(information[0], isA<DiagnosticsProperty<void>>());
real_test.expect(information[1], isA<DiagnosticsProperty<void>>());
real_test.expect(information[2], isA<DiagnosticsProperty<void>>());
real_test.expect(information[3], isA<DiagnosticsProperty<void>>());
real_test.expect(information[4], isA<DiagnosticsProperty<void>>());
real_test.expect(information[5], isA<DiagnosticsStackTrace>());
final DiagnosticsStackTrace stackTraceProperty = information[5] as DiagnosticsStackTrace;
real_test.expect(stackTraceProperty.name, '\nWhen the first method was called, this was the stack');
real_test.expect(stackTraceProperty.value, isInstanceOf<StackTrace>());
real_test.expect(stackTraceProperty.value, isA<StackTrace>());
}
await f1;
await f2;

View File

@ -29,7 +29,7 @@ void main() {
await tester.testTextInput.receiveAction(TextInputAction.done);
fail('Expected a PlatformException, but it was not thrown.');
} catch (e) {
expect(e, isInstanceOf<PlatformException>());
expect(e, isA<PlatformException>());
}
});
}

View File

@ -33,8 +33,7 @@ void main() {
),
);
expect(() => tester.getSemantics(find.text('hello')),
throwsA(isInstanceOf<StateError>()));
expect(() => tester.getSemantics(find.text('hello')), throwsStateError);
}, semanticsEnabled: false);
testWidgets('throws when there are multiple results from the finder', (WidgetTester tester) async {
@ -53,8 +52,7 @@ void main() {
),
);
expect(() => tester.getSemantics(find.text('hello')),
throwsA(isInstanceOf<StateError>()));
expect(() => tester.getSemantics(find.text('hello')), throwsStateError);
semanticsHandle.dispose();
});
@ -472,7 +470,7 @@ void main() {
expect(
expectAsync0(tester.pageBack),
throwsA(isInstanceOf<TestFailure>()),
throwsA(isA<TestFailure>()),
);
});
@ -629,7 +627,7 @@ void main() {
testWidgets('disallows re-entry', (WidgetTester tester) async {
final Completer<void> completer = Completer<void>();
tester.runAsync<void>(() => completer.future);
expect(() => tester.runAsync(() async { }), throwsA(isInstanceOf<TestFailure>()));
expect(() => tester.runAsync(() async { }), throwsA(isA<TestFailure>()));
completer.complete();
});
@ -685,7 +683,7 @@ void main() {
'calling dispose() on the AnimationController itself. Otherwise,\n'
'the ticker will leak.\n',
);
expect(error.diagnostics.last, isInstanceOf<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics.last, isA<DiagnosticsProperty<Ticker>>());
expect(error.diagnostics.last.value, ticker);
expect(error.toStringDeep(), startsWith(
'FlutterError\n'

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,
});

Some files were not shown because too many files have changed in this diff Show More