From 003541499b83c4e5e6d6944a1c164ddd0716df5c Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Thu, 16 Jan 2020 21:43:03 +0100 Subject: [PATCH] use isA() matcher (#48482) --- dev/bots/test/common.dart | 2 +- dev/bots/test/prepare_package_test.dart | 7 +- dev/devicelab/test/common.dart | 2 +- .../lib/src/flutter_test_alternative.dart | 2 +- dev/tools/test/common.dart | 2 +- dev/tools/vitool/test/vitool_test.dart | 2 +- .../flutter/test/animation/futures_test.dart | 6 +- .../test/flutter_test_alternative.dart | 2 +- .../foundation/consolidate_response_test.dart | 3 +- .../test/foundation/isolates_test.dart | 4 +- .../test/material/app_builder_test.dart | 2 +- packages/flutter/test/material/app_test.dart | 6 +- .../material/bottom_navigation_bar_test.dart | 2 +- .../test/material/chip_theme_test.dart | 16 +-- .../flutter/test/material/debug_test.dart | 12 +- .../test/material/outline_button_test.dart | 2 +- packages/flutter/test/material/page_test.dart | 2 +- .../material/paginated_data_table_test.dart | 4 +- .../test/material/popup_menu_test.dart | 2 +- .../flutter/test/material/scaffold_test.dart | 4 +- .../test/painting/border_rtl_test.dart | 2 +- .../flutter/test/painting/border_test.dart | 2 +- .../test/painting/decoration_test.dart | 28 ++--- .../test/painting/edge_insets_test.dart | 2 +- .../test/painting/image_cache_test.dart | 2 +- .../test/painting/image_provider_test.dart | 3 +- .../test/rendering/aspect_ratio_test.dart | 5 +- .../test/rendering/box_constraints_test.dart | 8 +- .../debug_overflow_indicator_test.dart | 2 +- .../flutter/test/rendering/flex_test.dart | 4 +- .../flutter/test/rendering/object_test.dart | 2 +- .../test/rendering/proxy_box_test.dart | 2 +- .../test/rendering/repaint_boundary_test.dart | 4 +- .../flutter/test/scheduler/ticker_test.dart | 2 +- .../test/services/asset_bundle_test.dart | 2 +- .../test/services/platform_channel_test.dart | 6 +- .../test/services/platform_views_test.dart | 10 +- .../test/widgets/animated_list_test.dart | 2 +- .../test/widgets/animated_switcher_test.dart | 8 +- .../test/widgets/app_navigator_key_test.dart | 4 +- packages/flutter/test/widgets/debug_test.dart | 8 +- packages/flutter/test/widgets/flow_test.dart | 4 +- .../flutter/test/widgets/heroes_test.dart | 2 +- packages/flutter/test/widgets/image_test.dart | 6 +- .../test/widgets/media_query_test.dart | 2 +- .../flutter/test/widgets/multichild_test.dart | 4 +- .../flutter/test/widgets/navigator_test.dart | 8 +- .../flutter/test/widgets/overlay_test.dart | 4 +- .../test/widgets/parent_data_test.dart | 6 +- .../test/widgets/physical_model_test.dart | 2 +- .../test/widgets/platform_view_test.dart | 2 +- .../widgets/render_object_widget_test.dart | 18 +-- .../flutter/test/widgets/routes_test.dart | 6 +- .../test/widgets/scroll_behavior_test.dart | 4 +- .../widgets/scroll_notification_test.dart | 6 +- .../test/widgets/scroll_physics_test.dart | 4 +- .../test/widgets/scroll_view_test.dart | 20 ++-- .../test/widgets/semantics_clipping_test.dart | 4 +- .../test/widgets/set_state_5_test.dart | 2 +- .../test/widgets/shape_decoration_test.dart | 2 +- .../single_child_scroll_view_test.dart | 2 +- ...size_changed_layout_notification_test.dart | 2 +- .../widgets/slivers_appbar_floating_test.dart | 2 +- .../widgets/slivers_appbar_pinned_test.dart | 2 +- .../slivers_appbar_scrolling_test.dart | 2 +- .../test/widgets/slivers_padding_test.dart | 16 +-- .../test/widgets/slivers_protocol_test.dart | 2 +- .../test/widgets/stateful_component_test.dart | 2 +- .../test/widgets/ticker_provider_test.dart | 6 +- .../test/widgets/transitions_test.dart | 4 +- .../test/widgets/widget_inspector_test.dart | 38 +++--- packages/flutter_driver/test/common.dart | 6 +- .../test/flutter_driver_test.dart | 59 +++++---- .../src/real_tests/io_extension_test.dart | 2 +- .../test/cupertino/translations_test.dart | 4 +- .../test/material/translations_test.dart | 112 +++++++++--------- packages/flutter_test/lib/src/matchers.dart | 10 +- .../flutter_test_variable_is_false_test.dart | 2 +- ...st_variable_is_not_true_or_false_test.dart | 2 +- .../flutter_test_variable_is_null_test.dart | 2 +- .../flutter_test_variable_is_true_test.dart | 2 +- .../no_flutter_test_variable_test.dart | 2 +- .../flutter_test_config.dart | 2 +- packages/flutter_test/test/goldens_test.dart | 2 +- .../test/test_async_utils_test.dart | 14 +-- .../test/test_text_input_test.dart | 2 +- .../flutter_test/test/widget_tester_test.dart | 12 +- .../hermetic/assemble_test.dart | 7 +- .../commands.shard/hermetic/attach_test.dart | 6 +- .../hermetic/build_fuchsia_test.dart | 9 +- .../hermetic/build_linux_test.dart | 5 +- .../hermetic/build_macos_test.dart | 5 +- .../hermetic/build_web_test.dart | 7 +- .../hermetic/build_windows_test.dart | 5 +- .../commands.shard/hermetic/config_test.dart | 3 +- .../commands.shard/hermetic/daemon_test.dart | 2 +- .../commands.shard/hermetic/run_test.dart | 2 +- .../commands.shard/hermetic/version_test.dart | 4 +- .../permeable/build_bundle_test.dart | 7 +- .../permeable/upgrade_test.dart | 5 +- .../android/android_device_test.dart | 2 +- .../general.shard/android/gradle_test.dart | 2 +- .../test/general.shard/base/common_test.dart | 2 +- .../test/general.shard/base/io_test.dart | 2 +- .../test/general.shard/base/logger_test.dart | 20 ++-- .../test/general.shard/base/process_test.dart | 4 +- .../general.shard/base/terminal_test.dart | 2 +- .../test/general.shard/build_info_test.dart | 2 +- .../build_system/build_system_test.dart | 2 +- .../build_system/source_test.dart | 4 +- .../build_system/targets/dart_test.dart | 14 +-- .../build_system/targets/macos_test.dart | 2 +- .../test/general.shard/bundle_shim_test.dart | 3 +- .../test/general.shard/cache_test.dart | 5 +- .../compile_incremental_test.dart | 5 +- .../test/general.shard/compile_test.dart | 5 +- .../test/general.shard/dart/pub_get_test.dart | 2 +- .../test/general.shard/doctor.dart | 12 +- .../general.shard/flutter_platform_test.dart | 11 +- .../test/general.shard/ios/devices_test.dart | 4 +- .../test/general.shard/ios/mac_test.dart | 6 +- .../general.shard/macos/cocoapods_test.dart | 4 +- .../test/general.shard/project_test.dart | 11 +- .../general.shard/resident_runner_test.dart | 4 +- .../resident_web_runner_test.dart | 18 +-- .../runner/flutter_command_runner_test.dart | 3 +- .../general.shard/terminal_handler_test.dart | 5 +- .../test/general.shard/testbed_test.dart | 2 +- .../tester/flutter_tester_test.dart | 2 +- .../general.shard/web/devfs_web_test.dart | 5 +- .../test/general.shard/web/devices_test.dart | 14 +-- .../test/general.shard/web/web_fs_test.dart | 2 +- packages/flutter_tools/test/src/common.dart | 9 +- .../flutter_tools/test/template_test.dart | 3 +- .../test/common.dart | 2 +- .../test/fuchsia_remote_connection_test.dart | 2 +- .../test/src/dart/dart_vm_test.dart | 6 +- .../src/runners/ssh_command_runner_test.dart | 2 +- 138 files changed, 433 insertions(+), 450 deletions(-) diff --git a/dev/bots/test/common.dart b/dev/bots/test/common.dart index 4060c06fda..6ca543fdc0 100644 --- a/dev/bots/test/common.dart +++ b/dev/bots/test/common.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index 9f4a122fc6..2f33ac9914 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -25,7 +25,7 @@ void main() { expectAsync1((List commandLine) async { return processRunner.runProcess(commandLine); })(['this_executable_better_not_exist_2857632534321']), - throwsA(isInstanceOf())); + throwsA(isA())); try { await processRunner.runProcess(['this_executable_better_not_exist_2857632534321']); } on PreparePackageException catch (e) { @@ -64,7 +64,7 @@ void main() { expectAsync1((List commandLine) async { return processRunner.runProcess(commandLine); })(['echo', 'test']), - throwsA(isInstanceOf())); + throwsA(isA())); }); }); group('ArchiveCreator for $platformName', () { @@ -185,8 +185,7 @@ void main() { 'git reset --hard $testRef': [ProcessResult(0, -1, 'output2', '')], }; processManager.fakeResults = calls; - expect(expectAsync0(creator.initializeRepo), - throwsA(isInstanceOf())); + expect(expectAsync0(creator.initializeRepo), throwsA(isA())); }); test('non-strict mode calls the right commands', () async { diff --git a/dev/devicelab/test/common.dart b/dev/devicelab/test/common.dart index 9449f93996..64db237395 100644 --- a/dev/devicelab/test/common.dart +++ b/dev/devicelab/test/common.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); diff --git a/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart b/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart index c2aacda6ea..1865b6f384 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); diff --git a/dev/tools/test/common.dart b/dev/tools/test/common.dart index 4060c06fda..6ca543fdc0 100644 --- a/dev/tools/test/common.dart +++ b/dev/tools/test/common.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that diff --git a/dev/tools/vitool/test/vitool_test.dart b/dev/tools/vitool/test/vitool_test.dart index fffcef2fb7..9bb65ca897 100644 --- a/dev/tools/vitool/test/vitool_test.dart +++ b/dev/tools/vitool/test/vitool_test.dart @@ -17,7 +17,7 @@ void main() { test('parsePixels', () { expect(parsePixels('23px'), 23); expect(parsePixels('9px'), 9); - expect(() { parsePixels('9pt'); }, throwsA(isInstanceOf())); + expect(() { parsePixels('9pt'); }, throwsArgumentError); }); test('parsePoints', () { diff --git a/packages/flutter/test/animation/futures_test.dart b/packages/flutter/test/animation/futures_test.dart index 0965ec8a97..e389f1c0cf 100644 --- a/packages/flutter/test/animation/futures_test.dart +++ b/packages/flutter/test/animation/futures_test.dart @@ -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>()); + expect(f.asStream().single, isA>()); await f.catchError((dynamic e) { throw 'do not reach'; }); expect(await f.then((_) => true), isTrue); - expect(f.whenComplete(() => false), isInstanceOf>()); - expect(f.timeout(const Duration(seconds: 5)), isInstanceOf>()); + expect(f.whenComplete(() => false), isA>()); + expect(f.timeout(const Duration(seconds: 5)), isA>()); }); } diff --git a/packages/flutter/test/flutter_test_alternative.dart b/packages/flutter/test/flutter_test_alternative.dart index 694f751977..a67c1c69b1 100644 --- a/packages/flutter/test/flutter_test_alternative.dart +++ b/packages/flutter/test/flutter_test_alternative.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); /// Whether we are running in a web browser. const bool isBrowser = identical(0, 0.0); diff --git a/packages/flutter/test/foundation/consolidate_response_test.dart b/packages/flutter/test/foundation/consolidate_response_test.dart index 208fe6c99a..43c42424c2 100644 --- a/packages/flutter/test/foundation/consolidate_response_test.dart +++ b/packages/flutter/test/foundation/consolidate_response_test.dart @@ -110,8 +110,7 @@ void main() { }); when(response.contentLength).thenReturn(-1); - expect(consolidateHttpClientResponseBytes(response), - throwsA(isInstanceOf())); + expect(consolidateHttpClientResponseBytes(response), throwsException); }); test('Propagates error to Future return value if onBytesReceived throws', () async { diff --git a/packages/flutter/test/foundation/isolates_test.dart b/packages/flutter/test/foundation/isolates_test.dart index c7cca03d66..bbd339d95b 100644 --- a/packages/flutter/test/foundation/isolates_test.dart +++ b/packages/flutter/test/foundation/isolates_test.dart @@ -27,9 +27,9 @@ Future test2Async(int value) async { void main() { test('compute()', () async { expect(await compute(test1, 0), 1); - expect(compute(test2, 0), throwsA(isInstanceOf())); + expect(compute(test2, 0), throwsException); expect(await compute(test1Async, 0), 1); - expect(compute(test2Async, 0), throwsA(isInstanceOf())); + expect(compute(test2Async, 0), throwsException); }); } diff --git a/packages/flutter/test/material/app_builder_test.dart b/packages/flutter/test/material/app_builder_test.dart index c25825a8f2..c174f473bd 100644 --- a/packages/flutter/test/material/app_builder_test.dart +++ b/packages/flutter/test/material/app_builder_test.dart @@ -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()); + expect(child, isA()); return const Placeholder(); }, ); diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index b8c2a8d065..5aaf52d93f 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -322,7 +322,7 @@ void main() { ), ); final dynamic exception = tester.takeException(); - expect(exception is String, isTrue); + expect(exception, isA()); 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()); + expect(key.currentState, isA()); 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()); + expect(key.currentState, isA()); }); testWidgets('Has default material and cupertino localizations', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 51a9793ca7..a3a2b894e0 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1449,7 +1449,7 @@ void main() { ), ), ); - }, throwsA(isInstanceOf())); + }, throwsAssertionError); }); testWidgets( diff --git a/packages/flutter/test/material/chip_theme_test.dart b/packages/flutter/test/material/chip_theme_test.dart index 6c25700f65..d4f1d1e035 100644 --- a/packages/flutter/test/material/chip_theme_test.dart +++ b/packages/flutter/test/material/chip_theme_test.dart @@ -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())); + expect(lightTheme.shape, isA()); 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())); + expect(darkTheme.shape, isA()); 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())); + expect(customTheme.shape, isA()); 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())); + expect(lerp.shape, isA()); 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())); + expect(lerpANull25.shape, isA()); 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())); + expect(lerpANull75.shape, isA()); 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())); + expect(lerpBNull25.shape, isA()); 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())); + expect(lerpBNull75.shape, isA()); expect(lerpBNull75.labelStyle.color, equals(Colors.white.withAlpha(0x38))); expect(lerpBNull75.secondaryLabelStyle.color, equals(Colors.black.withAlpha(0x38))); expect(lerpBNull75.brightness, equals(Brightness.light)); diff --git a/packages/flutter/test/material/debug_test.dart b/packages/flutter/test/material/debug_test.dart index f612b6a781..b42ea43ca5 100644 --- a/packages/flutter/test/material/debug_test.dart +++ b/packages/flutter/test/material/debug_test.dart @@ -22,8 +22,8 @@ void main() { 'Card, Dialog, Drawer, or Scaffold.\n', ), ); - expect(error.diagnostics[3], isInstanceOf>()); - expect(error.diagnostics[4], isInstanceOf()); + expect(error.diagnostics[3], isA>()); + expect(error.diagnostics[4], isA()); 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>()); - expect(error.diagnostics[5], isInstanceOf()); + expect(error.diagnostics[4], isA>()); + expect(error.diagnostics[5], isA()); 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>()); - expect(error.diagnostics[3], isInstanceOf()); + expect(error.diagnostics[2], isA>()); + expect(error.diagnostics[3], isA()); expect(error.diagnostics[4].level, DiagnosticLevel.hint); expect( error.diagnostics[4].toStringDeep(), diff --git a/packages/flutter/test/material/outline_button_test.dart b/packages/flutter/test/material/outline_button_test.dart index e6debab11b..a61baf9840 100644 --- a/packages/flutter/test/material/outline_button_test.dart +++ b/packages/flutter/test/material/outline_button_test.dart @@ -1047,7 +1047,7 @@ PhysicalModelLayer _findPhysicalLayer(Element element) { object = object.parent as RenderObject; } expect(object.debugLayer, isNotNull); - expect(object.debugLayer.firstChild, isInstanceOf()); + expect(object.debugLayer.firstChild, isA()); final PhysicalModelLayer layer = object.debugLayer.firstChild as PhysicalModelLayer; final Layer child = layer.firstChild; return child is PhysicalModelLayer ? child : layer; diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index 47fbded3a6..1beebb602c 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -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()); + expect(exception, isFlutterError); expect(exception.toStringDeep(), equalsIgnoringHashCodes( 'FlutterError\n' ' The builder for route "broken" returned null.\n' diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 546ce35043..d6a6ecd33d 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -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()); + 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()); + expect(exception, isFlutterError); expect(exception.diagnostics.first.level, DiagnosticLevel.summary); expect(exception.diagnostics.first.toString(), contains('A RenderFlex overflowed by')); diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 831d777179..644e96a2c7 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -345,7 +345,7 @@ void main() { icon: const Icon(Icons.view_carousel), itemBuilder: simplePopupMenuItemBuilder, ); - }, throwsA(isInstanceOf())); + }, throwsAssertionError); }); testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index d3d379839a..4efa7d22b2 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -1824,7 +1824,7 @@ void main() { 'the ScaffoldState rather than using the Scaffold.of() function.\n', ), ); - expect(error.diagnostics[4], isInstanceOf>()); + expect(error.diagnostics[4], isA>()); 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>()); + expect(error.diagnostics[4], isA>()); expect(error.toStringDeep(), 'FlutterError\n' ' Scaffold.geometryOf() called with a context that does not contain\n' diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index d238b08ca8..035a5cc7e6 100644 --- a/packages/flutter/test/painting/border_rtl_test.dart +++ b/packages/flutter/test/painting/border_rtl_test.dart @@ -502,7 +502,7 @@ void main() { ); expect( const BorderDirectional(start: magenta3) + const BorderDirectional(start: yellow2), - isNot(isInstanceOf()), // see shape_border_test.dart for better tests of this case + isNot(isA()), // see shape_border_test.dart for better tests of this case ); const BorderDirectional b3 = BorderDirectional(top: magenta3); const BorderDirectional b6 = BorderDirectional(top: magenta6); diff --git a/packages/flutter/test/painting/border_test.dart b/packages/flutter/test/painting/border_test.dart index e82095e23b..e25a10fa77 100644 --- a/packages/flutter/test/painting/border_test.dart +++ b/packages/flutter/test/painting/border_test.dart @@ -97,7 +97,7 @@ void main() { ); expect( const Border(left: magenta3) + const Border(left: yellow2), - isNot(isInstanceOf()), // see shape_border_test.dart for better tests of this case + isNot(isA()), // see shape_border_test.dart for better tests of this case ); const Border b3 = Border(top: magenta3); const Border b6 = Border(top: magenta6); diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index 1e1b661379..5747b4ef3a 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.dart @@ -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()); + expect(call.positionalArguments[0], isA()); 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()); + expect(call.positionalArguments[3], isA()); 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>()); - expect(error.diagnostics[3], isInstanceOf>()); + expect(error.diagnostics[2], isA>()); + expect(error.diagnostics[3], isA>()); 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()); // ignore: CONST_EVAL_THROWS_EXCEPTION - expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.25), isInstanceOf()); // ignore: CONST_EVAL_THROWS_EXCEPTION - expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.75), isInstanceOf()); // ignore: CONST_EVAL_THROWS_EXCEPTION - expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 1.0), isInstanceOf()); // ignore: CONST_EVAL_THROWS_EXCEPTION + expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.0), isA()); // ignore: CONST_EVAL_THROWS_EXCEPTION + expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.25), isA()); // ignore: CONST_EVAL_THROWS_EXCEPTION + expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 0.75), isA()); // ignore: CONST_EVAL_THROWS_EXCEPTION + expect(Decoration.lerp(const FlutterLogoDecoration(), const BoxDecoration(), 1.0), isA()); // 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()); + expect(call.positionalArguments[0], isA()); // 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()); + expect(call.positionalArguments[3], isA()); } }); @@ -450,7 +450,7 @@ void main() { expect(call.isMethod, isTrue); expect(call.positionalArguments, hasLength(4)); - expect(call.positionalArguments[0], isInstanceOf()); + expect(call.positionalArguments[0], isA()); // 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()); + expect(call.positionalArguments[3], isA()); } }); @@ -493,7 +493,7 @@ void main() { expect(call.isMethod, isTrue); expect(call.positionalArguments, hasLength(4)); - expect(call.positionalArguments[0], isInstanceOf()); + expect(call.positionalArguments[0], isA()); // 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()); + expect(call.positionalArguments[3], isA()); }); test('paintImage boxFit, scale and alignment test', () { diff --git a/packages/flutter/test/painting/edge_insets_test.dart b/packages/flutter/test/painting/edge_insets_test.dart index fdd5c5222a..74d4ba4c29 100644 --- a/packages/flutter/test/painting/edge_insets_test.dart +++ b/packages/flutter/test/painting/edge_insets_test.dart @@ -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())); + expect(a, isNot(isA())); 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)); diff --git a/packages/flutter/test/painting/image_cache_test.dart b/packages/flutter/test/painting/image_cache_test.dart index aa1da21712..376da657c0 100644 --- a/packages/flutter/test/painting/image_cache_test.dart +++ b/packages/flutter/test/painting/image_cache_test.dart @@ -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())); + expect(() => imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null)), throwsA(isA())); bool caughtError = false; final ImageStreamCompleter result = imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null), onError: (dynamic error, StackTrace stackTrace) { caughtError = true; diff --git a/packages/flutter/test/painting/image_provider_test.dart b/packages/flutter/test/painting/image_provider_test.dart index 87e37b5a3d..3379818de0 100644 --- a/packages/flutter/test/painting/image_provider_test.dart +++ b/packages/flutter/test/painting/image_provider_test.dart @@ -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() + isA() .having((NetworkImageLoadException e) => e.statusCode, 'statusCode', errorStatusCode) .having((NetworkImageLoadException e) => e.uri, 'uri', Uri.base.resolve(requestUrl)), ); diff --git a/packages/flutter/test/rendering/aspect_ratio_test.dart b/packages/flutter/test/rendering/aspect_ratio_test.dart index 69815b5194..9e8633f250 100644 --- a/packages/flutter/test/rendering/aspect_ratio_test.dart +++ b/packages/flutter/test/rendering/aspect_ratio_test.dart @@ -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()); + expect(errors.first.exception, isFlutterError); expect(errors.first.exception.toStringDeep(), 'FlutterError\n' ' RenderAspectRatio has unbounded constraints.\n' diff --git a/packages/flutter/test/rendering/box_constraints_test.dart b/packages/flutter/test/rendering/box_constraints_test.dart index d9a8f7a1ef..a71107ef29 100644 --- a/packages/flutter/test/rendering/box_constraints_test.dart +++ b/packages/flutter/test/rendering/box_constraints_test.dart @@ -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())); - expect(() => BoxConstraints.lerp(constraints1, constraints3, 0.5), throwsA(isInstanceOf())); - expect(() => BoxConstraints.lerp(constraints2, constraints3, 0.5), throwsA(isInstanceOf())); + 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', () { diff --git a/packages/flutter/test/rendering/debug_overflow_indicator_test.dart b/packages/flutter/test/rendering/debug_overflow_indicator_test.dart index f0fd349c0a..ef63120ec0 100644 --- a/packages/flutter/test/rendering/debug_overflow_indicator_test.dart +++ b/packages/flutter/test/rendering/debug_overflow_indicator_test.dart @@ -34,7 +34,7 @@ void main() { ); final dynamic exception = tester.takeException(); - expect(exception, isInstanceOf()); + 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()); diff --git a/packages/flutter/test/rendering/flex_test.dart b/packages/flutter/test/rendering/flex_test.dart index ad5aba6a4c..824aff1051 100644 --- a/packages/flutter/test/rendering/flex_test.dart +++ b/packages/flutter/test/rendering/flex_test.dart @@ -388,7 +388,7 @@ void main() { exceptions.addAll(renderer.takeAllFlutterExceptions()); }); expect(exceptions, isNotEmpty); - expect(exceptions.first, isInstanceOf()); + 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()); + expect(exceptions.first, isFlutterError); }); test('MainAxisSize.min inside tightly constrained', () { diff --git a/packages/flutter/test/rendering/object_test.dart b/packages/flutter/test/rendering/object_test.dart index 4ea24dc7c4..214884d496 100644 --- a/packages/flutter/test/rendering/object_test.dart +++ b/packages/flutter/test/rendering/object_test.dart @@ -148,7 +148,7 @@ void _testPaintingContextLayerReuse(_LayerTestPaintCallback pai box.markNeedsPaint(); pumpFrame(phase: EnginePhase.paint); expect(box.paintedLayers, hasLength(2)); - expect(box.paintedLayers[0], isInstanceOf()); + expect(box.paintedLayers[0], isA()); expect(box.paintedLayers[0], same(box.paintedLayers[1])); } diff --git a/packages/flutter/test/rendering/proxy_box_test.dart b/packages/flutter/test/rendering/proxy_box_test.dart index e028865280..1937322a95 100644 --- a/packages/flutter/test/rendering/proxy_box_test.dart +++ b/packages/flutter/test/rendering/proxy_box_test.dart @@ -490,7 +490,7 @@ void _testLayerReuse(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()); + expect(layer, isA()); expect(layer, isNotNull); // Mark for repaint otherwise pumpFrame is a noop. diff --git a/packages/flutter/test/rendering/repaint_boundary_test.dart b/packages/flutter/test/rendering/repaint_boundary_test.dart index 6cee7f6e31..02381722c3 100644 --- a/packages/flutter/test/rendering/repaint_boundary_test.dart +++ b/packages/flutter/test/rendering/repaint_boundary_test.dart @@ -60,7 +60,7 @@ void main() { child: repaintBoundary, ); layout(opacity, phase: EnginePhase.flushSemantics); - expect(repaintBoundary.debugLayer, isInstanceOf()); + expect(repaintBoundary.debugLayer, isA()); }); 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()); + expect(compositedBox.debugLayer, isA()); }); test('Framework ensures repaint boundary layer is not overwritten', () { diff --git a/packages/flutter/test/scheduler/ticker_test.dart b/packages/flutter/test/scheduler/ticker_test.dart index ee07bfbbc5..cf3c9eec4e 100644 --- a/packages/flutter/test/scheduler/ticker_test.dart +++ b/packages/flutter/test/scheduler/ticker_test.dart @@ -33,7 +33,7 @@ void main() { } expect(error, isNotNull); expect(error.diagnostics.length, 3); - expect(error.diagnostics.last, isInstanceOf>()); + expect(error.diagnostics.last, isA>()); expect( error.toStringDeep(), startsWith( diff --git a/packages/flutter/test/services/asset_bundle_test.dart b/packages/flutter/test/services/asset_bundle_test.dart index 0760131409..0cc3ddd759 100644 --- a/packages/flutter/test/services/asset_bundle_test.dart +++ b/packages/flutter/test/services/asset_bundle_test.dart @@ -68,7 +68,7 @@ void main() { } expect(error, isNotNull); expect(error.diagnostics.length, 2); - expect(error.diagnostics.last, isInstanceOf()); + expect(error.diagnostics.last, isA()); expect( error.toStringDeep(), 'FlutterError\n' diff --git a/packages/flutter/test/services/platform_channel_test.dart b/packages/flutter/test/services/platform_channel_test.dart index 85e9382d2f..f318edbc0b 100644 --- a/packages/flutter/test/services/platform_channel_test.dart +++ b/packages/flutter/test/services/platform_channel_test.dart @@ -70,7 +70,7 @@ void main() { } }, ); - expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isInstanceOf())); + expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isCastError)); expect(await channel.invokeListMethod('sayHello', 'hello'), ['hello', 'world']); }); @@ -102,7 +102,7 @@ void main() { } }, ); - expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isInstanceOf())); + expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isCastError)); expect(await channel.invokeMapMethod('sayHello', 'hello'), {'hello': 'world'}); }); @@ -292,7 +292,7 @@ void main() { await Future.delayed(Duration.zero); expect(events, isEmpty); expect(errors, hasLength(1)); - expect(errors[0], isInstanceOf()); + expect(errors[0], isA()); final PlatformException error = errors[0] as PlatformException; expect(error.code, '404'); expect(error.message, 'Not Found.'); diff --git a/packages/flutter/test/services/platform_views_test.dart b/packages/flutter/test/services/platform_views_test.dart index 33a313d1f5..0adbd46264 100644 --- a/packages/flutter/test/services/platform_views_test.dart +++ b/packages/flutter/test/services/platform_views_test.dart @@ -27,7 +27,7 @@ void main() { layoutDirection: TextDirection.ltr, ).setSize(const Size(100.0, 100.0)); }, - throwsA(isInstanceOf()), + throwsA(isA()), ); }); @@ -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())); + throwsA(isA())); }); test('dispose Android view', () async { @@ -170,7 +170,7 @@ void main() { layoutDirection: TextDirection.ltr, ); }, - throwsA(isInstanceOf()), + throwsA(isA()), ); }); @@ -199,7 +199,7 @@ void main() { expect( () => PlatformViewsService.initUiKitView( id: 0, viewType: 'web', layoutDirection: TextDirection.ltr), - throwsA(isInstanceOf()), + throwsA(isA()), ); }); @@ -228,7 +228,7 @@ void main() { () async { await viewController.dispose(); }, - throwsA(isInstanceOf()), + throwsA(isA()), ); }); }); diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart index 479412db68..30e68f8d63 100644 --- a/packages/flutter/test/widgets/animated_list_test.dart +++ b/packages/flutter/test/widgets/animated_list_test.dart @@ -344,7 +344,7 @@ void main() { 'https://api.flutter.dev/flutter/widgets/AnimatedListState-class.html\n' ), ); - expect(error.diagnostics[3], isInstanceOf>()); + expect(error.diagnostics[3], isA>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/animated_switcher_test.dart b/packages/flutter/test/widgets/animated_switcher_test.dart index 3864852882..ea67750a5f 100644 --- a/packages/flutter/test/widgets/animated_switcher_test.dart +++ b/packages/flutter/test/widgets/animated_switcher_test.dart @@ -262,7 +262,7 @@ void main() { expect(find.byType(Column), findsOneWidget); for (final Widget child in foundChildren) { - expect(child, isInstanceOf()); + expect(child, isA()); } 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()); + expect(child, isA()); 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()); + expect(child, isA()); 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()); + expect(child, isA()); expect( find.descendant(of: find.byWidget(child), matching: find.byType(ScaleTransition)), findsOneWidget, diff --git a/packages/flutter/test/widgets/app_navigator_key_test.dart b/packages/flutter/test/widgets/app_navigator_key_test.dart index 575b5ce622..cb4a10f097 100644 --- a/packages/flutter/test/widgets/app_navigator_key_test.dart +++ b/packages/flutter/test/widgets/app_navigator_key_test.dart @@ -20,7 +20,7 @@ void main() { color: const Color(0xFF112233), onGenerateRoute: generateRoute, )); - expect(key.currentState, isInstanceOf()); + expect(key.currentState, isA()); 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()); + expect(key.currentState, isA()); }); } diff --git a/packages/flutter/test/widgets/debug_test.dart b/packages/flutter/test/widgets/debug_test.dart index f374493df4..ea46c858e6 100644 --- a/packages/flutter/test/widgets/debug_test.dart +++ b/packages/flutter/test/widgets/debug_test.dart @@ -74,7 +74,7 @@ void main() { } finally { expect(error, isNotNull); expect(error.diagnostics.length, 4); - expect(error.diagnostics[2], isInstanceOf>()); + expect(error.diagnostics[2], isA>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( @@ -106,7 +106,7 @@ void main() { } finally { expect(error, isNotNull); expect(error.diagnostics.length, 5); - expect(error.diagnostics[2], isInstanceOf>()); + expect(error.diagnostics[2], isA>()); 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>()); + expect(error.diagnostics[1], isA>()); 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>()); + expect(error.diagnostics[1], isA>()); expect(error.diagnostics[1].style, DiagnosticsTreeStyle.errorProperty); expect( error.diagnostics[1].toStringDeep(), diff --git a/packages/flutter/test/widgets/flow_test.dart b/packages/flutter/test/widgets/flow_test.dart index df522f147c..4386b15e79 100644 --- a/packages/flutter/test/widgets/flow_test.dart +++ b/packages/flutter/test/widgets/flow_test.dart @@ -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()); + expect(layer, isA()); final OpacityLayer opacityLayer = layer as OpacityLayer; expect(opacityLayer.alpha, equals(opacity * 255)); - expect(layer.firstChild, isInstanceOf()); + expect(layer.firstChild, isA()); }); } diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index d150287c8d..f3e1a6ddd9 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -543,7 +543,7 @@ Future main() async { final FlutterError error = exception as FlutterError; expect(error.diagnostics.length, 3); final DiagnosticsNode last = error.diagnostics.last; - expect(last, isInstanceOf>()); + expect(last, isA>()); expect( last.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index db2d5e7456..ff656085b4 100644 --- a/packages/flutter/test/widgets/image_test.dart +++ b/packages/flutter/test/widgets/image_test.dart @@ -1101,14 +1101,14 @@ void main() { expect(find.byType(Center), findsOneWidget); expect(find.byType(Padding), findsOneWidget); expect(find.byType(RawImage), findsOneWidget); - expect(tester.widget(find.byType(Padding)).child, isInstanceOf()); + expect(tester.widget(find.byType(Padding)).child, isA()); 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
(find.byType(Center)).child, isInstanceOf()); - expect(tester.widget(find.byType(Padding)).child, isInstanceOf()); + expect(tester.widget
(find.byType(Center)).child, isA()); + expect(tester.widget(find.byType(Padding)).child, isA()); }, skip: isBrowser); testWidgets('Image state handles loadingBuilder update from null to non-null', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/media_query_test.dart b/packages/flutter/test/widgets/media_query_test.dart index ebc09fe018..966fa90d49 100644 --- a/packages/flutter/test/widgets/media_query_test.dart +++ b/packages/flutter/test/widgets/media_query_test.dart @@ -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>()); + expect(error.diagnostics.last, isA>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index fe6242a668..c51429f73b 100644 --- a/packages/flutter/test/widgets/multichild_test.dart +++ b/packages/flutter/test/widgets/multichild_test.dart @@ -13,12 +13,12 @@ void checkTree(WidgetTester tester, List expectedDecorations) { (Element element) => element is MultiChildRenderObjectElement )); expect(element, isNotNull); - expect(element.renderObject is RenderStack, isTrue); + expect(element.renderObject, isA()); 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()); final RenderDecoratedBox decoratedBox = child as RenderDecoratedBox; expect(decoratedBox.decoration, equals(decoration)); final StackParentData decoratedBoxParentData = decoratedBox.parentData as StackParentData; diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 5522c1179d..8e90e32b19 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -155,7 +155,7 @@ void main() { ); await tester.pumpWidget(widget); await tester.tap(find.byKey(targetKey)); - expect(exception, isInstanceOf()); + 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()); 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>()); + expect(error.diagnostics.last, isA>()); 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>()); + expect(error.diagnostics.last, isA>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index 0453fcd861..afa01f42f0 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -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>()); + expect(error.diagnostics[3], isA>()); expect(error.diagnostics[3].value, debugRequiredFor); - expect(error.diagnostics[4], isInstanceOf>()); + expect(error.diagnostics[4], isA>()); expect(error.toStringDeep(), equalsIgnoringHashCodes( 'FlutterError\n' ' No Overlay widget found.\n' diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index e7ba8de58c..52390c1b03 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart @@ -22,14 +22,14 @@ void checkTree(WidgetTester tester, List expectedParentData) { find.byElementPredicate((Element element) => element is MultiChildRenderObjectElement) ); expect(element, isNotNull); - expect(element.renderObject is RenderStack, isTrue); + expect(element.renderObject, isA()); 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()); final RenderDecoratedBox decoratedBox = child as RenderDecoratedBox; - expect(decoratedBox.parentData is StackParentData, isTrue); + expect(decoratedBox.parentData, isA()); final StackParentData parentData = decoratedBox.parentData as StackParentData; expect(parentData.top, equals(expected.top)); expect(parentData.right, equals(expected.right)); diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index dd495ee3e8..0780f5a753 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -105,7 +105,7 @@ void main() { ); final dynamic exception = tester.takeException(); - expect(exception, isInstanceOf()); + expect(exception, isFlutterError); expect(exception.diagnostics.first.level, DiagnosticLevel.summary); expect(exception.diagnostics.first.toString(), startsWith('A RenderFlex overflowed by ')); await expectLater( diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 2db80b5b32..b37ef085c6 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -128,7 +128,7 @@ void main() { ); final Layer textureParentLayer = tester.layers[tester.layers.length - 2]; - expect(textureParentLayer, isInstanceOf()); + expect(textureParentLayer, isA()); final ClipRectLayer clipRect = textureParentLayer as ClipRectLayer; expect(clipRect.clipRect, const Rect.fromLTWH(0.0, 0.0, 100.0, 50.0)); expect( diff --git a/packages/flutter/test/widgets/render_object_widget_test.dart b/packages/flutter/test/widgets/render_object_widget_test.dart index d1222906cc..6b781cdda6 100644 --- a/packages/flutter/test/widgets/render_object_widget_test.dart +++ b/packages/flutter/test/widgets/render_object_widget_test.dart @@ -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 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()); 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()); 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()); 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()); 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()); final RenderDecoratedBox parent = element.renderObject as RenderDecoratedBox; - expect(parent.child is RenderDecoratedBox, isTrue); + expect(parent.child, isA()); final RenderDecoratedBox child = parent.child as RenderDecoratedBox; expect(child.decoration, equals(kBoxDecorationB)); - expect(child.child is RenderDecoratedBox, isTrue); + expect(child.child, isA()); 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()); expect(element.renderObject, equals(parent)); expect(parent.child, isNull); diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 8db268cda0..17c04ef0b5 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -48,7 +48,7 @@ class TestRoute extends Route with LocalHistoryRoute { @override void didReplace(Route oldRoute) { - expect(oldRoute, isInstanceOf()); + expect(oldRoute, isA()); final TestRoute castRoute = oldRoute as TestRoute; log('didReplace ${castRoute.name}'); super.didReplace(castRoute); @@ -65,7 +65,7 @@ class TestRoute extends Route with LocalHistoryRoute { @override void didPopNext(Route nextRoute) { - expect(nextRoute, isInstanceOf()); + expect(nextRoute, isA()); final TestRoute castRoute = nextRoute as TestRoute; log('didPopNext ${castRoute.name}'); super.didPopNext(castRoute); @@ -73,7 +73,7 @@ class TestRoute extends Route with LocalHistoryRoute { @override void didChangeNext(Route nextRoute) { - expect(nextRoute, anyOf(isNull, isInstanceOf())); + expect(nextRoute, anyOf(isNull, isA())); final TestRoute castRoute = nextRoute as TestRoute; log('didChangeNext ${castRoute?.name}'); super.didChangeNext(castRoute); diff --git a/packages/flutter/test/widgets/scroll_behavior_test.dart b/packages/flutter/test/widgets/scroll_behavior_test.dart index 83d58659f2..2b5d130c01 100644 --- a/packages/flutter/test/widgets/scroll_behavior_test.dart +++ b/packages/flutter/test/widgets/scroll_behavior_test.dart @@ -47,7 +47,7 @@ void main() { expect(behavior, isNotNull); expect(behavior.flag, isTrue); - expect(position.physics, isInstanceOf()); + expect(position.physics, isA()); 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()); + expect(position.physics, isA()); // Regression test for https://github.com/flutter/flutter/issues/5856 metrics = position.copyWith(); expect(metrics.extentAfter, equals(400.0)); diff --git a/packages/flutter/test/widgets/scroll_notification_test.dart b/packages/flutter/test/widgets/scroll_notification_test.dart index 0801b7e939..adb0598122 100644 --- a/packages/flutter/test/widgets/scroll_notification_test.dart +++ b/packages/flutter/test/widgets/scroll_notification_test.dart @@ -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()); + expect(notification, isA()); 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()); + expect(notification, isA()); 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()); + expect(notification, isA()); expect(notification.depth, equals(0)); final ScrollEndNotification end = notification as ScrollEndNotification; expect(end.dragDetails, isNotNull); diff --git a/packages/flutter/test/widgets/scroll_physics_test.dart b/packages/flutter/test/widgets/scroll_physics_test.dart index 6c1dc3bc4e..6d830c284e 100644 --- a/packages/flutter/test/widgets/scroll_physics_test.dart +++ b/packages/flutter/test/widgets/scroll_physics_test.dart @@ -239,10 +239,10 @@ void main() { } finally { expect(error, isNotNull); expect(error.diagnostics.length, 4); - expect(error.diagnostics[2], isInstanceOf>()); + expect(error.diagnostics[2], isA>()); expect(error.diagnostics[2].style, DiagnosticsTreeStyle.errorProperty); expect(error.diagnostics[2].value, physics); - expect(error.diagnostics[3], isInstanceOf>()); + expect(error.diagnostics[3], isA>()); 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 diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index a7879ce5a2..ec6d8ab817 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -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()); + expect(view.physics, isA()); }); testWidgets('Non-primary ListViews are not always scrollable', (WidgetTester tester) async { final ListView view = ListView(primary: false); - expect(view.physics, isNot(isInstanceOf())); + expect(view.physics, isNot(isA())); }); testWidgets('Defaulting-to-primary ListViews are always scrollable', (WidgetTester tester) async { final ListView view = ListView(scrollDirection: Axis.vertical); - expect(view.physics, isInstanceOf()); + expect(view.physics, isA()); }); 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())); + expect(view.physics, isNot(isA())); }); 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()); + 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()); + expect(tester.takeException(), isA()); 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()); + expect(tester.takeException(), isA()); expect(finder, findsOneWidget); }); @@ -566,7 +566,7 @@ void main() { return const SizedBox(); }, itemCount: -1, - ), throwsA(isInstanceOf())); + ), throwsAssertionError); }); testWidgets('ListView.builder asserts on negative semanticChildCount', (WidgetTester tester) async { @@ -576,7 +576,7 @@ void main() { }, itemCount: 1, semanticChildCount: -1, - ), throwsA(isInstanceOf())); + ), throwsAssertionError); }); testWidgets('ListView.builder asserts on nonsensical childCount/semanticChildCount', (WidgetTester tester) async { @@ -586,6 +586,6 @@ void main() { }, itemCount: 1, semanticChildCount: 4, - ), throwsA(isInstanceOf())); + ), throwsAssertionError); }); } diff --git a/packages/flutter/test/widgets/semantics_clipping_test.dart b/packages/flutter/test/widgets/semantics_clipping_test.dart index a467a5b47d..da6145662e 100644 --- a/packages/flutter/test/widgets/semantics_clipping_test.dart +++ b/packages/flutter/test/widgets/semantics_clipping_test.dart @@ -40,7 +40,7 @@ void main() { )); final dynamic exception = tester.takeException(); - expect(exception, isInstanceOf()); + 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()); + expect(exception, isFlutterError); expect(exception.diagnostics.first.level, DiagnosticLevel.summary); expect(exception.diagnostics.first.toString(), contains('overflowed')); diff --git a/packages/flutter/test/widgets/set_state_5_test.dart b/packages/flutter/test/widgets/set_state_5_test.dart index cec26cc291..052032b1bd 100644 --- a/packages/flutter/test/widgets/set_state_5_test.dart +++ b/packages/flutter/test/widgets/set_state_5_test.dart @@ -29,6 +29,6 @@ class BadWidgetState extends State { void main() { testWidgets('setState() catches being used inside a constructor', (WidgetTester tester) async { await tester.pumpWidget(const BadWidget()); - expect(tester.takeException(), isInstanceOf()); + expect(tester.takeException(), isFlutterError); }); } diff --git a/packages/flutter/test/widgets/shape_decoration_test.dart b/packages/flutter/test/widgets/shape_decoration_test.dart index 56671ee038..87a93258e9 100644 --- a/packages/flutter/test/widgets/shape_decoration_test.dart +++ b/packages/flutter/test/widgets/shape_decoration_test.dart @@ -66,7 +66,7 @@ Future main() async { shape: BorderDirectional(start: BorderSide(color: Colors.red, width: 3)), ); - expect(decoration.padding, isInstanceOf()); + expect(decoration.padding, isA()); }); testWidgets('TestBorder and Directionality - 1', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index b5e1629262..8ba799cbc4 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -72,7 +72,7 @@ void main() { )); final ScrollableState scrollable = tester.state(find.byType(Scrollable)); - expect(scrollable.position, isInstanceOf()); + expect(scrollable.position, isA()); }); testWidgets('Sets PrimaryScrollController when primary', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart index ff24f87653..6f8c8c83c1 100644 --- a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart +++ b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart @@ -29,7 +29,7 @@ void main() { Center( child: NotificationListener( onNotification: (LayoutChangedNotification notification) { - expect(notification, isInstanceOf()); + expect(notification, isA()); notified = true; return true; }, diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart index 9563f344c6..a50e7bb272 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart @@ -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()); + expect(target.parent, isA()); final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData; final Offset actual = parentData.paintOffset; expect(actual, ideal); diff --git a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart index b97b05c0bb..d222442a80 100644 --- a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart @@ -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()); + expect(target.parent, isA()); final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData; final Offset actual = parentData.paintOffset; expect(actual, ideal); diff --git a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart index 3c8efeafe3..9728410e95 100644 --- a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart @@ -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()); + expect(target.parent, isA()); final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData; final Offset actual = parentData.paintOffset; expect(actual, ideal); diff --git a/packages/flutter/test/widgets/slivers_padding_test.dart b/packages/flutter/test/widgets/slivers_padding_test.dart index e1b6b3a059..305378a039 100644 --- a/packages/flutter/test/widgets/slivers_padding_test.dart +++ b/packages/flutter/test/widgets/slivers_padding_test.dart @@ -168,11 +168,11 @@ void main() { result = tester.hitTestOnBinding(const Offset(10.0, 10.0)); expect(result.path.first.target, tester.firstRenderObject(find.byType(Text))); result = tester.hitTestOnBinding(const Offset(10.0, 60.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(100.0, 100.0)); expect(result.path.first.target, tester.renderObjectList(find.byType(Text)).skip(1).first); result = tester.hitTestOnBinding(const Offset(100.0, 490.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(10.0, 520.0)); expect(result.path.first.target, tester.renderObjectList(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(find.byType(Text))); result = tester.hitTestOnBinding(const Offset(10.0, 600.0-60.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(100.0, 600.0-100.0)); expect(result.path.first.target, tester.renderObjectList(find.byType(Text)).skip(1).first); result = tester.hitTestOnBinding(const Offset(100.0, 600.0-490.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(10.0, 600.0-520.0)); expect(result.path.first.target, tester.renderObjectList(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(find.byType(Text))); result = tester.hitTestOnBinding(const Offset(800.0-60.0, 10.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(800.0-100.0, 100.0)); expect(result.path.first.target, tester.renderObjectList(find.byType(Text)).skip(1).first); result = tester.hitTestOnBinding(const Offset(800.0-490.0, 100.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(800.0-520.0, 10.0)); expect(result.path.first.target, tester.renderObjectList(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(find.byType(Text))); result = tester.hitTestOnBinding(const Offset(60.0, 10.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(100.0, 100.0)); expect(result.path.first.target, tester.renderObjectList(find.byType(Text)).skip(1).first); result = tester.hitTestOnBinding(const Offset(490.0, 100.0)); - expect(result.path.first.target, isInstanceOf()); + expect(result.path.first.target, isA()); result = tester.hitTestOnBinding(const Offset(520.0, 10.0)); expect(result.path.first.target, tester.renderObjectList(find.byType(Text)).last); }); diff --git a/packages/flutter/test/widgets/slivers_protocol_test.dart b/packages/flutter/test/widgets/slivers_protocol_test.dart index a89369b44a..deb480d320 100644 --- a/packages/flutter/test/widgets/slivers_protocol_test.dart +++ b/packages/flutter/test/widgets/slivers_protocol_test.dart @@ -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()); + expect(target.parent, isA()); final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData; final Offset actual = parentData.paintOffset; expect(actual, ideal); diff --git a/packages/flutter/test/widgets/stateful_component_test.dart b/packages/flutter/test/widgets/stateful_component_test.dart index 365fc324d5..4fbe63c9bf 100644 --- a/packages/flutter/test/widgets/stateful_component_test.dart +++ b/packages/flutter/test/widgets/stateful_component_test.dart @@ -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()); final RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox; expect(renderObject.decoration, equals(expectedDecoration)); } diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index b4dd6f4ff4..ffc17d9d68 100644 --- a/packages/flutter/test/widgets/ticker_provider_test.dart +++ b/packages/flutter/test/widgets/ticker_provider_test.dart @@ -118,7 +118,7 @@ void main() { 'calling dispose() on the AnimationController itself. Otherwise,\n' 'the ticker will leak.\n' ); - expect(error.diagnostics[3], isInstanceOf>()); + expect(error.diagnostics[3], isA>()); 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>()); + expect(error.diagnostics[3], isA>()); 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>()); + expect(error.diagnostics[3], isA>()); expect(error.toStringDeep().split('\n').take(14).join('\n'), equalsIgnoringHashCodes( 'FlutterError\n' ' _MultipleTickerTestState#00000(tickers: tracking 2 tickers) was\n' diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index 7ffba0dfa9..a0054843a4 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -80,7 +80,7 @@ void main() { actualDecoration = actualBox.decoration as BoxDecoration; expect(actualDecoration.color, const Color(0xFF7F7F7F)); - expect(actualDecoration.border, isInstanceOf()); + expect(actualDecoration.border, isA()); 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()); + expect(actualDecoration.border, isA()); final Border border = actualDecoration.border as Border; expect(border.left.width, closeTo(1.9, 0.1)); expect(border.left.style, BorderStyle.solid); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index 70c18dcc43..65261be484 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -728,7 +728,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(chainNode['node'], isMap); final Map jsonNode = chainNode['node'] as Map; expect(service.toObject(jsonNode['valueId'] as String), equals(element)); - expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf()); + expect(service.toObject(jsonNode['objectId'] as String), isA()); expect(chainNode['children'], isList); final List jsonChildren = chainNode['children'] as List; @@ -744,7 +744,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(jsonChildren[j], isMap); final Map childJson = jsonChildren[j] as Map; expect(service.toObject(childJson['valueId'] as String), equals(childrenElements[j])); - expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(childJson['objectId'] as String), isA()); } } }); @@ -761,7 +761,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < propertiesJson.length; ++i) { final Map propertyJson = propertiesJson[i] as Map; expect(service.toObject(propertyJson['valueId'] as String), equals(properties[i].value)); - expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(propertyJson['objectId'] as String), isA()); } }); @@ -790,7 +790,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < propertiesJson.length; ++i) { final Map propertyJson = propertiesJson[i] as Map; expect(service.toObject(propertyJson['valueId'] as String), equals(children[i].value)); - expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(propertyJson['objectId'] as String), isA()); } }); @@ -1168,7 +1168,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(chainNode['node'], isMap); final Map jsonNode = chainNode['node'] as Map; expect(service.toObject(jsonNode['valueId'] as String), equals(element)); - expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf()); + expect(service.toObject(jsonNode['objectId'] as String), isA()); expect(chainNode['children'], isList); final List jsonChildren = chainNode['children'] as List; @@ -1184,7 +1184,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(jsonChildren[j], isMap); final Map childJson = jsonChildren[j] as Map; expect(service.toObject(childJson['valueId'] as String), equals(childrenElements[j])); - expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(childJson['objectId'] as String), isA()); } } }); @@ -1200,7 +1200,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < propertiesJson.length; ++i) { final Map propertyJson = propertiesJson[i] as Map; expect(service.toObject(propertyJson['valueId'] as String), equals(properties[i].value)); - expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(propertyJson['objectId'] as String), isA()); } }); @@ -1228,7 +1228,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < propertiesJson.length; ++i) { final Map propertyJson = propertiesJson[i] as Map; expect(service.toObject(propertyJson['valueId'] as String), equals(children[i].value)); - expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(propertyJson['objectId'] as String), isA()); } }); @@ -1256,13 +1256,13 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < childrenJson.length; ++i) { final Map childJson = childrenJson[i] as Map; expect(service.toObject(childJson['valueId'] as String), equals(children[i].value)); - expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(childJson['objectId'] as String), isA()); final List propertiesJson = childJson['properties'] as List; final DiagnosticsNode diagnosticsNode = service.toObject(childJson['objectId'] as String) as DiagnosticsNode; final List expectedProperties = diagnosticsNode.getProperties(); for (final Map propertyJson in propertiesJson.cast>()) { final Object property = service.toObject(propertyJson['objectId'] as String); - expect(property, isInstanceOf()); + expect(property, isA()); expect(expectedProperties, contains(property)); } } @@ -1294,7 +1294,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { for (int i = 0; i < childrenJson.length; ++i) { final Map childJson = childrenJson[i] as Map; expect(service.toObject(childJson['valueId'] as String), equals(children[i].value)); - expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); + expect(service.toObject(childJson['objectId'] as String), isA()); final List propertiesJson = childJson['properties'] as List; for (final Map propertyJson in propertiesJson.cast>()) { expect(propertyJson, isNot(contains('children'))); @@ -1303,7 +1303,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { final List expectedProperties = diagnosticsNode.getProperties(); for (final Map propertyJson in propertiesJson.cast>()) { final Object property = service.toObject(propertyJson['objectId'] as String); - expect(property, isInstanceOf()); + expect(property, isA()); expect(expectedProperties, contains(property)); } } @@ -1670,7 +1670,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(rebuildEvents.length, equals(1)); Map event = rebuildEvents.removeLast(); - expect(event['startTime'], isInstanceOf()); + expect(event['startTime'], isA()); List data = event['events'] as List; 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()); + expect(event['startTime'], isA()); data = event['events'] as List; // 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()); + expect(event['startTime'], isA()); data = event['events'] as List; // 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()); + expect(event['startTime'], isA()); data = event['events'] as List; // 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()); + expect(event['startTime'], isA()); data = event['events'] as List; newLocations = event['newLocations'] as Map>; @@ -1872,7 +1872,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(repaintEvents.length, equals(1)); Map event = repaintEvents.removeLast(); - expect(event['startTime'], isInstanceOf()); + expect(event['startTime'], isA()); List data = event['events'] as List; 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()); + expect(event['startTime'], isA()); data = event['events'] as List; // No new locations were rebuilt. expect(event, isNot(contains('newLocations'))); diff --git a/packages/flutter_driver/test/common.dart b/packages/flutter_driver/test/common.dart index 80102180a8..e5987b02b1 100644 --- a/packages/flutter_driver/test/common.dart +++ b/packages/flutter_driver/test/common.dart @@ -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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); 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()); diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart index 894ed5182b..fbe67e9a9e 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -145,8 +145,7 @@ void main() { group('ByValueKey', () { test('restricts value types', () async { - expect(() => find.byValueKey(null), - throwsA(isInstanceOf())); + 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())); + 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())); + 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())); + 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())); - expect(driver.getTopLeft(null), throwsA(isInstanceOf())); - expect(driver.getTopRight(null), throwsA(isInstanceOf())); - expect(driver.getBottomLeft(null), throwsA(isInstanceOf())); - expect(driver.getBottomRight(null), throwsA(isInstanceOf())); + 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()); 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())); + 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())); + 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())); + 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())); + 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())); - expect(driver.getTopLeft(null), throwsA(isInstanceOf())); - expect(driver.getTopRight(null), throwsA(isInstanceOf())); - expect(driver.getBottomLeft(null), throwsA(isInstanceOf())); - expect(driver.getBottomRight(null), throwsA(isInstanceOf())); + 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())); + throwsA(isA())); }); test('getVmFlags', () async { expect(driver.getVmFlags(), - throwsA(isInstanceOf())); + throwsA(isA())); }); test('waitUntilFirstFrameRasterized', () async { expect(driver.waitUntilFirstFrameRasterized(), - throwsA(isInstanceOf())); + throwsA(isA())); }); test('appIsoloate', () async { expect(() => driver.appIsolate.invokeExtension('abc', {'abc': '123'}), - throwsA(isInstanceOf())); + throwsA(isA())); }); test('serviceClient', () async { expect(() => driver.serviceClient.getVM(), - throwsA(isInstanceOf())); + throwsA(isA())); }); }); }); @@ -1038,13 +1037,13 @@ void main() { test('tracing', () async { expect(driver.traceAction(() async { return Future.value(); }), - throwsA(isInstanceOf())); + throwsA(isA())); expect(driver.startTracing(), - throwsA(isInstanceOf())); + throwsA(isA())); expect(driver.stopTracingAndDownloadTimeline(), - throwsA(isInstanceOf())); + throwsA(isA())); expect(driver.clearTimeline(), - throwsA(isInstanceOf())); + throwsA(isA())); }); }); } @@ -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()); expect(script.startsWith(_kWebScriptPrefix), isTrue); expect(script.endsWith(_kWebScriptSuffix), isTrue); // Strip prefix and suffix diff --git a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart index dbde0501c1..3644bcf1dd 100644 --- a/packages/flutter_driver/test/src/real_tests/io_extension_test.dart +++ b/packages/flutter_driver/test/src/real_tests/io_extension_test.dart @@ -18,7 +18,7 @@ void main() { test('io_extension should throw exception', () { expect(() => registerWebServiceExtension(call), - throwsA(isInstanceOf())); + throwsA(isA())); }); }); } diff --git a/packages/flutter_localizations/test/cupertino/translations_test.dart b/packages/flutter_localizations/test/cupertino/translations_test.dart index d13974eb2c..3e5a7a0bcf 100644 --- a/packages/flutter_localizations/test/cupertino/translations_test.dart +++ b/packages/flutter_localizations/test/cupertino/translations_test.dart @@ -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()); 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()); expect(localizations.alertDialogLabel, '提醒'); expect(localizations.datePickerHourSemanticsLabel(1), '1 点'); expect(localizations.datePickerHourSemanticsLabel(12), '12 点'); diff --git a/packages/flutter_localizations/test/material/translations_test.dart b/packages/flutter_localizations/test/material/translations_test.dart index fa2c9468e9..1bb5c635e1 100644 --- a/packages/flutter_localizations/test/material/translations_test.dart +++ b/packages/flutter_localizations/test/material/translations_test.dart @@ -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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); }); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); }); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); 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()); }); 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()); 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()); 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()); 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()); 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()); expect(localizations.alertDialogLabel, '通知'); expect(localizations.anteMeridiemAbbreviation, '上午'); expect(localizations.closeButtonLabel, '關閉'); diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index ec459395df..7e26302522 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -162,7 +162,7 @@ const Matcher hasAGoodToStringDeep = _HasGoodToStringDeep(); /// A matcher for functions that throw [FlutterError]. /// -/// This is equivalent to `throwsA(isInstanceOf())`. +/// This is equivalent to `throwsA(isA())`. /// /// 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())`. +/// This is equivalent to `throwsA(isA())`. /// /// 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(); +final test_package.TypeMatcher isFlutterError = isA(); /// A matcher for [AssertionError]. /// @@ -207,11 +207,11 @@ final Matcher isFlutterError = isInstanceOf(); /// /// * [throwsAssertionError], to test if a function throws any [AssertionError]. /// * [isFlutterError], to test if any object is a [FlutterError]. -final Matcher isAssertionError = isInstanceOf(); +final test_package.TypeMatcher isAssertionError = isA(); /// 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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); /// Asserts that two [double]s are equal, within some tolerated error. /// diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart index 7799762585..e39c709235 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('$WidgetsBinding initializes with $LiveTestWidgetsFlutterBinding when FLUTTER_TEST = "false"', () { TestWidgetsFlutterBinding.ensureInitialized({'FLUTTER_TEST': 'false'}); - expect(WidgetsBinding.instance, isInstanceOf()); + expect(WidgetsBinding.instance, isA()); }, onPlatform: const { 'browser': [Skip('Browser will not use the live binding')] }); diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart index 8510a91a10..6b62b97345 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart @@ -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({'FLUTTER_TEST': 'value that is neither "true" nor "false"'}); - expect(WidgetsBinding.instance, isInstanceOf()); + expect(WidgetsBinding.instance, isA()); }); } diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart index 751c6e9c97..b42b4fbd14 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart @@ -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({'FLUTTER_TEST': null}); - expect(WidgetsBinding.instance, isInstanceOf()); + expect(WidgetsBinding.instance, isA()); }); } diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart index 0e8c16a90a..d44a683ae9 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart @@ -9,6 +9,6 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('$WidgetsBinding initializes with $AutomatedTestWidgetsFlutterBinding when FLUTTER_TEST = "true"', () { TestWidgetsFlutterBinding.ensureInitialized({'FLUTTER_TEST': 'true'}); - expect(WidgetsBinding.instance, isInstanceOf()); + expect(WidgetsBinding.instance, isA()); }); } diff --git a/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart b/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart index 16771c3ec1..72f75f100b 100644 --- a/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart +++ b/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart @@ -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({}); - expect(WidgetsBinding.instance, isInstanceOf()); + expect(WidgetsBinding.instance, isA()); }); } diff --git a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart index 5badb6398f..6e92939a83 100644 --- a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart +++ b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; Future main(FutureOr testMain()) async { reportTestException = (FlutterErrorDetails details, String testDescription) { - expect(details.exception, isInstanceOf()); + expect(details.exception, isA()); expect(details.exception.message, 'foo'); expect(testDescription, 'custom exception reporter'); }; diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart index fbff2b7787..4f30955c28 100644 --- a/packages/flutter_test/test/goldens_test.dart +++ b/packages/flutter_test/test/goldens_test.dart @@ -76,7 +76,7 @@ void main() { group('goldenFileComparator', () { test('is initialized by test framework', () { expect(goldenFileComparator, isNotNull); - expect(goldenFileComparator, isInstanceOf()); + expect(goldenFileComparator, isA()); final LocalFileComparator comparator = goldenFileComparator as LocalFileComparator; expect(comparator.basedir.path, contains('flutter_test')); }); diff --git a/packages/flutter_test/test/test_async_utils_test.dart b/packages/flutter_test/test/test_async_utils_test.dart index 5d7c9853ac..9e3e760b06 100644 --- a/packages/flutter_test/test/test_async_utils_test.dart +++ b/packages/flutter_test/test/test_async_utils_test.dart @@ -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>()); - real_test.expect(information[1], isInstanceOf>()); - real_test.expect(information[2], isInstanceOf>()); - real_test.expect(information[3], isInstanceOf>()); - real_test.expect(information[4], isInstanceOf>()); - real_test.expect(information[5], isInstanceOf()); + real_test.expect(information[0], isA>()); + real_test.expect(information[1], isA>()); + real_test.expect(information[2], isA>()); + real_test.expect(information[3], isA>()); + real_test.expect(information[4], isA>()); + real_test.expect(information[5], isA()); 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()); + real_test.expect(stackTraceProperty.value, isA()); } await f1; await f2; diff --git a/packages/flutter_test/test/test_text_input_test.dart b/packages/flutter_test/test/test_text_input_test.dart index 116e23fed9..dfcc6024c2 100644 --- a/packages/flutter_test/test/test_text_input_test.dart +++ b/packages/flutter_test/test/test_text_input_test.dart @@ -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()); + expect(e, isA()); } }); } diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index 0222794c67..fa854ab283 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -33,8 +33,7 @@ void main() { ), ); - expect(() => tester.getSemantics(find.text('hello')), - throwsA(isInstanceOf())); + 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())); + expect(() => tester.getSemantics(find.text('hello')), throwsStateError); semanticsHandle.dispose(); }); @@ -472,7 +470,7 @@ void main() { expect( expectAsync0(tester.pageBack), - throwsA(isInstanceOf()), + throwsA(isA()), ); }); @@ -629,7 +627,7 @@ void main() { testWidgets('disallows re-entry', (WidgetTester tester) async { final Completer completer = Completer(); tester.runAsync(() => completer.future); - expect(() => tester.runAsync(() async { }), throwsA(isInstanceOf())); + expect(() => tester.runAsync(() async { }), throwsA(isA())); 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>()); + expect(error.diagnostics.last, isA>()); expect(error.diagnostics.last.value, ticker); expect(error.toStringDeep(), startsWith( 'FlutterError\n' diff --git a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart index 3eeef208eb..ceeedc1056 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart @@ -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 commandRunner = createTestCommandRunner(AssembleCommand()); expect(commandRunner.run(['assemble', 'debug_macos_bundle_flutter_assets']), - throwsA(isInstanceOf())); + throwsToolExit()); }); testbed.test('Throws ToolExit if called with non-existent rule', () async { @@ -64,7 +63,7 @@ void main() { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand()); expect(commandRunner.run(['assemble', '-o Output', 'undefined']), - throwsA(isInstanceOf())); + throwsToolExit()); }); testbed.test('Does not log stack traces during build failure', () async { @@ -78,7 +77,7 @@ void main() { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand()); await expectLater(commandRunner.run(['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']), - throwsA(isInstanceOf())); + throwsToolExit()); expect(testLogger.errorText, contains('bar')); expect(testLogger.errorText, isNot(contains(testStackTrace.toString()))); }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index c51c3722bb..2231ed7026 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -240,7 +240,7 @@ void main() { }); testDeviceManager.addDevice(device); expect(createTestCommandRunner(AttachCommand()).run(['attach']), - throwsA(isA())); + throwsToolExit()); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -619,7 +619,7 @@ void main() { final AttachCommand command = AttachCommand(); await expectLater( createTestCommandRunner(command).run(['attach']), - throwsA(isInstanceOf()), + throwsToolExit(), ); expect(testLogger.statusText, contains('No supported devices connected')); }, overrides: { @@ -642,7 +642,7 @@ void main() { testDeviceManager.addDevice(aDeviceWithId('yy2')); await expectLater( createTestCommandRunner(command).run(['attach']), - throwsA(isInstanceOf()), + throwsToolExit(), ); expect(testLogger.statusText, contains('More than one device')); expect(testLogger.statusText, contains('xx1')); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart index 404ab8609a..3597a17aee 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart @@ -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 ['build', 'fuchsia']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -67,7 +66,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -89,7 +88,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { Platform: () => windowsPlatform, FileSystem: () => MemoryFileSystem(), @@ -111,7 +110,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart index e6a7244a7d..9f1f166bc4 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart @@ -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 ['build', 'linux'] - ), throwsA(isInstanceOf())); + ), throwsToolExit()); }, overrides: { Platform: () => notLinuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -220,7 +219,7 @@ BINARY_NAME=fizz_bar final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'linux']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false), }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart index 18ad8d42f3..2797f144b0 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart @@ -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 ['build', 'macos'] - ), throwsA(isInstanceOf())); + ), throwsToolExit()); }, overrides: { Platform: () => notMacosPlatform, FileSystem: () => MemoryFileSystem(), @@ -206,7 +205,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'macos']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false), }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart index 96c790d329..b5026e59dc 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart @@ -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 [], false, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); })); test('Refuses to build using runner when missing index.html', () => testbed.run(() async { @@ -82,7 +81,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'web', '--debug']), - throwsA(isInstanceOf())); + throwsA(isA())); }, overrides: { FeatureFlags: () => TestFeatureFlags(isWebEnabled: true), })); @@ -91,7 +90,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'web']), - throwsA(isInstanceOf())); + throwsToolExit()); }, overrides: { FeatureFlags: () => TestFeatureFlags(isWebEnabled: false), })); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart index 5b2f571b83..0ec38b5c69 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart @@ -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 ['build', 'windows'] - ), throwsA(isInstanceOf())); + ), throwsToolExit()); }, overrides: { Platform: () => windowsPlatform, FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows), @@ -110,7 +109,7 @@ void main() { expect(createTestCommandRunner(command).run( const ['build', 'windows'] - ), throwsA(isInstanceOf())); + ), throwsToolExit()); }, overrides: { Platform: () => notWindowsPlatform, FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart index bcb43383d6..8c6def3c89 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart @@ -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([ 'config', '--build-dir=/foo', - ]), throwsA(isInstanceOf())); + ]), throwsToolExit()); verifyNoAnalytics(); }, overrides: { Usage: () => mockUsage, diff --git a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart index ba5053b96e..0cda0357ee 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart @@ -47,7 +47,7 @@ void main() { final Map response = await responses.stream.firstWhere(_notEvent); expect(response['id'], 0); expect(response['result'], isNotEmpty); - expect(response['result'] is String, true); + expect(response['result'], isA()); await responses.close(); await commands.close(); }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index 466f4c8c63..3be414b11f 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -111,7 +111,7 @@ void main() { ]); fail('Expect exception'); } catch (e) { - expect(e, isInstanceOf()); + expect(e, isA()); } final BufferLogger bufferLogger = globals.logger as BufferLogger; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart index 30b8c86c23..53f64d5343 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/version_test.dart @@ -107,7 +107,7 @@ void main() { '--no-pub', version, ]), - throwsA(isInstanceOf()), + throwsToolExit(), ); }, overrides: { ProcessManager: () => MockProcessManager(), @@ -119,7 +119,7 @@ void main() { await command.getTags(); fail('ToolExit expected'); } catch(e) { - expect(e, isInstanceOf()); + expect(e, isA()); } }, overrides: { ProcessManager: () => MockProcessManager(failGitTag: true), diff --git a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart index 3018b67388..2db9ff820c 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart @@ -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())); + ]), throwsToolExit()); }, overrides: { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -127,7 +126,7 @@ void main() { 'bundle', '--no-pub', '--target-platform=linux-x64', - ]), throwsA(isInstanceOf())); + ]), throwsToolExit()); }, overrides: { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -145,7 +144,7 @@ void main() { 'bundle', '--no-pub', '--target-platform=darwin-x64', - ]), throwsA(isInstanceOf())); + ]), throwsToolExit()); }, overrides: { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), diff --git a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart index 4fc4ebc137..e89aac6ec6 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart @@ -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())); + expect(result, throwsToolExit()); }, overrides: { Platform: () => fakePlatform, }); @@ -89,7 +88,7 @@ void main() { gitTagVersion, flutterVersion, ); - expect(result, throwsA(isA())); + expect(result, throwsToolExit()); }, overrides: { Platform: () => fakePlatform, }); diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart index d2d82a78be..603e18f771 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart @@ -652,7 +652,7 @@ flutter: when(mockProcessManager.run(argThat(contains('forward')))) .thenAnswer((_) async => ProcessResult(0, 0, '123456', '')); - expect(forwarder.forward(123, hostPort: 456), throwsA(isInstanceOf())); + expect(forwarder.forward(123, hostPort: 456), throwsA(isA())); }, overrides: { ProcessManager: () => mockProcessManager, }); diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart index 7ff225e41d..da7dcd3ec8 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart @@ -1356,7 +1356,7 @@ plugin1=${plugin1.path} localGradleErrors: const [], ); }, - throwsA(isInstanceOf())); + throwsA(isA())); }, overrides: { AndroidSdk: () => mockAndroidSdk, diff --git a/packages/flutter_tools/test/general.shard/base/common_test.dart b/packages/flutter_tools/test/general.shard/base/common_test.dart index 958e0ad71d..0ffb6c2899 100644 --- a/packages/flutter_tools/test/general.shard/base/common_test.dart +++ b/packages/flutter_tools/test/general.shard/base/common_test.dart @@ -26,7 +26,7 @@ void main() { }); testWithoutContext('Throws if accessing the Zone', () { - expect(() => context.get(), throwsA(isInstanceOf())); + expect(() => context.get(), throwsA(isA())); }); }); } diff --git a/packages/flutter_tools/test/general.shard/base/io_test.dart b/packages/flutter_tools/test/general.shard/base/io_test.dart index c6778d0a24..603b07c625 100644 --- a/packages/flutter_tools/test/general.shard/base/io_test.dart +++ b/packages/flutter_tools/test/general.shard/base/io_test.dart @@ -70,7 +70,7 @@ void main() { }); test('exit throws a StateError if called without being overriden', () { - expect(() => exit(0), throwsA(isInstanceOf())); + expect(() => exit(0), throwsAssertionError); }); test('exit does not throw a StateError if overriden', () { diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart index 3b15509114..eb7bf9c3d0 100644 --- a/packages/flutter_tools/test/general.shard/base/logger_test.dart +++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart @@ -144,8 +144,8 @@ void main() { expect(lines.length, equals(1)); // Verify that stopping or canceling multiple times throws. - expect(ansiSpinner.stop, throwsA(isInstanceOf())); - expect(ansiSpinner.cancel, throwsA(isInstanceOf())); + expect(ansiSpinner.stop, throwsAssertionError); + expect(ansiSpinner.cancel, throwsAssertionError); done = true; }); expect(done, isTrue); @@ -323,8 +323,8 @@ void main() { expect(lines[1], equals('')); // Verify that stopping or canceling multiple times throws. - expect(() { ansiStatus.cancel(); }, throwsA(isInstanceOf())); - expect(() { ansiStatus.stop(); }, throwsA(isInstanceOf())); + expect(() { ansiStatus.cancel(); }, throwsAssertionError); + expect(() { ansiStatus.stop(); }, throwsAssertionError); done = true; }); expect(done, isTrue); @@ -367,8 +367,8 @@ void main() { expect(lines[1], equals('')); // Verify that stopping or canceling multiple times throws. - expect(ansiStatus.stop, throwsA(isInstanceOf())); - expect(ansiStatus.cancel, throwsA(isInstanceOf())); + expect(ansiStatus.stop, throwsAssertionError); + expect(ansiStatus.cancel, throwsAssertionError); done = true; }); expect(done, isTrue); @@ -736,8 +736,8 @@ void main() { expect(lines[1], equals('')); // Verify that stopping or canceling multiple times throws. - expect(summaryStatus.cancel, throwsA(isInstanceOf())); - expect(summaryStatus.stop, throwsA(isInstanceOf())); + expect(summaryStatus.cancel, throwsAssertionError); + expect(summaryStatus.stop, throwsAssertionError); }); testWithoutContext('SummaryStatus works when stopped', () async { @@ -759,8 +759,8 @@ void main() { expect(lines[1], equals('')); // Verify that stopping or canceling multiple times throws. - expect(summaryStatus.stop, throwsA(isInstanceOf())); - expect(summaryStatus.cancel, throwsA(isInstanceOf())); + expect(summaryStatus.stop, throwsAssertionError); + expect(summaryStatus.cancel, throwsAssertionError); }); testWithoutContext('sequential startProgress calls with StdoutLogger', () async { diff --git a/packages/flutter_tools/test/general.shard/base/process_test.dart b/packages/flutter_tools/test/general.shard/base/process_test.dart index 605d417ff9..025976729e 100644 --- a/packages/flutter_tools/test/general.shard/base/process_test.dart +++ b/packages/flutter_tools/test/general.shard/base/process_test.dart @@ -38,7 +38,7 @@ void main() { when(mockProcessManager.run(['false'])).thenAnswer( (Invocation invocation) => Future.value(ProcessResult(0, 1, '', ''))); expect(() async => await processUtils.run(['false'], throwOnError: true), - throwsA(isInstanceOf())); + throwsA(isA())); }); }); @@ -236,7 +236,7 @@ void main() { ['dummy'], timeout: delay - const Duration(milliseconds: 500), timeoutRetries: 0, - ), throwsA(isInstanceOf())); + ), throwsA(isA())); }); }); diff --git a/packages/flutter_tools/test/general.shard/base/terminal_test.dart b/packages/flutter_tools/test/general.shard/base/terminal_test.dart index 78bb1d4647..d36b95982c 100644 --- a/packages/flutter_tools/test/general.shard/base/terminal_test.dart +++ b/packages/flutter_tools/test/general.shard/base/terminal_test.dart @@ -120,7 +120,7 @@ void main() { ['a', 'b', 'c'], prompt: 'Please choose something', logger: null, - ), throwsA(isInstanceOf())); + ), throwsStateError); }); testWithoutContext('character prompt', () async { diff --git a/packages/flutter_tools/test/general.shard/build_info_test.dart b/packages/flutter_tools/test/general.shard/build_info_test.dart index 7aa13b91b9..fcd28eefb6 100644 --- a/packages/flutter_tools/test/general.shard/build_info_test.dart +++ b/packages/flutter_tools/test/general.shard/build_info_test.dart @@ -75,7 +75,7 @@ void main() { expect(BuildMode.fromName('profile'), BuildMode.profile); expect(BuildMode.fromName('jit_release'), BuildMode.jitRelease); expect(BuildMode.fromName('release'), BuildMode.release); - expect(() => BuildMode.fromName('foo'), throwsA(isInstanceOf())); + expect(() => BuildMode.fromName('foo'), throwsArgumentError); }); }); } diff --git a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart index 778fb59791..6bc91d59f3 100644 --- a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart @@ -309,7 +309,7 @@ void main() { barTarget.dependencies.add(fooTarget); fooTarget.dependencies.add(barTarget); - expect(() => checkCycles(barTarget), throwsA(isInstanceOf())); + expect(() => checkCycles(barTarget), throwsA(isA())); }); test('Target with depfile dependency will not run twice without invalidation', () => testbed.run(() async { diff --git a/packages/flutter_tools/test/general.shard/build_system/source_test.dart b/packages/flutter_tools/test/general.shard/build_system/source_test.dart index a1dd81ab39..56e22bb477 100644 --- a/packages/flutter_tools/test/general.shard/build_system/source_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/source_test.dart @@ -141,14 +141,14 @@ void main() { globals.fs.file('abcd.bar').createSync(); - expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf())); + expect(() => fizzSource.accept(visitor), throwsA(isA())); })); test('can\'t substitute foo', () => testbed.run(() { const Source invalidBase = Source.pattern('foo'); - expect(() => invalidBase.accept(visitor), throwsA(isInstanceOf())); + expect(() => invalidBase.accept(visitor), throwsA(isA())); })); test('can substitute optional files', () => testbed.run(() { diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart index c3c92957f7..baa0699cef 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart @@ -113,7 +113,7 @@ flutter_tools:lib/'''); final BuildResult result = await buildSystem.build(const KernelSnapshot(), androidEnvironment..defines.remove(kBuildMode)); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('kernel_snapshot handles null result from kernel compilation', () => testbed.run(() async { @@ -141,7 +141,7 @@ flutter_tools:lib/'''); }); final BuildResult result = await buildSystem.build(const KernelSnapshot(), androidEnvironment); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('kernel_snapshot does not use track widget creation on profile builds', () => testbed.run(() async { @@ -283,35 +283,35 @@ flutter_tools:lib/'''); final BuildResult result = await buildSystem.build(const AotElfProfile(), androidEnvironment..defines.remove(kBuildMode)); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('aot_elf_profile throws error if missing target platform', () => testbed.run(() async { final BuildResult result = await buildSystem.build(const AotElfProfile(), androidEnvironment..defines.remove(kTargetPlatform)); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('aot_assembly_profile throws error if missing build mode', () => testbed.run(() async { final BuildResult result = await buildSystem.build(const AotAssemblyProfile(), iosEnvironment..defines.remove(kBuildMode)); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('aot_assembly_profile throws error if missing target platform', () => testbed.run(() async { final BuildResult result = await buildSystem.build(const AotAssemblyProfile(), iosEnvironment..defines.remove(kTargetPlatform)); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('aot_assembly_profile throws error if built for non-iOS platform', () => testbed.run(() async { final BuildResult result = await buildSystem .build(const AotAssemblyProfile(), androidEnvironment); - expect(result.exceptions.values.single.exception, isInstanceOf()); + expect(result.exceptions.values.single.exception, isA()); })); test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async { diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart index e3c86708aa..c2fc39cea1 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart @@ -126,7 +126,7 @@ void main() { ..writeAsStringSync('testing'); expect(() async => await const DebugMacOSBundleFlutterAssets().build(environment), - throwsA(isInstanceOf())); + throwsException); })); test('debug macOS application creates correctly structured framework', () => testbed.run(() async { diff --git a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart index 706bf73264..770602be3f 100644 --- a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart +++ b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/bundle.dart'; @@ -62,7 +61,7 @@ void main() { targetPlatform: TargetPlatform.linux_x64, depfilePath: 'example.d', precompiled: false, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); })); } diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index c0aaf67f81..ec1ae04199 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -12,7 +12,6 @@ import 'package:platform/platform.dart'; import 'package:process/process.dart'; import 'package:flutter_tools/src/android/gradle_utils.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/base/file_system.dart'; @@ -72,7 +71,7 @@ void main() { testUsingContext('throws tool exit when lockfile open fails', () async { when(mockFileSystem.file(argThat(endsWith('lockfile')))).thenReturn(mockFile); when(mockFile.openSync(mode: anyNamed('mode'))).thenThrow(const FileSystemException()); - expect(() async => await Cache.lock(), throwsA(isA())); + expect(() async => await Cache.lock(), throwsToolExit()); }, overrides: { FileSystem: () => mockFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -231,7 +230,7 @@ void main() { 'FLUTTER_STORAGE_BASE_URL': ' http://foo', }); final Cache cache = Cache(); - expect(() => cache.storageBaseUrl, throwsA(isInstanceOf())); + expect(() => cache.storageBaseUrl, throwsToolExit()); }, overrides: { Platform: () => MockPlatform(), }); diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart index 9279c8b7c4..79788bacc1 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:flutter_tools/src/base/async_guard.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; @@ -82,7 +81,7 @@ void main() { '/path/to/main.dart', null, /* invalidatedFiles */ outputPath: '/build/', - )), throwsA(isInstanceOf())); + )), throwsToolExit()); }, overrides: { ProcessManager: () => mockProcessManager, OutputPreferences: () => OutputPreferences(showColor: false), @@ -100,7 +99,7 @@ void main() { '/path/to/main.dart', null, /* invalidatedFiles */ outputPath: '/build/', - )), throwsA(isInstanceOf())); + )), throwsToolExit()); }, overrides: { ProcessManager: () => mockProcessManager, OutputPreferences: () => OutputPreferences(showColor: false), diff --git a/packages/flutter_tools/test/general.shard/compile_test.dart b/packages/flutter_tools/test/general.shard/compile_test.dart index 412e9d504e..7901a82ed2 100644 --- a/packages/flutter_tools/test/general.shard/compile_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/compile.dart'; import '../src/common.dart'; @@ -25,7 +24,7 @@ void main() { final Future output = stdoutHandler.compilerOutput.future; stdoutHandler.handler('message with no result'); - expect(output, throwsA(isInstanceOf())); + expect(output, throwsToolExit()); }); test('TargetModel values', () { @@ -41,6 +40,6 @@ void main() { expect(TargetModel('dartdevc'), TargetModel.dartdevc); expect(TargetModel.dartdevc.toString(), 'dartdevc'); - expect(() => TargetModel('foobar'), throwsA(isInstanceOf())); + expect(() => TargetModel('foobar'), throwsAssertionError); }); } diff --git a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart index ff95577f20..f820969924 100644 --- a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart @@ -328,7 +328,7 @@ void main() { await pub.get(context: PubContext.flutterTests, checkLastModified: true); expect(true, isFalse, reason: 'pub.get did not throw'); } catch (error) { - expect(error, isInstanceOf()); + expect(error, isA()); expect(error.message, '/: unexpected concurrent modification of pubspec.yaml while running pub.'); } expect(testLogger.statusText, 'Running "flutter pub get" in /...\n'); diff --git a/packages/flutter_tools/test/general.shard/doctor.dart b/packages/flutter_tools/test/general.shard/doctor.dart index 9f0913f0c0..3839adf344 100644 --- a/packages/flutter_tools/test/general.shard/doctor.dart +++ b/packages/flutter_tools/test/general.shard/doctor.dart @@ -20,9 +20,9 @@ void main() { test('doctor validators includes desktop when features are enabled', () => testbed.run(() { expect(DoctorValidatorsProvider.defaultInstance.validators, - contains(isInstanceOf())); + contains(isA())); expect(DoctorValidatorsProvider.defaultInstance.validators, - contains(isInstanceOf())); + contains(isA())); }, overrides: { FeatureFlags: () => TestFeatureFlags( isLinuxEnabled: true, @@ -32,9 +32,9 @@ void main() { test('doctor validators does not include desktop when features are enabled', () => testbed.run(() { expect(DoctorValidatorsProvider.defaultInstance.validators, - isNot(contains(isInstanceOf()))); + isNot(contains(isA()))); expect(DoctorValidatorsProvider.defaultInstance.validators, - isNot(contains(isInstanceOf()))); + isNot(contains(isA()))); }, overrides: { FeatureFlags: () => TestFeatureFlags( isLinuxEnabled: false, @@ -44,7 +44,7 @@ void main() { test('doctor validators includes web when feature is enabled', () => testbed.run(() { expect(DoctorValidatorsProvider.defaultInstance.validators, - contains(isInstanceOf())); + contains(isA())); }, overrides: { FeatureFlags: () => TestFeatureFlags( isWebEnabled: true, @@ -53,7 +53,7 @@ void main() { test('doctor validators does not include web when feature is disabled', () => testbed.run(() { expect(DoctorValidatorsProvider.defaultInstance.validators, - isNot(contains(isInstanceOf()))); + isNot(contains(isA()))); }, overrides: { FeatureFlags: () => TestFeatureFlags( isWebEnabled: false, diff --git a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart index fb9f9f1259..13ef1afe95 100644 --- a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter_tools/src/build_info.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/test/flutter_platform.dart'; import 'package:meta/meta.dart'; @@ -21,13 +20,13 @@ void main() { testUsingContext('ensureConfiguration throws an error if an explicitObservatoryPort is specified and more than one test file', () async { final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', explicitObservatoryPort: 1234); flutterPlatform.loadChannel('test1.dart', MockSuitePlatform()); - expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA())); + expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit()); }); testUsingContext('ensureConfiguration throws an error if a precompiled entrypoint is specified and more that one test file', () { final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', precompiledDillPath: 'example.dill'); flutterPlatform.loadChannel('test1.dart', MockSuitePlatform()); - expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA())); + expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsToolExit()); }); group('The FLUTTER_TEST environment variable is passed to the test process', () { @@ -50,7 +49,7 @@ void main() { await untilCalled(mockProcessManager.start(any, environment: anyNamed('environment'))); final VerificationResult toVerify = verify(mockProcessManager.start(any, environment: captureAnyNamed('environment'))); expect(toVerify.captured, hasLength(1)); - expect(toVerify.captured.first, isInstanceOf>()); + expect(toVerify.captured.first, isA>()); return toVerify.captured.first as Map; } @@ -91,7 +90,7 @@ void main() { shellPath: 'abc', enableObservatory: false, startPaused: true, - ), throwsA(isA())); + ), throwsAssertionError); expect(() => installHook( buildMode: BuildMode.debug, @@ -99,7 +98,7 @@ void main() { enableObservatory: false, startPaused: false, observatoryPort: 123, - ), throwsA(isA())); + ), throwsAssertionError); FlutterPlatform capturedPlatform; final Map expectedPrecompiledDillFiles = {'Key': 'Value'}; diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart index fbf7ff002d..74fb188a59 100644 --- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart @@ -84,7 +84,7 @@ void main() { testUsingContext('throws UnsupportedError exception if instantiated on ${platform.operatingSystem}', () { expect( () { IOSDevice('device-123'); }, - throwsA(isInstanceOf()), + throwsAssertionError, ); }, overrides: { Platform: () => platform, @@ -788,7 +788,7 @@ void main() { .thenAnswer((Invocation invocation) => Future.value('')); expect( () async { await IOSDevice.getAttachedDevices(); }, - throwsA(isInstanceOf()), + throwsA(isA()), ); }, overrides: { IMobileDevice: () => mockIMobileDevice, diff --git a/packages/flutter_tools/test/general.shard/ios/mac_test.dart b/packages/flutter_tools/test/general.shard/ios/mac_test.dart index ae846bfea7..0f2c9d7dfc 100644 --- a/packages/flutter_tools/test/general.shard/ios/mac_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/mac_test.dart @@ -108,7 +108,7 @@ void main() { [ideviceInfoPath, '-u', 'foo', '-k', 'bar'], environment: {'DYLD_LIBRARY_PATH': libimobiledevicePath}, )).thenAnswer((_) => Future.value(ProcessResult(1, 255, 'No device found with udid foo, is it plugged in?', ''))); - expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA())); }, overrides: { ProcessManager: () => mockProcessManager, Cache: () => mockCache, @@ -129,7 +129,7 @@ void main() { ); return Future.value(result); }); - expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA())); }, overrides: { ProcessManager: () => mockProcessManager, Cache: () => mockCache, @@ -171,7 +171,7 @@ void main() { ); return Future.value(result); }); - expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA())); }, overrides: { ProcessManager: () => mockProcessManager, Cache: () => mockCache, diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart index ecd7e47115..504a7ddaf6 100644 --- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart @@ -345,7 +345,7 @@ void main() { ); fail('ToolExit expected'); } catch(e) { - expect(e, isInstanceOf()); + expect(e, isA()); verifyNever(mockProcessManager.run( argThat(containsAllInOrder(['pod', 'install'])), workingDirectory: anyNamed('workingDirectory'), @@ -394,7 +394,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by ); fail('ToolExit expected'); } catch (e) { - expect(e, isInstanceOf()); + expect(e, isA()); expect( testLogger.errorText, contains("CocoaPods's specs repository is too out-of-date to satisfy dependencies"), diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart index 1fcdfe69d1..4a404b621d 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'package:file/file.dart'; import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; @@ -29,7 +28,7 @@ void main() { testInMemory('fails on null directory', () async { expect( () => FlutterProject.fromDirectory(null), - throwsA(isInstanceOf()), + throwsAssertionError, ); }); @@ -41,7 +40,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsA(isInstanceOf()), + throwsToolExit(), ); }); @@ -53,7 +52,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsA(isInstanceOf()), + throwsToolExit(), ); }); @@ -65,7 +64,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsA(isInstanceOf()), + throwsToolExit(), ); }); @@ -110,7 +109,7 @@ void main() { final FlutterProject project = await someProject(); await expectLater( project.android.makeHostAppEditable(), - throwsA(isInstanceOf()), + throwsAssertionError, ); }); testInMemory('exits on already editable module', () async { diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index ef835f1ca2..e576d2c51a 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -445,7 +445,7 @@ void main() { when(mockDevice.supportsScreenshot).thenReturn(false); expect(() => residentRunner.screenshot(mockFlutterDevice), - throwsA(isInstanceOf())); + throwsAssertionError); })); test('ResidentRunner does not toggle banner in non-debug mode', () => testbed.run(() async { @@ -725,7 +725,7 @@ void main() { expect(nextPlatform('iOS', TestFeatureFlags()), 'fuchsia'); expect(nextPlatform('fuchsia', TestFeatureFlags()), 'android'); expect(nextPlatform('fuchsia', TestFeatureFlags(isMacOSEnabled: true)), 'macOS'); - expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsA(isInstanceOf())); + expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsAssertionError); }); } diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 96698bf4ea..0e336d8f78 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -926,7 +926,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -945,7 +945,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -964,7 +964,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -983,7 +983,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -1002,7 +1002,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -1021,7 +1021,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -1041,7 +1041,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsException); unhandledErrorCompleter.complete(); await expectation; @@ -1060,7 +1060,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsToolExit()); unhandledErrorCompleter.complete(); await expectation; @@ -1082,7 +1082,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsA(isInstanceOf())); + ), throwsStateError); unhandledErrorCompleter.complete(); await expectation; diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart index 5517c430a9..9aa3c5cf99 100644 --- a/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -76,7 +75,7 @@ void main() { final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion; when(version.ensureVersionFile()).thenThrow(const FileSystemException()); - expect(() async => await runner.run(['dummy']), throwsA(isA())); + expect(() async => await runner.run(['dummy']), throwsToolExit()); }, overrides: { FileSystem: () => fs, diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart index 9243191ec6..57c1395d09 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -4,7 +4,6 @@ import 'dart:async'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -249,7 +248,7 @@ void main() { .thenAnswer((Invocation invocation) async { return OperationResult(1, 'fail', fatal: true); }); - expect(terminalHandler.processTerminalInput('r'), throwsA(isInstanceOf())); + expect(terminalHandler.processTerminalInput('r'), throwsToolExit()); }); testUsingContext('r - hotReload unsupported', () async { @@ -292,7 +291,7 @@ void main() { .thenAnswer((Invocation invocation) async { return OperationResult(1, 'fail', fatal: true); }); - expect(() => terminalHandler.processTerminalInput('R'), throwsA(isInstanceOf())); + expect(() => terminalHandler.processTerminalInput('R'), throwsToolExit()); }); testUsingContext('R - hot restart unsupported', () async { diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart index 6e10a6b43d..3ad3e1ead6 100644 --- a/packages/flutter_tools/test/general.shard/testbed_test.dart +++ b/packages/flutter_tools/test/general.shard/testbed_test.dart @@ -76,7 +76,7 @@ void main() { expect(testbed.run(() async { Timer.periodic(const Duration(seconds: 1), (Timer timer) { }); - }), throwsA(isInstanceOf())); + }), throwsStateError); }); test('Doesnt throw a StateError if Timer is left cleaned up', () async { diff --git a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart index ea2eed139b..86beb374d1 100644 --- a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart +++ b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart @@ -61,7 +61,7 @@ void main() { expect(devices, hasLength(1)); final Device device = devices.single; - expect(device, isInstanceOf()); + expect(device, isA()); expect(device.id, 'flutter-tester'); }); }); diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart index 437cd6e32b..7c71f9e5d3 100644 --- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'dart:io'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/convert.dart'; @@ -80,7 +79,7 @@ void main() { }); test('Throws a tool exit if bind fails with a SocketException', () => testbed.run(() async { - expect(WebAssetServer.start('hello', 1234), throwsA(isInstanceOf())); + expect(WebAssetServer.start('hello', 1234), throwsToolExit()); })); test('Can catch exceptions through the onError callback', () => testbed.run(() async { @@ -92,7 +91,7 @@ void main() { when(request.uri).thenReturn(Uri.parse('http://foobar/foo.js')); requestController.add(request); - expect(closeCompleter.future, throwsA(isInstanceOf())); + expect(closeCompleter.future, throwsStateError); })); test('Handles against malformed manifest', () => testbed.run(() async { diff --git a/packages/flutter_tools/test/general.shard/web/devices_test.dart b/packages/flutter_tools/test/general.shard/web/devices_test.dart index 47958a7ad7..f3c0d5174b 100644 --- a/packages/flutter_tools/test/general.shard/web/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devices_test.dart @@ -41,8 +41,8 @@ void main() { expect(chromeDevice.supportsFlutterExit, true); expect(chromeDevice.supportsScreenshot, false); expect(await chromeDevice.isLocalEmulator, false); - expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isInstanceOf()); - expect(chromeDevice.getLogReader(), isInstanceOf()); + expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isA()); + expect(chromeDevice.getLogReader(), isA()); expect(await chromeDevice.portForwarder.forward(1), 1); }); @@ -57,8 +57,8 @@ void main() { expect(device.supportsFlutterExit, true); expect(device.supportsScreenshot, false); expect(await device.isLocalEmulator, false); - expect(device.getLogReader(app: mockWebApplicationPackage), isInstanceOf()); - expect(device.getLogReader(), isInstanceOf()); + expect(device.getLogReader(app: mockWebApplicationPackage), isA()); + expect(device.getLogReader(), isA()); expect(await device.portForwarder.forward(1), 1); }); @@ -67,7 +67,7 @@ void main() { final WebDevices deviceDiscoverer = WebDevices(); final List devices = await deviceDiscoverer.pollingGetDevices(); - expect(devices, contains(isInstanceOf())); + expect(devices, contains(isA())); }, overrides: { ChromeLauncher: () => mockChromeLauncher, }); @@ -77,7 +77,7 @@ void main() { final WebDevices deviceDiscoverer = WebDevices(); final List devices = await deviceDiscoverer.pollingGetDevices(); - expect(devices, isNot(contains(isInstanceOf()))); + expect(devices, isNot(contains(isA()))); }, overrides: { ChromeLauncher: () => mockChromeLauncher, }); @@ -87,7 +87,7 @@ void main() { final WebDevices deviceDiscoverer = WebDevices(); final List devices = await deviceDiscoverer.pollingGetDevices(); - expect(devices, contains(isInstanceOf())); + expect(devices, contains(isA())); }, overrides: { ChromeLauncher: () => mockChromeLauncher, }); diff --git a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart index a81216dcc2..5b61bf97b0 100644 --- a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart +++ b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart @@ -216,7 +216,7 @@ void main() { port: '1234', urlTunneller: null, dartDefines: const [], - ), throwsA(isInstanceOf())); + ), throwsException); })); } diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index 419674a7fc..fb446bc744 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -22,7 +22,7 @@ export 'package:test_core/test_core.dart' hide TypeMatcher, isInstanceOf; // Def /// A matcher that compares the type of the actual value to the type argument T. // TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed -Matcher isInstanceOf() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that @@ -91,6 +91,9 @@ void updateFileModificationTime( globals.fs.file(path).setLastModifiedSync(modificationTime); } +/// Matcher for functions that throw [AssertionError]. +final Matcher throwsAssertionError = throwsA(isA()); + /// Matcher for functions that throw [ToolExit]. Matcher throwsToolExit({ int exitCode, Pattern message }) { Matcher matcher = isToolExit; @@ -104,7 +107,7 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) { } /// Matcher for [ToolExit]s. -final Matcher isToolExit = isInstanceOf(); +final test_package.TypeMatcher isToolExit = isA(); /// Matcher for functions that throw [ProcessExit]. Matcher throwsProcessExit([ dynamic exitCode ]) { @@ -114,7 +117,7 @@ Matcher throwsProcessExit([ dynamic exitCode ]) { } /// Matcher for [ProcessExit]s. -final Matcher isProcessExit = isInstanceOf(); +final test_package.TypeMatcher isProcessExit = isA(); /// Creates a flutter project in the [temp] directory using the /// [arguments] list if specified, or `--no-pub` if not. diff --git a/packages/flutter_tools/test/template_test.dart b/packages/flutter_tools/test/template_test.dart index 2aedd4e744..936cf5702c 100644 --- a/packages/flutter_tools/test/template_test.dart +++ b/packages/flutter_tools/test/template_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/template.dart'; import 'package:flutter_tools/src/globals.dart' as globals; @@ -24,7 +23,7 @@ void main() { when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException()); expect(() => template.render(mockDirectory, {}), - throwsA(isInstanceOf())); + throwsToolExit()); })); } diff --git a/packages/fuchsia_remote_debug_protocol/test/common.dart b/packages/fuchsia_remote_debug_protocol/test/common.dart index bc195e5a61..ea979f0e63 100644 --- a/packages/fuchsia_remote_debug_protocol/test/common.dart +++ b/packages/fuchsia_remote_debug_protocol/test/common.dart @@ -11,4 +11,4 @@ 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() => test_package.TypeMatcher(); +test_package.TypeMatcher isInstanceOf() => isA(); diff --git a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart index 94d9849d29..833d79b2bd 100644 --- a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart @@ -161,7 +161,7 @@ void main() { // Should fail as no env variable has been passed. expect(failingFunction, - throwsA(isInstanceOf())); + throwsA(isA())); }); }); } diff --git a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart index 832ed6949f..c3ae83a88f 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart @@ -217,7 +217,7 @@ void main() { } // Both views should be invalid as they were missing required fields. - expect(failingFunction, throwsA(isInstanceOf())); + expect(failingFunction, throwsA(isA())); }); test('get isolates by pattern', () async { @@ -311,7 +311,7 @@ void main() { } // Both views should be invalid as they were missing required fields. - expect(failingFunction, throwsA(isInstanceOf())); + expect(failingFunction, throwsA(isA())); }); }); @@ -346,7 +346,7 @@ void main() { await vm.invokeRpc('somesillyfunction', timeout: timeoutTime); } - expect(failingFunction, throwsA(isInstanceOf())); + expect(failingFunction, throwsA(isA())); }); }); } diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart index 6e5567c1d4..e2a86706d3 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart @@ -98,7 +98,7 @@ void main() { await runner.run('oihaw'); } - expect(failingFunction, throwsA(isInstanceOf())); + expect(failingFunction, throwsA(isA())); }); test('verify correct args with config', () async {