From b67d5ec6e9f4aa42bf420e95be76a572911e645e Mon Sep 17 00:00:00 2001 From: Anthony <591699+clocksmith@users.noreply.github.com> Date: Fri, 17 Jan 2020 18:13:01 -0500 Subject: [PATCH] [a11y] Make sure RenderFractionalTranslation updates its semantics after the translation field is set (#48985) --- 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 +- .../demo/cupertino/cupertino_picker_demo.dart | 5 - .../flutter/lib/src/cupertino/picker.dart | 3 +- packages/flutter/lib/src/cupertino/route.dart | 13 +- .../lib/src/cupertino/segmented_control.dart | 2 - .../cupertino/sliding_segmented_control.dart | 2 - .../flutter/lib/src/painting/image_cache.dart | 12 +- .../lib/src/painting/image_stream.dart | 12 +- .../flutter/lib/src/rendering/editable.dart | 10 +- .../flutter/lib/src/rendering/proxy_box.dart | 1 + .../flutter/test/animation/futures_test.dart | 6 +- .../flutter/test/cupertino/picker_test.dart | 21 +- .../flutter/test/cupertino/refresh_test.dart | 153 ++++++++++-- .../flutter/test/cupertino/route_test.dart | 72 ------ .../flutter/test/cupertino/switch_test.dart | 16 +- .../test/cupertino/text_field_test.dart | 34 ++- .../test/flutter_test_alternative.dart | 2 +- .../foundation/consolidate_response_test.dart | 3 +- .../test/foundation/isolates_test.dart | 4 +- .../foundation/service_extensions_test.dart | 28 +-- .../flutter/test/material/app_bar_test.dart | 95 ++++---- .../test/material/app_builder_test.dart | 2 +- packages/flutter/test/material/app_test.dart | 6 +- .../test/material/back_button_test.dart | 19 +- .../material/bottom_navigation_bar_test.dart | 2 +- .../test/material/chip_theme_test.dart | 16 +- .../flutter/test/material/debug_test.dart | 12 +- .../flutter/test/material/drawer_test.dart | 10 +- .../test/material/expansion_tile_test.dart | 6 +- ...flexible_space_bar_collapse_mode_test.dart | 136 ++++++++++- .../material/flexible_space_bar_test.dart | 50 ++-- .../test/material/outline_button_test.dart | 2 +- packages/flutter/test/material/page_test.dart | 89 +++---- .../material/page_transitions_theme_test.dart | 36 ++- .../material/paginated_data_table_test.dart | 4 +- .../test/material/popup_menu_test.dart | 8 +- .../test/material/refresh_indicator_test.dart | 7 +- .../flutter/test/material/scaffold_test.dart | 86 ++++--- .../flutter/test/material/scrollbar_test.dart | 19 +- .../flutter/test/material/search_test.dart | 9 +- .../flutter/test/material/slider_test.dart | 53 ++--- .../test/material/switch_list_tile_test.dart | 29 +-- .../flutter/test/material/switch_test.dart | 33 ++- .../test/material/text_field_test.dart | 221 +++++++++--------- .../test/material/theme_data_test.dart | 1 - .../test/material/typography_test.dart | 37 +-- .../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 | 126 +++++----- .../test/rendering/repaint_boundary_test.dart | 4 +- .../flutter/test/rendering/viewport_test.dart | 7 +- .../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/basic_test.dart | 63 +++++ packages/flutter/test/widgets/debug_test.dart | 8 +- .../draggable_scrollable_sheet_test.dart | 16 +- .../flutter/test/widgets/drawer_test.dart | 10 +- .../widgets/editable_text_cursor_test.dart | 44 ++-- .../test/widgets/editable_text_test.dart | 10 +- packages/flutter/test/widgets/flow_test.dart | 4 +- .../flutter/test/widgets/heroes_test.dart | 24 +- packages/flutter/test/widgets/image_test.dart | 6 +- .../widgets/list_wheel_scroll_view_test.dart | 6 +- .../test/widgets/media_query_test.dart | 2 +- .../test/widgets/modal_barrier_test.dart | 5 +- .../flutter/test/widgets/multichild_test.dart | 4 +- .../flutter/test/widgets/navigator_test.dart | 8 +- .../test/widgets/nested_scroll_view_test.dart | 21 +- .../flutter/test/widgets/overlay_test.dart | 4 +- .../test/widgets/page_transitions_test.dart | 21 +- .../flutter/test/widgets/page_view_test.dart | 3 +- .../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/scrollable_dispose_test.dart | 7 +- .../test/widgets/scrollable_fling_test.dart | 16 +- .../flutter/test/widgets/scrollable_test.dart | 74 +++--- .../test/widgets/selectable_text_test.dart | 144 +++++++----- .../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/sliver_fill_remaining_test.dart | 32 ++- .../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/text_selection_test.dart | 6 +- .../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 ++--- .../test/src/real_tests/extension_test.dart | 47 ++-- .../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 | 13 +- .../lib/src/android/android_emulator.dart | 65 +----- .../src/build_runner/resident_web_runner.dart | 50 +--- .../lib/src/build_system/targets/web.dart | 1 - .../lib/src/commands/emulators.dart | 11 +- .../flutter_tools/lib/src/web/bootstrap.dart | 20 +- .../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 | 83 ++++--- .../android/android_emulator_test.dart | 120 +--------- .../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 +- .../fuchsia/fuchsia_device_test.dart | 25 +- .../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 | 22 +- .../runner/flutter_command_runner_test.dart | 3 +- .../general.shard/terminal_handler_test.dart | 5 +- .../test/general.shard/testbed_test.dart | 12 +- .../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 | 18 +- packages/flutter_tools/test/src/common.dart | 9 +- packages/flutter_tools/test/src/context.dart | 4 - packages/flutter_tools/test/src/testbed.dart | 4 - .../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 +- 196 files changed, 1686 insertions(+), 1607 deletions(-) diff --git a/dev/bots/test/common.dart b/dev/bots/test/common.dart index 6ca543fdc06..4060c06fdac 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); 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 2f33ac9914e..9f4a122fc6c 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(isA())); + throwsA(isInstanceOf())); 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(isA())); + throwsA(isInstanceOf())); }); }); group('ArchiveCreator for $platformName', () { @@ -185,7 +185,8 @@ void main() { 'git reset --hard $testRef': [ProcessResult(0, -1, 'output2', '')], }; processManager.fakeResults = calls; - expect(expectAsync0(creator.initializeRepo), throwsA(isA())); + expect(expectAsync0(creator.initializeRepo), + throwsA(isInstanceOf())); }); test('non-strict mode calls the right commands', () async { diff --git a/dev/devicelab/test/common.dart b/dev/devicelab/test/common.dart index 64db2373950..9449f939963 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); 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 1865b6f3848..c2aacda6ea6 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); diff --git a/dev/tools/test/common.dart b/dev/tools/test/common.dart index 6ca543fdc06..4060c06fdac 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); 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 9bb65ca897b..fffcef2fb7b 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'); }, throwsArgumentError); + expect(() { parsePixels('9pt'); }, throwsA(isInstanceOf())); }); test('parsePoints', () { diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart index f45819e94d6..9ce07f69ceb 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart @@ -108,7 +108,6 @@ class _CupertinoPickerDemoState extends State { onTap: () async { await showCupertinoModalPopup( context: context, - semanticsDismissible: true, builder: (BuildContext context) { return _BottomPicker( child: CupertinoPicker( @@ -145,7 +144,6 @@ class _CupertinoPickerDemoState extends State { onTap: () { showCupertinoModalPopup( context: context, - semanticsDismissible: true, builder: (BuildContext context) { return _BottomPicker( child: CupertinoTimerPicker( @@ -178,7 +176,6 @@ class _CupertinoPickerDemoState extends State { onTap: () { showCupertinoModalPopup( context: context, - semanticsDismissible: true, builder: (BuildContext context) { return _BottomPicker( child: CupertinoDatePicker( @@ -210,7 +207,6 @@ class _CupertinoPickerDemoState extends State { onTap: () { showCupertinoModalPopup( context: context, - semanticsDismissible: true, builder: (BuildContext context) { return _BottomPicker( child: CupertinoDatePicker( @@ -242,7 +238,6 @@ class _CupertinoPickerDemoState extends State { onTap: () { showCupertinoModalPopup( context: context, - semanticsDismissible: true, builder: (BuildContext context) { return _BottomPicker( child: CupertinoDatePicker( diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index 2ab858d8abe..f20f796f0d1 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -35,8 +35,7 @@ const double _kOverAndUnderCenterOpacity = 0.447; /// that child the initially selected child. /// /// Can be used with [showCupertinoModalPopup] to display the picker modally at the -/// bottom of the screen. When calling [showCupertinoModalPopup], be sure to set -/// `semanticsDismissible` to true to enable dismissing the modal via semantics. +/// bottom of the screen. /// /// Sizes itself to its parent. All children are sized to the same size based /// on [itemExtent]. diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart index 8ecbaeca3b0..61e88f6b0e7 100644 --- a/packages/flutter/lib/src/cupertino/route.dart +++ b/packages/flutter/lib/src/cupertino/route.dart @@ -792,18 +792,14 @@ class _CupertinoModalPopupRoute extends PopupRoute { this.barrierColor, this.barrierLabel, this.builder, - bool semanticsDismissible, ImageFilter filter, RouteSettings settings, }) : super( filter: filter, settings: settings, - ) { - _semanticsDismissible = semanticsDismissible; - } + ); final WidgetBuilder builder; - bool _semanticsDismissible; @override final String barrierLabel; @@ -815,7 +811,7 @@ class _CupertinoModalPopupRoute extends PopupRoute { bool get barrierDismissible => true; @override - bool get semanticsDismissible => _semanticsDismissible ?? false; + bool get semanticsDismissible => false; @override Duration get transitionDuration => _kModalPopupTransitionDuration; @@ -875,9 +871,6 @@ class _CupertinoModalPopupRoute extends PopupRoute { /// popup to the [Navigator] furthest from or nearest to the given `context`. It /// is `false` by default. /// -/// The `semanticsDismissble` argument is used to determine whether the -/// semantics of the modal barrier are included in the semantics tree. -/// /// The `builder` argument typically builds a [CupertinoActionSheet] widget. /// Content below the widget is dimmed with a [ModalBarrier]. The widget built /// by the `builder` does not share a context with the location that @@ -898,7 +891,6 @@ Future showCupertinoModalPopup({ @required WidgetBuilder builder, ImageFilter filter, bool useRootNavigator = true, - bool semanticsDismissible, }) { assert(useRootNavigator != null); return Navigator.of(context, rootNavigator: useRootNavigator).push( @@ -907,7 +899,6 @@ Future showCupertinoModalPopup({ barrierLabel: 'Dismiss', builder: builder, filter: filter, - semanticsDismissible: semanticsDismissible, ), ); } diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 4d5cb5fc189..04c276b0f05 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -61,8 +61,6 @@ const Duration _kFadeDuration = Duration(milliseconds: 165); /// /// See also: /// -/// * [CupertinoSegmentedControl], a segmented control widget in the style used -/// up until iOS 13. /// * class CupertinoSegmentedControl extends StatefulWidget { /// Creates an iOS-style segmented control bar. diff --git a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart index b593fd80619..d923851df3c 100644 --- a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart @@ -118,8 +118,6 @@ class _FontWeightTween extends Tween { /// /// See also: /// -/// * [CupertinoSlidingSegmentedControl], a segmented control widget in the -/// style introduced in iOS 13. /// * class CupertinoSlidingSegmentedControl extends StatefulWidget { /// Creates an iOS-style segmented control bar. diff --git a/packages/flutter/lib/src/painting/image_cache.dart b/packages/flutter/lib/src/painting/image_cache.dart index 7a296ae4a23..75e8d051846 100644 --- a/packages/flutter/lib/src/painting/image_cache.dart +++ b/packages/flutter/lib/src/painting/image_cache.dart @@ -32,7 +32,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB /// {@tool snippet} /// /// This sample shows how to supply your own caching logic and replace the -/// global [imageCache] variable. +/// global [imageCache] varible. /// /// ```dart /// /// This is the custom implementation of [ImageCache] where we can override @@ -64,6 +64,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB /// } /// ``` /// {@end-tool} + class ImageCache { final Map _pendingImages = {}; final Map _cache = {}; @@ -140,13 +141,12 @@ class ImageCache { } /// Evicts a single entry from the cache, returning true if successful. - /// Pending images waiting for completion are removed as well, returning true - /// if successful. + /// Pending images waiting for completion are removed as well, returning true if successful. /// - /// When a pending image is removed the listener on it is removed as well to - /// prevent it from adding itself to the cache if it eventually completes. + /// When a pending image is removed the listener on it is removed as well to prevent + /// it from adding itself to the cache if it eventually completes. /// - /// The `key` must be equal to an object used to cache an image in + /// The [key] must be equal to an object used to cache an image in /// [ImageCache.putIfAbsent]. /// /// If the key is not immediately available, as is common, consider using diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index 9fefe9665bd..79d257dd0e9 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -15,7 +15,7 @@ import 'package:flutter/scheduler.dart'; /// actual data of the image once it has been obtained. @immutable class ImageInfo { - /// Creates an [ImageInfo] object for the given [image] and [scale]. + /// Creates an [ImageInfo] object for the given image and scale. /// /// Both the image and the scale must not be null. const ImageInfo({ @required this.image, this.scale = 1.0 }) @@ -35,9 +35,9 @@ class ImageInfo { /// /// For example, if this is 2.0 it means that there are four image pixels for /// every one logical pixel, and the image's actual width and height (as given - /// by the [dart:ui.Image.width] and [dart:ui.Image.height] properties) are - /// double the height and width that should be used when painting the image - /// (e.g. in the arguments given to [Canvas.drawImage]). + /// by the [dart:ui.Image.width] and [dart:ui.Image.height] properties) are double the + /// height and width that should be used when painting the image (e.g. in the + /// arguments given to [Canvas.drawImage]). final double scale; @override @@ -58,11 +58,11 @@ class ImageInfo { /// Interface for receiving notifications about the loading of an image. /// -/// This class overrides [operator ==] and [hashCode] to compare the individual +/// This class overrides `operator ==` and `hashCode` to compare the individual /// callbacks in the listener, meaning that if you add an instance of this class /// as a listener (e.g. via [ImageStream.addListener]), you can instantiate a /// _different_ instance of this class when you remove the listener, and the -/// listener will be properly removed as long as all associated callbacks are +/// listener will be properly removed as long all associated callbacks are /// equal. /// /// Used by [ImageStream] and [ImageStreamCompleter]. diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 171bdc776e7..1b89c0e7830 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -409,14 +409,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ) { // Changes made by the keyboard can sometimes be "out of band" for listening // components, so always send those events, even if we didn't think it - // changed. Also, focusing an empty field is sent as a selection change even - // if the selection offset didn't change. - final bool focusingEmpty = nextSelection.baseOffset == 0 - && nextSelection.extentOffset == 0 - && !hasFocus; - if (nextSelection == selection - && cause != SelectionChangedCause.keyboard - && !focusingEmpty) { + // changed. + if (nextSelection == selection && cause != SelectionChangedCause.keyboard) { return; } if (onSelectionChanged != null) { diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index afa7b563aa5..a5d4bf4e3e5 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -2472,6 +2472,7 @@ class RenderFractionalTranslation extends RenderProxyBox { return; _translation = value; markNeedsPaint(); + markNeedsSemanticsUpdate(); } @override diff --git a/packages/flutter/test/animation/futures_test.dart b/packages/flutter/test/animation/futures_test.dart index e389f1c0cf8..0965ec8a97b 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, isA>()); + expect(f.asStream().single, isInstanceOf>()); await f.catchError((dynamic e) { throw 'do not reach'; }); expect(await f.then((_) => true), isTrue); - expect(f.whenComplete(() => false), isA>()); - expect(f.timeout(const Duration(seconds: 5)), isA>()); + expect(f.whenComplete(() => false), isInstanceOf>()); + expect(f.timeout(const Duration(seconds: 5)), isInstanceOf>()); }); } diff --git a/packages/flutter/test/cupertino/picker_test.dart b/packages/flutter/test/cupertino/picker_test.dart index b5ff312f740..2d39125786a 100644 --- a/packages/flutter/test/cupertino/picker_test.dart +++ b/packages/flutter/test/cupertino/picker_test.dart @@ -153,6 +153,7 @@ void main() { testWidgets( 'scrolling calls onSelectedItemChanged and triggers haptic feedback', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final List selectedItems = []; final List systemCalls = []; @@ -199,11 +200,15 @@ void main() { arguments: 'HapticFeedbackType.selectionClick', ), ); - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'do not trigger haptic effects on non-iOS devices', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; final List selectedItems = []; final List systemCalls = []; @@ -233,9 +238,13 @@ void main() { await tester.drag(find.text('0'), const Offset(0.0, -100.0)); expect(selectedItems, [1]); expect(systemCalls, isEmpty); - }, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform platform) => platform != TargetPlatform.iOS).toSet())); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets('a drag in between items settles back', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final List selectedItems = []; @@ -288,9 +297,11 @@ void main() { moreOrLessEquals(350.0, epsilon: 0.5), ); expect(selectedItems, [9]); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('a big fling that overscrolls springs back', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final List selectedItems = []; @@ -346,6 +357,8 @@ void main() { // Falling back to 0 shouldn't produce more callbacks. [8, 6, 4, 2, 0], ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); }); } diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart index 738e4c9fc53..64fbe51193b 100644 --- a/packages/flutter/test/cupertino/refresh_test.dart +++ b/packages/flutter/test/cupertino/refresh_test.dart @@ -74,6 +74,8 @@ void main() { final VoidCallback uiTestGroup = () { testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -94,9 +96,13 @@ void main() { tester.getTopLeft(find.widgetWithText(Container, '0')), const Offset(0.0, 0.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('calls the indicator builder when starting to overscroll', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -130,11 +136,15 @@ void main() { tester.getTopLeft(find.widgetWithText(Container, '0')), const Offset(0.0, 50.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets( "don't call the builder if overscroll doesn't move slivers like on Android", (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.android; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -159,9 +169,14 @@ void main() { tester.getTopLeft(find.widgetWithText(Container, '0')), const Offset(0.0, 0.0), ); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets('let the builder update as canceled drag scrolls away', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -213,9 +228,13 @@ void main() { tester.getTopLeft(find.widgetWithText(Container, '0')), const Offset(0.0, 0.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('drag past threshold triggers refresh task', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final List platformCallLog = []; SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async { @@ -276,11 +295,14 @@ void main() { platformCallLog.last, isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.mediumImpact'), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); testWidgets( 'refreshing task keeps the sliver expanded forever until done', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -348,11 +370,15 @@ void main() { 60.0, // Default value. )); verifyNoMoreInteractions(mockHelper); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'refreshing task keeps the sliver expanded forever until completes with error', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final FlutterError error = FlutterError('Oops'); double errorCount = 0; @@ -434,9 +460,14 @@ void main() { errorCount++; }, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets('expanded refreshing sliver scrolls normally', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -510,9 +541,13 @@ void main() { tester.getRect(find.widgetWithText(Center, '0')), const Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('expanded refreshing sliver goes away when done', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -581,9 +616,13 @@ void main() { tester.getRect(find.widgetWithText(Center, '0')), const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('builder still called when sliver snapped back more than 90%', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -665,11 +704,15 @@ void main() { 60.0, // Default value. )); expect(find.text('-1'), findsOneWidget); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets( 'retracting sliver during done cannot be pulled to refresh again until fully retracted', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -748,12 +791,17 @@ void main() { 40.0, 100.0, // Default value. 60.0, // Default value. - )); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + )); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'sliver held in overscroll when task finishes completes normally', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -800,7 +848,10 @@ void main() { tester.getRect(find.widgetWithText(Center, '0')), const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'sliver scrolled away when task completes properly removes itself', @@ -810,6 +861,8 @@ void main() { // the indicator can be scrolled away while refreshing. return; } + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -887,11 +940,16 @@ void main() { tester.getRect(find.widgetWithText(Center, '0')), const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( "don't do anything unless it can be overscrolled at the start of the list", (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -915,11 +973,16 @@ void main() { await tester.fling(find.byType(Container).first, const Offset(0.0, -200.0), 3000.0); verifyNoMoreInteractions(mockHelper); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'without an onRefresh, builder is called with arm for one frame then sliver goes away', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -961,7 +1024,10 @@ void main() { tester.getRect(find.widgetWithText(Center, '0')), const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets('Should not crash when dragged', (WidgetTester tester) async { await tester.pumpWidget( @@ -985,11 +1051,13 @@ void main() { await tester.pump(); expect(tester.takeException(), isNull); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); }; final VoidCallback stateMachineTestGroup = () { testWidgets('starts in inactive state', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1008,9 +1076,13 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder, skipOffstage: false))), RefreshIndicatorMode.inactive, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('goes to drag and returns to inactive in a small drag', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1039,9 +1111,13 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder, skipOffstage: false))), RefreshIndicatorMode.inactive, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('goes to armed the frame it passes the threshold', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1071,11 +1147,15 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))), RefreshIndicatorMode.armed, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets( 'goes to refresh the frame it crossed back the refresh threshold', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1111,11 +1191,16 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))), RefreshIndicatorMode.refresh, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'goes to done internally as soon as the task finishes', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1158,11 +1243,16 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))), RefreshIndicatorMode.done, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'goes back to inactive when retracting back past 10% of arming distance', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1216,11 +1306,16 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))), RefreshIndicatorMode.inactive, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( 'goes back to inactive if already scrolled away when task completes', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1275,11 +1370,16 @@ void main() { tester.getTopLeft(find.widgetWithText(Container, '0')).dy, moreOrLessEquals(-145.0332383665717), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets( "don't have to build any indicators or occupy space during refresh", (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( @@ -1325,7 +1425,10 @@ void main() { CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder, skipOffstage: false))), RefreshIndicatorMode.inactive, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, + ); testWidgets('buildSimpleRefreshIndicator dark mode', (WidgetTester tester) async { const CupertinoDynamicColor color = CupertinoColors.inactiveGray; diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index cf1c6be16f8..ef2a58e2fae 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -3,14 +3,11 @@ // found in the LICENSE file. import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; -import '../widgets/semantics_tester.dart'; - void main() { MockNavigatorObserver navigatorObserver; @@ -1055,75 +1052,6 @@ void main() { expect(rootObserver.dialogCount, 0); expect(nestedObserver.dialogCount, 1); }); - - testWidgets('showCupertinoModalPopup does not allow for semantics dismiss by default', (WidgetTester tester) async { - debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(CupertinoApp( - home: Navigator( - onGenerateRoute: (RouteSettings settings) { - return PageRouteBuilder( - pageBuilder: (BuildContext context, Animation _, Animation __) { - return GestureDetector( - onTap: () async { - await showCupertinoModalPopup( - context: context, - builder: (BuildContext context) => const SizedBox(), - ); - }, - child: const Text('tap'), - ); - }, - ); - }, - ), - )); - - // Push the route. - await tester.tap(find.text('tap')); - await tester.pumpAndSettle(); - - expect(semantics, isNot(includesNodeWith( - actions: [SemanticsAction.tap], - label: 'Dismiss', - ))); - debugDefaultTargetPlatformOverride = null; - }); - - testWidgets('showCupertinoModalPopup allows for semantics dismiss when set', (WidgetTester tester) async { - debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(CupertinoApp( - home: Navigator( - onGenerateRoute: (RouteSettings settings) { - return PageRouteBuilder( - pageBuilder: (BuildContext context, Animation _, Animation __) { - return GestureDetector( - onTap: () async { - await showCupertinoModalPopup( - context: context, - semanticsDismissible: true, - builder: (BuildContext context) => const SizedBox(), - ); - }, - child: const Text('tap'), - ); - }, - ); - }, - ), - )); - - // Push the route. - await tester.tap(find.text('tap')); - await tester.pumpAndSettle(); - - expect(semantics, includesNodeWith( - actions: [SemanticsAction.tap], - label: 'Dismiss', - )); - debugDefaultTargetPlatformOverride = null; - }); } class MockNavigatorObserver extends Mock implements NavigatorObserver {} diff --git a/packages/flutter/test/cupertino/switch_test.dart b/packages/flutter/test/cupertino/switch_test.dart index 3857a26fca6..2935cecf930 100644 --- a/packages/flutter/test/cupertino/switch_test.dart +++ b/packages/flutter/test/cupertino/switch_test.dart @@ -43,6 +43,7 @@ void main() { }); testWidgets('Switch emits light haptic vibration on tap', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final Key switchKey = UniqueKey(); bool value = false; @@ -79,9 +80,11 @@ void main() { expect(log, hasLength(1)); expect(log.single, isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Using other widgets that rebuild the switch will not cause vibrations', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final Key switchKey = UniqueKey(); final Key switchKey2 = UniqueKey(); bool value = false; @@ -149,9 +152,11 @@ void main() { expect(log, hasLength(4)); expect(log[3], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Haptic vibration triggers on drag', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; bool value = false; final List log = []; @@ -186,9 +191,11 @@ void main() { expect(log, hasLength(1)); expect(log[0], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('No haptic vibration triggers from a programmatic value change', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final Key switchKey = UniqueKey(); bool value = false; @@ -237,7 +244,8 @@ void main() { await tester.pump(); expect(log, hasLength(0)); - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Switch can drag (LTR)', (WidgetTester tester) async { bool value = false; diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 0d6d514943f..ce9ea76ec96 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -425,7 +425,9 @@ void main() { expect(editableText.cursorOffset, const Offset(-2.0 / 3.0, 0)); }); - testWidgets('Cursor animates', (WidgetTester tester) async { + testWidgets('Cursor animates on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( const CupertinoApp( home: CupertinoTextField(), @@ -457,9 +459,13 @@ void main() { await tester.pump(const Duration(milliseconds: 50)); expect(renderEditable.cursorColor.alpha, 0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - testWidgets('Cursor radius is 2.0', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = null; + }); + + testWidgets('Cursor radius is 2.0 on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( const CupertinoApp( home: CupertinoTextField(), @@ -470,7 +476,9 @@ void main() { final RenderEditable renderEditable = editableTextState.renderEditable; expect(renderEditable.cursorRadius, const Radius.circular(2.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Cupertino cursor android golden', (WidgetTester tester) async { final Widget widget = CupertinoApp( @@ -499,7 +507,9 @@ void main() { ); }); - testWidgets('Cupertino cursor golden', (WidgetTester tester) async { + testWidgets('Cupertino cursor iOS golden', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final Widget widget = CupertinoApp( home: Center( child: RepaintBoundary( @@ -520,13 +530,12 @@ void main() { await tester.tapAt(textOffsetToPosition(tester, testValue.length)); await tester.pumpAndSettle(); + debugDefaultTargetPlatformOverride = null; await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile( - 'text_field_cursor_test.cupertino_${describeEnum(debugDefaultTargetPlatformOverride).toLowerCase()}.1.png', - ), + matchesGoldenFile('text_field_cursor_test.cupertino.1.png'), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets( 'can control text content via controller', @@ -2937,7 +2946,8 @@ void main() { expect(editableText.cursorColor.value, 0x87654321); }); - testWidgets('shows selection handles', (WidgetTester tester) async { + testWidgets('iOS shows selection handles', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; const String testText = 'lorem ipsum'; final TextEditingController controller = TextEditingController(text: testText); @@ -2967,7 +2977,9 @@ void main() { expect(left.opacity.value, equals(1.0)); expect(right.opacity.value, equals(1.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('when CupertinoTextField would be blocked by keyboard, it is shown with enough space for the selection handle', (WidgetTester tester) async { final ScrollController scrollController = ScrollController(); diff --git a/packages/flutter/test/flutter_test_alternative.dart b/packages/flutter/test/flutter_test_alternative.dart index a67c1c69b1a..694f7519770 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); /// 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 43c42424c22..208fe6c99a5 100644 --- a/packages/flutter/test/foundation/consolidate_response_test.dart +++ b/packages/flutter/test/foundation/consolidate_response_test.dart @@ -110,7 +110,8 @@ void main() { }); when(response.contentLength).thenReturn(-1); - expect(consolidateHttpClientResponseBytes(response), throwsException); + expect(consolidateHttpClientResponseBytes(response), + throwsA(isInstanceOf())); }); 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 bbd339d95ba..c7cca03d66e 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), throwsException); + expect(compute(test2, 0), throwsA(isInstanceOf())); expect(await compute(test1Async, 0), 1); - expect(compute(test2Async, 0), throwsException); + expect(compute(test2Async, 0), throwsA(isInstanceOf())); }); } diff --git a/packages/flutter/test/foundation/service_extensions_test.dart b/packages/flutter/test/foundation/service_extensions_test.dart index ab0e26b165d..4844dd42d46 100644 --- a/packages/flutter/test/foundation/service_extensions_test.dart +++ b/packages/flutter/test/foundation/service_extensions_test.dart @@ -489,51 +489,43 @@ void main() { extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'iOS'); - result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'macOS'})); - expect(result, {'value': 'macOS'}); - expect(binding.reassembled, 2); - expect(defaultTargetPlatform, TargetPlatform.macOS); - expect(extensionChangedEvents.length, 2); - extensionChangedEvent = extensionChangedEvents.last; - expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); - expect(extensionChangedEvent['value'], 'macOS'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'android'})); expect(result, {'value': 'android'}); - expect(binding.reassembled, 3); + expect(binding.reassembled, 2); expect(defaultTargetPlatform, TargetPlatform.android); - expect(extensionChangedEvents.length, 3); + expect(extensionChangedEvents.length, 2); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'android'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'fuchsia'})); expect(result, {'value': 'fuchsia'}); - expect(binding.reassembled, 4); + expect(binding.reassembled, 3); expect(defaultTargetPlatform, TargetPlatform.fuchsia); - expect(extensionChangedEvents.length, 4); + expect(extensionChangedEvents.length, 3); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'fuchsia'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'default'})); expect(result, {'value': 'android'}); - expect(binding.reassembled, 5); + expect(binding.reassembled, 4); expect(defaultTargetPlatform, TargetPlatform.android); - expect(extensionChangedEvents.length, 5); + expect(extensionChangedEvents.length, 4); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'android'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'iOS'})); expect(result, {'value': 'iOS'}); - expect(binding.reassembled, 6); + expect(binding.reassembled, 5); expect(defaultTargetPlatform, TargetPlatform.iOS); - expect(extensionChangedEvents.length, 6); + expect(extensionChangedEvents.length, 5); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'iOS'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'bogus'})); expect(result, {'value': 'android'}); - expect(binding.reassembled, 7); + expect(binding.reassembled, 6); expect(defaultTargetPlatform, TargetPlatform.android); - expect(extensionChangedEvents.length, 7); + expect(extensionChangedEvents.length, 6); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'android'); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 3f8cd34578f..fe8e7fa49f7 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_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/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -84,68 +83,66 @@ void main() { Size size = tester.getSize(title); expect(center.dx, lessThan(400 - size.width / 2.0)); - for (final TargetPlatform platform in [TargetPlatform.iOS, TargetPlatform.macOS]) { - // Clear the widget tree to avoid animating between platforms. - await tester.pumpWidget(Container(key: UniqueKey())); + // Clear the widget tree to avoid animating between Android and iOS. + await tester.pumpWidget(Container(key: UniqueKey())); - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: platform), - home: Scaffold( - appBar: AppBar( - title: const Text('X'), - ), + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( + title: const Text('X'), ), ), - ); + ), + ); - center = tester.getCenter(title); - size = tester.getSize(title); - expect(center.dx, greaterThan(400 - size.width / 2.0), reason: 'on ${describeEnum(platform)}'); - expect(center.dx, lessThan(400 + size.width / 2.0), reason: 'on ${describeEnum(platform)}'); + center = tester.getCenter(title); + size = tester.getSize(title); + expect(center.dx, greaterThan(400 - size.width / 2.0)); + expect(center.dx, lessThan(400 + size.width / 2.0)); - // One action is still centered. + // One action is still centered. - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: platform), - home: Scaffold( - appBar: AppBar( - title: const Text('X'), - actions: const [ - Icon(Icons.thumb_up), - ], - ), + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( + title: const Text('X'), + actions: const [ + Icon(Icons.thumb_up), + ], ), ), - ); + ), + ); - center = tester.getCenter(title); - size = tester.getSize(title); - expect(center.dx, greaterThan(400 - size.width / 2.0), reason: 'on ${describeEnum(platform)}'); - expect(center.dx, lessThan(400 + size.width / 2.0), reason: 'on ${describeEnum(platform)}'); + center = tester.getCenter(title); + size = tester.getSize(title); + expect(center.dx, greaterThan(400 - size.width / 2.0)); + expect(center.dx, lessThan(400 + size.width / 2.0)); - // Two actions is left aligned again. + // Two actions is left aligned again. - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: platform), - home: Scaffold( - appBar: AppBar( - title: const Text('X'), - actions: const [ - Icon(Icons.thumb_up), - Icon(Icons.thumb_up), - ], - ), + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( + title: const Text('X'), + actions: const [ + Icon(Icons.thumb_up), + Icon(Icons.thumb_up), + ], ), ), - ); + ), + ); - center = tester.getCenter(title); - size = tester.getSize(title); - expect(center.dx, lessThan(400 - size.width / 2.0), reason: 'on ${describeEnum(platform)}'); - } + center = tester.getCenter(title); + size = tester.getSize(title); + expect(center.dx, lessThan(400 - size.width / 2.0)); }); testWidgets('AppBar centerTitle:true centers on Android', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/app_builder_test.dart b/packages/flutter/test/material/app_builder_test.dart index c174f473bd2..c25825a8f2e 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, isA()); + expect(child, isInstanceOf()); return const Placeholder(); }, ); diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index 5aaf52d93f5..b8c2a8d0658 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, isA()); + expect(exception is String, isTrue); 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, isA()); + expect(key.currentState, isInstanceOf()); 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, isA()); + expect(key.currentState, isInstanceOf()); }); testWidgets('Has default material and cupertino localizations', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 6942ef21d77..dea09f789e2 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -66,37 +66,30 @@ void main() { }); testWidgets('BackButton icon', (WidgetTester tester) async { - final Key androidKey = UniqueKey(); final Key iOSKey = UniqueKey(); - final Key macOSKey = UniqueKey(); + final Key androidKey = UniqueKey(); + await tester.pumpWidget( MaterialApp( home: Column( children: [ - Theme( - data: ThemeData(platform: TargetPlatform.android), - child: BackButtonIcon(key: androidKey), - ), Theme( data: ThemeData(platform: TargetPlatform.iOS), child: BackButtonIcon(key: iOSKey), ), Theme( - data: ThemeData(platform: TargetPlatform.macOS), - child: BackButtonIcon(key: macOSKey), + data: ThemeData(platform: TargetPlatform.android), + child: BackButtonIcon(key: androidKey), ), ], ), ), ); - final Icon androidIcon = tester.widget(find.descendant(of: find.byKey(androidKey), matching: find.byType(Icon))); final Icon iOSIcon = tester.widget(find.descendant(of: find.byKey(iOSKey), matching: find.byType(Icon))); - final Icon macOSIcon = tester.widget(find.descendant(of: find.byKey(macOSKey), matching: find.byType(Icon))); - expect(iOSIcon.icon == androidIcon.icon, isFalse); - expect(macOSIcon.icon == androidIcon.icon, isFalse); - expect(macOSIcon.icon == iOSIcon.icon, isTrue); + final Icon androidIcon = tester.widget(find.descendant(of: find.byKey(androidKey), matching: find.byType(Icon))); + expect(iOSIcon == androidIcon, false); }); testWidgets('BackButton semantics', (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 a3a2b894e01..51a9793ca7e 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() { ), ), ); - }, throwsAssertionError); + }, throwsA(isInstanceOf())); }); testWidgets( diff --git a/packages/flutter/test/material/chip_theme_test.dart b/packages/flutter/test/material/chip_theme_test.dart index d4f1d1e0357..6c25700f65d 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, isA()); + expect(lightTheme.shape, equals(isInstanceOf())); 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, isA()); + expect(darkTheme.shape, equals(isInstanceOf())); 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, isA()); + expect(customTheme.shape, equals(isInstanceOf())); 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, isA()); + expect(lerp.shape, equals(isInstanceOf())); 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, isA()); + expect(lerpANull25.shape, equals(isInstanceOf())); 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, isA()); + expect(lerpANull75.shape, equals(isInstanceOf())); 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, isA()); + expect(lerpBNull25.shape, equals(isInstanceOf())); 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, isA()); + expect(lerpBNull75.shape, equals(isInstanceOf())); 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 b42ea43ca51..f612b6a781c 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], isA>()); - expect(error.diagnostics[4], isA()); + expect(error.diagnostics[3], isInstanceOf>()); + expect(error.diagnostics[4], isInstanceOf()); 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], isA>()); - expect(error.diagnostics[5], isA()); + expect(error.diagnostics[4], isInstanceOf>()); + expect(error.diagnostics[5], isInstanceOf()); 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], isA>()); - expect(error.diagnostics[3], isA()); + expect(error.diagnostics[2], isInstanceOf>()); + expect(error.diagnostics[3], isInstanceOf()); expect(error.diagnostics[4].level, DiagnosticLevel.hint); expect( error.diagnostics[4].toStringDeep(), diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index 765373e1cac..131291bbea5 100644 --- a/packages/flutter/test/material/drawer_test.dart +++ b/packages/flutter/test/material/drawer_test.dart @@ -57,8 +57,9 @@ void main() { expect(find.text('header'), findsOneWidget); }); - testWidgets('Drawer dismiss barrier has label', (WidgetTester tester) async { + testWidgets('Drawer dismiss barrier has label on iOS', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( const MaterialApp( home: Scaffold( @@ -79,9 +80,10 @@ void main() { )); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); - testWidgets('Drawer dismiss barrier has no label', (WidgetTester tester) async { + testWidgets('Drawer dismiss barrier has no label on Android', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const MaterialApp( @@ -103,7 +105,7 @@ void main() { ))); semantics.dispose(); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); testWidgets('Scaffold drawerScrimColor', (WidgetTester tester) async { // The scrim is a Container within a Semantics node labeled "Dismiss", diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 57957777323..3f6954aac8c 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -58,6 +58,7 @@ void main() { await tester.pumpWidget(MaterialApp( theme: ThemeData( + platform: TargetPlatform.iOS, dividerColor: _dividerColor, ), home: Material( @@ -153,7 +154,7 @@ void main() { expect(collapsedContainerDecoration.color, Colors.transparent); expect(collapsedContainerDecoration.border.top.color, _dividerColor); expect(collapsedContainerDecoration.border.bottom.color, _dividerColor); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('ListTileTheme', (WidgetTester tester) async { final Key expandedTitleKey = UniqueKey(); @@ -164,6 +165,7 @@ void main() { await tester.pumpWidget( MaterialApp( theme: ThemeData( + platform: TargetPlatform.iOS, accentColor: _accentColor, unselectedWidgetColor: _unselectedWidgetColor, textTheme: const TextTheme(subhead: TextStyle(color: _headerColor)), @@ -212,7 +214,7 @@ void main() { expect(textColor(collapsedTitleKey), _accentColor); expect(iconColor(expandedIconKey), _unselectedWidgetColor); expect(iconColor(collapsedIconKey), _accentColor); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('ExpansionTile subtitle', (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart b/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart index d31086daa5d..029e191658d 100644 --- a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_collapse_mode_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/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -11,10 +10,10 @@ const double expandedAppbarHeight = 250.0; final Key appbarContainerKey = UniqueKey(); void main() { - testWidgets('FlexibleSpaceBar collapse mode none', (WidgetTester tester) async { + testWidgets('FlexibleSpaceBar collapse mode none on Android', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( - theme: ThemeData(platform: debugDefaultTargetPlatformOverride), + theme: ThemeData(platform: TargetPlatform.android), home: Scaffold( body: CustomScrollView( key: blockKey, @@ -47,12 +46,50 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, equals(0.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async { + testWidgets('FlexibleSpaceBar collapse mode none on IOS', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( - theme: ThemeData(platform: debugDefaultTargetPlatformOverride), + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( + key: blockKey, + slivers: [ + SliverAppBar( + expandedHeight: expandedAppbarHeight, + pinned: true, + flexibleSpace: FlexibleSpaceBar( + background: Container( + key: appbarContainerKey, + ), + collapseMode: CollapseMode.none, + ), + ), + SliverToBoxAdapter( + child: Container( + height: 10000.0, + ), + ), + ], + ), + ), + ), + ); + + final Finder appbarContainer = find.byKey(appbarContainerKey); + final Offset topBeforeScroll = tester.getTopLeft(appbarContainer); + await slowDrag(tester, blockKey, const Offset(0.0, -100.0)); + final Offset topAfterScroll = tester.getTopLeft(appbarContainer); + + expect(topBeforeScroll.dy, equals(0.0)); + expect(topAfterScroll.dy, equals(0.0)); + }); + + testWidgets('FlexibleSpaceBar collapse mode pin on Android', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: Scaffold( body: CustomScrollView( key: blockKey, @@ -85,12 +122,52 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, equals(-100.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async { + testWidgets('FlexibleSpaceBar collapse mode pin on IOS', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( - theme: ThemeData(platform: debugDefaultTargetPlatformOverride), + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( + key: blockKey, + slivers: [ + SliverAppBar( + expandedHeight: expandedAppbarHeight, + pinned: true, + flexibleSpace: FlexibleSpaceBar( + background: Container( + key: appbarContainerKey, + ), + collapseMode: CollapseMode.pin, + ), + ), + SliverToBoxAdapter( + child: Container( + height: 10000.0, + ), + ), + ], + ), + ), + ), + ); + + final Finder appbarContainer = find.byKey(appbarContainerKey); + final Offset topBeforeScroll = tester.getTopLeft(appbarContainer); + await slowDrag(tester, blockKey, const Offset(0.0, -100.0)); + final Offset topAfterScroll = tester.getTopLeft(appbarContainer); + + expect(topBeforeScroll.dy, equals(0.0)); + expect(topAfterScroll.dy, equals(-100.0)); + }); + + + + testWidgets('FlexibleSpaceBar collapse mode parallax on Android', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: Scaffold( body: CustomScrollView( key: blockKey, @@ -124,7 +201,46 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, lessThan(10.0)); expect(topAfterScroll.dy, greaterThan(-50.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }); + + testWidgets('FlexibleSpaceBar collapse mode parallax on IOS', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( + key: blockKey, + slivers: [ + SliverAppBar( + expandedHeight: expandedAppbarHeight, + pinned: true, + flexibleSpace: FlexibleSpaceBar( + background: Container( + key: appbarContainerKey, + ), + collapseMode: CollapseMode.parallax, + ), + ), + SliverToBoxAdapter( + child: Container( + height: 10000.0, + ), + ), + ], + ), + ), + ), + ); + + final Finder appbarContainer = find.byKey(appbarContainerKey); + final Offset topBeforeScroll = tester.getTopLeft(appbarContainer); + await slowDrag(tester, blockKey, const Offset(0.0, -100.0)); + final Offset topAfterScroll = tester.getTopLeft(appbarContainer); + + expect(topBeforeScroll.dy, equals(0.0)); + expect(topAfterScroll.dy, lessThan(10.0)); + expect(topAfterScroll.dy, greaterThan(-50.0)); + }); } Future slowDrag(WidgetTester tester, Key widget, Offset offset) async { diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index c8ac87271e9..83bff201228 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -25,28 +25,26 @@ void main() { Size size = tester.getSize(title); expect(center.dx, lessThan(400.0 - size.width / 2.0)); - for (final TargetPlatform platform in [ TargetPlatform.iOS, TargetPlatform.macOS ]) { - // Clear the widget tree to avoid animating between platforms. - await tester.pumpWidget(Container(key: UniqueKey())); + // Clear the widget tree to avoid animating between Android and iOS. + await tester.pumpWidget(Container(key: UniqueKey())); - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: platform), - home: Scaffold( - appBar: AppBar( - flexibleSpace: const FlexibleSpaceBar( - title: Text('X'), - ), + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( + flexibleSpace: const FlexibleSpaceBar( + title: Text('X'), ), ), ), - ); + ), + ); - center = tester.getCenter(title); - size = tester.getSize(title); - expect(center.dx, greaterThan(400.0 - size.width / 2.0)); - expect(center.dx, lessThan(400.0 + size.width / 2.0)); - } + center = tester.getCenter(title); + size = tester.getSize(title); + expect(center.dx, greaterThan(400.0 - size.width / 2.0)); + expect(center.dx, lessThan(400.0 + size.width / 2.0)); }); testWidgets('FlexibleSpaceBarSettings provides settings to a FlexibleSpaceBar', (WidgetTester tester) async { @@ -156,15 +154,6 @@ void main() { await tester.pumpWidget(buildFrame(TargetPlatform.iOS, false)); expect(getTitleBottomLeft(), const Offset(72.0, 16.0)); - // Clear the widget tree to avoid animating between iOS and macOS. - await tester.pumpWidget(Container(key: UniqueKey())); - - await tester.pumpWidget(buildFrame(TargetPlatform.macOS, null)); - expect(getTitleBottomLeft(), const Offset(390.0, 16.0)); - - await tester.pumpWidget(buildFrame(TargetPlatform.macOS, false)); - expect(getTitleBottomLeft(), const Offset(72.0, 16.0)); - }, skip: isBrowser); testWidgets('FlexibleSpaceBar test titlePadding override', (WidgetTester tester) async { @@ -206,15 +195,6 @@ void main() { await tester.pumpWidget(buildFrame(TargetPlatform.iOS, false)); expect(getTitleBottomLeft(), Offset.zero); - - // Clear the widget tree to avoid animating between iOS and macOS. - await tester.pumpWidget(Container(key: UniqueKey())); - - await tester.pumpWidget(buildFrame(TargetPlatform.macOS, null)); - expect(getTitleBottomLeft(), const Offset(390.0, 0.0)); - - await tester.pumpWidget(buildFrame(TargetPlatform.macOS, false)); - expect(getTitleBottomLeft(), Offset.zero); }, skip: isBrowser); } diff --git a/packages/flutter/test/material/outline_button_test.dart b/packages/flutter/test/material/outline_button_test.dart index a61baf9840c..e6debab11b2 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, isA()); + expect(object.debugLayer.firstChild, isInstanceOf()); 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 9f342ee6cee..47fbded3a68 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_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/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart' show CupertinoPageRoute; import 'package:flutter/rendering.dart'; @@ -11,9 +10,10 @@ import 'package:flutter_test/flutter_test.dart'; import '../rendering/mock_canvas.dart'; void main() { - testWidgets('test page transition', (WidgetTester tester) async { + testWidgets('test Android page transition', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -66,12 +66,13 @@ void main() { expect(find.text('Page 1'), isOnstage); expect(find.text('Page 2'), findsNothing); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); - testWidgets('test page transition', (WidgetTester tester) async { + testWidgets('test iOS page transition', (WidgetTester tester) async { final Key page2Key = UniqueKey(); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -144,12 +145,13 @@ void main() { // Page 1 is back where it started. expect(widget1InitialTopLeft == widget1TransientTopLeft, true); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('test fullscreen dialog transition', (WidgetTester tester) async { + testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material(child: Text('Page 1')), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material(child: Text('Page 1')), ), ); @@ -204,11 +206,12 @@ void main() { // Page 1 is back where it started. expect(widget1InitialTopLeft == widget1TransientTopLeft, true); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('test no back gesture on Android', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: const Scaffold(body: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -234,11 +237,12 @@ void main() { // Page 2 didn't move expect(tester.getTopLeft(find.text('Page 2')), Offset.zero); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); - testWidgets('test back gesture', (WidgetTester tester) async { + testWidgets('test back gesture on iOS', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Scaffold(body: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -275,7 +279,7 @@ void main() { await tester.pump(); expect(tester.getTopLeft(find.text('Page 2')), const Offset(100.0, 0.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('back gesture while OS changes', (WidgetTester tester) async { final Map routes = { @@ -342,36 +346,13 @@ void main() { expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 3); expect(find.text('PUSH'), findsOneWidget); expect(find.text('HELLO'), findsNothing); - - await tester.pumpWidget( - MaterialApp( - theme: ThemeData(platform: TargetPlatform.macOS), - routes: routes, - ), - ); - await tester.tap(find.text('PUSH')); - expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 2); - expect(find.text('PUSH'), findsNothing); - expect(find.text('HELLO'), findsOneWidget); - final Offset helloPosition5 = tester.getCenter(find.text('HELLO')); - await gesture.down(const Offset(2.5, 300.0)); - await tester.pump(const Duration(milliseconds: 20)); - await gesture.moveBy(const Offset(100.0, 0.0)); - expect(find.text('PUSH'), findsNothing); - expect(find.text('HELLO'), findsOneWidget); - await tester.pump(const Duration(milliseconds: 20)); - expect(find.text('PUSH'), findsOneWidget); - expect(find.text('HELLO'), findsOneWidget); - final Offset helloPosition6 = tester.getCenter(find.text('HELLO')); - expect(helloPosition5.dx, lessThan(helloPosition6.dx)); - expect(helloPosition5.dy, helloPosition6.dy); - expect(Theme.of(tester.element(find.text('HELLO'))).platform, TargetPlatform.macOS); }); - testWidgets('test no back gesture on fullscreen dialogs', (WidgetTester tester) async { + testWidgets('test no back gesture on iOS fullscreen dialogs', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold(body: Text('Page 1')), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Scaffold(body: Text('Page 1')), ), ); @@ -396,7 +377,7 @@ void main() { // Page 2 didn't move expect(tester.getTopLeft(find.text('Page 2')), Offset.zero); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('test adaptable transitions switch during execution', (WidgetTester tester) async { await tester.pumpWidget( @@ -436,6 +417,7 @@ void main() { // Re-pump the same app but with iOS instead of Android. await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -470,7 +452,7 @@ void main() { // Page 1 is back where it started. expect(widget1InitialTopLeft == widget1TransientTopLeft, true); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('throws when builder returns null', (WidgetTester tester) async { await tester.pumpWidget(const MaterialApp( @@ -488,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, isFlutterError); + expect(exception, isInstanceOf()); expect(exception.toStringDeep(), equalsIgnoringHashCodes( 'FlutterError\n' ' The builder for route "broken" returned null.\n' @@ -496,9 +478,10 @@ void main() { )); }); - testWidgets('test edge swipe then drop back at starting point works', (WidgetTester tester) async { + testWidgets('test iOS edge swipe then drop back at starting point works', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), onGenerateRoute: (RouteSettings settings) { return MaterialPageRoute( settings: settings, @@ -529,11 +512,12 @@ void main() { expect(find.text('Page 1'), findsNothing); expect(find.text('Page 2'), isOnstage); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('test edge swipe then drop back at ending point works', (WidgetTester tester) async { + testWidgets('test iOS edge swipe then drop back at ending point works', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), onGenerateRoute: (RouteSettings settings) { return MaterialPageRoute( settings: settings, @@ -562,7 +546,7 @@ void main() { expect(find.text('Page 1'), isOnstage); expect(find.text('Page 2'), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Back swipe dismiss interrupted by route push', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/28728 @@ -570,6 +554,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Scaffold( key: scaffoldKey, body: Center( @@ -657,7 +642,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('route'), findsOneWidget); expect(find.text('push'), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('During back swipe the route ignores input', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/39989 @@ -669,6 +654,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Scaffold( key: homeScaffoldKey, body: GestureDetector( @@ -727,7 +713,7 @@ void main() { await tester.pumpAndSettle(); expect(tester.getTopLeft(find.byKey(pageScaffoldKey)), const Offset(400, 0)); expect(tester.getTopLeft(find.byKey(homeScaffoldKey)).dx, lessThan(0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('After a pop caused by a back-swipe, input reaches the exposed route', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/41024 @@ -739,6 +725,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Scaffold( key: homeScaffoldKey, body: GestureDetector( @@ -798,9 +785,9 @@ void main() { await tester.tap(find.byKey(homeScaffoldKey)); expect(homeTapCount, 2); expect(pageTapCount, 1); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('A MaterialPageRoute should slide out with CupertinoPageTransition when a compatible PageRoute is pushed on top of it', (WidgetTester tester) async { + testWidgets('On iOS, a MaterialPageRoute should slide out with CupertinoPageTransition when a compatible PageRoute is pushed on top of it', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/44864. await tester.pumpWidget( @@ -826,5 +813,5 @@ void main() { // Title of the first route slides to the left. expect(titleInitialTopLeft.dy, equals(titleTransientTopLeft.dy)); expect(titleInitialTopLeft.dx, greaterThan(titleTransientTopLeft.dx)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); } diff --git a/packages/flutter/test/material/page_transitions_theme_test.dart b/packages/flutter/test/material/page_transitions_theme_test.dart index 920ea1aa627..d1a4c4997b9 100644 --- a/packages/flutter/test/material/page_transitions_theme_test.dart +++ b/packages/flutter/test/material/page_transitions_theme_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -12,16 +11,11 @@ void main() { await tester.pumpWidget(const MaterialApp(home: Text('home'))); final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home'))).pageTransitionsTheme; expect(theme.builders, isNotNull); - for (final TargetPlatform platform in TargetPlatform.values) { - if (platform == TargetPlatform.fuchsia) { - // No builder on Fuchsia. - continue; - } - expect(theme.builders[platform], isNotNull, reason: 'theme builder for $platform is null'); - } + expect(theme.builders[TargetPlatform.android], isNotNull); + expect(theme.builders[TargetPlatform.iOS], isNotNull); }); - testWidgets('Default PageTranstionsTheme builds a CupertionPageTransition', (WidgetTester tester) async { + testWidgets('Default PageTranstionsTheme builds a CupertionPageTransition for iOS', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: FlatButton( @@ -34,18 +28,19 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), routes: routes, ), ); - expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); + expect(Theme.of(tester.element(find.text('push'))).platform, TargetPlatform.iOS); expect(find.byType(CupertinoPageTransition), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); expect(find.byType(CupertinoPageTransition), findsOneWidget); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Default PageTranstionsTheme builds a _FadeUpwardsPageTransition for android', (WidgetTester tester) async { final Map routes = { @@ -60,6 +55,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), routes: routes, ), ); @@ -71,16 +67,16 @@ void main() { ); } - expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); + expect(Theme.of(tester.element(find.text('push'))).platform, TargetPlatform.android); expect(findFadeUpwardsPageTransition(), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); expect(findFadeUpwardsPageTransition(), findsOneWidget); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); - testWidgets('pageTranstionsTheme override builds a _OpenUpwardsPageTransition', (WidgetTester tester) async { + testWidgets('pageTranstionsTheme override builds a _OpenUpwardsPageTransition for android', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: FlatButton( @@ -94,6 +90,7 @@ void main() { await tester.pumpWidget( MaterialApp( theme: ThemeData( + platform: TargetPlatform.android, pageTransitionsTheme: const PageTransitionsTheme( builders: { TargetPlatform.android: OpenUpwardsPageTransitionsBuilder(), // creates a _OpenUpwardsPageTransition @@ -111,16 +108,16 @@ void main() { ); } - expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); + expect(Theme.of(tester.element(find.text('push'))).platform, TargetPlatform.android); expect(findOpenUpwardsPageTransition(), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); expect(findOpenUpwardsPageTransition(), findsOneWidget); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); - testWidgets('pageTranstionsTheme override builds a _ZoomPageTransition', (WidgetTester tester) async { + testWidgets('pageTranstionsTheme override builds a _ZoomPageTransition for android', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: FlatButton( @@ -134,6 +131,7 @@ void main() { await tester.pumpWidget( MaterialApp( theme: ThemeData( + platform: TargetPlatform.android, pageTransitionsTheme: const PageTransitionsTheme( builders: { TargetPlatform.android: ZoomPageTransitionsBuilder(), // creates a _ZoomPageTransition @@ -151,12 +149,12 @@ void main() { ); } - expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); + expect(Theme.of(tester.element(find.text('push'))).platform, TargetPlatform.android); expect(findZoomPageTransition(), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); expect(findZoomPageTransition(), findsOneWidget); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); + }); } diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index d6a6ecd33d4..546ce35043a 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, isFlutterError); + expect(exception, isInstanceOf()); 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, isFlutterError); + expect(exception, isInstanceOf()); 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 5b77d2f4cd7..831d777179f 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -325,12 +325,6 @@ void main() { expect(find.byIcon(Icons.more_vert), findsNothing); expect(find.byIcon(Icons.more_horiz), findsOneWidget); - - await tester.pumpWidget(build(TargetPlatform.macOS)); - await tester.pumpAndSettle(); // Run theme change animation. - - expect(find.byIcon(Icons.more_vert), findsNothing); - expect(find.byIcon(Icons.more_horiz), findsOneWidget); }); group('PopupMenuButton with Icon', () { @@ -351,7 +345,7 @@ void main() { icon: const Icon(Icons.view_carousel), itemBuilder: simplePopupMenuItemBuilder, ); - }, throwsAssertionError); + }, throwsA(isInstanceOf())); }); testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/refresh_indicator_test.dart b/packages/flutter/test/material/refresh_indicator_test.dart index b24097e62a1..965c60daf47 100644 --- a/packages/flutter/test/material/refresh_indicator_test.dart +++ b/packages/flutter/test/material/refresh_indicator_test.dart @@ -387,7 +387,8 @@ void main() { expect(tester.takeException(), isFlutterError); }); - testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll', (WidgetTester tester) async { + testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; refreshCalled = false; double lastScrollOffset; final ScrollController controller = ScrollController(); @@ -419,5 +420,7 @@ void main() { expect(controller.offset, greaterThan(lastScrollOffset)); expect(controller.offset, lessThan(0.0)); expect(refreshCalled, isTrue); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); } diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index 138c76a9bf9..d3d379839ad 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -320,17 +320,17 @@ void main() { ); } - testWidgets('Tapping the status bar scrolls to top', (WidgetTester tester) async { - await tester.pumpWidget(_buildStatusBarTestApp(debugDefaultTargetPlatformOverride)); + testWidgets('Tapping the status bar scrolls to top on iOS', (WidgetTester tester) async { + await tester.pumpWidget(_buildStatusBarTestApp(TargetPlatform.iOS)); final ScrollableState scrollable = tester.state(find.byType(Scrollable)); scrollable.position.jumpTo(500.0); expect(scrollable.position.pixels, equals(500.0)); await tester.tapAt(const Offset(100.0, 10.0)); await tester.pumpAndSettle(); expect(scrollable.position.pixels, equals(0.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Tapping the status bar does not scroll to top', (WidgetTester tester) async { + testWidgets('Tapping the status bar does not scroll to top on Android', (WidgetTester tester) async { await tester.pumpWidget(_buildStatusBarTestApp(TargetPlatform.android)); final ScrollableState scrollable = tester.state(find.byType(Scrollable)); scrollable.position.jumpTo(500.0); @@ -339,7 +339,7 @@ void main() { await tester.pump(); await tester.pump(const Duration(seconds: 1)); expect(scrollable.position.pixels, equals(500.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android })); + }); testWidgets('Bottom sheet cannot overlap app bar', (WidgetTester tester) async { final Key sheetKey = UniqueKey(); @@ -506,7 +506,7 @@ void main() { }); group('back arrow', () { - Future expectBackIcon(WidgetTester tester, IconData expectedIcon) async { + Future expectBackIcon(WidgetTester tester, TargetPlatform platform, IconData expectedIcon) async { final GlobalKey rootKey = GlobalKey(); final Map routes = { '/': (_) => Container(key: rootKey, child: const Text('Home')), @@ -515,7 +515,9 @@ void main() { body: const Text('Scaffold'), ), }; - await tester.pumpWidget(MaterialApp(routes: routes)); + await tester.pumpWidget( + MaterialApp(theme: ThemeData(platform: platform), routes: routes) + ); Navigator.pushNamed(rootKey.currentContext, '/scaffold'); await tester.pump(); @@ -525,20 +527,24 @@ void main() { expect(icon.icon, expectedIcon); } - testWidgets('Back arrow uses correct default', (WidgetTester tester) async { - await expectBackIcon(tester, Icons.arrow_back); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + testWidgets('Back arrow uses correct default on Android', (WidgetTester tester) async { + await expectBackIcon(tester, TargetPlatform.android, Icons.arrow_back); + }); - testWidgets('Back arrow uses correct default', (WidgetTester tester) async { - await expectBackIcon(tester, Icons.arrow_back_ios); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + testWidgets('Back arrow uses correct default on Fuchsia', (WidgetTester tester) async { + await expectBackIcon(tester, TargetPlatform.fuchsia, Icons.arrow_back); + }); + + testWidgets('Back arrow uses correct default on iOS', (WidgetTester tester) async { + await expectBackIcon(tester, TargetPlatform.iOS, Icons.arrow_back_ios); + }); }); group('close button', () { - Future expectCloseIcon(WidgetTester tester, PageRoute routeBuilder(), String type) async { - const IconData expectedIcon = Icons.close; + Future expectCloseIcon(WidgetTester tester, TargetPlatform platform, IconData expectedIcon, PageRoute routeBuilder()) async { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: platform), home: Scaffold(appBar: AppBar(), body: const Text('Page 1')), ), ); @@ -549,8 +555,8 @@ void main() { await tester.pump(const Duration(seconds: 1)); final Icon icon = tester.widget(find.byType(Icon)); - expect(icon.icon, expectedIcon, reason: "didn't find close icon for $type"); - expect(find.byType(CloseButton), findsOneWidget, reason: "didn't find close button for $type"); + expect(icon.icon, expectedIcon); + expect(find.byType(CloseButton), findsOneWidget); } PageRoute materialRouteBuilder() { @@ -580,17 +586,41 @@ void main() { ); } - testWidgets('Close button shows correctly', (WidgetTester tester) async { - await expectCloseIcon(tester, materialRouteBuilder, 'materialRouteBuilder'); - }, variant: TargetPlatformVariant.all()); + testWidgets('Close button shows correctly on Android', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.android, Icons.close, materialRouteBuilder); + }); - testWidgets('Close button shows correctly with PageRouteBuilder', (WidgetTester tester) async { - await expectCloseIcon(tester, pageRouteBuilder, 'pageRouteBuilder'); - }, variant: TargetPlatformVariant.all()); + testWidgets('Close button shows correctly on Fuchsia', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.fuchsia, Icons.close, materialRouteBuilder); + }); - testWidgets('Close button shows correctly with custom page route', (WidgetTester tester) async { - await expectCloseIcon(tester, customPageRouteBuilder, 'customPageRouteBuilder'); - }, variant: TargetPlatformVariant.all()); + testWidgets('Close button shows correctly on iOS', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.iOS, Icons.close, materialRouteBuilder); + }); + + testWidgets('Close button shows correctly with PageRouteBuilder on Android', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.android, Icons.close, pageRouteBuilder); + }); + + testWidgets('Close button shows correctly with PageRouteBuilder on Fuchsia', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.fuchsia, Icons.close, pageRouteBuilder); + }); + + testWidgets('Close button shows correctly with PageRouteBuilder on iOS', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.iOS, Icons.close, pageRouteBuilder); + }); + + testWidgets('Close button shows correctly with custom page route on Android', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.android, Icons.close, customPageRouteBuilder); + }); + + testWidgets('Close button shows correctly with custom page route on Fuchsia', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.fuchsia, Icons.close, customPageRouteBuilder); + }); + + testWidgets('Close button shows correctly with custom page route on iOS', (WidgetTester tester) async { + await expectCloseIcon(tester, TargetPlatform.iOS, Icons.close, customPageRouteBuilder); + }); }); group('body size', () { @@ -1794,7 +1824,7 @@ void main() { 'the ScaffoldState rather than using the Scaffold.of() function.\n', ), ); - expect(error.diagnostics[4], isA>()); + expect(error.diagnostics[4], isInstanceOf>()); expect(error.toStringDeep(), 'FlutterError\n' ' Scaffold.of() called with a context that does not contain a\n' @@ -1863,7 +1893,7 @@ void main() { 'Scaffold.geometryOf().\n', ), ); - expect(error.diagnostics[4], isA>()); + expect(error.diagnostics[4], isInstanceOf>()); expect(error.toStringDeep(), 'FlutterError\n' ' Scaffold.geometryOf() called with a context that does not contain\n' diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index ad92f0dbdfd..1d1edd850e6 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -153,20 +152,6 @@ void main() { await tester.drag(find.byType(SingleChildScrollView), const Offset(0.0, -10.0)); await tester.pump(); await tester.pump(const Duration(milliseconds: 200)); - expect(find.byType(Scrollbar), paints..rrect()); - expect(find.byType(CupertinoScrollbar), paints..rrect()); - await gesture.up(); - await tester.pumpAndSettle(); - - await tester.pumpWidget(viewWithScroll(TargetPlatform.macOS)); - await gesture.down( - tester.getCenter(find.byType(SingleChildScrollView)), - ); - await gesture.moveBy(const Offset(0.0, -10.0)); - await tester.drag(find.byType(SingleChildScrollView), const Offset(0.0, -10.0)); - await tester.pump(); - await tester.pump(const Duration(milliseconds: 200)); - expect(find.byType(Scrollbar), paints..rrect()); expect(find.byType(CupertinoScrollbar), paints..rrect()); }); @@ -188,7 +173,7 @@ void main() { ); } - await tester.pumpWidget(viewWithScroll(debugDefaultTargetPlatformOverride)); + await tester.pumpWidget(viewWithScroll(TargetPlatform.iOS)); final TestGesture gesture = await tester.startGesture( tester.getCenter(find.byType(SingleChildScrollView)) ); @@ -199,6 +184,6 @@ void main() { expect(find.byType(CupertinoScrollbar), paints..rrect()); final CupertinoScrollbar scrollbar = find.byType(CupertinoScrollbar).evaluate().first.widget as CupertinoScrollbar; expect(scrollbar.controller, isNotNull); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); } diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index 239db29c2b1..2c4b705f699 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -573,8 +573,7 @@ void main() { SemanticsFlag.isTextField, SemanticsFlag.isFocused, SemanticsFlag.isHeader, - if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && - debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, + if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS) SemanticsFlag.namesRoute, ], actions: [ SemanticsAction.tap, @@ -623,7 +622,8 @@ void main() { semantics.dispose(); }); - testWidgets('does not include routeName', (WidgetTester tester) async { + testWidgets('does not include routeName on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final SemanticsTester semantics = SemanticsTester(tester); final _TestSearchDelegate delegate = _TestSearchDelegate(); await tester.pumpWidget(TestHomePage( @@ -636,8 +636,9 @@ void main() { expect(semantics, hasSemantics(buildExpected(routeName: ''), ignoreId: true, ignoreRect: true, ignoreTransform: true)); + debugDefaultTargetPlatformOverride = null; semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); }); } diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 96451b05fe5..e3f0b4bcfe0 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -1250,14 +1250,16 @@ void main() { )); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }); - testWidgets('Slider Semantics', (WidgetTester tester) async { + testWidgets('Slider Semantics - iOS', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( Theme( - data: ThemeData.light(), + data: ThemeData.light().copyWith( + platform: TargetPlatform.iOS, + ), child: Directionality( textDirection: TextDirection.ltr, child: MediaQuery( @@ -1292,7 +1294,7 @@ void main() { ignoreTransform: true, )); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Slider semantics with custom formatter', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); @@ -1483,34 +1485,27 @@ void main() { ); } - for (final TargetPlatform platform in [TargetPlatform.iOS, TargetPlatform.macOS]) { - value = 0.5; - await tester.pumpWidget(buildFrame(platform)); - expect(find.byType(Slider), findsOneWidget); - expect(find.byType(CupertinoSlider), findsOneWidget); + await tester.pumpWidget(buildFrame(TargetPlatform.iOS)); + expect(find.byType(Slider), findsOneWidget); + expect(find.byType(CupertinoSlider), findsOneWidget); - expect(value, 0.5, reason: 'on ${describeEnum(platform)}'); - final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(CupertinoSlider))); - // Drag to the right end of the track. - await gesture.moveBy(const Offset(600.0, 0.0)); - expect(value, 1.0, reason: 'on ${describeEnum(platform)}'); - await gesture.up(); - } + expect(value, 0.5); + TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(CupertinoSlider))); + // Drag to the right end of the track. + await gesture.moveBy(const Offset(600.0, 0.0)); + expect(value, 1.0); - for (final TargetPlatform platform in [TargetPlatform.android, TargetPlatform.fuchsia]) { - value = 0.5; - await tester.pumpWidget(buildFrame(platform)); - await tester.pumpAndSettle(); // Finish the theme change animation. - expect(find.byType(Slider), findsOneWidget); - expect(find.byType(CupertinoSlider), findsNothing); + value = 0.5; + await tester.pumpWidget(buildFrame(TargetPlatform.android)); + await tester.pumpAndSettle(); // Finish the theme change animation. + expect(find.byType(Slider), findsOneWidget); + expect(find.byType(CupertinoSlider), findsNothing); - expect(value, 0.5, reason: 'on ${describeEnum(platform)}'); - final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Slider))); - // Drag to the right end of the track. - await gesture.moveBy(const Offset(600.0, 0.0)); - expect(value, 1.0, reason: 'on ${describeEnum(platform)}'); - await gesture.up(); - } + expect(value, 0.5); + gesture = await tester.startGesture(tester.getCenter(find.byType(Slider))); + // Drag to the right end of the track. + await gesture.moveBy(const Offset(600.0, 0.0)); + expect(value, 1.0); }); testWidgets('Slider respects height from theme', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart index 11c1f810dc6..6a21366e781 100644 --- a/packages/flutter/test/material/switch_list_tile_test.dart +++ b/packages/flutter/test/material/switch_list_tile_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import '../rendering/mock_canvas.dart'; @@ -86,26 +85,20 @@ void main() { ); } - for (final TargetPlatform platform in [ TargetPlatform.iOS, TargetPlatform.macOS ]) { - value = false; - await tester.pumpWidget(buildFrame(platform)); - expect(find.byType(CupertinoSwitch), findsOneWidget); - expect(value, isFalse, reason: 'on ${describeEnum(platform)}'); + await tester.pumpWidget(buildFrame(TargetPlatform.iOS)); + expect(find.byType(CupertinoSwitch), findsOneWidget); + expect(value, isFalse); - await tester.tap(find.byType(SwitchListTile)); - expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); - } + await tester.tap(find.byType(SwitchListTile)); + expect(value, isTrue); - for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia ]) { - value = false; - await tester.pumpWidget(buildFrame(platform)); - await tester.pumpAndSettle(); // Finish the theme change animation. + await tester.pumpWidget(buildFrame(TargetPlatform.android)); + await tester.pumpAndSettle(); // Finish the theme change animation. - expect(find.byType(CupertinoSwitch), findsNothing); - expect(value, isFalse, reason: 'on ${describeEnum(platform)}'); - await tester.tap(find.byType(SwitchListTile)); - expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); - } + expect(find.byType(CupertinoSwitch), findsNothing); + expect(value, isTrue); + await tester.tap(find.byType(SwitchListTile)); + expect(value, isFalse); }); testWidgets('SwitchListTile contentPadding', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index 222ab591405..6aa8e9b5a2f 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -610,28 +610,23 @@ void main() { ); } - for (final TargetPlatform platform in [ TargetPlatform.iOS, TargetPlatform.macOS ]) { - value = false; - await tester.pumpWidget(buildFrame(platform)); - expect(find.byType(CupertinoSwitch), findsOneWidget, reason: 'on ${describeEnum(platform)}'); + await tester.pumpWidget(buildFrame(TargetPlatform.iOS)); + expect(find.byType(CupertinoSwitch), findsOneWidget); - final CupertinoSwitch adaptiveSwitch = tester.widget(find.byType(CupertinoSwitch)); - expect(adaptiveSwitch.trackColor, inactiveTrackColor, reason: 'on ${describeEnum(platform)}'); + final CupertinoSwitch adaptiveSwitch = tester.widget(find.byType(CupertinoSwitch)); + expect(adaptiveSwitch.trackColor, inactiveTrackColor); - expect(value, isFalse, reason: 'on ${describeEnum(platform)}'); - await tester.tap(find.byType(Switch)); - expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); - } + expect(value, isFalse); + await tester.tap(find.byType(Switch)); + expect(value, isTrue); + + await tester.pumpWidget(buildFrame(TargetPlatform.android)); + await tester.pumpAndSettle(); // Finish the theme change animation. + expect(find.byType(CupertinoSwitch), findsNothing); + expect(value, isTrue); + await tester.tap(find.byType(Switch)); + expect(value, isFalse); - for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia ]) { - value = false; - await tester.pumpWidget(buildFrame(platform)); - await tester.pumpAndSettle(); // Finish the theme change animation. - expect(find.byType(CupertinoSwitch), findsNothing); - expect(value, isFalse, reason: 'on ${describeEnum(platform)}'); - await tester.tap(find.byType(Switch)); - expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); - } }); testWidgets('Switch is focusable and has correct focus color', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 84a0068d61d..78a5cae6291 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -304,7 +304,9 @@ void main() { await checkCursorToggle(); }); - testWidgets('Cursor animates', (WidgetTester tester) async { + testWidgets('Cursor animates on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( const MaterialApp( home: Material( @@ -338,9 +340,13 @@ void main() { await tester.pump(const Duration(milliseconds: 50)); expect(renderEditable.cursorColor.alpha, 0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - testWidgets('Cursor radius is 2.0', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = null; + }); + + testWidgets('Cursor radius is 2.0 on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + await tester.pumpWidget( const MaterialApp( home: Material( @@ -353,7 +359,9 @@ void main() { final RenderEditable renderEditable = editableTextState.renderEditable; expect(renderEditable.cursorRadius, const Radius.circular(2.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('cursor has expected defaults', (WidgetTester tester) async { await tester.pumpWidget( @@ -408,7 +416,9 @@ void main() { ); }); - testWidgets('Material cursor golden', (WidgetTester tester) async { + testWidgets('Material cursor iOS golden', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final Widget widget = overlay( child: const RepaintBoundary( key: ValueKey(1), @@ -428,13 +438,12 @@ void main() { await tester.tapAt(textOffsetToPosition(tester, testValue.length)); await tester.pump(); + debugDefaultTargetPlatformOverride = null; await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile( - 'text_field_cursor_test_${describeEnum(debugDefaultTargetPlatformOverride).toLowerCase()}.material.1.png', - ), + matchesGoldenFile('text_field_cursor_test.material.1.png'), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('text field selection toolbar renders correctly inside opacity', (WidgetTester tester) async { await tester.pumpWidget( @@ -487,13 +496,14 @@ void main() { ); }, skip: isBrowser); - testWidgets('text field toolbar options correctly changes options', + testWidgets('text field toolbar options correctly changes options (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -534,9 +544,9 @@ void main() { expect(find.text('Copy'), findsOneWidget); expect(find.text('Cut'), findsNothing); expect(find.text('Select All'), findsNothing); - }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, skip: isBrowser); - testWidgets('text field toolbar options correctly changes options', + testWidgets('text field toolbar options correctly changes options (Android)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', @@ -567,8 +577,10 @@ void main() { expect(find.text('COPY'), findsOneWidget); expect(find.text('CUT'), findsNothing); expect(find.text('SELECT ALL'), findsNothing); - }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, skip: isBrowser); + // TODO(hansmuller): restore these tests after the fix for #24876 has landed. + /* testWidgets('cursor layout has correct width', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; await tester.pumpWidget( @@ -585,10 +597,10 @@ void main() { await expectLater( find.byType(TextField), - matchesGoldenFile('text_field_cursor_width_test.0.0.png', version: 0), + matchesGoldenFile('text_field_test.0.0.png'), ); EditableText.debugDeterministicCursor = false; - }, skip: !isLinux); + }, skip: !Platform.isLinux); testWidgets('cursor layout has correct radius', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; @@ -607,10 +619,11 @@ void main() { await expectLater( find.byType(TextField), - matchesGoldenFile('text_field_cursor_width_test.1.0.png', version: 0), + matchesGoldenFile('text_field_test.1.0.png'), ); EditableText.debugDeterministicCursor = false; - }, skip: !isLinux); + }, skip: !Platform.isLinux); + */ testWidgets('Overflowing a line with spaces stops the cursor at the end', (WidgetTester tester) async { final TextEditingController controller = TextEditingController(); @@ -857,27 +870,6 @@ void main() { expect(handle.opacity.value, equals(1.0)); }); - - testWidgets('Long pressing a field with selection 0,0 shows the selection menu', (WidgetTester tester) async { - await tester.pumpWidget(overlay( - child: TextField( - controller: TextEditingController.fromValue( - const TextEditingValue( - selection: TextSelection(baseOffset: 0, extentOffset: 0), - ), - ), - ), - )); - - expect(find.text('PASTE'), findsNothing); - - final Offset emptyPos = textOffsetToPosition(tester, 0); - await tester.longPressAt(emptyPos, pointer: 7); - await tester.pumpAndSettle(); - - expect(find.text('PASTE'), findsOneWidget); - }); - testWidgets('Entering text hides selection handle caret', (WidgetTester tester) async { final TextEditingController controller = TextEditingController(); @@ -986,10 +978,11 @@ void main() { expect(find.text('CUT'), findsNothing); }); - testWidgets('does not paint toolbar when no options available', (WidgetTester tester) async { + testWidgets('does not paint toolbar when no options available on ios', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: TextField( readOnly: true, ), @@ -1005,9 +998,9 @@ void main() { await tester.pumpAndSettle(); expect(find.byType(CupertinoTextSelectionToolbar), paintsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('text field build empty toolbar when no options available', (WidgetTester tester) async { + testWidgets('text field build empty toolbar when no options available android', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp( home: Material( @@ -1029,7 +1022,7 @@ void main() { matching: find.byType(Container), )); expect(container.size, Size.zero); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }); testWidgets('Sawping controllers should update selection', (WidgetTester tester) async { TextEditingController controller = TextEditingController(text: 'readonly'); @@ -5507,13 +5500,14 @@ void main() { }); testWidgets( - 'tap moves cursor to the edge of the word it tapped', + 'tap moves cursor to the edge of the word it tapped on (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5537,9 +5531,12 @@ void main() { // But don't trigger the toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); - testWidgets('tap moves cursor to the position tapped', (WidgetTester tester) async { + testWidgets( + 'tap moves cursor to the position tapped (Android)', + (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); @@ -5568,16 +5565,18 @@ void main() { // But don't trigger the toolbar. expect(find.byType(FlatButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, + ); testWidgets( - 'two slow taps do not trigger a word selection', + 'two slow taps do not trigger a word selection (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5603,16 +5602,18 @@ void main() { // No toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'double tap selects word and first tap of double tap moves cursor', + 'double tap selects word and first tap of double tap moves cursor (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5648,10 +5649,11 @@ void main() { // Selected text shows 3 toolbar buttons. expect(find.byType(CupertinoButton), findsNWidgets(3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'double tap selects word and first tap of double tap moves cursor and shows toolbar', + 'double tap selects word and first tap of double tap moves cursor and shows toolbar (Android)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', @@ -5693,10 +5695,11 @@ void main() { // Selected text shows 4 toolbar buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, + ); testWidgets( - 'double tap on top of cursor also selects word', + 'double tap on top of cursor also selects word (Android)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', @@ -5742,7 +5745,8 @@ void main() { // Selected text shows 4 toolbar buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, + ); testWidgets( 'double double tap just shows the selection menu', @@ -5869,13 +5873,14 @@ void main() { ); testWidgets( - 'double tap hold selects word', + 'double tap hold selects word (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5913,16 +5918,18 @@ void main() { ); // The toolbar is still showing. expect(find.byType(CupertinoButton), findsNWidgets(3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'tap after a double tap select is not affected', + 'tap after a double tap select is not affected (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5959,16 +5966,18 @@ void main() { // No toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'long press moves cursor to the exact long press position and shows toolbar', + 'long press moves cursor to the exact long press position and shows toolbar (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -5992,10 +6001,11 @@ void main() { // Collapsed toolbar shows 2 buttons. expect(find.byType(CupertinoButton), findsNWidgets(2)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'long press selects word and shows toolbar', + 'long press selects word and shows toolbar (Android)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', @@ -6024,16 +6034,18 @@ void main() { // Collapsed toolbar shows 4 buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, + ); testWidgets( - 'long press tap cannot initiate a double tap', + 'long press tap cannot initiate a double tap (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6061,16 +6073,18 @@ void main() { // Collapsed toolbar shows 2 buttons. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'long press drag moves the cursor under the drag and shows toolbar on lift', + 'long press drag moves the cursor under the drag and shows toolbar on lift (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6127,14 +6141,16 @@ void main() { ); // The toolbar now shows up. expect(find.byType(CupertinoButton), findsNWidgets(2)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); - testWidgets('long press drag can edge scroll', (WidgetTester tester) async { + testWidgets('long press drag can edge scroll (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6216,16 +6232,17 @@ void main() { expect(firstCharEndpoint.length, 1); // The first character is now offscreen to the left. expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-257, epsilon: 1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets( - 'long tap after a double tap select is not affected', + 'long tap after a double tap select is not affected (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6259,16 +6276,18 @@ void main() { // Long press toolbar. expect(find.byType(CupertinoButton), findsNWidgets(2)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'double tap after a long tap is not affected', + 'double tap after a long tap is not affected (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6300,14 +6319,18 @@ void main() { const TextSelection(baseOffset: 8, extentOffset: 12), ); expect(find.byType(CupertinoButton), findsNWidgets(3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); - testWidgets('double tap chains work', (WidgetTester tester) async { + testWidgets( + 'double tap chains work (iOS)', + (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: Center( child: TextField( @@ -6364,9 +6387,10 @@ void main() { const TextSelection(baseOffset: 8, extentOffset: 12), ); expect(find.byType(CupertinoButton), findsNWidgets(3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); - testWidgets('force press does not select a word', (WidgetTester tester) async { + testWidgets('force press does not select a word on (android)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); @@ -6394,7 +6418,7 @@ void main() { pressureMin: 0.0, ), ); - await gesture.updateWithCustomEvent(PointerMoveEvent(pointer: pointerValue, position: offset + const Offset(150.0, 9.0), pressure: 0.5, pressureMin: 0, pressureMax: 1,),); + await gesture.updateWithCustomEvent(PointerMoveEvent(pointer: pointerValue, position: offset + const Offset(150.0, 9.0), pressure: 0.5, pressureMin: 0, pressureMax: 1)); // We don't want this gesture to select any word on Android. expect(controller.selection, const TextSelection.collapsed(offset: -1)); @@ -6402,14 +6426,15 @@ void main() { await gesture.up(); await tester.pump(); expect(find.byType(FlatButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }); - testWidgets('force press selects word', (WidgetTester tester) async { + testWidgets('force press selects word (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: TextField( controller: controller, @@ -6434,15 +6459,7 @@ void main() { ), ); - await gesture.updateWithCustomEvent( - PointerMoveEvent( - pointer: pointerValue, - position: textfieldStart + const Offset(150.0, 9.0), - pressure: 0.5, - pressureMin: 0, - pressureMax: 1, - ), - ); + await gesture.updateWithCustomEvent(PointerMoveEvent(pointer: pointerValue, position: textfieldStart + const Offset(150.0, 9.0), pressure: 0.5, pressureMin: 0, pressureMax: 1)); // We expect the force press to select a word at the given location. expect( controller.selection, @@ -6452,15 +6469,15 @@ void main() { await gesture.up(); await tester.pump(); expect(find.byType(CupertinoButton), findsNWidgets(3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('tap on non-force-press-supported devices work', (WidgetTester tester) async { + testWidgets('tap on non-force-press-supported devices work (iOS)', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( text: 'Atwater Peel Sherbrooke Bonaventure', ); - await tester.pumpWidget(Container(key: GlobalKey())); await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Material( child: TextField( controller: controller, @@ -6486,15 +6503,7 @@ void main() { ), ); - await gesture.updateWithCustomEvent( - PointerMoveEvent( - pointer: pointerValue, - position: textfieldStart + const Offset(150.0, 9.0), - pressure: 0.5, - pressureMin: 0, - pressureMax: 1, - ), - ); + await gesture.updateWithCustomEvent(PointerMoveEvent(pointer: pointerValue, position: textfieldStart + const Offset(150.0, 9.0), pressure: 0.5, pressureMin: 0, pressureMax: 1)); await gesture.up(); // The event should fallback to a normal tap and move the cursor. // Single taps selects the edge of the word. @@ -6506,10 +6515,7 @@ void main() { await tester.pump(); // Single taps shouldn't trigger the toolbar. expect(find.byType(CupertinoButton), findsNothing); - - // TODO(gspencergoog): Add in TargetPlatform.macOS in the line below when we figure out what global state is leaking. - // https://github.com/flutter/flutter/issues/43445 - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + }); testWidgets('default TextField debugFillProperties', (WidgetTester tester) async { final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); @@ -6916,6 +6922,7 @@ void main() { }); testWidgets('iOS selection handles are rendered and not faded away', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; const String testText = 'lorem ipsum'; final TextEditingController controller = TextEditingController(text: testText); @@ -6944,7 +6951,9 @@ void main() { expect(left.opacity.value, equals(1.0)); expect(right.opacity.value, equals(1.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Tap shows handles but not toolbar', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index 65b6418f4fe..041ed51daf5 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -196,7 +196,6 @@ void main() { const PageTransitionsTheme pageTransitionTheme = PageTransitionsTheme( builders: { TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), - TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), }, ); diff --git a/packages/flutter/test/material/typography_test.dart b/packages/flutter/test/material/typography_test.dart index afc12ee4f63..726f2c4de99 100644 --- a/packages/flutter/test/material/typography_test.dart +++ b/packages/flutter/test/material/typography_test.dart @@ -21,36 +21,17 @@ void main() { expect(Typography(platform: TargetPlatform.fuchsia).black.title.fontFamily, 'Roboto'); }); - // Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ - final Matcher isDisplayFont = predicate((TextStyle s) { - return s.fontFamily == '.SF UI Display'; - }, 'Uses SF Display font'); - - final Matcher isTextFont = predicate((TextStyle s) { - return s.fontFamily == '.SF UI Text'; - }, 'Uses SF Text font'); - test('Typography on iOS defaults to the correct SF font family based on size', () { - final Typography typography = Typography(platform: TargetPlatform.iOS); - for (final TextTheme textTheme in [typography.black, typography.white]) { - expect(textTheme.display4, isDisplayFont); - expect(textTheme.display3, isDisplayFont); - expect(textTheme.display2, isDisplayFont); - expect(textTheme.display1, isDisplayFont); - expect(textTheme.headline, isDisplayFont); - expect(textTheme.title, isDisplayFont); - expect(textTheme.subhead, isTextFont); - expect(textTheme.body2, isTextFont); - expect(textTheme.body1, isTextFont); - expect(textTheme.caption, isTextFont); - expect(textTheme.button, isTextFont); - expect(textTheme.subtitle, isTextFont); - expect(textTheme.overline, isTextFont); - } - }); + // Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ + final Matcher isDisplayFont = predicate((TextStyle s) { + return s.fontFamily == '.SF UI Display'; + }, 'Uses SF Display font'); - test('Typography on macOS defaults to the correct SF font family based on size', () { - final Typography typography = Typography(platform: TargetPlatform.macOS); + final Matcher isTextFont = predicate((TextStyle s) { + return s.fontFamily == '.SF UI Text'; + }, 'Uses SF Text font'); + + final Typography typography = Typography(platform: TargetPlatform.iOS); for (final TextTheme textTheme in [typography.black, typography.white]) { expect(textTheme.display4, isDisplayFont); expect(textTheme.display3, isDisplayFont); diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index 035a5cc7e63..d238b08ca8e 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(isA()), // see shape_border_test.dart for better tests of this case + isNot(isInstanceOf()), // 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 e25a10fa77b..e82095e23bd 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(isA()), // see shape_border_test.dart for better tests of this case + isNot(isInstanceOf()), // 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 5747b4ef3a9..1e1b6613793 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], isA()); + expect(call.positionalArguments[0], isInstanceOf()); 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], isA()); + expect(call.positionalArguments[3], isInstanceOf()); 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], isA>()); - expect(error.diagnostics[3], isA>()); + expect(error.diagnostics[2], isInstanceOf>()); + expect(error.diagnostics[3], isInstanceOf>()); 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), 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 + 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 }); 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], isA()); + expect(call.positionalArguments[0], isInstanceOf()); // 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], isA()); + expect(call.positionalArguments[3], isInstanceOf()); } }); @@ -450,7 +450,7 @@ void main() { expect(call.isMethod, isTrue); expect(call.positionalArguments, hasLength(4)); - expect(call.positionalArguments[0], isA()); + expect(call.positionalArguments[0], isInstanceOf()); // 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], isA()); + expect(call.positionalArguments[3], isInstanceOf()); } }); @@ -493,7 +493,7 @@ void main() { expect(call.isMethod, isTrue); expect(call.positionalArguments, hasLength(4)); - expect(call.positionalArguments[0], isA()); + expect(call.positionalArguments[0], isInstanceOf()); // 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], isA()); + expect(call.positionalArguments[3], isInstanceOf()); }); 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 74d4ba4c291..fdd5c5222a2 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(isA())); + expect(a, isNot(isInstanceOf())); 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 376da657c0e..aa1da21712c 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(isA())); + expect(() => imageCache.putIfAbsent(errorImage, () => errorImage.load(errorImage, null)), throwsA(isInstanceOf())); 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 3379818de01..87e37b5a3d8 100644 --- a/packages/flutter/test/painting/image_provider_test.dart +++ b/packages/flutter/test/painting/image_provider_test.dart @@ -11,6 +11,7 @@ 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'; @@ -181,7 +182,7 @@ void main() { final dynamic err = await caughtError.future; expect( err, - isA() + const TypeMatcher() .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 9e8633f2501..69815b51944 100644 --- a/packages/flutter/test/rendering/aspect_ratio_test.dart +++ b/packages/flutter/test/rendering/aspect_ratio_test.dart @@ -4,8 +4,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter_test/flutter_test.dart'; - +import '../flutter_test_alternative.dart'; import 'rendering_tester.dart'; void main() { @@ -114,7 +113,7 @@ void main() { errors.addAll(renderer.takeAllFlutterErrorDetails()); }); expect(errors, hasLength(2)); - expect(errors.first.exception, isFlutterError); + expect(errors.first.exception, isA()); 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 a71107ef290..d9a8f7a1ef4 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 'package:flutter_test/flutter_test.dart'; +import '../flutter_test_alternative.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), throwsAssertionError); - expect(() => BoxConstraints.lerp(constraints1, constraints3, 0.5), throwsAssertionError); - expect(() => BoxConstraints.lerp(constraints2, constraints3, 0.5), throwsAssertionError); + 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())); }); 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 ef63120ec04..f0fd349c0a9 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, isFlutterError); + expect(exception, isInstanceOf()); 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 824aff10510..ad5aba6a4ce 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, isFlutterError); + expect(exceptions.first, isInstanceOf()); }); test('MainAxisSize.min inside unconstrained', () { @@ -416,7 +416,7 @@ void main() { exceptions.addAll(renderer.takeAllFlutterExceptions()); }); expect(exceptions, isNotEmpty); - expect(exceptions.first, isFlutterError); + expect(exceptions.first, isInstanceOf()); }); 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 214884d4961..4ea24dc7c4f 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], isA()); + expect(box.paintedLayers[0], isInstanceOf()); 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 94a078ca014..ee06a85abcc 100644 --- a/packages/flutter/test/rendering/proxy_box_test.dart +++ b/packages/flutter/test/rendering/proxy_box_test.dart @@ -81,25 +81,21 @@ void main() { }); test('RenderPhysicalModel compositing on non-Fuchsia', () { - for (final TargetPlatform platform in TargetPlatform.values) { - if (platform == TargetPlatform.fuchsia) { - continue; - } - debugDefaultTargetPlatformOverride = platform; + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final RenderPhysicalModel root = RenderPhysicalModel(color: const Color(0xffff00ff)); - layout(root, phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); + final RenderPhysicalModel root = RenderPhysicalModel(color: const Color(0xffff00ff)); + layout(root, phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); - // Flutter now composites physical shapes on all platforms. - root.elevation = 1.0; - pumpFrame(phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); + // Flutter now composites physical shapes on all platforms. + root.elevation = 1.0; + pumpFrame(phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); + + root.elevation = 0.0; + pumpFrame(phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); - root.elevation = 0.0; - pumpFrame(phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); - } debugDefaultTargetPlatformOverride = null; }); @@ -125,53 +121,44 @@ void main() { }); group('RenderPhysicalShape', () { + setUp(() { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + }); + test('shape change triggers repaint', () { - for (final TargetPlatform platform in TargetPlatform.values) { - if (platform == TargetPlatform.fuchsia) { - continue; - } - debugDefaultTargetPlatformOverride = platform; + final RenderPhysicalShape root = RenderPhysicalShape( + color: const Color(0xffff00ff), + clipper: const ShapeBorderClipper(shape: CircleBorder()), + ); + layout(root, phase: EnginePhase.composite); + expect(root.debugNeedsPaint, isFalse); - final RenderPhysicalShape root = RenderPhysicalShape( - color: const Color(0xffff00ff), - clipper: const ShapeBorderClipper(shape: CircleBorder()), - ); - layout(root, phase: EnginePhase.composite); - expect(root.debugNeedsPaint, isFalse); + // Same shape, no repaint. + root.clipper = const ShapeBorderClipper(shape: CircleBorder()); + expect(root.debugNeedsPaint, isFalse); - // Same shape, no repaint. - root.clipper = const ShapeBorderClipper(shape: CircleBorder()); - expect(root.debugNeedsPaint, isFalse); - - // Different shape triggers repaint. - root.clipper = const ShapeBorderClipper(shape: StadiumBorder()); - expect(root.debugNeedsPaint, isTrue); - } - debugDefaultTargetPlatformOverride = null; + // Different shape triggers repaint. + root.clipper = const ShapeBorderClipper(shape: StadiumBorder()); + expect(root.debugNeedsPaint, isTrue); }); test('compositing on non-Fuchsia', () { - for (final TargetPlatform platform in TargetPlatform.values) { - if (platform == TargetPlatform.fuchsia) { - continue; - } - debugDefaultTargetPlatformOverride = platform; - final RenderPhysicalShape root = RenderPhysicalShape( - color: const Color(0xffff00ff), - clipper: const ShapeBorderClipper(shape: CircleBorder()), - ); - layout(root, phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); + final RenderPhysicalShape root = RenderPhysicalShape( + color: const Color(0xffff00ff), + clipper: const ShapeBorderClipper(shape: CircleBorder()), + ); + layout(root, phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); - // On non-Fuchsia platforms, we composite physical shape layers - root.elevation = 1.0; - pumpFrame(phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); + // On non-Fuchsia platforms, we composite physical shape layers + root.elevation = 1.0; + pumpFrame(phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); + + root.elevation = 0.0; + pumpFrame(phase: EnginePhase.composite); + expect(root.needsCompositing, isTrue); - root.elevation = 0.0; - pumpFrame(phase: EnginePhase.composite); - expect(root.needsCompositing, isTrue); - } debugDefaultTargetPlatformOverride = null; }); }); @@ -467,6 +454,18 @@ void main() { // transform -> clip _testFittedBoxWithClipRectLayer(); }); + + test('RenderFractionalTranslation updates its semantics after its translation value is set', () { + final _TestSemanticsUpdateRenderFractionalTranslation box = _TestSemanticsUpdateRenderFractionalTranslation( + translation: const Offset(0.5, 0.5), + ); + layout(box, constraints: BoxConstraints.tight(const Size(200.0, 200.0))); + expect(box.markNeedsSemanticsUpdateCallCount, 1); + box.translation = const Offset(0.4, 0.4); + expect(box.markNeedsSemanticsUpdateCallCount, 2); + box.translation = const Offset(0.3, 0.3); + expect(box.markNeedsSemanticsUpdateCallCount, 3); + }); } class _TestRectClipper extends CustomClipper { @@ -503,7 +502,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, isA()); + expect(layer, isInstanceOf()); expect(layer, isNotNull); // Mark for repaint otherwise pumpFrame is a noop. @@ -523,3 +522,18 @@ class _TestPathClipper extends CustomClipper { @override bool shouldReclip(_TestPathClipper oldClipper) => false; } + +class _TestSemanticsUpdateRenderFractionalTranslation extends RenderFractionalTranslation { + _TestSemanticsUpdateRenderFractionalTranslation({ + @required Offset translation, + RenderBox child, + }) : super(translation: translation, child: child); + + int markNeedsSemanticsUpdateCallCount = 0; + + @override + void markNeedsSemanticsUpdate() { + markNeedsSemanticsUpdateCallCount++; + super.markNeedsSemanticsUpdate(); + } +} diff --git a/packages/flutter/test/rendering/repaint_boundary_test.dart b/packages/flutter/test/rendering/repaint_boundary_test.dart index 02381722c3b..6cee7f6e318 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, isA()); + expect(repaintBoundary.debugLayer, isInstanceOf()); }); 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, isA()); + expect(compositedBox.debugLayer, isInstanceOf()); }); test('Framework ensures repaint boundary layer is not overwritten', () { diff --git a/packages/flutter/test/rendering/viewport_test.dart b/packages/flutter/test/rendering/viewport_test.dart index dc1b0961492..c0c641ecab1 100644 --- a/packages/flutter/test/rendering/viewport_test.dart +++ b/packages/flutter/test/rendering/viewport_test.dart @@ -1145,8 +1145,10 @@ void main() { ); }); - testWidgets('Handles infinite constraints when TargetPlatform is iOS or macOS', (WidgetTester tester) async { + testWidgets('Handles infinite constraints when TargetPlatform is iOS', (WidgetTester tester) async { // regression test for https://github.com/flutter/flutter/issues/45866 + final TargetPlatform oldTargetPlatform = debugDefaultTargetPlatformOverride; + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1175,5 +1177,6 @@ void main() { expect(find.text('b'), findsOneWidget); await tester.drag(find.text('b'), const Offset(0, 200)); await tester.pumpAndSettle(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = oldTargetPlatform; + }); } diff --git a/packages/flutter/test/scheduler/ticker_test.dart b/packages/flutter/test/scheduler/ticker_test.dart index cf3c9eec4e3..ee07bfbbc53 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, isA>()); + expect(error.diagnostics.last, isInstanceOf>()); 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 0cc3ddd7592..07601314096 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, isA()); + expect(error.diagnostics.last, isInstanceOf()); 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 f318edbc0b2..85e9382d2f7 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(isCastError)); + expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isInstanceOf())); expect(await channel.invokeListMethod('sayHello', 'hello'), ['hello', 'world']); }); @@ -102,7 +102,7 @@ void main() { } }, ); - expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isCastError)); + expect(channel.invokeMethod>('sayHello', 'hello'), throwsA(isInstanceOf())); 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], isA()); + expect(errors[0], isInstanceOf()); 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 0adbd46264b..33a313d1f56 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(isA()), + throwsA(isInstanceOf()), ); }); @@ -55,7 +55,7 @@ void main() { expect( () => PlatformViewsService.initAndroidView( id: 0, viewType: 'web', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)), - throwsA(isA())); + throwsA(isInstanceOf())); }); test('dispose Android view', () async { @@ -170,7 +170,7 @@ void main() { layoutDirection: TextDirection.ltr, ); }, - throwsA(isA()), + throwsA(isInstanceOf()), ); }); @@ -199,7 +199,7 @@ void main() { expect( () => PlatformViewsService.initUiKitView( id: 0, viewType: 'web', layoutDirection: TextDirection.ltr), - throwsA(isA()), + throwsA(isInstanceOf()), ); }); @@ -228,7 +228,7 @@ void main() { () async { await viewController.dispose(); }, - throwsA(isA()), + throwsA(isInstanceOf()), ); }); }); diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart index 30e68f8d63d..479412db683 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], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); 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 ea67750a5fa..38648528829 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, isA()); + expect(child, isInstanceOf()); } await tester.pumpWidget( @@ -280,7 +280,7 @@ void main() { await tester.pump(const Duration(milliseconds: 50)); for (final Widget child in foundChildren) { - expect(child, isA()); + expect(child, isInstanceOf()); 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, isA()); + expect(child, isInstanceOf()); 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, isA()); + expect(child, isInstanceOf()); 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 cb4a10f0978..575b5ce622f 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, isA()); + expect(key.currentState, isInstanceOf()); 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, isA()); + expect(key.currentState, isInstanceOf()); }); } diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index 2b2a287188d..abbb4e2978d 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -145,6 +145,69 @@ void main() { await tester.tap(find.byKey(key1)); expect(_pointerDown, isTrue); }); + + testWidgets('semantics bounds are updated', (WidgetTester tester) async { + final GlobalKey fractionalTranslationKey = GlobalKey(); + final GlobalKey textKey = GlobalKey(); + Offset offset = const Offset(0.4, 0.4); + + await tester.pumpWidget( + StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: Semantics( + explicitChildNodes: true, + child: FractionalTranslation( + key: fractionalTranslationKey, + translation: offset, + transformHitTests: true, + child: GestureDetector( + onTap: () { + setState(() { + offset = const Offset(0.8, 0.8); + }); + }, + child: SizedBox( + width: 100.0, + height: 100.0, + child: Text( + 'foo', + key: textKey, + ), + ), + ), + ), + ), + ), + ); + }, + ) + ); + + expect( + tester.getSemantics(find.byKey(textKey)).transform, + Matrix4( + 3.0, 0.0, 0.0, 0.0, + 0.0, 3.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 1170.0, 870.0, 0.0, 1.0, + ), + ); + + await tester.tap(find.byKey(fractionalTranslationKey)); + await tester.pump(); + expect( + tester.getSemantics(find.byKey(textKey)).transform, + Matrix4( + 3.0, 0.0, 0.0, 0.0, + 0.0, 3.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 1290.0, 990.0, 0.0, 1.0, + ), + ); + }); }); group('Row', () { diff --git a/packages/flutter/test/widgets/debug_test.dart b/packages/flutter/test/widgets/debug_test.dart index ea46c858e6d..f374493df43 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], isA>()); + expect(error.diagnostics[2], isInstanceOf>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( @@ -106,7 +106,7 @@ void main() { } finally { expect(error, isNotNull); expect(error.diagnostics.length, 5); - expect(error.diagnostics[2], isA>()); + expect(error.diagnostics[2], isInstanceOf>()); 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], isA>()); + expect(error.diagnostics[1], isInstanceOf>()); 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], isA>()); + expect(error.diagnostics[1], isInstanceOf>()); expect(error.diagnostics[1].style, DiagnosticsTreeStyle.errorProperty); expect( error.diagnostics[1].toStringDeep(), diff --git a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart index 14ad68cd93e..db35bf8a0ec 100644 --- a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart +++ b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart @@ -105,7 +105,7 @@ void main() { expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 21'), findsOneWidget); expect(find.text('Item 31'), findsOneWidget); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be dragged down when not full height', (WidgetTester tester) async { await tester.pumpWidget(_boilerplate(null)); @@ -118,7 +118,7 @@ void main() { expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 21'), findsNothing); expect(find.text('Item 36'), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be dragged down when list is shorter than full height', (WidgetTester tester) async { await tester.pumpWidget(_boilerplate(null, itemCount: 30, initialChildSize: .25)); @@ -135,7 +135,7 @@ void main() { await tester.pumpAndSettle(); expect(find.text('Item 1').hitTestable(), findsOneWidget); expect(find.text('Item 29').hitTestable(), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be dragged up and cover its container and scroll in single motion, and then dragged back down', (WidgetTester tester) async { int taps = 0; @@ -164,7 +164,7 @@ void main() { expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 18'), findsOneWidget); expect(find.text('Item 36'), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be flung up gently', (WidgetTester tester) async { int taps = 0; @@ -187,7 +187,7 @@ void main() { expect(find.text('Item 21'), findsOneWidget); expect(find.text('Item 36'), findsOneWidget); expect(find.text('Item 70'), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be flung up', (WidgetTester tester) async { int taps = 0; @@ -208,7 +208,7 @@ void main() { expect(find.text('Item 1'), findsNothing); expect(find.text('Item 21'), findsNothing); expect(find.text('Item 70'), findsOneWidget); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be flung down when not full height', (WidgetTester tester) async { await tester.pumpWidget(_boilerplate(null)); @@ -221,7 +221,7 @@ void main() { expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 21'), findsNothing); expect(find.text('Item 36'), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); testWidgets('Can be flung up and then back down', (WidgetTester tester) async { int taps = 0; @@ -260,7 +260,7 @@ void main() { expect(find.text('Item 1'), findsOneWidget); expect(find.text('Item 21'), findsNothing); expect(find.text('Item 70'), findsNothing); - }, skip: isBrowser, variant: TargetPlatformVariant.all()); + }, skip: isBrowser); debugDefaultTargetPlatformOverride = null; }); diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index 70e73fb3a10..5fe4c4c3718 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -304,7 +304,9 @@ void main() { expect(buttonPressed, equals(true)); }); - testWidgets('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async { + testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final SemanticsTester semantics = SemanticsTester(tester); final GlobalKey scaffoldKey = GlobalKey(); @@ -329,7 +331,9 @@ void main() { expect(semantics, includesNodeWith(label: 'Dismiss')); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); @@ -357,7 +361,7 @@ void main() { expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.android })); + }); testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 9556d9a5f7b..e0d4861de48 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -145,9 +145,10 @@ void main() { ); }); - testWidgets('Cursor animates', (WidgetTester tester) async { - const Widget widget = MaterialApp( - home: Material( + testWidgets('Cursor animates on iOS', (WidgetTester tester) async { + final Widget widget = MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: TextField( maxLines: 3, ), @@ -199,7 +200,7 @@ void main() { // Cursor starts coming back. expect(renderEditable.cursorColor.alpha, 79); expect(renderEditable, paints..rrect(color: const Color(0x4f2196f3))); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Cursor does not animate on Android', (WidgetTester tester) async { const Widget widget = MaterialApp( @@ -240,10 +241,11 @@ void main() { expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); }); - testWidgets('Cursor does not animates when debugDeterministicCursor is set', (WidgetTester tester) async { + testWidgets('Cursor does not animates on iOS when debugDeterministicCursor is set', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; - const Widget widget = MaterialApp( - home: Material( + final Widget widget = MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: TextField( maxLines: 3, ), @@ -275,7 +277,7 @@ void main() { expect(renderEditable, paints..rrect(color: const Color(0xff2196f3))); EditableText.debugDeterministicCursor = false; - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Cursor does not animate on Android when debugDeterministicCursor is set', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; @@ -344,9 +346,10 @@ void main() { expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); }); - testWidgets('Cursor radius is 2.0', (WidgetTester tester) async { - const Widget widget = MaterialApp( - home: Material( + testWidgets('Cursor radius is 2.0 on iOS', (WidgetTester tester) async { + final Widget widget = MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: TextField( maxLines: 3, ), @@ -358,7 +361,7 @@ void main() { final RenderEditable renderEditable = editableTextState.renderEditable; expect(renderEditable.cursorRadius, const Radius.circular(2.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Cursor gets placed correctly after going out of bounds', (WidgetTester tester) async { const String text = 'hello world this is fun and cool and awesome!'; @@ -642,7 +645,9 @@ void main() { expect(controller.selection.baseOffset, text.length); }, skip: isBrowser); - testWidgets('Floating cursor is painted', (WidgetTester tester) async { + testWidgets('Floating cursor is painted on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final TextEditingController controller = TextEditingController(); const TextStyle textStyle = TextStyle(); const String text = 'hello world this is fun and cool and awesome!'; @@ -651,6 +656,7 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: Padding( padding: const EdgeInsets.only(top: 0.25), child: Material( @@ -725,13 +731,16 @@ void main() { editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End)); await tester.pumpAndSettle(); debugDefaultTargetPlatformOverride = null; - }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, skip: isBrowser); - testWidgets('cursor layout', (WidgetTester tester) async { + testWidgets('cursor layout iOS', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + String changedValue; final Widget widget = MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: RepaintBoundary( key: const ValueKey(1), child: Column( @@ -742,7 +751,7 @@ void main() { key: editableTextKey, controller: TextEditingController(), focusNode: FocusNode(), - style: Typography(platform: debugDefaultTargetPlatformOverride).black.subhead, + style: Typography(platform: TargetPlatform.iOS).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -784,5 +793,6 @@ void main() { find.byKey(const ValueKey(1)), matchesGoldenFile('editable_text_test.2.png'), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); } diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index c6d105f66b8..34af7e7d6dd 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -3757,7 +3757,9 @@ void main() { }); // Regression test for https://github.com/flutter/flutter/issues/31287 - testWidgets('text selection handle visibility', (WidgetTester tester) async { + testWidgets('iOS text selection handle visibility', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + // Text with two separate words to select. const String testText = 'XXXXX XXXXX'; final TextEditingController controller = TextEditingController(text: testText); @@ -3772,7 +3774,7 @@ void main() { showSelectionHandles: true, controller: controller, focusNode: FocusNode(), - style: Typography(platform: debugDefaultTargetPlatformOverride).black.subhead, + style: Typography(platform: TargetPlatform.iOS).black.subhead, cursorColor: Colors.blue, backgroundCursorColor: Colors.grey, selectionControls: cupertinoTextSelectionControls, @@ -3922,7 +3924,9 @@ void main() { // at all. Again, both handles should be invisible. scrollable.controller.jumpTo(0); await verifyVisibility(HandlePositionInViewport.rightEdge, false, HandlePositionInViewport.rightEdge, false); - }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }, skip: isBrowser); testWidgets('scrolling doesn\'t bounce', (WidgetTester tester) async { // 3 lines of text, where the last line overflows and requires scrolling. diff --git a/packages/flutter/test/widgets/flow_test.dart b/packages/flutter/test/widgets/flow_test.dart index 4386b15e798..df522f147c0 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, isA()); + expect(layer, isInstanceOf()); final OpacityLayer opacityLayer = layer as OpacityLayer; expect(opacityLayer.alpha, equals(opacity * 255)); - expect(layer.firstChild, isA()); + expect(layer.firstChild, isInstanceOf()); }); } diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index acd9f197759..d150287c8da 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, isA>()); + expect(last, isInstanceOf>()); expect( last.toStringDeep(), equalsIgnoringHashCodes( @@ -1614,7 +1614,10 @@ Future main() async { testWidgets('Heroes do not transition on back gestures by default', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( - routes: routes, + theme: ThemeData( + platform: TargetPlatform.iOS, + ), + routes: routes, )); expect(find.byKey(firstKey), isOnstage); @@ -1649,11 +1652,14 @@ Future main() async { expect(find.byKey(firstKey), isInCard); expect(find.byKey(secondKey), isOnstage); expect(find.byKey(secondKey), isInCard); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Heroes can transition on gesture in one frame', (WidgetTester tester) async { transitionFromUserGestures = true; await tester.pumpWidget(MaterialApp( + theme: ThemeData( + platform: TargetPlatform.iOS, + ), routes: routes, )); @@ -1692,11 +1698,14 @@ Future main() async { expect(find.byKey(firstKey), isOnstage); expect(find.byKey(firstKey), isInCard); expect(find.byKey(secondKey), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Heroes animate should hide destination hero and display original hero in case of dismissed', (WidgetTester tester) async { transitionFromUserGestures = true; await tester.pumpWidget(MaterialApp( + theme: ThemeData( + platform: TargetPlatform.iOS, + ), routes: routes, )); @@ -1728,7 +1737,7 @@ Future main() async { expect(find.byKey(firstKey), findsNothing); expect(find.byKey(secondKey), isOnstage); expect(find.byKey(secondKey), isInCard); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Handles transitions when a non-default initial route is set', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( @@ -2289,6 +2298,9 @@ Future main() async { testWidgets('Remove user gesture driven flights when the gesture is invalid', (WidgetTester tester) async { transitionFromUserGestures = true; await tester.pumpWidget(MaterialApp( + theme: ThemeData( + platform: TargetPlatform.iOS, + ), routes: routes, )); @@ -2312,7 +2324,7 @@ Future main() async { // The simple route should still be on top. expect(find.byKey(simpleKey), findsOneWidget); expect(tester.takeException(), isNull); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); // Regression test for https://github.com/flutter/flutter/issues/40239. testWidgets( diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index ff656085b47..db2d5e74565 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, isA()); + expect(tester.widget(find.byType(Padding)).child, isInstanceOf()); 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, isA()); - expect(tester.widget(find.byType(Padding)).child, isA()); + expect(tester.widget
(find.byType(Center)).child, isInstanceOf()); + expect(tester.widget(find.byType(Padding)).child, isInstanceOf()); }, skip: isBrowser); testWidgets('Image state handles loadingBuilder update from null to non-null', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index 0d86ddb963d..d871f17f92a 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -1203,6 +1203,8 @@ void main() { }); testWidgets('high fling velocities lands exactly on items', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 40); final List scrolledPositions = []; @@ -1250,7 +1252,9 @@ void main() { expect(controller.selectedItem, 49); // More importantly, lands tightly on 49. expect(scrolledPositions.last, moreOrLessEquals(49 * 100.0, epsilon: 0.3)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); }); testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/media_query_test.dart b/packages/flutter/test/widgets/media_query_test.dart index 966fa90d49a..ebc09fe0189 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, isA>()); + expect(error.diagnostics.last, isInstanceOf>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/modal_barrier_test.dart b/packages/flutter/test/widgets/modal_barrier_test.dart index c5019332249..1a29f7ec0f7 100644 --- a/packages/flutter/test/widgets/modal_barrier_test.dart +++ b/packages/flutter/test/widgets/modal_barrier_test.dart @@ -340,6 +340,8 @@ void main() { }); testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, @@ -362,7 +364,8 @@ void main() { expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index c51429f73b3..fe6242a6681 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, isA()); + expect(element.renderObject is RenderStack, isTrue); final RenderStack renderObject = element.renderObject as RenderStack; try { RenderObject child = renderObject.firstChild; for (final BoxDecoration decoration in expectedDecorations) { - expect(child, isA()); + expect(child is RenderDecoratedBox, isTrue); 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 8e90e32b197..5522c1179d5 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, isFlutterError); + expect(exception, isInstanceOf()); expect('$exception', startsWith('Navigator operation requested with a context')); }); @@ -1027,7 +1027,7 @@ void main() { ); final dynamic exception = tester.takeException(); - expect(exception, isA()); + expect(exception is String, isTrue); 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, isA>()); + expect(error.diagnostics.last, isInstanceOf>()); 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, isA>()); + expect(error.diagnostics.last, isInstanceOf>()); expect( error.toStringDeep(), equalsIgnoringHashCodes( diff --git a/packages/flutter/test/widgets/nested_scroll_view_test.dart b/packages/flutter/test/widgets/nested_scroll_view_test.dart index c5895c4cbcf..231f9a51242 100644 --- a/packages/flutter/test/widgets/nested_scroll_view_test.dart +++ b/packages/flutter/test/widgets/nested_scroll_view_test.dart @@ -113,6 +113,7 @@ Widget buildTest({ ScrollController controller, String title = 'TTTTTTTT' }) { void main() { testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget(buildTest()); expect(find.text('aaa2'), findsOneWidget); await tester.pump(const Duration(milliseconds: 250)); @@ -127,8 +128,10 @@ void main() { // TODO(ianh): Once we improve how we handle scrolling down from overscroll, // the following expectation should switch to 200.0. expect(tester.renderObject(find.byType(AppBar)).size.height, 120.0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('NestedScrollView overscroll and release and hold', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget(buildTest()); expect(find.text('aaa2'), findsOneWidget); await tester.pump(const Duration(milliseconds: 250)); @@ -146,8 +149,10 @@ void main() { await tester.pump(const Duration(milliseconds: 10)); expect(find.text('aaa2'), findsNothing); await tester.pump(const Duration(milliseconds: 1000)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); testWidgets('NestedScrollView overscroll and release', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget(buildTest()); expect(find.text('aaa2'), findsOneWidget); await tester.pump(const Duration(milliseconds: 500)); @@ -159,10 +164,8 @@ void main() { await gesture1.up(); await tester.pumpAndSettle(); expect(find.text('aaa2'), findsOneWidget); - }, - skip: true, // https://github.com/flutter/flutter/issues/9040 - variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - + debugDefaultTargetPlatformOverride = null; + }, skip: true); // https://github.com/flutter/flutter/issues/9040 testWidgets('NestedScrollView', (WidgetTester tester) async { await tester.pumpWidget(buildTest()); expect(find.text('aaa2'), findsOneWidget); @@ -607,11 +610,12 @@ void main() { debugDisableShadows = true; }); - testWidgets('NestedScrollView and bouncing', (WidgetTester tester) async { + testWidgets('NestedScrollView and iOS bouncing', (WidgetTester tester) async { // This verifies that overscroll bouncing works correctly on iOS. For // example, this checks that if you pull to overscroll, friction is applied; // it also makes sure that if you scroll back the other way, the scroll // positions of the inner and outer list don't have a discontinuity. + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; const Key key1 = ValueKey(1); const Key key2 = ValueKey(2); await tester.pumpWidget( @@ -670,7 +674,8 @@ void main() { await tester.pump(); expect(tester.getRect(find.byKey(key1)), const Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); await gesture.up(); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + debugDefaultTargetPlatformOverride = null; + }); } class TestHeader extends SliverPersistentHeaderDelegate { diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index afa01f42f09..0453fcd8610 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], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); expect(error.diagnostics[3].value, debugRequiredFor); - expect(error.diagnostics[4], isA>()); + expect(error.diagnostics[4], isInstanceOf>()); expect(error.toStringDeep(), equalsIgnoringHashCodes( 'FlutterError\n' ' No Overlay widget found.\n' diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index 290ed0897ac..1120c6e0e40 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -157,7 +157,10 @@ void main() { ), }; - await tester.pumpWidget(MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp( + routes: routes, + theme: ThemeData(platform: TargetPlatform.iOS), + )); Navigator.pushNamed(containerKey1.currentContext, '/settings'); @@ -196,7 +199,7 @@ void main() { settingsOffset = tester.getTopLeft(find.text('Settings')); expect(settingsOffset.dx, greaterThan(100.0)); expect(settingsOffset.dy, 100.0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Check back gesture doesn\'t start during transitions', (WidgetTester tester) async { final GlobalKey containerKey1 = GlobalKey(); @@ -206,7 +209,10 @@ void main() { '/settings': (_) => Scaffold(key: containerKey2, body: const Text('Settings')), }; - await tester.pumpWidget(MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp( + routes: routes, + theme: ThemeData(platform: TargetPlatform.iOS), + )); Navigator.pushNamed(containerKey1.currentContext, '/settings'); @@ -239,7 +245,7 @@ void main() { expect(find.text('Home'), isOnstage); expect(find.text('Settings'), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); // Tests bug https://github.com/flutter/flutter/issues/6451 testWidgets('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async { @@ -250,7 +256,10 @@ void main() { '/sheet': (_) => PersistentBottomSheetTest(key: containerKey2), }; - await tester.pumpWidget(MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp( + routes: routes, + theme: ThemeData(platform: TargetPlatform.iOS), + )); Navigator.pushNamed(containerKey1.currentContext, '/sheet'); @@ -293,7 +302,7 @@ void main() { // Sheet did not call setState (since the gesture did nothing). expect(sheet.setStateCalled, isFalse); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Test completed future', (WidgetTester tester) async { final Map routes = { diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index b2ba9365d71..f48c62c2c38 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -83,6 +83,7 @@ void main() { testWidgets('PageView does not squish when overscrolled', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: PageView( children: List.generate(10, (int i) { return Container( @@ -112,7 +113,7 @@ void main() { expect(leftOf(0), lessThan(0.0)); expect(sizeOf(0), equals(const Size(800.0, 600.0))); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('PageController control test', (WidgetTester tester) async { final PageController controller = PageController(initialPage: 4); diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index 52390c1b03f..e7ba8de58c3 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, isA()); + expect(element.renderObject is RenderStack, isTrue); final RenderStack renderObject = element.renderObject as RenderStack; try { RenderObject child = renderObject.firstChild; for (final TestParentData expected in expectedParentData) { - expect(child, isA()); + expect(child is RenderDecoratedBox, isTrue); final RenderDecoratedBox decoratedBox = child as RenderDecoratedBox; - expect(decoratedBox.parentData, isA()); + expect(decoratedBox.parentData is StackParentData, isTrue); 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 0780f5a753a..dd495ee3e8f 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, isFlutterError); + expect(exception, isInstanceOf()); 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 b37ef085c6f..2db80b5b32f 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, isA()); + expect(textureParentLayer, isInstanceOf()); 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 6b781cdda65..d1222906cc6 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); 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, isA()); + expect(renderObject.child is RenderDecoratedBox, isTrue); 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); final RenderDecoratedBox parent = element.renderObject as RenderDecoratedBox; - expect(parent.child, isA()); + expect(parent.child is RenderDecoratedBox, isTrue); final RenderDecoratedBox child = parent.child as RenderDecoratedBox; expect(child.decoration, equals(kBoxDecorationB)); - expect(child.child, isA()); + expect(child.child is RenderDecoratedBox, isTrue); 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); 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 17c04ef0b54..8db268cda01 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, isA()); + expect(oldRoute, isInstanceOf()); 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, isA()); + expect(nextRoute, isInstanceOf()); 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, isA())); + expect(nextRoute, anyOf(isNull, isInstanceOf())); 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 2b5d130c013..83d58659f2e 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, isA()); + expect(position.physics, isInstanceOf()); 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, isA()); + expect(position.physics, isInstanceOf()); // 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 adb0598122c..0801b7e9393 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, isA()); + expect(notification, isInstanceOf()); 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, isA()); + expect(notification, isInstanceOf()); 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, isA()); + expect(notification, isInstanceOf()); 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 6d830c284e1..6c1dc3bc4eb 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], isA>()); + expect(error.diagnostics[2], isInstanceOf>()); expect(error.diagnostics[2].style, DiagnosticsTreeStyle.errorProperty); expect(error.diagnostics[2].value, physics); - expect(error.diagnostics[3], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); 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 ec6d8ab8179..a7879ce5a2f 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, isA()); + expect(view.physics, isInstanceOf()); }); testWidgets('Non-primary ListViews are not always scrollable', (WidgetTester tester) async { final ListView view = ListView(primary: false); - expect(view.physics, isNot(isA())); + expect(view.physics, isNot(isInstanceOf())); }); testWidgets('Defaulting-to-primary ListViews are always scrollable', (WidgetTester tester) async { final ListView view = ListView(scrollDirection: Axis.vertical); - expect(view.physics, isA()); + expect(view.physics, isInstanceOf()); }); testWidgets('Defaulting-to-not-primary ListViews are not always scrollable', (WidgetTester tester) async { final ListView view = ListView(scrollDirection: Axis.horizontal); - expect(view.physics, isNot(isA())); + expect(view.physics, isNot(isInstanceOf())); }); 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(), isFlutterError); + expect(tester.takeException(), isInstanceOf()); 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(), isA()); + expect(tester.takeException(), isInstanceOf()); 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(), isA()); + expect(tester.takeException(), isInstanceOf()); expect(finder, findsOneWidget); }); @@ -566,7 +566,7 @@ void main() { return const SizedBox(); }, itemCount: -1, - ), throwsAssertionError); + ), throwsA(isInstanceOf())); }); testWidgets('ListView.builder asserts on negative semanticChildCount', (WidgetTester tester) async { @@ -576,7 +576,7 @@ void main() { }, itemCount: 1, semanticChildCount: -1, - ), throwsAssertionError); + ), throwsA(isInstanceOf())); }); testWidgets('ListView.builder asserts on nonsensical childCount/semanticChildCount', (WidgetTester tester) async { @@ -586,6 +586,6 @@ void main() { }, itemCount: 1, semanticChildCount: 4, - ), throwsAssertionError); + ), throwsA(isInstanceOf())); }); } diff --git a/packages/flutter/test/widgets/scrollable_dispose_test.dart b/packages/flutter/test/widgets/scrollable_dispose_test.dart index 1a970f41d2b..edaee2fec62 100644 --- a/packages/flutter/test/widgets/scrollable_dispose_test.dart +++ b/packages/flutter/test/widgets/scrollable_dispose_test.dart @@ -28,9 +28,10 @@ void main() { await tester.pump(const Duration(hours: 5)); }); - testWidgets('Disposing a (nested) Scrollable while holding in overscroll does not crash', (WidgetTester tester) async { + testWidgets('Disposing a (nested) Scrollable while holding in overscroll (iOS) does not crash', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/27707. + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final ScrollController controller = ScrollController(); final Key outterContainer = GlobalKey(); @@ -87,5 +88,7 @@ void main() { ); await tester.pumpAndSettle(); expect(controller.hasClients, isFalse); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); } diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index b4e347047b7..16f6a168a51 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -43,7 +43,7 @@ void main() { await tester.pump(); // trigger fling expect(getCurrentOffset(), dragOffset); await tester.pump(const Duration(seconds: 5)); - final double androidResult = getCurrentOffset(); + final double result1 = getCurrentOffset(); await pumpTest(tester, TargetPlatform.iOS); await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); @@ -52,19 +52,9 @@ void main() { await tester.pump(); // trigger fling expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666)); await tester.pump(const Duration(seconds: 5)); - final double iOSResult = getCurrentOffset(); + final double result2 = getCurrentOffset(); - await pumpTest(tester, TargetPlatform.macOS); - await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); - // Scroll starts ease into the scroll on iOS. - expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666)); - await tester.pump(); // trigger fling - expect(getCurrentOffset(), moreOrLessEquals(210.71026666666666)); - await tester.pump(const Duration(seconds: 5)); - final double macOSResult = getCurrentOffset(); - - expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android - expect(androidResult, lessThan(macOSResult)); // macOS is slipperier than Android + expect(result1, lessThan(result2)); // iOS (result2) is slipperier than Android (result1) }); testWidgets('fling and tap to stop', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart index 3490e5af5c7..023684912b8 100644 --- a/packages/flutter/test/widgets/scrollable_test.dart +++ b/packages/flutter/test/widgets/scrollable_test.dart @@ -97,7 +97,7 @@ void main() { await tester.pump(); // trigger fling expect(getScrollOffset(tester), dragOffset); await tester.pump(const Duration(seconds: 5)); - final double androidResult = getScrollOffset(tester); + final double result1 = getScrollOffset(tester); resetScrollOffset(tester); @@ -108,25 +108,13 @@ void main() { await tester.pump(); // trigger fling expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669)); await tester.pump(const Duration(seconds: 5)); - final double iOSResult = getScrollOffset(tester); + final double result2 = getScrollOffset(tester); - resetScrollOffset(tester); - - await pumpTest(tester, TargetPlatform.macOS); - await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); - // Scroll starts ease into the scroll on iOS. - expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669)); - await tester.pump(); // trigger fling - expect(getScrollOffset(tester), moreOrLessEquals(197.16666666666669)); - await tester.pump(const Duration(seconds: 5)); - final double macOSResult = getScrollOffset(tester); - - expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android - expect(androidResult, lessThan(macOSResult)); // macOS is slipperier than Android + expect(result1, lessThan(result2)); // iOS (result2) is slipperier than Android (result1) }); testWidgets('Holding scroll', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + await pumpTest(tester, TargetPlatform.iOS); await tester.drag(find.byType(Viewport), const Offset(0.0, 200.0), touchSlopY: 0.0); expect(getScrollOffset(tester), -200.0); await tester.pump(); // trigger ballistic @@ -142,10 +130,10 @@ void main() { // Once the hold is let go, it should still snap back to origin. expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 2); expect(getScrollOffset(tester), 0.0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Repeated flings builds momentum', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Repeated flings builds momentum on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.pump(); // trigger fling await tester.pump(const Duration(milliseconds: 10)); @@ -155,9 +143,9 @@ void main() { // On iOS, the velocity will be larger than the velocity of the last fling by a // non-trivial amount. expect(getScrollVelocity(tester), greaterThan(1100.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - testWidgets('Repeated flings do not build momentum on Android', (WidgetTester tester) async { + resetScrollOffset(tester); + await pumpTest(tester, TargetPlatform.android); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.pump(); // trigger fling @@ -170,8 +158,8 @@ void main() { expect(getScrollVelocity(tester), moreOrLessEquals(1000.0)); }); - testWidgets('No iOS/macOS momentum build with flings in opposite directions', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('No iOS momentum build with flings in opposite directions', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.pump(); // trigger fling await tester.pump(const Duration(milliseconds: 10)); @@ -182,10 +170,10 @@ void main() { // opposite direction. expect(getScrollVelocity(tester), greaterThan(-1000.0)); expect(getScrollVelocity(tester), lessThan(0.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('No iOS/macOS momentum kept on hold gestures', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('No iOS momentum kept on hold gestures', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); await tester.fling(find.byType(Viewport), const Offset(0.0, -dragOffset), 1000.0); await tester.pump(); // trigger fling await tester.pump(const Duration(milliseconds: 10)); @@ -195,7 +183,7 @@ void main() { await gesture.up(); // After a hold longer than 2 frames, previous velocity is lost. expect(getScrollVelocity(tester), 0.0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets('Drags creeping unaffected on Android', (WidgetTester tester) async { await pumpTest(tester, TargetPlatform.android); @@ -208,8 +196,8 @@ void main() { expect(getScrollOffset(tester), 1.5); }); - testWidgets('Drags creeping must break threshold on iOS/macOS', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Drags creeping must break threshold on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); await gesture.moveBy(const Offset(0.0, -0.5)); expect(getScrollOffset(tester), 0.0); @@ -226,18 +214,18 @@ void main() { await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 50)); // -0.5 over threshold transferred. expect(getScrollOffset(tester), 0.5); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Big drag over threshold magnitude preserved on iOS/macOS', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Big drag over threshold magnitude preserved on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); await gesture.moveBy(const Offset(0.0, -30.0)); // No offset lost from threshold. expect(getScrollOffset(tester), 30.0); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Slow threshold breaks are attenuated on iOS/macOS', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Slow threshold breaks are attenuated on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); // This is a typical 'hesitant' iOS scroll start. await gesture.moveBy(const Offset(0.0, -10.0)); @@ -245,10 +233,10 @@ void main() { await gesture.moveBy(const Offset(0.0, -10.0), timeStamp: const Duration(milliseconds: 20)); // Subsequent motions unaffected. expect(getScrollOffset(tester), moreOrLessEquals(11.16666666666666673)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Small continuing motion preserved on iOS/macOS', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Small continuing motion preserved on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold. expect(getScrollOffset(tester), 30.0); @@ -258,10 +246,10 @@ void main() { expect(getScrollOffset(tester), 31.0); await gesture.moveBy(const Offset(0.0, -0.5), timeStamp: const Duration(milliseconds: 60)); expect(getScrollOffset(tester), 31.5); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Motion stop resets threshold on iOS/macOS', (WidgetTester tester) async { - await pumpTest(tester, debugDefaultTargetPlatformOverride); + testWidgets('Motion stop resets threshold on iOS', (WidgetTester tester) async { + await pumpTest(tester, TargetPlatform.iOS); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Viewport))); await gesture.moveBy(const Offset(0.0, -30.0)); // Break threshold. expect(getScrollOffset(tester), 30.0); @@ -281,9 +269,9 @@ void main() { expect(getScrollOffset(tester), 31.5); await gesture.moveBy(const Offset(0.0, -1.0), timeStamp: const Duration(milliseconds: 180)); expect(getScrollOffset(tester), 32.5); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('Scroll pointer signals are handled on Fuchsia', (WidgetTester tester) async { + testWidgets('Scroll pointer signals are handled', (WidgetTester tester) async { await pumpTest(tester, TargetPlatform.fuchsia); final Offset scrollEventLocation = tester.getCenter(find.byType(Viewport)); final TestPointer testPointer = TestPointer(1, ui.PointerDeviceKind.mouse); diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/widgets/selectable_text_test.dart index 9db166387e5..20d991cbff7 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -2321,11 +2321,12 @@ void main() { }); testWidgets( - 'tap moves cursor to the edge of the word it tapped', + 'tap moves cursor to the edge of the word it tapped on (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2348,7 +2349,8 @@ void main() { // But don't trigger the toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( 'tap moves cursor to the position tapped (Android)', @@ -2383,11 +2385,12 @@ void main() { ); testWidgets( - 'two slow taps do not trigger a word selection', + 'two slow taps do not trigger a word selection (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2413,14 +2416,16 @@ void main() { // No toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'double tap selects word and first tap of double tap moves cursor', + 'double tap selects word and first tap of double tap moves cursor (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2457,7 +2462,8 @@ void main() { // Selected text shows 1 toolbar buttons. expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( 'double tap selects word and first tap of double tap moves cursor and shows toolbar (Android)', @@ -2554,11 +2560,12 @@ void main() { ); testWidgets( - 'double tap hold selects word', + 'double tap hold selects word (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2596,14 +2603,16 @@ void main() { ); // The toolbar is still showing. expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( 'tap after a double tap select is not affected (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2641,14 +2650,16 @@ void main() { // No toolbar. expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'long press moves cursor to the exact long press position and shows toolbar', + 'long press moves cursor to the exact long press position and shows toolbar (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2672,7 +2683,8 @@ void main() { // Collapsed toolbar shows 2 buttons. expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( 'long press selects word and shows toolbar (Android)', @@ -2707,11 +2719,12 @@ void main() { ); testWidgets( - 'long press tap cannot initiate a double tap', + 'long press tap cannot initiate a double tap (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2738,14 +2751,16 @@ void main() { ); expect(find.byType(CupertinoButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( 'long press drag moves the cursor under the drag and shows toolbar on lift (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2802,12 +2817,14 @@ void main() { ); // The toolbar now shows up. expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); - testWidgets('long press drag can edge scroll', (WidgetTester tester) async { + testWidgets('long press drag can edge scroll (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText( 'Atwater Peel Sherbrooke Bonaventure Angrignon Peel Côte-des-Neiges', @@ -2891,14 +2908,15 @@ void main() { expect(firstCharEndpoint.length, 1); // The first character is now offscreen to the left. expect(firstCharEndpoint[0].point.dx, moreOrLessEquals(-125, epsilon: 1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); testWidgets( - 'long tap after a double tap select is not affected', + 'long tap after a double tap select is not affected (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2933,14 +2951,16 @@ void main() { // Long press toolbar. expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); //convert testWidgets( - 'double tap after a long tap is not affected', + 'double tap after a long tap is not affected (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -2973,14 +2993,16 @@ void main() { const TextSelection(baseOffset: 8, extentOffset: 12), ); expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets( - 'double tap chains work', + 'double tap chains work (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: Center( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), @@ -3038,7 +3060,8 @@ void main() { const TextSelection(baseOffset: 8, extentOffset: 12), ); expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }, + ); testWidgets('force press does not select a word on (android)', (WidgetTester tester) async { await tester.pumpWidget( @@ -3076,10 +3099,11 @@ void main() { expect(find.byType(FlatButton), findsNothing); }); - testWidgets('force press selects word', (WidgetTester tester) async { + testWidgets('force press selects word (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), ), @@ -3115,12 +3139,13 @@ void main() { await gesture.up(); await tester.pump(); expect(find.byType(CupertinoButton), findsNWidgets(1)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + }); - testWidgets('tap on non-force-press-supported devices work', (WidgetTester tester) async { + testWidgets('tap on non-force-press-supported devices work (iOS)', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: const Material( child: SelectableText('Atwater Peel Sherbrooke Bonaventure'), ), ), @@ -3159,11 +3184,7 @@ void main() { await tester.pump(); // Single taps shouldn't trigger the toolbar. expect(find.byType(CupertinoButton), findsNothing); - - // TODO(gspencergoog): Add in TargetPlatform.macOS in the line below when we - // figure out what global state is leaking. - // https://github.com/flutter/flutter/issues/43445 - }, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); + }); testWidgets('default SelectableText debugFillProperties', (WidgetTester tester) async { final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); @@ -3545,7 +3566,8 @@ void main() { expect(right.opacity.value, equals(1.0)); }); - testWidgets('selection handles are rendered and not faded away', (WidgetTester tester) async { + testWidgets('iOS selection handles are rendered and not faded away', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; const String testText = 'lorem ipsum'; await tester.pumpWidget( @@ -3571,7 +3593,9 @@ void main() { expect(left.opacity.value, equals(1.0)); expect(right.opacity.value, equals(1.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('Long press shows handles and toolbar', (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/widgets/semantics_clipping_test.dart b/packages/flutter/test/widgets/semantics_clipping_test.dart index da6145662e4..a467a5b47dc 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, isFlutterError); + expect(exception, isInstanceOf()); 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, isFlutterError); + expect(exception, isInstanceOf()); 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 052032b1bdd..cec26cc2918 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(), isFlutterError); + expect(tester.takeException(), isInstanceOf()); }); } diff --git a/packages/flutter/test/widgets/shape_decoration_test.dart b/packages/flutter/test/widgets/shape_decoration_test.dart index 87a93258e9a..56671ee038f 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, isA()); + expect(decoration.padding, isInstanceOf()); }); 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 8ba799cbc48..b5e16292628 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, isA()); + expect(scrollable.position, isInstanceOf()); }); 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 6f8c8c83c17..ff24f876533 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, isA()); + expect(notification, isInstanceOf()); notified = true; return true; }, diff --git a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart index c7a45b697ab..44502fd2b1e 100644 --- a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart @@ -283,6 +283,7 @@ void main() { }); testWidgets('alignment with a flexible works', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final GlobalKey key = GlobalKey(); final List slivers = [ sliverBox, @@ -346,10 +347,13 @@ void main() { ); expect(tester.getBottomLeft(button).dy, lessThan(600.0)); expect(tester.getCenter(button).dx, equals(400.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); group('fillOverscroll: true, relevant platforms', () { testWidgets('child without size is sized by extent and overscroll', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final List slivers = [ sliverBox, SliverFillRemaining( @@ -374,9 +378,12 @@ void main() { await tester.pumpAndSettle(); final RenderBox box3 = tester.renderObject(find.byType(Container).last); expect(box3.size.height, equals(450)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('child with smaller size is overridden and sized by extent and overscroll', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final GlobalKey key = GlobalKey(); final List slivers = [ sliverBox, @@ -421,9 +428,12 @@ void main() { tester.renderObject(find.byKey(key)).size.height, equals(450), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('extent is overridden by child size and overscroll if precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final GlobalKey key = GlobalKey(); final ScrollController controller = ScrollController(); final List slivers = [ @@ -463,10 +473,12 @@ void main() { tester.renderObject(find.byKey(key)).size.height, equals(148.0), ); + // Check that the button alignment is true to expectations final Finder button = find.byType(RaisedButton); expect(tester.getBottomLeft(button).dy, equals(550.0)); expect(tester.getCenter(button).dx, equals(400.0)); + debugDefaultTargetPlatformOverride = null; // Drag for overscroll await tester.drag(find.byType(Scrollable), const Offset(0.0, -50.0)); @@ -486,9 +498,12 @@ void main() { tester.renderObject(find.byKey(key)).size.height, equals(148.0), ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('fillOverscroll works when child has no size and precedingScrollExtent > viewportMainAxisExtent', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final GlobalKey key = GlobalKey(); final ScrollController controller = ScrollController(); final List slivers = [ @@ -542,9 +557,12 @@ void main() { tester.widgetList(find.byType(DecoratedBox)).last.decoration, amberBox, ); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); testWidgets('alignment with a flexible works with fillOverscroll', (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final GlobalKey key = GlobalKey(); final List slivers = [ sliverBox, @@ -630,7 +648,9 @@ void main() { ); expect(tester.getBottomLeft(button).dy, equals(600.0)); expect(tester.getCenter(button).dx, equals(400.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); }); group('fillOverscroll: true, is ignored on irrevelant platforms', () { diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart index a50e7bb272d..9563f344c67 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, isA()); + expect(target.parent, isInstanceOf()); 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 d222442a808..b97b05c0bbf 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, isA()); + expect(target.parent, isInstanceOf()); 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 9728410e95a..3c8efeafe3c 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, isA()); + expect(target.parent, isInstanceOf()); 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 305378a039e..e1b6b3a0599 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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, isA()); + expect(result.path.first.target, isInstanceOf()); 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 deb480d3206..a89369b44a5 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, isA()); + expect(target.parent, isInstanceOf()); 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 4fbe63c9bf3..365fc324d57 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, isA()); + expect(element.renderObject is RenderDecoratedBox, isTrue); final RenderDecoratedBox renderObject = element.renderObject as RenderDecoratedBox; expect(renderObject.decoration, equals(expectedDecoration)); } diff --git a/packages/flutter/test/widgets/text_selection_test.dart b/packages/flutter/test/widgets/text_selection_test.dart index fc2dc864ec8..e6db40eabbb 100644 --- a/packages/flutter/test/widgets/text_selection_test.dart +++ b/packages/flutter/test/widgets/text_selection_test.dart @@ -7,6 +7,7 @@ import 'package:flutter/gestures.dart' show PointerDeviceKind; import 'package:flutter/widgets.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; void main() { int tapCount; @@ -551,6 +552,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/37032. testWidgets("selection handle's GestureDetector should not cover the entire screen", (WidgetTester tester) async { + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final TextEditingController controller = TextEditingController(text: 'a'); await tester.pumpWidget( @@ -581,7 +583,9 @@ void main() { expect(hitRect.size.width, lessThan(textFieldRect.size.width)); expect(hitRect.size.height, lessThan(textFieldRect.size.height)); - }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); + + debugDefaultTargetPlatformOverride = null; + }); } class FakeTextSelectionGestureDetectorBuilderDelegate implements TextSelectionGestureDetectorBuilderDelegate { diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index ffc17d9d689..b4dd6f4ff47 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], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); 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], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); 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], isA>()); + expect(error.diagnostics[3], isInstanceOf>()); 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 a0054843a49..7ffba0dfa91 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, isA()); + expect(actualDecoration.border, isInstanceOf()); 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, isA()); + expect(actualDecoration.border, isInstanceOf()); 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 65261be484a..70c18dcc436 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), isA()); + expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf()); 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), isA()); + expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); } } }); @@ -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), isA()); + expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); } }); @@ -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), isA()); + expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); } }); @@ -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), isA()); + expect(service.toObject(jsonNode['objectId'] as String), isInstanceOf()); 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), isA()); + expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); } } }); @@ -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), isA()); + expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); } }); @@ -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), isA()); + expect(service.toObject(propertyJson['objectId'] as String), isInstanceOf()); } }); @@ -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), isA()); + expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); 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, isA()); + expect(property, isInstanceOf()); 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), isA()); + expect(service.toObject(childJson['objectId'] as String), isInstanceOf()); 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, isA()); + expect(property, isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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'], isA()); + expect(event['startTime'], isInstanceOf()); 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 e5987b02b12..80102180a85 100644 --- a/packages/flutter_driver/test/common.dart +++ b/packages/flutter_driver/test/common.dart @@ -4,7 +4,6 @@ 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 @@ -14,7 +13,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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that @@ -26,6 +25,3 @@ 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 fbe67e9a9ed..894ed5182b3 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -145,7 +145,8 @@ void main() { group('ByValueKey', () { test('restricts value types', () async { - expect(() => find.byValueKey(null), throwsDriverError); + expect(() => find.byValueKey(null), + throwsA(isInstanceOf())); }); test('finds by ValueKey', () async { @@ -194,7 +195,7 @@ void main() { group('tap', () { test('requires a target reference', () async { - expect(driver.tap(null), throwsDriverError); + expect(driver.tap(null), throwsA(isInstanceOf())); }); test('sends the tap command', () async { @@ -213,7 +214,7 @@ void main() { group('getText', () { test('requires a target reference', () async { - expect(driver.getText(null), throwsDriverError); + expect(driver.getText(null), throwsA(isInstanceOf())); }); test('sends the getText command', () async { @@ -255,7 +256,7 @@ void main() { group('waitFor', () { test('requires a target reference', () async { - expect(driver.waitFor(null), throwsDriverError); + expect(driver.waitFor(null), throwsA(isInstanceOf())); }); test('sends the waitFor command', () async { @@ -378,11 +379,11 @@ void main() { group('getOffset', () { test('requires a target reference', () async { - 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); + 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())); }); test('sends the getCenter command', () async { @@ -645,7 +646,7 @@ void main() { await driver.waitFor(find.byTooltip('foo')); fail('expected an exception'); } catch (error) { - expect(error, isA()); + expect(error is DriverError, isTrue); expect(error.message, 'Error in Flutter application: {message: This is a failure}'); } }); @@ -704,7 +705,7 @@ void main() { group('ByValueKey', () { test('restricts value types', () async { expect(() => find.byValueKey(null), - throwsDriverError); + throwsA(isInstanceOf())); }); test('finds by ValueKey', () async { @@ -756,7 +757,7 @@ void main() { group('tap', () { test('requires a target reference', () async { - expect(driver.tap(null), throwsDriverError); + expect(driver.tap(null), throwsA(isInstanceOf())); }); test('sends the tap command', () async { @@ -776,7 +777,7 @@ void main() { group('getText', () { test('requires a target reference', () async { - expect(driver.getText(null), throwsDriverError); + expect(driver.getText(null), throwsA(isInstanceOf())); }); test('sends the getText command', () async { @@ -800,7 +801,7 @@ void main() { group('waitFor', () { test('requires a target reference', () async { - expect(driver.waitFor(null), throwsDriverError); + expect(driver.waitFor(null), throwsA(isInstanceOf())); }); test('sends the waitFor command', () async { @@ -879,11 +880,11 @@ void main() { group('getOffset', () { test('requires a target reference', () async { - 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); + 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())); }); test('sends the getCenter command', () async { @@ -1001,27 +1002,27 @@ void main() { group('WebFlutterDriver Unimplemented error', () { test('forceGC', () async { expect(driver.forceGC(), - throwsA(isA())); + throwsA(isInstanceOf())); }); test('getVmFlags', () async { expect(driver.getVmFlags(), - throwsA(isA())); + throwsA(isInstanceOf())); }); test('waitUntilFirstFrameRasterized', () async { expect(driver.waitUntilFirstFrameRasterized(), - throwsA(isA())); + throwsA(isInstanceOf())); }); test('appIsoloate', () async { expect(() => driver.appIsolate.invokeExtension('abc', {'abc': '123'}), - throwsA(isA())); + throwsA(isInstanceOf())); }); test('serviceClient', () async { expect(() => driver.serviceClient.getVM(), - throwsA(isA())); + throwsA(isInstanceOf())); }); }); }); @@ -1037,13 +1038,13 @@ void main() { test('tracing', () async { expect(driver.traceAction(() async { return Future.value(); }), - throwsA(isA())); + throwsA(isInstanceOf())); expect(driver.startTracing(), - throwsA(isA())); + throwsA(isInstanceOf())); expect(driver.stopTracingAndDownloadTimeline(), - throwsA(isA())); + throwsA(isInstanceOf())); expect(driver.clearTimeline(), - throwsA(isA())); + throwsA(isInstanceOf())); }); }); } @@ -1053,7 +1054,7 @@ void main() { /// script will be in the following format: // window.flutterDriver('[actual script]') String _checkAndEncode(dynamic script) { - expect(script, isA()); + expect(script is String, isTrue); expect(script.startsWith(_kWebScriptPrefix), isTrue); expect(script.endsWith(_kWebScriptSuffix), isTrue); // Strip prefix and suffix diff --git a/packages/flutter_driver/test/src/real_tests/extension_test.dart b/packages/flutter_driver/test/src/real_tests/extension_test.dart index 7b8aa9e6adc..e5b0c8c0aed 100644 --- a/packages/flutter_driver/test/src/real_tests/extension_test.dart +++ b/packages/flutter_driver/test/src/real_tests/extension_test.dart @@ -563,36 +563,35 @@ void main() { children: [ const Text('Hello1', key: ValueKey('text1')), Container( - height: 25.0, - child: RichText( - key: const ValueKey('text2'), - text: const TextSpan(text: 'Hello2'), - ), + height: 25.0, + child: RichText( + key: const ValueKey('text2'), + text: const TextSpan(text: 'Hello2') + ) ), Container( - height: 25.0, - child: EditableText( - key: const ValueKey('text3'), - controller: TextEditingController(text: 'Hello3'), - focusNode: FocusNode(), - style: const TextStyle(), - cursorColor: Colors.red, - backgroundCursorColor: Colors.black, - ), + height: 25.0, + child: EditableText( + key: const ValueKey('text3'), + controller: TextEditingController(text: 'Hello3'), + focusNode: FocusNode(), + style: const TextStyle(), + cursorColor: Colors.red, + backgroundCursorColor: Colors.black) ), Container( - height: 25.0, - child: TextField( - key: const ValueKey('text4'), - controller: TextEditingController(text: 'Hello4'), - ), + height: 25.0, + child: TextField( + key: const ValueKey('text4'), + controller: TextEditingController(text: 'Hello4') + ) ), Container( - height: 25.0, - child: TextFormField( - key: const ValueKey('text5'), - controller: TextEditingController(text: 'Hello5'), - ), + height: 25.0, + child: TextFormField( + key: const ValueKey('text5'), + controller: TextEditingController(text: 'Hello5') + ) ), ], )) 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 3644bcf1dd9..dbde0501c16 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(isA())); + throwsA(isInstanceOf())); }); }); } diff --git a/packages/flutter_localizations/test/cupertino/translations_test.dart b/packages/flutter_localizations/test/cupertino/translations_test.dart index 3e5a7a0bcfb..d13974eb2cf 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, isA()); + expect(localizations is CupertinoLocalizationFr, true); 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, isA()); + expect(localizations is CupertinoLocalizationZh, true); 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 1bb5c635e1a..fa2c9468e99 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, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale('zh', 'TW'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHantTw, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'HK'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHantHk, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'TW'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHantTw, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHans, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHant, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHans, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHans, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'TW'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHans, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'CN'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHant, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZhHant, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Latn', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Latn', countryCode: 'TW'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'TW'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Cyrl', countryCode: 'RU'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: null, countryCode: 'RU'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); locale = const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Cyrl', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationZh, true); }); 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, isA()); + expect(localizations is MaterialLocalizationSr, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrCyrl, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrLatn, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: null, countryCode: 'SR'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSr, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: 'SR'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrCyrl, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: 'SR'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrLatn, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Cyrl', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrCyrl, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: 'Latn', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSrLatn, true); locale = const Locale.fromSubtags(languageCode: 'sr', scriptCode: null, countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationSr, true); }); 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, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Cyrl', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'AU'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEnAu, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'GB'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEnGb, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'SG'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEnSg, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: null, countryCode: 'MX'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hant', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hant', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'en', scriptCode: 'Hans', countryCode: 'CN'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEn, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEs, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: '419'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEs419, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'MX'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEsMx, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEsUs, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'AR'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEsAr, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: null, countryCode: 'ES'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEs, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: 'Latn', countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEs, true); locale = const Locale.fromSubtags(languageCode: 'es', scriptCode: 'Latn', countryCode: 'US'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationEsUs, true); locale = const Locale.fromSubtags(languageCode: 'fr', scriptCode: null, countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationFr, true); locale = const Locale.fromSubtags(languageCode: 'fr', scriptCode: null, countryCode: 'CA'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationFrCa, true); locale = const Locale.fromSubtags(languageCode: 'de', scriptCode: null, countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationDe, true); locale = const Locale.fromSubtags(languageCode: 'de', scriptCode: null, countryCode: 'CH'); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationDeCh, true); locale = const Locale.fromSubtags(languageCode: 'th', scriptCode: null, countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationTh, true); locale = const Locale.fromSubtags(languageCode: 'ru', scriptCode: null, countryCode: null); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); localizations = await GlobalMaterialLocalizations.delegate.load(locale); - expect(localizations, isA()); + expect(localizations is MaterialLocalizationRu, true); }); 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, isA()); + expect(localizations is MaterialLocalizationZh, true); 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, isA()); + expect(localizations is MaterialLocalizationZhHans, true); 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, isA()); + expect(localizations is MaterialLocalizationZhHant, true); 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, isA()); + expect(localizations is MaterialLocalizationZhHantTw, true); 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, isA()); + expect(localizations is MaterialLocalizationZhHantHk, true); 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 7e263025222..ec459395df1 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(isA())`. +/// This is equivalent to `throwsA(isInstanceOf())`. /// /// 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(isA())`. +/// This is equivalent to `throwsA(isInstanceOf())`. /// /// 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 test_package.TypeMatcher isFlutterError = isA(); +final Matcher isFlutterError = isInstanceOf(); /// A matcher for [AssertionError]. /// @@ -207,11 +207,11 @@ final test_package.TypeMatcher isFlutterError = isA( /// /// * [throwsAssertionError], to test if a function throws any [AssertionError]. /// * [isFlutterError], to test if any object is a [FlutterError]. -final test_package.TypeMatcher isAssertionError = isA(); +final Matcher isAssertionError = isInstanceOf(); /// 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 -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); /// 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 e39c709235d..7799762585e 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, isA()); + expect(WidgetsBinding.instance, isInstanceOf()); }, 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 6b62b973450..8510a91a10a 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, isA()); + expect(WidgetsBinding.instance, isInstanceOf()); }); } 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 b42b4fbd148..751c6e9c97f 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, isA()); + expect(WidgetsBinding.instance, isInstanceOf()); }); } 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 d44a683ae9a..0e8c16a90af 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, isA()); + expect(WidgetsBinding.instance, isInstanceOf()); }); } 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 72f75f100b6..16771c3ec1a 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, isA()); + expect(WidgetsBinding.instance, isInstanceOf()); }); } 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 6e92939a831..5badb6398f9 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, isA()); + expect(details.exception, isInstanceOf()); 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 4f30955c286..fbff2b77876 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, isA()); + expect(goldenFileComparator, isInstanceOf()); 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 9e3e760b06a..5d7c9853acd 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], 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()); + 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()); 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, isA()); + real_test.expect(stackTraceProperty.value, isInstanceOf()); } 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 dfcc6024c2c..116e23fed9b 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, isA()); + expect(e, isInstanceOf()); } }); } diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index 2d06a491b02..0222794c67a 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -33,7 +33,8 @@ void main() { ), ); - expect(() => tester.getSemantics(find.text('hello')), throwsStateError); + expect(() => tester.getSemantics(find.text('hello')), + throwsA(isInstanceOf())); }, semanticsEnabled: false); testWidgets('throws when there are multiple results from the finder', (WidgetTester tester) async { @@ -52,7 +53,8 @@ void main() { ), ); - expect(() => tester.getSemantics(find.text('hello')), throwsStateError); + expect(() => tester.getSemantics(find.text('hello')), + throwsA(isInstanceOf())); semanticsHandle.dispose(); }); @@ -470,7 +472,7 @@ void main() { expect( expectAsync0(tester.pageBack), - throwsA(isA()), + throwsA(isInstanceOf()), ); }); @@ -627,7 +629,7 @@ void main() { testWidgets('disallows re-entry', (WidgetTester tester) async { final Completer completer = Completer(); tester.runAsync(() => completer.future); - expect(() => tester.runAsync(() async { }), throwsA(isA())); + expect(() => tester.runAsync(() async { }), throwsA(isInstanceOf())); completer.complete(); }); @@ -683,7 +685,7 @@ void main() { 'calling dispose() on the AnimationController itself. Otherwise,\n' 'the ticker will leak.\n', ); - expect(error.diagnostics.last, isA>()); + expect(error.diagnostics.last, isInstanceOf>()); expect(error.diagnostics.last.value, ticker); expect(error.toStringDeep(), startsWith( 'FlutterError\n' @@ -744,6 +746,7 @@ void main() { } }, variant: TargetPlatformVariant.all()); }); + } class FakeMatcher extends AsyncMatcher { diff --git a/packages/flutter_tools/lib/src/android/android_emulator.dart b/packages/flutter_tools/lib/src/android/android_emulator.dart index 0aeb57d58f9..b7c0557d200 100644 --- a/packages/flutter_tools/lib/src/android/android_emulator.dart +++ b/packages/flutter_tools/lib/src/android/android_emulator.dart @@ -8,12 +8,8 @@ import 'package:meta/meta.dart'; import '../android/android_sdk.dart'; import '../android/android_workflow.dart'; -import '../base/common.dart'; import '../base/file_system.dart'; -import '../base/io.dart'; import '../base/process.dart'; -import '../base/utils.dart'; -import '../convert.dart'; import '../device.dart'; import '../emulator.dart'; import '../globals.dart' as globals; @@ -54,59 +50,18 @@ class AndroidEmulator extends Emulator { @override Future launch() async { - final Process process = await processUtils.start( - [getEmulatorPath(androidSdk), '-avd', id], + final Future launchResult = processUtils.run( + [getEmulatorPath(), '-avd', id], + throwOnError: true, ); - - // Record output from the emulator process. - final List stdoutList = []; - final List stderrList = []; - final StreamSubscription stdoutSubscription = process.stdout - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen(stdoutList.add); - final StreamSubscription stderrSubscription = process.stderr - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen(stderrList.add); - final Future stdioFuture = waitGroup(>[ - stdoutSubscription.asFuture(), - stderrSubscription.asFuture(), + // The emulator continues running on a successful launch, so if it hasn't + // quit within 3 seconds we assume that's a success and just return. This + // means that on a slow machine, a failure that takes more than three + // seconds won't be recognized as such... :-/ + return Future.any(>[ + launchResult, + Future.delayed(const Duration(seconds: 3)), ]); - - // The emulator continues running on success, so we don't wait for the - // process to complete before continuing. However, if the process fails - // after the startup phase (3 seconds), then we only echo its output if - // its error code is non-zero and its stderr is non-empty. - bool earlyFailure = true; - unawaited(process.exitCode.then((int status) async { - if (status == 0) { - globals.printTrace('The Android emulator exited successfully'); - return; - } - // Make sure the process' stdout and stderr are drained. - await stdioFuture; - unawaited(stdoutSubscription.cancel()); - unawaited(stderrSubscription.cancel()); - if (stdoutList.isNotEmpty) { - globals.printTrace('Android emulator stdout:'); - stdoutList.forEach(globals.printTrace); - } - if (!earlyFailure && stderrList.isEmpty) { - globals.printStatus('The Android emulator exited with code $status'); - return; - } - final String when = earlyFailure ? 'during startup' : 'after startup'; - globals.printError('The Android emulator exited with code $status $when'); - globals.printError('Android emulator stderr:'); - stderrList.forEach(globals.printError); - globals.printError('Address these issues and try again.'); - })); - - // Wait a few seconds for the emulator to start. - await Future.delayed(const Duration(seconds: 3)); - earlyFailure = false; - return; } } diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index cd194a7567c..fecf566706d 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart @@ -22,14 +22,11 @@ import '../base/os.dart'; import '../base/terminal.dart'; import '../base/utils.dart'; import '../build_info.dart'; -import '../compile.dart'; import '../convert.dart'; import '../devfs.dart'; import '../device.dart'; import '../features.dart'; import '../globals.dart' as globals; -import '../platform_plugins.dart'; -import '../plugins.dart'; import '../project.dart'; import '../reporting/reporting.dart'; import '../resident_runner.dart'; @@ -101,10 +98,6 @@ abstract class ResidentWebRunner extends ResidentRunner { final List dartDefines; DateTime firstBuildTime; - // Used with the new compiler to generate a bootstrap file containing plugins - // and platform initialization. - Directory _generatedEntrypointDirectory; - // Only the debug builds of the web support the service protocol. @override bool get supportsServiceProtocol => isRunningDebug && deviceIsDebuggable; @@ -158,7 +151,6 @@ abstract class ResidentWebRunner extends ResidentRunner { await _stdOutSub?.cancel(); await _webFs?.stop(); await device.device.stopApp(null); - _generatedEntrypointDirectory?.deleteSync(recursive: true); if (ChromeLauncher.hasChromeInstance) { final Chrome chrome = await ChromeLauncher.connectedInstance; await chrome.close(); @@ -486,46 +478,6 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner { return OperationResult.ok; } - // Flutter web projects need to include a generated main entrypoint to call the - // appropriate bootstrap method and inject plugins. - // Keep this in sync with build_system/targets/web.dart. - Future _generateEntrypoint(String main, String packagesPath) async { - File result = _generatedEntrypointDirectory?.childFile('web_entrypoint.dart'); - if (_generatedEntrypointDirectory == null) { - _generatedEntrypointDirectory ??= globals.fs.systemTempDirectory.createTempSync('flutter_tools.') - ..createSync(); - result = _generatedEntrypointDirectory.childFile('web_entrypoint.dart'); - - final bool hasWebPlugins = findPlugins(flutterProject) - .any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey)); - await injectPlugins(flutterProject, checkProjects: true); - - final PackageUriMapper packageUriMapper = PackageUriMapper(main, packagesPath, null, null); - final String generatedPath = globals.fs.currentDirectory - .childDirectory('lib') - .childFile('generated_plugin_registrant.dart') - .absolute.path; - final Uri generatedImport = packageUriMapper.map(generatedPath); - - final String entrypoint = [ - 'import "${packageUriMapper.map(main)}" as entrypoint;', - 'import "dart:ui" as ui;', - if (hasWebPlugins) - 'import "package:flutter_web_plugins/flutter_web_plugins.dart";', - if (hasWebPlugins) - 'import "$generatedImport";', - 'Future main() async {', - if (hasWebPlugins) - ' registerPlugins(webPluginRegistry);' - ' await ui.webOnlyInitializePlatform();', - ' entrypoint.main();', - '}', - ].join('\n'); - result.writeAsStringSync(entrypoint); - } - return result.path; - } - Future _updateDevFS({bool fullRestart = false}) async { final bool isFirstUpload = !assetBundle.wasBuiltOnce(); final bool rebuildBundle = assetBundle.needsBuild(); @@ -547,7 +499,7 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner { timeout: timeoutConfiguration.fastOperation, ); final UpdateFSReport report = await device.devFS.update( - mainPath: await _generateEntrypoint(mainPath, packagesFilePath), + mainPath: mainPath, target: target, bundle: assetBundle, firstBuildTime: firstBuildTime, diff --git a/packages/flutter_tools/lib/src/build_system/targets/web.dart b/packages/flutter_tools/lib/src/build_system/targets/web.dart index fbf941eb28e..57e27e08a3e 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/web.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/web.dart @@ -32,7 +32,6 @@ const String kDart2jsOptimization = 'Dart2jsOptimization'; const String kCspMode = 'cspMode'; /// Generates an entry point for a web target. -// Keep this in sync with build_runner/resident_web_runner.dart class WebEntrypointTarget extends Target { const WebEntrypointTarget(); diff --git a/packages/flutter_tools/lib/src/commands/emulators.dart b/packages/flutter_tools/lib/src/commands/emulators.dart index 0eaab4c2cbe..14671f30e7b 100644 --- a/packages/flutter_tools/lib/src/commands/emulators.dart +++ b/packages/flutter_tools/lib/src/commands/emulators.dart @@ -69,7 +69,16 @@ class EmulatorsCommand extends FlutterCommand { "More than one emulator matches '$id':", ); } else { - await emulators.first.launch(); + try { + await emulators.first.launch(); + } + catch (e) { + if (e is String) { + globals.printError(e); + } else { + rethrow; + } + } } } diff --git a/packages/flutter_tools/lib/src/web/bootstrap.dart b/packages/flutter_tools/lib/src/web/bootstrap.dart index 92f2b2cfee2..d0435a7c3ea 100644 --- a/packages/flutter_tools/lib/src/web/bootstrap.dart +++ b/packages/flutter_tools/lib/src/web/bootstrap.dart @@ -55,8 +55,7 @@ window.\$hotReloadHook = function(modules) { // once we've reloaded every module, trigger the hot reload. if (reloadCount == modules.length) { require(["$entrypoint", "dart_sdk"], function(app, dart_sdk) { - // See L81 below for an explanation. - window.\$mainEntrypoint = app[Object.keys(app)[0]].main; + window.\$mainEntrypoint = app.main.main; window.\$hotReload(resolve); }); } @@ -79,23 +78,22 @@ define("main_module", ["$entrypoint", "dart_sdk"], function(app, dart_sdk) { let voidToNull = () => (voidToNull = dart_sdk.dart.constFn(dart_sdk.dart.fnType(dart_sdk.core.Null, [dart_sdk.dart.void])))(); // Attach the main entrypoint and hot reload functionality to the window. - // The app module will have a single property which contains the actual application - // code. The property name is based off of the entrypoint that is generated, for example - // the file `foo/bar/baz.dart` will generate a property named approximately - // `foo__bar__baz`. Rather than attempt to guess, we assume the first property of - // this object is the module. - window.\$mainEntrypoint = app[Object.keys(app)[0]].main; + window.\$mainEntrypoint = app.main.main; if (window.\$hotReload == null) { window.\$hotReload = function(cb) { dart_sdk.developer.invokeExtension("ext.flutter.disassemble", "{}").then((_) => { dart_sdk.dart.hotRestart(); - window.\$mainEntrypoint(); - window.requestAnimationFrame(cb); + dart_sdk.ui.webOnlyInitializePlatform().then(dart_sdk.core.Null, dart_sdk.dart.fn(_ => { + window.\$mainEntrypoint(); + window.requestAnimationFrame(cb); + }, voidToNull())); }); } } - window.\$mainEntrypoint(); + dart_sdk.ui.webOnlyInitializePlatform().then(dart_sdk.core.Null, dart_sdk.dart.fn(_ => { + app.main.main(); + }, voidToNull())); }); // Require JS configuration. 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 ceeedc10564..3eeef208eb3 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart @@ -3,6 +3,7 @@ // 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'; @@ -52,7 +53,7 @@ void main() { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand()); expect(commandRunner.run(['assemble', 'debug_macos_bundle_flutter_assets']), - throwsToolExit()); + throwsA(isInstanceOf())); }); testbed.test('Throws ToolExit if called with non-existent rule', () async { @@ -63,7 +64,7 @@ void main() { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand()); expect(commandRunner.run(['assemble', '-o Output', 'undefined']), - throwsToolExit()); + throwsA(isInstanceOf())); }); testbed.test('Does not log stack traces during build failure', () async { @@ -77,7 +78,7 @@ void main() { final CommandRunner commandRunner = createTestCommandRunner(AssembleCommand()); await expectLater(commandRunner.run(['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']), - throwsToolExit()); + throwsA(isInstanceOf())); 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 2231ed70260..c51c3722bb4 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']), - throwsToolExit()); + throwsA(isA())); }, overrides: { FileSystem: () => testFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -619,7 +619,7 @@ void main() { final AttachCommand command = AttachCommand(); await expectLater( createTestCommandRunner(command).run(['attach']), - throwsToolExit(), + throwsA(isInstanceOf()), ); 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']), - throwsToolExit(), + throwsA(isInstanceOf()), ); 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 3597a17aee0..404ab8609ab 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,6 +5,7 @@ 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'; @@ -49,7 +50,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsToolExit()); + throwsA(isInstanceOf())); }, overrides: { Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -66,7 +67,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsToolExit()); + throwsA(isInstanceOf())); }, overrides: { Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -88,7 +89,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsToolExit()); + throwsA(isInstanceOf())); }, overrides: { Platform: () => windowsPlatform, FileSystem: () => MemoryFileSystem(), @@ -110,7 +111,7 @@ void main() { expect( createTestCommandRunner(command) .run(const ['build', 'fuchsia']), - throwsToolExit()); + throwsA(isInstanceOf())); }, 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 9f1f166bc48..e6a7244a7df 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,6 +8,7 @@ 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'; @@ -100,7 +101,7 @@ void main() { expect(createTestCommandRunner(command).run( const ['build', 'linux'] - ), throwsToolExit()); + ), throwsA(isInstanceOf())); }, overrides: { Platform: () => notLinuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -219,7 +220,7 @@ BINARY_NAME=fizz_bar final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'linux']), - throwsToolExit()); + throwsA(isInstanceOf())); }, 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 2797f144b08..18ad8d42f39 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,6 +6,7 @@ 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'; @@ -126,7 +127,7 @@ void main() { expect(createTestCommandRunner(command).run( const ['build', 'macos'] - ), throwsToolExit()); + ), throwsA(isInstanceOf())); }, overrides: { Platform: () => notMacosPlatform, FileSystem: () => MemoryFileSystem(), @@ -205,7 +206,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'macos']), - throwsToolExit()); + throwsA(isInstanceOf())); }, 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 b5026e59dc4..96c790d3296 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,6 +5,7 @@ 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'; @@ -59,7 +60,7 @@ void main() { false, const [], false, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); })); test('Refuses to build using runner when missing index.html', () => testbed.run(() async { @@ -81,7 +82,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'web', '--debug']), - throwsA(isA())); + throwsA(isInstanceOf())); }, overrides: { FeatureFlags: () => TestFeatureFlags(isWebEnabled: true), })); @@ -90,7 +91,7 @@ void main() { final CommandRunner runner = createTestCommandRunner(BuildCommand()); expect(() => runner.run(['build', 'web']), - throwsToolExit()); + throwsA(isInstanceOf())); }, 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 0ec38b5c698..5b2f571b837 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,6 +5,7 @@ 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'; @@ -76,7 +77,7 @@ void main() { setUpMockProjectFilesForBuild(); expect(createTestCommandRunner(command).run( const ['build', 'windows'] - ), throwsToolExit()); + ), throwsA(isInstanceOf())); }, overrides: { Platform: () => windowsPlatform, FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows), @@ -109,7 +110,7 @@ void main() { expect(createTestCommandRunner(command).run( const ['build', 'windows'] - ), throwsToolExit()); + ), throwsA(isInstanceOf())); }, 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 8c6def3c898..bcb43383d6b 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart @@ -7,6 +7,7 @@ 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'; @@ -101,7 +102,7 @@ void main() { expect(() => commandRunner.run([ 'config', '--build-dir=/foo', - ]), throwsToolExit()); + ]), throwsA(isInstanceOf())); 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 0cda0357ee4..ba5053b96ee 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'], isA()); + expect(response['result'] is String, true); 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 3be414b11f6..466f4c8c632 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, isA()); + expect(e, isInstanceOf()); } 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 53f64d53431..30b8c86c230 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, ]), - throwsToolExit(), + throwsA(isInstanceOf()), ); }, overrides: { ProcessManager: () => MockProcessManager(), @@ -119,7 +119,7 @@ void main() { await command.getTags(); fail('ToolExit expected'); } catch(e) { - expect(e, isA()); + expect(e, isInstanceOf()); } }, 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 2db9ff820c3..3018b673887 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,6 +4,7 @@ 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'; @@ -108,7 +109,7 @@ void main() { 'bundle', '--no-pub', '--target-platform=windows-x64', - ]), throwsToolExit()); + ]), throwsA(isInstanceOf())); }, overrides: { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -126,7 +127,7 @@ void main() { 'bundle', '--no-pub', '--target-platform=linux-x64', - ]), throwsToolExit()); + ]), throwsA(isInstanceOf())); }, overrides: { FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -144,7 +145,7 @@ void main() { 'bundle', '--no-pub', '--target-platform=darwin-x64', - ]), throwsToolExit()); + ]), throwsA(isInstanceOf())); }, 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 e89aac6ec6b..4fc4ebc137f 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart @@ -2,6 +2,7 @@ // 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'; @@ -62,7 +63,7 @@ void main() { const GitTagVersion.unknown(), flutterVersion, ); - expect(result, throwsToolExit()); + expect(result, throwsA(isInstanceOf())); }, overrides: { Platform: () => fakePlatform, }); @@ -88,7 +89,7 @@ void main() { gitTagVersion, flutterVersion, ); - expect(result, throwsToolExit()); + expect(result, throwsA(isA())); }, 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 dcc600d5a9d..d2d82a78be1 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 @@ -13,6 +13,7 @@ import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; +import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/project.dart'; @@ -43,6 +44,45 @@ class MockAndroidApk extends Mock implements AndroidApk { File get file => MockFile(); } +class MockProcessUtils extends Mock implements ProcessUtils { + @override + Future run( + List cmd, { + bool throwOnError = false, + RunResultChecker whiteListFailures, + String workingDirectory, + bool allowReentrantFlutter = false, + Map environment, + Duration timeout, + int timeoutRetries = 0, + }) async { + if (cmd.contains('version')) { + return RunResult(ProcessResult(0, 0, 'Android Debug Bridge version 1.0.41', ''), cmd); + } + if (cmd.contains('android.intent.action.RUN')) { + _runCmd = cmd; + } + return RunResult(ProcessResult(0, 0, '', ''), cmd); + } + + @override + Future stream( + List cmd, { + String workingDirectory, + bool allowReentrantFlutter = false, + String prefix = '', + bool trace = false, + RegExp filter, + StringConverter mapFunction, + Map environment, + }) async { + return 0; + } + + List _runCmd; + List get runCmd => _runCmd; +} + class MockAndroidSdkVersion extends Mock implements AndroidSdkVersion {} void main() { @@ -57,11 +97,13 @@ void main() { MockAndroidApk mockApk; MockProcessManager mockProcessManager; MockAndroidSdk mockAndroidSdk; + MockProcessUtils mockProcessUtils; setUp(() { mockApk = MockAndroidApk(); mockProcessManager = MockProcessManager(); mockAndroidSdk = MockAndroidSdk(); + mockProcessUtils = MockProcessUtils(); }); testUsingContext('succeeds with --cache-sksl', () async { @@ -82,20 +124,6 @@ void main() { )).thenAnswer((_) async { return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]', ''); }); - when(mockProcessManager.run( - any, - workingDirectory: anyNamed('workingDirectory'), - environment: anyNamed('environment') - )).thenAnswer((_) async { - return ProcessResult(0, 0, '', ''); - }); - when(mockProcessManager.start( - any, - workingDirectory: anyNamed('workingDirectory'), - environment: anyNamed('environment') - )).thenAnswer((_) async { - return FakeProcess(); - }); final LaunchResult launchResult = await device.startApp( mockApk, @@ -106,14 +134,18 @@ void main() { ), platformArgs: {}, ); - expect(launchResult.started, isTrue); - expect(verify(mockProcessManager.run(captureAny)).captured.last.join(','), - contains(['--ez', 'cache-sksl', 'true'].join(','))); + + final int cmdIndex = mockProcessUtils.runCmd.indexOf('cache-sksl'); + expect( + mockProcessUtils.runCmd.sublist(cmdIndex - 1, cmdIndex + 2), + equals(['--ez', 'cache-sksl', 'true']), + ); }, overrides: { AndroidSdk: () => mockAndroidSdk, FileSystem: () => MemoryFileSystem(), ProcessManager: () => mockProcessManager, + ProcessUtils: () => mockProcessUtils, }); testUsingContext('can run a release build on x64', () async { @@ -134,20 +166,6 @@ void main() { )).thenAnswer((_) async { return ProcessResult(0, 0, '[ro.build.version.sdk]: [24]\n[ro.product.cpu.abi]: [x86_64]', ''); }); - when(mockProcessManager.run( - any, - workingDirectory: anyNamed('workingDirectory'), - environment: anyNamed('environment') - )).thenAnswer((_) async { - return ProcessResult(0, 0, '', ''); - }); - when(mockProcessManager.start( - any, - workingDirectory: anyNamed('workingDirectory'), - environment: anyNamed('environment') - )).thenAnswer((_) async { - return FakeProcess(); - }); final LaunchResult launchResult = await device.startApp( mockApk, @@ -162,6 +180,7 @@ void main() { AndroidSdk: () => mockAndroidSdk, FileSystem: () => MemoryFileSystem(), ProcessManager: () => mockProcessManager, + ProcessUtils: () => mockProcessUtils, }); }); }); @@ -633,7 +652,7 @@ flutter: when(mockProcessManager.run(argThat(contains('forward')))) .thenAnswer((_) async => ProcessResult(0, 0, '123456', '')); - expect(forwarder.forward(123, hostPort: 456), throwsA(isA())); + expect(forwarder.forward(123, hostPort: 456), throwsA(isInstanceOf())); }, overrides: { ProcessManager: () => mockProcessManager, }); diff --git a/packages/flutter_tools/test/general.shard/android/android_emulator_test.dart b/packages/flutter_tools/test/general.shard/android/android_emulator_test.dart index 9b776a2916f..5f37cc25564 100644 --- a/packages/flutter_tools/test/general.shard/android/android_emulator_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_emulator_test.dart @@ -2,22 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - -import 'package:file/file.dart'; -import 'package:file/memory.dart'; -import 'package:flutter_tools/src/android/android_sdk.dart' - show getEmulatorPath, AndroidSdk, androidSdk; import 'package:flutter_tools/src/android/android_emulator.dart'; -import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/device.dart'; -import 'package:mockito/mockito.dart'; -import 'package:quiver/testing/async.dart'; import '../../src/common.dart'; import '../../src/context.dart'; -import '../../src/fake_process_manager.dart'; -import '../../src/mocks.dart' show MockAndroidSdk; void main() { group('android_emulator', () { @@ -29,10 +18,8 @@ void main() { }); testUsingContext('flags emulators with config', () { const String emulatorID = '1234'; - final AndroidEmulator emulator = AndroidEmulator( - emulatorID, - {'name': 'test'}, - ); + final AndroidEmulator emulator = + AndroidEmulator(emulatorID, {'name': 'test'}); expect(emulator.id, emulatorID); expect(emulator.hasConfig, true); }); @@ -44,7 +31,8 @@ void main() { 'hw.device.manufacturer': manufacturer, 'avd.ini.displayname': displayName, }; - final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties); + final AndroidEmulator emulator = + AndroidEmulator(emulatorID, properties); expect(emulator.id, emulatorID); expect(emulator.name, displayName); expect(emulator.manufacturer, manufacturer); @@ -57,7 +45,8 @@ void main() { final Map properties = { 'avd.ini.displayname': displayName, }; - final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties); + final AndroidEmulator emulator = + AndroidEmulator(emulatorID, properties); expect(emulator.name, displayName); }); testUsingContext('uses cleaned up ID if no displayname is set', () { @@ -67,7 +56,8 @@ void main() { final Map properties = { 'avd.ini.notadisplayname': 'this is not a display name', }; - final AndroidEmulator emulator = AndroidEmulator(emulatorID, properties); + final AndroidEmulator emulator = + AndroidEmulator(emulatorID, properties); expect(emulator.name, 'This is my ID'); }); testUsingContext('parses ini files', () { @@ -84,98 +74,4 @@ void main() { expect(results['avd.ini.displayname'], 'dispName'); }); }); - - group('Android emulator launch ', () { - const String emulatorID = 'i1234'; - const String errorText = '[Android emulator test error]'; - MockAndroidSdk mockSdk; - FakeProcessManager successProcessManager; - FakeProcessManager errorProcessManager; - FakeProcessManager lateFailureProcessManager; - MemoryFileSystem fs; - - setUp(() { - fs = MemoryFileSystem(); - mockSdk = MockAndroidSdk(); - when(mockSdk.emulatorPath).thenReturn('emulator'); - - const List command = [ - 'emulator', '-avd', emulatorID, - ]; - - successProcessManager = FakeProcessManager.list([ - const FakeCommand(command: command), - ]); - - errorProcessManager = FakeProcessManager.list([ - const FakeCommand( - command: command, - exitCode: 1, - stderr: errorText, - stdout: 'dummy text', - duration: Duration(seconds: 1), - ), - ]); - - lateFailureProcessManager = FakeProcessManager.list([ - const FakeCommand( - command: command, - exitCode: 1, - stderr: '', - stdout: 'dummy text', - duration: Duration(seconds: 4), - ), - ]); - }); - - testUsingContext('succeeds', () async { - final AndroidEmulator emulator = AndroidEmulator(emulatorID); - expect(getEmulatorPath(androidSdk), mockSdk.emulatorPath); - final Completer completer = Completer(); - FakeAsync().run((FakeAsync time) { - unawaited(emulator.launch().whenComplete(completer.complete)); - time.elapse(const Duration(seconds: 5)); - time.flushMicrotasks(); - }); - await completer.future; - - }, overrides: { - ProcessManager: () => successProcessManager, - AndroidSdk: () => mockSdk, - FileSystem: () => fs, - }); - - testUsingContext('prints error on failure', () async { - final AndroidEmulator emulator = AndroidEmulator(emulatorID); - final Completer completer = Completer(); - FakeAsync().run((FakeAsync time) { - unawaited(emulator.launch().whenComplete(completer.complete)); - time.elapse(const Duration(seconds: 5)); - time.flushMicrotasks(); - }); - await completer.future; - - expect(testLogger.errorText, contains(errorText)); - }, overrides: { - ProcessManager: () => errorProcessManager, - AndroidSdk: () => mockSdk, - FileSystem: () => fs, - }); - - testUsingContext('prints nothing on late failure with empty stderr', () async { - final AndroidEmulator emulator = AndroidEmulator(emulatorID); - final Completer completer = Completer(); - FakeAsync().run((FakeAsync time) async { - unawaited(emulator.launch().whenComplete(completer.complete)); - time.elapse(const Duration(seconds: 5)); - time.flushMicrotasks(); - }); - await completer.future; - expect(testLogger.errorText, isEmpty); - }, overrides: { - ProcessManager: () => lateFailureProcessManager, - AndroidSdk: () => mockSdk, - FileSystem: () => fs, - }); - }); } 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 da7dcd3ec85..7ff225e41d3 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(isA())); + throwsA(isInstanceOf())); }, 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 0ffb6c28995..958e0ad71d7 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(isA())); + expect(() => context.get(), throwsA(isInstanceOf())); }); }); } 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 603b07c6257..c6778d0a240 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), throwsAssertionError); + expect(() => exit(0), throwsA(isInstanceOf())); }); 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 eb7bf9c3d0a..3b155091142 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, throwsAssertionError); - expect(ansiSpinner.cancel, throwsAssertionError); + expect(ansiSpinner.stop, throwsA(isInstanceOf())); + expect(ansiSpinner.cancel, throwsA(isInstanceOf())); 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(); }, throwsAssertionError); - expect(() { ansiStatus.stop(); }, throwsAssertionError); + expect(() { ansiStatus.cancel(); }, throwsA(isInstanceOf())); + expect(() { ansiStatus.stop(); }, throwsA(isInstanceOf())); 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, throwsAssertionError); - expect(ansiStatus.cancel, throwsAssertionError); + expect(ansiStatus.stop, throwsA(isInstanceOf())); + expect(ansiStatus.cancel, throwsA(isInstanceOf())); 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, throwsAssertionError); - expect(summaryStatus.stop, throwsAssertionError); + expect(summaryStatus.cancel, throwsA(isInstanceOf())); + expect(summaryStatus.stop, throwsA(isInstanceOf())); }); 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, throwsAssertionError); - expect(summaryStatus.cancel, throwsAssertionError); + expect(summaryStatus.stop, throwsA(isInstanceOf())); + expect(summaryStatus.cancel, throwsA(isInstanceOf())); }); 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 025976729ec..605d417ff9c 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(isA())); + throwsA(isInstanceOf())); }); }); @@ -236,7 +236,7 @@ void main() { ['dummy'], timeout: delay - const Duration(milliseconds: 500), timeoutRetries: 0, - ), throwsA(isA())); + ), throwsA(isInstanceOf())); }); }); 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 d36b95982cd..78bb1d46473 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, - ), throwsStateError); + ), throwsA(isInstanceOf())); }); 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 fcd28eefb6f..7aa13b91b9a 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'), throwsArgumentError); + expect(() => BuildMode.fromName('foo'), throwsA(isInstanceOf())); }); }); } 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 6bc91d59f31..778fb59791d 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(isA())); + expect(() => checkCycles(barTarget), throwsA(isInstanceOf())); }); 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 56e22bb4775..a1dd81ab393 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(isA())); + expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf())); })); test('can\'t substitute foo', () => testbed.run(() { const Source invalidBase = Source.pattern('foo'); - expect(() => invalidBase.accept(visitor), throwsA(isA())); + expect(() => invalidBase.accept(visitor), throwsA(isInstanceOf())); })); 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 baa0699cef9..c3c92957f7b 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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, isA()); + expect(result.exceptions.values.single.exception, isInstanceOf()); })); 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 c2fc39cea17..e3c86708aad 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), - throwsException); + throwsA(isInstanceOf())); })); 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 770602be3f2..706bf732642 100644 --- a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart +++ b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart @@ -2,6 +2,7 @@ // 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'; @@ -61,7 +62,7 @@ void main() { targetPlatform: TargetPlatform.linux_x64, depfilePath: 'example.d', precompiled: false, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); })); } diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index ec1ae041992..c0aaf67f815 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -12,6 +12,7 @@ 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'; @@ -71,7 +72,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(), throwsToolExit()); + expect(() async => await Cache.lock(), throwsA(isA())); }, overrides: { FileSystem: () => mockFileSystem, ProcessManager: () => FakeProcessManager.any(), @@ -230,7 +231,7 @@ void main() { 'FLUTTER_STORAGE_BASE_URL': ' http://foo', }); final Cache cache = Cache(); - expect(() => cache.storageBaseUrl, throwsToolExit()); + expect(() => cache.storageBaseUrl, throwsA(isInstanceOf())); }, 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 79788bacc19..9279c8b7c47 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart @@ -5,6 +5,7 @@ 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'; @@ -81,7 +82,7 @@ void main() { '/path/to/main.dart', null, /* invalidatedFiles */ outputPath: '/build/', - )), throwsToolExit()); + )), throwsA(isInstanceOf())); }, overrides: { ProcessManager: () => mockProcessManager, OutputPreferences: () => OutputPreferences(showColor: false), @@ -99,7 +100,7 @@ void main() { '/path/to/main.dart', null, /* invalidatedFiles */ outputPath: '/build/', - )), throwsToolExit()); + )), throwsA(isInstanceOf())); }, 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 7901a82ed28..412e9d504ed 100644 --- a/packages/flutter_tools/test/general.shard/compile_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_test.dart @@ -2,6 +2,7 @@ // 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'; @@ -24,7 +25,7 @@ void main() { final Future output = stdoutHandler.compilerOutput.future; stdoutHandler.handler('message with no result'); - expect(output, throwsToolExit()); + expect(output, throwsA(isInstanceOf())); }); test('TargetModel values', () { @@ -40,6 +41,6 @@ void main() { expect(TargetModel('dartdevc'), TargetModel.dartdevc); expect(TargetModel.dartdevc.toString(), 'dartdevc'); - expect(() => TargetModel('foobar'), throwsAssertionError); + expect(() => TargetModel('foobar'), throwsA(isInstanceOf())); }); } 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 f8209699245..ff95577f203 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, isA()); + expect(error, isInstanceOf()); 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 3839adf3441..9f0913f0c08 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(isA())); + contains(isInstanceOf())); expect(DoctorValidatorsProvider.defaultInstance.validators, - contains(isA())); + contains(isInstanceOf())); }, 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(isA()))); + isNot(contains(isInstanceOf()))); expect(DoctorValidatorsProvider.defaultInstance.validators, - isNot(contains(isA()))); + isNot(contains(isInstanceOf()))); }, 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(isA())); + contains(isInstanceOf())); }, 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(isA()))); + isNot(contains(isInstanceOf()))); }, 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 13ef1afe95b..fb9f9f12597 100644 --- a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart @@ -3,6 +3,7 @@ // 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'; @@ -20,13 +21,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()), throwsToolExit()); + expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA())); }); 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()), throwsToolExit()); + expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA())); }); group('The FLUTTER_TEST environment variable is passed to the test process', () { @@ -49,7 +50,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, isA>()); + expect(toVerify.captured.first, isInstanceOf>()); return toVerify.captured.first as Map; } @@ -90,7 +91,7 @@ void main() { shellPath: 'abc', enableObservatory: false, startPaused: true, - ), throwsAssertionError); + ), throwsA(isA())); expect(() => installHook( buildMode: BuildMode.debug, @@ -98,7 +99,7 @@ void main() { enableObservatory: false, startPaused: false, observatoryPort: 123, - ), throwsAssertionError); + ), throwsA(isA())); FlutterPlatform capturedPlatform; final Map expectedPrecompiledDillFiles = {'Key': 'Value'}; diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart index c0a2a0b7cbe..2810fcff2ab 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart @@ -12,6 +12,7 @@ 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'; +import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/time.dart'; import 'package:flutter_tools/src/build_info.dart'; @@ -29,8 +30,8 @@ import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/vmservice.dart'; import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; -import 'package:platform/platform.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -39,10 +40,11 @@ void main() { group('fuchsia device', () { MemoryFileSystem memoryFileSystem; MockFile sshConfig; - + MockProcessUtils mockProcessUtils; setUp(() { memoryFileSystem = MemoryFileSystem(); sshConfig = MockFile(); + mockProcessUtils = MockProcessUtils(); when(sshConfig.absolute).thenReturn(sshConfig); }); @@ -116,27 +118,27 @@ void main() { }); testUsingContext('targetPlatform arm64 works', () async { - when(globals.processManager.run(any)).thenAnswer((Invocation _) async { - return ProcessResult(1, 0, 'aarch64', ''); + when(mockProcessUtils.run(any)).thenAnswer((Invocation _) { + return Future.value(RunResult(ProcessResult(1, 0, 'aarch64', ''), [''])); }); final FuchsiaDevice device = FuchsiaDevice('123'); expect(await device.targetPlatform, TargetPlatform.fuchsia_arm64); }, overrides: { FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig), FuchsiaSdk: () => MockFuchsiaSdk(), - ProcessManager: () => MockProcessManager(), + ProcessUtils: () => mockProcessUtils, }); testUsingContext('targetPlatform x64 works', () async { - when(globals.processManager.run(any)).thenAnswer((Invocation _) async { - return ProcessResult(1, 0, 'x86_64', ''); + when(mockProcessUtils.run(any)).thenAnswer((Invocation _) { + return Future.value(RunResult(ProcessResult(1, 0, 'x86_64', ''), [''])); }); final FuchsiaDevice device = FuchsiaDevice('123'); expect(await device.targetPlatform, TargetPlatform.fuchsia_x64); }, overrides: { FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig), FuchsiaSdk: () => MockFuchsiaSdk(), - ProcessManager: () => MockProcessManager(), + ProcessUtils: () => mockProcessUtils, }); }); @@ -324,8 +326,8 @@ void main() { }); }); - group('screenshot', () { - MockProcessManager mockProcessManager; + group('screenshot', () { + MockProcessManager mockProcessManager; setUp(() { mockProcessManager = MockProcessManager(); @@ -548,7 +550,6 @@ void main() { }, testOn: 'posix'); }); - group(FuchsiaIsolateDiscoveryProtocol, () { MockPortForwarder portForwarder; MockVMService vmService; @@ -959,6 +960,8 @@ class MockProcessManager extends Mock implements ProcessManager {} class MockProcessResult extends Mock implements ProcessResult {} +class MockProcessUtils extends Mock implements ProcessUtils {} + class MockFile extends Mock implements File {} class MockProcess extends Mock implements Process {} 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 74fb188a597..fbf7ff002dc 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'); }, - throwsAssertionError, + throwsA(isInstanceOf()), ); }, overrides: { Platform: () => platform, @@ -788,7 +788,7 @@ void main() { .thenAnswer((Invocation invocation) => Future.value('')); expect( () async { await IOSDevice.getAttachedDevices(); }, - throwsA(isA()), + throwsA(isInstanceOf()), ); }, 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 0f2c9d7dfcd..ae846bfea7b 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(isA())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); }, overrides: { ProcessManager: () => mockProcessManager, Cache: () => mockCache, @@ -129,7 +129,7 @@ void main() { ); return Future.value(result); }); - expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); }, overrides: { ProcessManager: () => mockProcessManager, Cache: () => mockCache, @@ -171,7 +171,7 @@ void main() { ); return Future.value(result); }); - expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isA())); + expect(() async => await iMobileDevice.getInfoForDevice('foo', 'bar'), throwsA(isInstanceOf())); }, 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 504a7ddaf60..ecd7e471155 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, isA()); + expect(e, isInstanceOf()); 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, isA()); + expect(e, isInstanceOf()); 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 4a404b621d1..1fcdfe69d12 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart @@ -6,6 +6,7 @@ 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'; @@ -28,7 +29,7 @@ void main() { testInMemory('fails on null directory', () async { expect( () => FlutterProject.fromDirectory(null), - throwsAssertionError, + throwsA(isInstanceOf()), ); }); @@ -40,7 +41,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsToolExit(), + throwsA(isInstanceOf()), ); }); @@ -52,7 +53,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsToolExit(), + throwsA(isInstanceOf()), ); }); @@ -64,7 +65,7 @@ void main() { expect( () => FlutterProject.fromDirectory(directory), - throwsToolExit(), + throwsA(isInstanceOf()), ); }); @@ -109,7 +110,7 @@ void main() { final FlutterProject project = await someProject(); await expectLater( project.android.makeHostAppEditable(), - throwsAssertionError, + throwsA(isInstanceOf()), ); }); 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 e576d2c51aa..ef835f1ca2e 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), - throwsAssertionError); + throwsA(isInstanceOf())); })); 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()), throwsAssertionError); + expect(() => nextPlatform('unknown', TestFeatureFlags()), throwsA(isInstanceOf())); }); } 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 d2b159ca11b..96698bf4eae 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 @@ -82,8 +82,6 @@ void main() { dartDefines: const [], urlTunneller: null, ) as ResidentWebRunner; - globals.fs.currentDirectory.childFile('.packages') - ..writeAsStringSync('\n'); }, overrides: { WebFsFactory: () => ({ @@ -380,8 +378,6 @@ void main() { pathToReload: anyNamed('pathToReload'), invalidatedFiles: anyNamed('invalidatedFiles'), )).thenAnswer((Invocation invocation) async { - // Generated entrypoint file in temp dir. - expect(invocation.namedArguments[#mainPath], contains('entrypoint.dart')); return UpdateFSReport(success: true) ..invalidatedModules = ['example']; }); @@ -930,7 +926,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -949,7 +945,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -968,7 +964,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -987,7 +983,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -1006,7 +1002,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -1025,7 +1021,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -1045,7 +1041,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsException); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -1064,7 +1060,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsToolExit()); + ), throwsA(isInstanceOf())); unhandledErrorCompleter.complete(); await expectation; @@ -1086,7 +1082,7 @@ void main() { final Future expectation = expectLater(() => residentWebRunner.run( connectionInfoCompleter: connectionInfoCompleter, - ), throwsStateError); + ), throwsA(isInstanceOf())); 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 9aa3c5cf992..5517c430a95 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,6 +3,7 @@ // 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'; @@ -75,7 +76,7 @@ void main() { final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion; when(version.ensureVersionFile()).thenThrow(const FileSystemException()); - expect(() async => await runner.run(['dummy']), throwsToolExit()); + expect(() async => await runner.run(['dummy']), throwsA(isA())); }, 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 57c1395d096..9243191ec6a 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -4,6 +4,7 @@ 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'; @@ -248,7 +249,7 @@ void main() { .thenAnswer((Invocation invocation) async { return OperationResult(1, 'fail', fatal: true); }); - expect(terminalHandler.processTerminalInput('r'), throwsToolExit()); + expect(terminalHandler.processTerminalInput('r'), throwsA(isInstanceOf())); }); testUsingContext('r - hotReload unsupported', () async { @@ -291,7 +292,7 @@ void main() { .thenAnswer((Invocation invocation) async { return OperationResult(1, 'fail', fatal: true); }); - expect(() => terminalHandler.processTerminalInput('R'), throwsToolExit()); + expect(() => terminalHandler.processTerminalInput('R'), throwsA(isInstanceOf())); }); 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 57354425aba..6e10a6b43d4 100644 --- a/packages/flutter_tools/test/general.shard/testbed_test.dart +++ b/packages/flutter_tools/test/general.shard/testbed_test.dart @@ -10,11 +10,9 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/error_handling_file_system.dart'; -import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; -import '../src/context.dart'; import '../src/testbed.dart'; void main() { @@ -78,7 +76,7 @@ void main() { expect(testbed.run(() async { Timer.periodic(const Duration(seconds: 1), (Timer timer) { }); - }), throwsStateError); + }), throwsA(isInstanceOf())); }); test('Doesnt throw a StateError if Timer is left cleaned up', () async { @@ -89,14 +87,6 @@ void main() { timer.cancel(); }); }); - - test('Throws if ProcessUtils is injected',() { - final Testbed testbed = Testbed(overrides: { - ProcessUtils: () => null, - }); - - expect(() => testbed.run(() {}), throwsA(isInstanceOf())); - }); }); } 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 86beb374d12..ea2eed139b1 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, isA()); + expect(device, isInstanceOf()); 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 7c71f9e5d38..437cd6e32bb 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,6 +5,7 @@ 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'; @@ -79,7 +80,7 @@ void main() { }); test('Throws a tool exit if bind fails with a SocketException', () => testbed.run(() async { - expect(WebAssetServer.start('hello', 1234), throwsToolExit()); + expect(WebAssetServer.start('hello', 1234), throwsA(isInstanceOf())); })); test('Can catch exceptions through the onError callback', () => testbed.run(() async { @@ -91,7 +92,7 @@ void main() { when(request.uri).thenReturn(Uri.parse('http://foobar/foo.js')); requestController.add(request); - expect(closeCompleter.future, throwsStateError); + expect(closeCompleter.future, throwsA(isInstanceOf())); })); 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 f3c0d5174bd..47958a7ad75 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), isA()); - expect(chromeDevice.getLogReader(), isA()); + expect(chromeDevice.getLogReader(app: mockWebApplicationPackage), isInstanceOf()); + expect(chromeDevice.getLogReader(), isInstanceOf()); 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), isA()); - expect(device.getLogReader(), isA()); + expect(device.getLogReader(app: mockWebApplicationPackage), isInstanceOf()); + expect(device.getLogReader(), isInstanceOf()); 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(isA())); + expect(devices, contains(isInstanceOf())); }, overrides: { ChromeLauncher: () => mockChromeLauncher, }); @@ -77,7 +77,7 @@ void main() { final WebDevices deviceDiscoverer = WebDevices(); final List devices = await deviceDiscoverer.pollingGetDevices(); - expect(devices, isNot(contains(isA()))); + expect(devices, isNot(contains(isInstanceOf()))); }, overrides: { ChromeLauncher: () => mockChromeLauncher, }); @@ -87,7 +87,7 @@ void main() { final WebDevices deviceDiscoverer = WebDevices(); final List devices = await deviceDiscoverer.pollingGetDevices(); - expect(devices, contains(isA())); + expect(devices, contains(isInstanceOf())); }, 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 49a9809c9a9..a81216dcc25 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 @@ -8,6 +8,7 @@ import 'package:built_collection/built_collection.dart'; import 'package:dwds/asset_handler.dart'; import 'package:dwds/dwds.dart'; import 'package:flutter_tools/src/base/os.dart'; +import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/project.dart'; @@ -17,10 +18,8 @@ import 'package:flutter_tools/src/globals.dart' as globals; import 'package:http_multi_server/http_multi_server.dart'; import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; -import 'package:process/process.dart'; import '../../src/common.dart'; -import '../../src/mocks.dart'; import '../../src/testbed.dart'; void main() { @@ -31,7 +30,7 @@ void main() { MockHttpMultiServer mockHttpMultiServer; MockBuildDaemonClient mockBuildDaemonClient; MockOperatingSystemUtils mockOperatingSystemUtils; - MockProcessManager mockProcessManager; + MockProcessUtils mockProcessUtils; bool lastInitializePlatform; dynamic lastAddress; int lastPort; @@ -46,7 +45,7 @@ void main() { mockBuildDaemonClient = MockBuildDaemonClient(); mockOperatingSystemUtils = MockOperatingSystemUtils(); mockDwds = MockDwds(); - mockProcessManager = MockProcessManager(); + mockProcessUtils = MockProcessUtils(); when(mockBuildDaemonCreator.startBuildDaemon(any, release: anyNamed('release'), initializePlatform: anyNamed('initializePlatform'))) .thenAnswer((Invocation invocation) async { lastInitializePlatform = invocation.namedArguments[#initializePlatform] as bool; @@ -55,14 +54,15 @@ void main() { when(mockOperatingSystemUtils.findFreePort()).thenAnswer((Invocation _) async { return 1234; }); - when(mockProcessManager.start( + when(mockProcessUtils.stream( any, workingDirectory: anyNamed('workingDirectory'), + mapFunction: anyNamed('mapFunction'), environment: anyNamed('environment'), )).thenAnswer((Invocation invocation) async { final String workingDirectory = invocation.namedArguments[#workingDirectory] as String; globals.fs.file(globals.fs.path.join(workingDirectory, '.packages')).createSync(recursive: true); - return FakeProcess(); + return 0; }); when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) { return Stream.fromFuture(Future.value( @@ -93,7 +93,7 @@ void main() { OperatingSystemUtils: () => mockOperatingSystemUtils, BuildDaemonCreator: () => mockBuildDaemonCreator, ChromeLauncher: () => mockChromeLauncher, - ProcessManager: () => mockProcessManager, + ProcessUtils: () => mockProcessUtils, HttpMultiServerFactory: () => (dynamic address, int port) async { lastAddress = address; lastPort = port; @@ -216,7 +216,7 @@ void main() { port: '1234', urlTunneller: null, dartDefines: const [], - ), throwsException); + ), throwsA(isInstanceOf())); })); } @@ -226,5 +226,5 @@ class MockDwds extends Mock implements Dwds {} class MockHttpMultiServer extends Mock implements HttpMultiServer {} class MockChromeLauncher extends Mock implements ChromeLauncher {} class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {} +class MockProcessUtils extends Mock implements ProcessUtils {} class MockPub extends Mock implements Pub {} -class MockProcessManager extends Mock implements ProcessManager {} diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index fb446bc744e..419674a7fcb 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 -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that @@ -91,9 +91,6 @@ 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; @@ -107,7 +104,7 @@ Matcher throwsToolExit({ int exitCode, Pattern message }) { } /// Matcher for [ToolExit]s. -final test_package.TypeMatcher isToolExit = isA(); +final Matcher isToolExit = isInstanceOf(); /// Matcher for functions that throw [ProcessExit]. Matcher throwsProcessExit([ dynamic exitCode ]) { @@ -117,7 +114,7 @@ Matcher throwsProcessExit([ dynamic exitCode ]) { } /// Matcher for [ProcessExit]s. -final test_package.TypeMatcher isProcessExit = isA(); +final Matcher isProcessExit = isInstanceOf(); /// 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/src/context.dart b/packages/flutter_tools/test/src/context.dart index ad679441e38..80d2d303775 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -12,7 +12,6 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/signals.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/time.dart'; @@ -64,9 +63,6 @@ void testUsingContext( 'that you are dealing with in your test.' ); } - if (overrides.containsKey(ProcessUtils)) { - throw StateError('Do not inject ProcessUtils for testing, use ProcessManager instead.'); - } // Ensure we don't rely on the default [Config] constructor which will // leak a sticky $HOME/.flutter_settings behind! diff --git a/packages/flutter_tools/test/src/testbed.dart b/packages/flutter_tools/test/src/testbed.dart index 4bd9694b1a5..5934d282142 100644 --- a/packages/flutter_tools/test/src/testbed.dart +++ b/packages/flutter_tools/test/src/testbed.dart @@ -12,7 +12,6 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/signals.dart'; import 'package:flutter_tools/src/base/terminal.dart'; @@ -114,9 +113,6 @@ class Testbed { // Add the test-specific overrides ...?overrides, }; - if (testOverrides.containsKey(ProcessUtils)) { - throw StateError('Do not inject ProcessUtils for testing, use ProcessManager instead.'); - } // Cache the original flutter root to restore after the test case. final String originalFlutterRoot = Cache.flutterRoot; // Track pending timers to verify that they were correctly cleaned up. diff --git a/packages/flutter_tools/test/template_test.dart b/packages/flutter_tools/test/template_test.dart index 936cf5702ce..2aedd4e7449 100644 --- a/packages/flutter_tools/test/template_test.dart +++ b/packages/flutter_tools/test/template_test.dart @@ -2,6 +2,7 @@ // 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; @@ -23,7 +24,7 @@ void main() { when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException()); expect(() => template.render(mockDirectory, {}), - throwsToolExit()); + throwsA(isInstanceOf())); })); } diff --git a/packages/fuchsia_remote_debug_protocol/test/common.dart b/packages/fuchsia_remote_debug_protocol/test/common.dart index ea979f0e63c..bc195e5a610 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. -test_package.TypeMatcher isInstanceOf() => isA(); +Matcher isInstanceOf() => test_package.TypeMatcher(); 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 833d79b2bd3..94d9849d29c 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(isA())); + throwsA(isInstanceOf())); }); }); } 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 c3ae83a88fb..832ed6949fe 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(isA())); + expect(failingFunction, throwsA(isInstanceOf())); }); 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(isA())); + expect(failingFunction, throwsA(isInstanceOf())); }); }); @@ -346,7 +346,7 @@ void main() { await vm.invokeRpc('somesillyfunction', timeout: timeoutTime); } - expect(failingFunction, throwsA(isA())); + expect(failingFunction, throwsA(isInstanceOf())); }); }); } 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 e2a86706d3c..6e5567c1d40 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(isA())); + expect(failingFunction, throwsA(isInstanceOf())); }); test('verify correct args with config', () async {