diff --git a/dev/bots/check_tests_cross_imports.dart b/dev/bots/check_tests_cross_imports.dart index 08e1783ab6d..2a78194b599 100644 --- a/dev/bots/check_tests_cross_imports.dart +++ b/dev/bots/check_tests_cross_imports.dart @@ -111,27 +111,19 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/text_test.dart', 'packages/flutter/test/widgets/reorderable_list_test.dart', 'packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart', - 'packages/flutter/test/widgets/async_lifecycle_test.dart', 'packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart', 'packages/flutter/test/widgets/scrollable_restoration_test.dart', 'packages/flutter/test/widgets/text_golden_test.dart', - 'packages/flutter/test/widgets/multi_view_parent_data_test.dart', - 'packages/flutter/test/widgets/view_test.dart', 'packages/flutter/test/widgets/two_dimensional_viewport_test.dart', 'packages/flutter/test/widgets/list_view_viewporting_test.dart', 'packages/flutter/test/widgets/table_test.dart', 'packages/flutter/test/widgets/shortcuts_test.dart', 'packages/flutter/test/widgets/ticker_provider_test.dart', - 'packages/flutter/test/widgets/slotted_render_object_widget_test.dart', - 'packages/flutter/test/widgets/semantics_2_test.dart', 'packages/flutter/test/widgets/semantics_clipping_test.dart', - 'packages/flutter/test/widgets/reparent_state_test.dart', - 'packages/flutter/test/widgets/transitions_test.dart', 'packages/flutter/test/widgets/restoration_scopes_moving_test.dart', 'packages/flutter/test/widgets/linked_scroll_view_test.dart', 'packages/flutter/test/widgets/sliver_floating_header_test.dart', 'packages/flutter/test/widgets/page_transitions_test.dart', - 'packages/flutter/test/widgets/parent_data_test.dart', 'packages/flutter/test/widgets/editable_text_scribble_test.dart', 'packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart', 'packages/flutter/test/widgets/autofill_group_test.dart', @@ -139,68 +131,47 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/range_maintaining_scroll_physics_test.dart', 'packages/flutter/test/widgets/scroll_position_test.dart', 'packages/flutter/test/widgets/sliver_tree_test.dart', - 'packages/flutter/test/widgets/binding_live_test.dart', 'packages/flutter/test/widgets/interactive_viewer_test.dart', - 'packages/flutter/test/widgets/list_view_fling_test.dart', 'packages/flutter/test/widgets/selectable_region_test.dart', - 'packages/flutter/test/widgets/selectable_text_test.dart', 'packages/flutter/test/widgets/editable_text_scribe_test.dart', - 'packages/flutter/test/widgets/semantics_7_test.dart', 'packages/flutter/test/widgets/scrollable_test.dart', 'packages/flutter/test/widgets/semantics_debugger_test.dart', 'packages/flutter/test/widgets/semantics_test.dart', 'packages/flutter/test/widgets/page_route_builder_test.dart', - 'packages/flutter/test/widgets/opacity_repaint_test.dart', 'packages/flutter/test/widgets/two_dimensional_scroll_view_test.dart', 'packages/flutter/test/widgets/routes_test.dart', 'packages/flutter/test/widgets/listener_test.dart', 'packages/flutter/test/widgets/text_selection_test.dart', - 'packages/flutter/test/widgets/list_view_relayout_test.dart', - 'packages/flutter/test/widgets/semantics_4_test.dart', - 'packages/flutter/test/widgets/multi_view_binding_test.dart', 'packages/flutter/test/widgets/app_test.dart', 'packages/flutter/test/widgets/widget_inspector_test.dart', 'packages/flutter/test/widgets/radio_group_test.dart', 'packages/flutter/test/widgets/list_view_test.dart', - 'packages/flutter/test/widgets/binding_deferred_first_frame_test.dart', 'packages/flutter/test/widgets/sliver_resizing_header_test.dart', 'packages/flutter/test/widgets/navigator_replacement_test.dart', - 'packages/flutter/test/widgets/scroll_delegate_test.dart', 'packages/flutter/test/widgets/implicit_animations_test.dart', - 'packages/flutter/test/widgets/list_view_correction_test.dart', 'packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart', 'packages/flutter/test/widgets/page_storage_test.dart', 'packages/flutter/test/widgets/sliver_main_axis_group_test.dart', - 'packages/flutter/test/widgets/semantics_zero_surface_size_test.dart', 'packages/flutter/test/widgets/color_filter_test.dart', 'packages/flutter/test/widgets/semantics_merge_test.dart', - 'packages/flutter/test/widgets/semantics_9_test.dart', 'packages/flutter/test/widgets/modal_barrier_test.dart', 'packages/flutter/test/widgets/sliver_semantics_test.dart', 'packages/flutter/test/widgets/slivers_padding_test.dart', 'packages/flutter/test/widgets/sliver_constraints_test.dart', 'packages/flutter/test/widgets/autocomplete_test.dart', - 'packages/flutter/test/widgets/icon_data_test.dart', 'packages/flutter/test/widgets/expansible_test.dart', 'packages/flutter/test/widgets/decorated_sliver_test.dart', 'packages/flutter/test/widgets/shape_decoration_test.dart', - 'packages/flutter/test/widgets/semantics_refactor_regression_test.dart', 'packages/flutter/test/widgets/run_app_test.dart', - 'packages/flutter/test/widgets/animated_opacity_repaint_test.dart', - 'packages/flutter/test/widgets/semantics_6_test.dart', 'packages/flutter/test/widgets/shadow_test.dart', 'packages/flutter/test/widgets/routes_transition_test.dart', 'packages/flutter/test/widgets/placeholder_test.dart', - 'packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart', 'packages/flutter/test/widgets/route_notification_messages_test.dart', 'packages/flutter/test/widgets/animated_cross_fade_test.dart', 'packages/flutter/test/widgets/editable_text_shortcuts_test.dart', 'packages/flutter/test/widgets/gesture_detector_test.dart', - 'packages/flutter/test/widgets/tree_shape_test.dart', - 'packages/flutter/test/widgets/rich_text_test.dart', 'packages/flutter/test/widgets/router_test.dart', 'packages/flutter/test/widgets/scroll_notification_test.dart', - 'packages/flutter/test/widgets/sensitive_content_error_handling_test.dart', 'packages/flutter/test/widgets/magnifier_test.dart', 'packages/flutter/test/widgets/backdrop_filter_test.dart', 'packages/flutter/test/widgets/editable_text_test.dart', @@ -209,11 +180,6 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/scrollable_helpers_test.dart', 'packages/flutter/test/widgets/slivers_appbar_stretch_test.dart', 'packages/flutter/test/widgets/sliver_cross_axis_group_test.dart', - 'packages/flutter/test/widgets/drag_boundary_test.dart', - 'packages/flutter/test/widgets/semantics_traversal_test.dart', - 'packages/flutter/test/widgets/sensitive_content_unknown_test.dart', - 'packages/flutter/test/widgets/overlay_test.dart', - 'packages/flutter/test/widgets/semantics_8_test.dart', 'packages/flutter/test/widgets/list_wheel_scroll_view_test.dart', 'packages/flutter/test/widgets/scrollable_dispose_test.dart', 'packages/flutter/test/widgets/pop_scope_test.dart', @@ -223,33 +189,23 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/obscured_animated_image_test.dart', 'packages/flutter/test/widgets/platform_menu_bar_test.dart', 'packages/flutter/test/widgets/inherited_test.dart', - 'packages/flutter/test/widgets/sliver_fill_viewport_test.dart', - 'packages/flutter/test/widgets/wrap_test.dart', 'packages/flutter/test/widgets/heroes_test.dart', - 'packages/flutter/test/widgets/overlay_portal_test.dart', 'packages/flutter/test/widgets/slivers_evil_test.dart', - 'packages/flutter/test/widgets/semantics_11_test.dart', 'packages/flutter/test/widgets/container_test.dart', 'packages/flutter/test/widgets/drawer_test.dart', 'packages/flutter/test/widgets/framework_test.dart', 'packages/flutter/test/widgets/ticker_mode_test.dart', 'packages/flutter/test/widgets/absorb_pointer_test.dart', 'packages/flutter/test/widgets/semantics_role_checks_test.dart', - 'packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart', 'packages/flutter/test/widgets/media_query_test.dart', 'packages/flutter/test/widgets/editable_text_cursor_test.dart', 'packages/flutter/test/widgets/sliver_fill_remaining_test.dart', - 'packages/flutter/test/widgets/router_restoration_test.dart', 'packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart', 'packages/flutter/test/widgets/editable_text_show_on_screen_test.dart', 'packages/flutter/test/widgets/system_context_menu_test.dart', - 'packages/flutter/test/widgets/error_widget_test.dart', - 'packages/flutter/test/widgets/semantics_checks_test.dart', 'packages/flutter/test/widgets/scrollable_fling_test.dart', 'packages/flutter/test/widgets/debug_test.dart', 'packages/flutter/test/widgets/banner_test.dart', - 'packages/flutter/test/widgets/sensitive_content_test.dart', - 'packages/flutter/test/widgets/semantics_10_test.dart', 'packages/flutter/test/widgets/sliver_persistent_header_test.dart', 'packages/flutter/test/widgets/transformed_scrollable_test.dart', 'packages/flutter/test/widgets/run_app_async_test.dart', @@ -263,26 +219,17 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/spell_check_test.dart', 'packages/flutter/test/widgets/slivers_appbar_floating_test.dart', 'packages/flutter/test/widgets/toggleable_test.dart', - 'packages/flutter/test/widgets/semantics_1_test.dart', - 'packages/flutter/test/widgets/sensitive_content_host_test.dart', 'packages/flutter/test/widgets/mouse_region_test.dart', 'packages/flutter/test/widgets/draggable_test.dart', 'packages/flutter/test/widgets/page_transitions_builder_test.dart', 'packages/flutter/test/widgets/selectable_region_context_menu_test.dart', - 'packages/flutter/test/widgets/default_colors_test.dart', - 'packages/flutter/test/widgets/multi_view_tree_updates_test.dart', 'packages/flutter/test/widgets/sliversemantics_test.dart', 'packages/flutter/test/widgets/scroll_activity_test.dart', 'packages/flutter/test/widgets/tap_region_test.dart', 'packages/flutter/test/widgets/lookup_boundary_test.dart', 'packages/flutter/test/widgets/reassemble_test.dart', - 'packages/flutter/test/widgets/semantics_5_test.dart', - 'packages/flutter/test/widgets/clip_test.dart', - 'packages/flutter/test/widgets/independent_widget_layout_test.dart', - 'packages/flutter/test/widgets/binding_first_frame_developer_test.dart', 'packages/flutter/test/widgets/html_element_view_test.dart', 'packages/flutter/test/widgets/navigator_test.dart', - 'packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart', 'packages/flutter/test/widgets/text_semantics_test.dart', 'packages/flutter/test/widgets/safe_area_test.dart', 'packages/flutter/test/widgets/page_view_test.dart', @@ -290,15 +237,12 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/scroll_view_test.dart', 'packages/flutter/test/widgets/focus_traversal_test.dart', 'packages/flutter/test/widgets/sliver_list_test.dart', - 'packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart', 'packages/flutter/test/widgets/page_forward_transitions_test.dart', 'packages/flutter/test/widgets/context_menu_controller_test.dart', - 'packages/flutter/test/widgets/semantics_3_test.dart', 'packages/flutter/test/widgets/slivers_test.dart', 'packages/flutter/test/widgets/navigator_restoration_test.dart', 'packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart', 'packages/flutter/test/widgets/simple_semantics_test.dart', - 'packages/flutter/test/widgets/sliver_appbar_opacity_test.dart', 'packages/flutter/test/widgets/image_filter_test.dart', 'packages/flutter/test/widgets/navigator_on_did_remove_page_test.dart', 'packages/flutter/test/widgets/opacity_test.dart', @@ -307,15 +251,11 @@ class TestsCrossImportChecker { 'packages/flutter/test/widgets/scrollable_semantics_test.dart', 'packages/flutter/test/widgets/sliver_visibility_test.dart', 'packages/flutter/test/widgets/rotated_box_test.dart', - 'packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart', 'packages/flutter/test/widgets/single_child_scroll_view_test.dart', 'packages/flutter/test/widgets/pinned_header_sliver_test.dart', - 'packages/flutter/test/widgets/focus_manager_test.dart', 'packages/flutter/test/widgets/raw_radio_test.dart', 'packages/flutter/test/widgets/syncing_test.dart', 'packages/flutter/test/widgets/form_test.dart', - 'packages/flutter/test/widgets/implicit_semantics_test.dart', - 'packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart', }; /// These Cupertino tests are known to have cross imports. These cross imports @@ -341,7 +281,6 @@ class TestsCrossImportChecker { 'packages/flutter/test/cupertino/magnifier_test.dart', 'packages/flutter/test/cupertino/text_field_restoration_test.dart', 'packages/flutter/test/cupertino/sheet_test.dart', - 'packages/flutter/test/cupertino/action_sheet_test.dart', 'packages/flutter/test/cupertino/form_row_test.dart', 'packages/flutter/test/cupertino/colors_test.dart', 'packages/flutter/test/cupertino/text_form_field_row_restoration_test.dart', diff --git a/packages/flutter/test/cupertino/action_sheet_test.dart b/packages/flutter/test/cupertino/action_sheet_test.dart index 5286f2ad84e..0726d580fbc 100644 --- a/packages/flutter/test/cupertino/action_sheet_test.dart +++ b/packages/flutter/test/cupertino/action_sheet_test.dart @@ -11,7 +11,6 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -1845,9 +1844,8 @@ void main() { await tester.tap(find.text('Go')); await tester.pump(); - // The inherited ScrollBehavior should not apply Scrollbars since they are + // The inherited ScrollBehavior should not apply scrollbars since they are // already built in to the widget. - expect(find.byType(Scrollbar), findsNothing); expect(find.byType(RawScrollbar), findsNothing); // Built in CupertinoScrollbars should only number 2: one for the actions, // one for the content. @@ -2450,7 +2448,7 @@ void main() { tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; - const Color focusColor = Colors.orange; + const focusColor = Color(0xffffaaaa); final Color defaultDarkFocusColor = HSLColor.fromColor( focusColor.withOpacity(kCupertinoButtonTintedOpacityDark), diff --git a/packages/flutter/test/cupertino/app_test.dart b/packages/flutter/test/cupertino/app_test.dart index 4a889b3ce37..d5a984ad474 100644 --- a/packages/flutter/test/cupertino/app_test.dart +++ b/packages/flutter/test/cupertino/app_test.dart @@ -579,6 +579,8 @@ void main() { debugBrightnessOverride = null; }); + // TODO(justinmc): Cupertino tests should not import Material. + // https://github.com/flutter/flutter/issues/177028 testWidgets('CupertinoApp creates a Material theme with colors based off of Cupertino theme', ( WidgetTester tester, ) async { diff --git a/packages/flutter/test/cupertino/colors_test.dart b/packages/flutter/test/cupertino/colors_test.dart index 29988914acb..7e90948f4ea 100644 --- a/packages/flutter/test/cupertino/colors_test.dart +++ b/packages/flutter/test/cupertino/colors_test.dart @@ -532,6 +532,8 @@ void main() { expect(color.value, dynamicColor.darkHighContrastElevatedColor.value); }); + // TODO(justinmc): Don't test Material interactions in Cupertino tests. + // https://github.com/flutter/flutter/issues/177028 group('MaterialApp:', () { Color? color; setUp(() { diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 9f1cd246d07..5cd37c3075e 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -2140,6 +2140,8 @@ void main() { handle.dispose(); }); + // TODO(justinmc): Don't test Material interactions in Cupertino tests. + // https://github.com/flutter/flutter/issues/177028 testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async { Widget buildDatePicker(Brightness brightness) { return MaterialApp( @@ -2167,6 +2169,8 @@ void main() { expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); }); + // TODO(justinmc): Don't test Material interactions in Cupertino tests. + // https://github.com/flutter/flutter/issues/177028 testWidgets('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async { Widget buildTimerPicker(Brightness brightness) { return MaterialApp( diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 52a80a881dc..c82847e9ef3 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -1846,9 +1846,8 @@ void main() { await tester.tap(find.text('Go')); await tester.pump(); - // The inherited ScrollBehavior should not apply Scrollbars since they are + // The inherited ScrollBehavior should not apply scrollbars since they are // already built in to the widget. - expect(find.byType(Scrollbar), findsNothing); expect(find.byType(RawScrollbar), findsNothing); // Built in CupertinoScrollbars should only number 2: one for the actions, // one for the content. diff --git a/packages/flutter/test/cupertino/form_row_test.dart b/packages/flutter/test/cupertino/form_row_test.dart index 21c3f937a35..e1fcfaca80c 100644 --- a/packages/flutter/test/cupertino/form_row_test.dart +++ b/packages/flutter/test/cupertino/form_row_test.dart @@ -148,6 +148,8 @@ void main() { expect(errorTextStyle.style.color, CupertinoColors.destructiveRed); }); + // TODO(justinmc): Don't test Material interactions in Cupertino tests. + // https://github.com/flutter/flutter/issues/177028 testWidgets('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async { const Widget prefix = Text('Prefix'); const Widget helper = Text('Helper'); diff --git a/packages/flutter/test/cupertino/picker_test.dart b/packages/flutter/test/cupertino/picker_test.dart index aeb690f6363..36db3e8f89a 100644 --- a/packages/flutter/test/cupertino/picker_test.dart +++ b/packages/flutter/test/cupertino/picker_test.dart @@ -697,6 +697,8 @@ void main() { ); }); + // TODO(justinmc): Don't test Material interactions in Cupertino tests. + // https://github.com/flutter/flutter/issues/177028 testWidgets('Picker adapts to MaterialApp dark mode', (WidgetTester tester) async { Widget buildCupertinoPicker(Brightness brightness) { return MaterialApp( diff --git a/packages/flutter/test/cupertino/text_selection_test.dart b/packages/flutter/test/cupertino/text_selection_test.dart index 88baa408c78..59fd26181fc 100644 --- a/packages/flutter/test/cupertino/text_selection_test.dart +++ b/packages/flutter/test/cupertino/text_selection_test.dart @@ -555,7 +555,6 @@ void main() { localizationsDelegates: const >[ _LongCupertinoLocalizations.delegate, DefaultWidgetsLocalizations.delegate, - DefaultMaterialLocalizations.delegate, ], home: Directionality( textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/material/selectable_text_test.dart similarity index 100% rename from packages/flutter/test/widgets/selectable_text_test.dart rename to packages/flutter/test/material/selectable_text_test.dart diff --git a/packages/flutter/test/widgets/sliver_appbar_opacity_test.dart b/packages/flutter/test/material/sliver_appbar_opacity_test.dart similarity index 100% rename from packages/flutter/test/widgets/sliver_appbar_opacity_test.dart rename to packages/flutter/test/material/sliver_appbar_opacity_test.dart diff --git a/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart b/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart index fe43f81c695..fc12777b12f 100644 --- a/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart +++ b/packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart @@ -4,16 +4,18 @@ import 'dart:ui'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { + const red = Color(0xffff0000); + testWidgets('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async { RenderTestObject.paintCount = 0; await tester.pumpWidget( ColoredBox( - color: Colors.red, + color: red, child: ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), child: const TestWidget(), @@ -25,7 +27,7 @@ void main() { await tester.pumpWidget( ColoredBox( - color: Colors.red, + color: red, child: ImageFiltered( imageFilter: ImageFilter.blur(sigmaX: 6, sigmaY: 6), child: const TestWidget(), diff --git a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart index 8a2a5d2f242..b463ee2ac29 100644 --- a/packages/flutter/test/widgets/animated_opacity_repaint_test.dart +++ b/packages/flutter/test/widgets/animated_opacity_repaint_test.dart @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { + const red = Color(0xffff0000); + testWidgets('RenderAnimatedOpacityMixin does not drop layer when animating to 1', ( WidgetTester tester, ) async { @@ -19,7 +21,7 @@ void main() { final opacityTween = Tween(begin: 0, end: 1); await tester.pumpWidget( ColoredBox( - color: Colors.red, + color: red, child: FadeTransition(opacity: controller.drive(opacityTween), child: const TestWidget()), ), ); @@ -55,7 +57,7 @@ void main() { final opacityTween = Tween(begin: 0, end: 0.99); // Layer is dropped at 1 await tester.pumpWidget( ColoredBox( - color: Colors.red, + color: red, child: FadeTransition(opacity: controller.drive(opacityTween), child: const TestWidget()), ), ); @@ -92,7 +94,7 @@ void main() { await tester.pumpWidget( ColoredBox( - color: Colors.red, + color: red, child: FadeTransition(opacity: controller.drive(opacityTween), child: const TestWidget()), ), ); diff --git a/packages/flutter/test/widgets/async_lifecycle_test.dart b/packages/flutter/test/widgets/async_lifecycle_test.dart index ae9dd03dbca..2c8a6ea6d7b 100644 --- a/packages/flutter/test/widgets/async_lifecycle_test.dart +++ b/packages/flutter/test/widgets/async_lifecycle_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; @@ -49,6 +49,9 @@ class InvalidDidUpdateWidgetLifecycleWidgetState } void main() { + const red = Color(0xffff0000); + const green = Color(0xff00ff00); + testWidgets( 'async onInit throws FlutterError', experimentalLeakTesting: LeakTesting.settings @@ -65,8 +68,8 @@ void main() { experimentalLeakTesting: LeakTesting.settings .withIgnoredAll(), // leaking by design because of exception (WidgetTester tester) async { - await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.green)); - await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.red)); + await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: green)); + await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: red)); expect(tester.takeException(), isFlutterError); }, diff --git a/packages/flutter/test/widgets/binding_deferred_first_frame_test.dart b/packages/flutter/test/widgets/binding_deferred_first_frame_test.dart index a1acf62d93b..c9b65f6a566 100644 --- a/packages/flutter/test/widgets/binding_deferred_first_frame_test.dart +++ b/packages/flutter/test/widgets/binding_deferred_first_frame_test.dart @@ -4,7 +4,6 @@ import 'dart:async'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/binding_first_frame_developer_test.dart b/packages/flutter/test/widgets/binding_first_frame_developer_test.dart index 94cca9a8b13..60d6ffc67f2 100644 --- a/packages/flutter/test/widgets/binding_first_frame_developer_test.dart +++ b/packages/flutter/test/widgets/binding_first_frame_developer_test.dart @@ -5,7 +5,7 @@ import 'dart:developer' as developer; import 'dart:ui'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart b/packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart index 6ffb7403eb7..2c64664d28b 100644 --- a/packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart +++ b/packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart @@ -5,7 +5,7 @@ import 'dart:ui'; import 'package:fake_async/fake_async.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/binding_live_test.dart b/packages/flutter/test/widgets/binding_live_test.dart index 72f7d3e0e72..54fa14b3788 100644 --- a/packages/flutter/test/widgets/binding_live_test.dart +++ b/packages/flutter/test/widgets/binding_live_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; // This file is for tests for WidgetsBinding that require a `LiveTestWidgetsFlutterBinding`. diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index edd3985136b..8b718c8cbc4 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -8,8 +8,8 @@ @Tags(['reduced-test-set']) library; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'test_border.dart' show TestBorder; @@ -58,6 +58,11 @@ class NotifyClipper extends CustomClipper { } void main() { + const black = Color(0xff000000); + const white = Color(0xffffffff); + const red = Color(0xffff0000); + const blue = Color(0xff0000ff); + testWidgets('ClipRect with a FittedBox child sized to zero works with semantics', ( WidgetTester tester, ) async { @@ -379,7 +384,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -389,13 +394,11 @@ void main() { angle: 1.0, // radians child: ClipRect( child: ColoredBox( - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -421,14 +424,14 @@ void main() { left: 0.0, width: 100.0, height: 100.0, - child: ClipRect(child: Container(color: Colors.blue)), + child: ClipRect(child: Container(color: blue)), ), Positioned( top: 50.0, left: 50.0, width: 100.0, height: 100.0, - child: Transform.rotate(angle: 1.0, child: Container(color: Colors.red)), + child: Transform.rotate(angle: 1.0, child: Container(color: red)), ), ], ), @@ -445,7 +448,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -461,13 +464,11 @@ void main() { bottomRight: Radius.elliptical(15.0, 6.0), ), child: ColoredBox( - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -487,7 +488,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -497,13 +498,11 @@ void main() { angle: 1.0, // radians child: ClipOval( child: ColoredBox( - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -523,7 +522,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -538,13 +537,11 @@ void main() { ), ), child: ColoredBox( - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -563,7 +560,7 @@ void main() { return Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -573,14 +570,12 @@ void main() { angle: 1.0, // radians child: PhysicalModel( borderRadius: const BorderRadius.all(Radius.circular(20.0)), - color: Colors.red, + color: red, clipBehavior: clipBehavior, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -625,7 +620,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -635,13 +630,11 @@ void main() { angle: 1.0, // radians child: PhysicalModel( borderRadius: const BorderRadius.all(Radius.circular(20.0)), - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -662,7 +655,7 @@ void main() { return Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -677,13 +670,11 @@ void main() { ), ), clipBehavior: clipBehavior, - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), @@ -726,7 +717,7 @@ void main() { Center( child: RepaintBoundary( child: ColoredBox( - color: Colors.white, + color: white, child: Padding( padding: const EdgeInsets.all(100.0), child: SizedBox( @@ -740,13 +731,11 @@ void main() { borderRadius: BorderRadius.all(Radius.circular(20.0)), ), ), - color: Colors.red, + color: red, child: ColoredBox( - color: Colors.white, + color: white, child: RepaintBoundary( - child: Center( - child: Container(color: Colors.black, height: 10.0, width: 10.0), - ), + child: Center(child: Container(color: black, height: 10.0, width: 10.0)), ), ), ), diff --git a/packages/flutter/test/widgets/default_colors_test.dart b/packages/flutter/test/widgets/default_colors_test.dart index c52b20c7a1f..bb5f469727e 100644 --- a/packages/flutter/test/widgets/default_colors_test.dart +++ b/packages/flutter/test/widgets/default_colors_test.dart @@ -5,7 +5,7 @@ import 'dart:typed_data'; import 'dart:ui' as ui; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import '../impeller_test_helpers.dart'; diff --git a/packages/flutter/test/widgets/drag_boundary_test.dart b/packages/flutter/test/widgets/drag_boundary_test.dart index 40fe0d5a247..156d3c3d048 100644 --- a/packages/flutter/test/widgets/drag_boundary_test.dart +++ b/packages/flutter/test/widgets/drag_boundary_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index 09045bf7584..f61532fb619 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -135,6 +135,8 @@ void main() { expect(tester.testTextInput.setClientArgs!['inputAction'], equals(serializedActionName)); } + // TODO(justinmc): Widgets tests should not import Material. + // https://github.com/flutter/flutter/issues/177028 testWidgets( 'Tapping the Live Text button calls onLiveTextInput', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/editable_text_utils.dart b/packages/flutter/test/widgets/editable_text_utils.dart index e1c58d2f1ce..d44040d3131 100644 --- a/packages/flutter/test/widgets/editable_text_utils.dart +++ b/packages/flutter/test/widgets/editable_text_utils.dart @@ -3,9 +3,9 @@ // 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'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; /// On web, the context menu (aka toolbar) is provided by the browser. @@ -135,7 +135,7 @@ class OverflowWidgetTextEditingController extends TextEditingController { style: style, children: [ const TextSpan(text: 'Hi'), - WidgetSpan(child: Container(color: Colors.redAccent, height: 100.0)), + WidgetSpan(child: Container(color: const Color(0xffff0000), height: 100.0)), ], ); } diff --git a/packages/flutter/test/widgets/error_widget_test.dart b/packages/flutter/test/widgets/error_widget_test.dart index b4fa5370178..cb03630bcef 100644 --- a/packages/flutter/test/widgets/error_widget_test.dart +++ b/packages/flutter/test/widgets/error_widget_test.dart @@ -3,11 +3,13 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; void main() { + const red = Color(0xffff0000); + testWidgets('ErrorWidget displays actual error when throwing during build', ( WidgetTester tester, ) async { @@ -17,7 +19,7 @@ void main() { await tester.pumpWidget( Container( key: container, - color: Colors.red, + color: red, padding: const EdgeInsets.all(10), child: Builder( builder: (BuildContext context) { @@ -53,7 +55,7 @@ void main() { await tester.pumpWidget( Container( key: container, - color: Colors.red, + color: red, padding: const EdgeInsets.all(10), // This widget throws during build, which causes the construction of an // ErrorWidget with the build error. However, during construction of diff --git a/packages/flutter/test/widgets/focus_manager_test.dart b/packages/flutter/test/widgets/focus_manager_test.dart index 0d86dfa1849..57279283ae7 100644 --- a/packages/flutter/test/widgets/focus_manager_test.dart +++ b/packages/flutter/test/widgets/focus_manager_test.dart @@ -6,7 +6,6 @@ import 'dart:math' as math; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter/test/widgets/icon_data_test.dart b/packages/flutter/test/widgets/icon_data_test.dart index d5ba951a439..727190dce10 100644 --- a/packages/flutter/test/widgets/icon_data_test.dart +++ b/packages/flutter/test/widgets/icon_data_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/implicit_semantics_test.dart b/packages/flutter/test/widgets/implicit_semantics_test.dart index 0e932e5f2e8..ce33f8e810e 100644 --- a/packages/flutter/test/widgets/implicit_semantics_test.dart +++ b/packages/flutter/test/widgets/implicit_semantics_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/independent_widget_layout_test.dart b/packages/flutter/test/widgets/independent_widget_layout_test.dart index 34de270acfd..133b03afd92 100644 --- a/packages/flutter/test/widgets/independent_widget_layout_test.dart +++ b/packages/flutter/test/widgets/independent_widget_layout_test.dart @@ -4,8 +4,8 @@ import 'dart:ui' show FlutterView; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; class ScheduledFrameTrackingPlatformDispatcher extends TestPlatformDispatcher { diff --git a/packages/flutter/test/widgets/list_view_correction_test.dart b/packages/flutter/test/widgets/list_view_correction_test.dart index f8cc03a9b12..531a0089f8e 100644 --- a/packages/flutter/test/widgets/list_view_correction_test.dart +++ b/packages/flutter/test/widgets/list_view_correction_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/list_view_fling_test.dart b/packages/flutter/test/widgets/list_view_fling_test.dart index ebf7019b4b4..18e3eaa4fc6 100644 --- a/packages/flutter/test/widgets/list_view_fling_test.dart +++ b/packages/flutter/test/widgets/list_view_fling_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; const double kHeight = 10.0; diff --git a/packages/flutter/test/widgets/list_view_relayout_test.dart b/packages/flutter/test/widgets/list_view_relayout_test.dart index e6ce1ac4deb..09dddb9a7ec 100644 --- a/packages/flutter/test/widgets/list_view_relayout_test.dart +++ b/packages/flutter/test/widgets/list_view_relayout_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/multi_view_binding_test.dart b/packages/flutter/test/widgets/multi_view_binding_test.dart index d4c7f842374..be7269c0e9c 100644 --- a/packages/flutter/test/widgets/multi_view_binding_test.dart +++ b/packages/flutter/test/widgets/multi_view_binding_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; @@ -28,7 +28,7 @@ void main() { final rootWidget = RootWidget( child: View( view: FakeFlutterView(tester.view), - child: const ColoredBox(color: Colors.orange), + child: const ColoredBox(color: Color(0xfffff3e0)), ), ); tester.binding.attachToBuildOwner(rootWidget); diff --git a/packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart b/packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart index a53dbd55107..79eaf61b79c 100644 --- a/packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart +++ b/packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'multi_view_testing.dart'; diff --git a/packages/flutter/test/widgets/multi_view_parent_data_test.dart b/packages/flutter/test/widgets/multi_view_parent_data_test.dart index 8c3683e27bd..ba5be26f92a 100644 --- a/packages/flutter/test/widgets/multi_view_parent_data_test.dart +++ b/packages/flutter/test/widgets/multi_view_parent_data_test.dart @@ -2,8 +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/cupertino.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'multi_view_testing.dart'; diff --git a/packages/flutter/test/widgets/multi_view_tree_updates_test.dart b/packages/flutter/test/widgets/multi_view_tree_updates_test.dart index e0b7c851473..72752603c6b 100644 --- a/packages/flutter/test/widgets/multi_view_tree_updates_test.dart +++ b/packages/flutter/test/widgets/multi_view_tree_updates_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'multi_view_testing.dart'; diff --git a/packages/flutter/test/widgets/observer_tester.dart b/packages/flutter/test/widgets/observer_tester.dart index 597d652f4bc..fb0a89f7942 100644 --- a/packages/flutter/test/widgets/observer_tester.dart +++ b/packages/flutter/test/widgets/observer_tester.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; typedef OnObservation = void Function(Route? route, Route? previousRoute); diff --git a/packages/flutter/test/widgets/opacity_repaint_test.dart b/packages/flutter/test/widgets/opacity_repaint_test.dart index 1ca3cce4d58..3138e94e250 100644 --- a/packages/flutter/test/widgets/opacity_repaint_test.dart +++ b/packages/flutter/test/widgets/opacity_repaint_test.dart @@ -2,18 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { + const red = Color(0xffff0000); + testWidgets('RenderOpacity avoids repainting and does not drop layer at fully opaque', ( WidgetTester tester, ) async { RenderTestObject.paintCount = 0; await tester.pumpWidget( const ColoredBox( - color: Colors.red, + color: red, child: Opacity(opacity: 0.0, child: TestWidget()), ), ); @@ -22,7 +24,7 @@ void main() { await tester.pumpWidget( const ColoredBox( - color: Colors.red, + color: red, child: Opacity(opacity: 0.1, child: TestWidget()), ), ); @@ -31,7 +33,7 @@ void main() { await tester.pumpWidget( const ColoredBox( - color: Colors.red, + color: red, child: Opacity(opacity: 1, child: TestWidget()), ), ); @@ -46,7 +48,7 @@ void main() { await tester.pumpWidget( const ColoredBox( - color: Colors.red, + color: red, child: Opacity(opacity: 0.5, child: TestWidget()), ), ); @@ -55,7 +57,7 @@ void main() { await tester.pumpWidget( const ColoredBox( - color: Colors.red, + color: red, child: Opacity(opacity: 0.0, child: TestWidget()), ), ); diff --git a/packages/flutter/test/widgets/overlay_portal_test.dart b/packages/flutter/test/widgets/overlay_portal_test.dart index 8a0f2ca57fa..0ad0b7f0268 100644 --- a/packages/flutter/test/widgets/overlay_portal_test.dart +++ b/packages/flutter/test/widgets/overlay_portal_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/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/src/foundation/constants.dart'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index b5982ef81f8..c4f82111cd5 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index cc9da857241..5c29f2632db 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_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/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 41e475d177b..0660d9eb280 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; class StateMarker extends StatefulWidget { @@ -47,6 +47,8 @@ class DeactivateLoggerState extends State { } void main() { + const green = Color(0xff00ff00); + testWidgets('can reparent state', (WidgetTester tester) async { final GlobalKey left = GlobalKey(); final GlobalKey right = GlobalKey(); @@ -57,11 +59,11 @@ void main() { textDirection: TextDirection.ltr, children: [ ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: left), ), ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: right, child: grandchild), ), ], @@ -83,11 +85,11 @@ void main() { textDirection: TextDirection.ltr, children: [ ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: right, child: newGrandchild), ), ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: left), ), ], @@ -107,7 +109,7 @@ void main() { await tester.pumpWidget( Center( child: ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: left, child: Container()), ), ), @@ -166,7 +168,7 @@ void main() { await tester.pumpWidget( Center( child: ColoredBox( - color: Colors.green, + color: green, child: StateMarker(key: left, child: Container()), ), ), diff --git a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart index 615e42993d6..8258a01e34d 100644 --- a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; // This is a regression test for https://github.com/flutter/flutter/issues/5840. @@ -95,6 +95,8 @@ void main() { var layoutBuilderChild = keyedWidget; Widget deepChild = Container(); + const green = Color(0xff00ff00); + await tester.pumpWidget( MediaQuery( data: MediaQueryData.fromView(tester.view), @@ -112,17 +114,17 @@ void main() { }, ), ColoredBox( - color: Colors.green, + color: green, child: ColoredBox( - color: Colors.green, + color: green, child: ColoredBox( - color: Colors.green, + color: green, child: ColoredBox( - color: Colors.green, + color: green, child: ColoredBox( - color: Colors.green, + color: green, child: ColoredBox( - color: Colors.green, + color: green, child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { childSetState = setState; diff --git a/packages/flutter/test/widgets/rich_text_test.dart b/packages/flutter/test/widgets/rich_text_test.dart index 061f6e5d3ff..d61c8705782 100644 --- a/packages/flutter/test/widgets/rich_text_test.dart +++ b/packages/flutter/test/widgets/rich_text_test.dart @@ -3,8 +3,8 @@ // found in the LICENSE file. import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { @@ -172,7 +172,7 @@ void main() { textDirection: TextDirection.ltr, child: Center( child: ColoredBox( - color: Colors.green, + color: const Color(0xff00ff00), child: IntrinsicHeight( child: RichText( text: const TextSpan( diff --git a/packages/flutter/test/widgets/router_restoration_test.dart b/packages/flutter/test/widgets/router_restoration_test.dart index 132166992b2..0f2802c16db 100644 --- a/packages/flutter/test/widgets/router_restoration_test.dart +++ b/packages/flutter/test/widgets/router_restoration_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 7e5cd17204d..70c831f6733 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -753,6 +753,9 @@ void main() { expect(secondaryAnimationPageOne.parent, kAlwaysDismissedAnimation); }); + // TODO(justinmc): Widgets tests should not import Material/Cupertino. This + // test can probably go into Cupertino with a CupertinoApp. + // https://github.com/flutter/flutter/issues/177028 testWidgets( 'delegated transitions are removed when secondary animation is dismissed and next route is removed', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/scroll_delegate_test.dart b/packages/flutter/test/widgets/scroll_delegate_test.dart index d4689b21fae..09863320217 100644 --- a/packages/flutter/test/widgets/scroll_delegate_test.dart +++ b/packages/flutter/test/widgets/scroll_delegate_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; diff --git a/packages/flutter/test/widgets/semantics_10_test.dart b/packages/flutter/test/widgets/semantics_10_test.dart index 11cb1074bc9..697f565d56d 100644 --- a/packages/flutter/test/widgets/semantics_10_test.dart +++ b/packages/flutter/test/widgets/semantics_10_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/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_11_test.dart b/packages/flutter/test/widgets/semantics_11_test.dart index bd706b0e84f..d0be354872c 100644 --- a/packages/flutter/test/widgets/semantics_11_test.dart +++ b/packages/flutter/test/widgets/semantics_11_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/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_1_test.dart b/packages/flutter/test/widgets/semantics_1_test.dart index 281d083f856..82f21e3d50c 100644 --- a/packages/flutter/test/widgets/semantics_1_test.dart +++ b/packages/flutter/test/widgets/semantics_1_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_2_test.dart b/packages/flutter/test/widgets/semantics_2_test.dart index f5975171dea..781cb1a790b 100644 --- a/packages/flutter/test/widgets/semantics_2_test.dart +++ b/packages/flutter/test/widgets/semantics_2_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_3_test.dart b/packages/flutter/test/widgets/semantics_3_test.dart index 9ffb4e0dd6a..3786feea858 100644 --- a/packages/flutter/test/widgets/semantics_3_test.dart +++ b/packages/flutter/test/widgets/semantics_3_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_4_test.dart b/packages/flutter/test/widgets/semantics_4_test.dart index d8659751819..b398fef192b 100644 --- a/packages/flutter/test/widgets/semantics_4_test.dart +++ b/packages/flutter/test/widgets/semantics_4_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_5_test.dart b/packages/flutter/test/widgets/semantics_5_test.dart index 8fafc2c9782..f3a97818f9d 100644 --- a/packages/flutter/test/widgets/semantics_5_test.dart +++ b/packages/flutter/test/widgets/semantics_5_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_6_test.dart b/packages/flutter/test/widgets/semantics_6_test.dart index 13ceb5f31d8..7776bce7050 100644 --- a/packages/flutter/test/widgets/semantics_6_test.dart +++ b/packages/flutter/test/widgets/semantics_6_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_7_test.dart b/packages/flutter/test/widgets/semantics_7_test.dart index 48a17bb7fc3..9aa70b179fd 100644 --- a/packages/flutter/test/widgets/semantics_7_test.dart +++ b/packages/flutter/test/widgets/semantics_7_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_8_test.dart b/packages/flutter/test/widgets/semantics_8_test.dart index 7d777b556ea..c52deb1a55a 100644 --- a/packages/flutter/test/widgets/semantics_8_test.dart +++ b/packages/flutter/test/widgets/semantics_8_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_9_test.dart b/packages/flutter/test/widgets/semantics_9_test.dart index dcc2700d7f0..e288071000f 100644 --- a/packages/flutter/test/widgets/semantics_9_test.dart +++ b/packages/flutter/test/widgets/semantics_9_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/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_checks_test.dart b/packages/flutter/test/widgets/semantics_checks_test.dart index 3beb5da32f3..71e6eef2066 100644 --- a/packages/flutter/test/widgets/semantics_checks_test.dart +++ b/packages/flutter/test/widgets/semantics_checks_test.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/semantics_refactor_regression_test.dart b/packages/flutter/test/widgets/semantics_refactor_regression_test.dart index f80d018c821..57dcdf66ae0 100644 --- a/packages/flutter/test/widgets/semantics_refactor_regression_test.dart +++ b/packages/flutter/test/widgets/semantics_refactor_regression_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_traversal_test.dart b/packages/flutter/test/widgets/semantics_traversal_test.dart index 6dc5f8485ce..55cab4a0bad 100644 --- a/packages/flutter/test/widgets/semantics_traversal_test.dart +++ b/packages/flutter/test/widgets/semantics_traversal_test.dart @@ -5,7 +5,6 @@ import 'dart:collection'; import 'dart:math' as math; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart b/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart index 27c5764840f..a0ab0f86b5b 100644 --- a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart +++ b/packages/flutter/test/widgets/semantics_zero_surface_size_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/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/sensitive_content_error_handling_test.dart b/packages/flutter/test/widgets/sensitive_content_error_handling_test.dart index bd913c0f877..a8bfa8b9d20 100644 --- a/packages/flutter/test/widgets/sensitive_content_error_handling_test.dart +++ b/packages/flutter/test/widgets/sensitive_content_error_handling_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'sensitive_content_utils.dart'; diff --git a/packages/flutter/test/widgets/sensitive_content_host_test.dart b/packages/flutter/test/widgets/sensitive_content_host_test.dart index 92802461d45..6c6f5b5707c 100644 --- a/packages/flutter/test/widgets/sensitive_content_host_test.dart +++ b/packages/flutter/test/widgets/sensitive_content_host_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'sensitive_content_utils.dart'; diff --git a/packages/flutter/test/widgets/sensitive_content_test.dart b/packages/flutter/test/widgets/sensitive_content_test.dart index 7a98779e694..85491d80c29 100644 --- a/packages/flutter/test/widgets/sensitive_content_test.dart +++ b/packages/flutter/test/widgets/sensitive_content_test.dart @@ -4,8 +4,8 @@ import 'dart:async' show Completer; -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'sensitive_content_utils.dart'; diff --git a/packages/flutter/test/widgets/sensitive_content_unknown_test.dart b/packages/flutter/test/widgets/sensitive_content_unknown_test.dart index 630ec618317..ab2159551df 100644 --- a/packages/flutter/test/widgets/sensitive_content_unknown_test.dart +++ b/packages/flutter/test/widgets/sensitive_content_unknown_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { diff --git a/packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart b/packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart index 27e12dfeef6..f6114ec2b30 100644 --- a/packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart +++ b/packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import '../rendering/rendering_tester.dart' show TestClipPaintingContext; diff --git a/packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart b/packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart index ebdf018d472..0bd3a1bcb5a 100644 --- a/packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart +++ b/packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; const double VIEWPORT_HEIGHT = 500; diff --git a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart index 09f635fb337..09c33044549 100644 --- a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('SliverFillViewport control test', (WidgetTester tester) async { final children = List.generate(20, (int i) { return ColoredBox( - color: Colors.green, + color: const Color(0xff00ff00), child: Text('$i', textDirection: TextDirection.ltr), ); }); diff --git a/packages/flutter/test/widgets/slotted_render_object_widget_test.dart b/packages/flutter/test/widgets/slotted_render_object_widget_test.dart index 504c45cb229..77250beaa5c 100644 --- a/packages/flutter/test/widgets/slotted_render_object_widget_test.dart +++ b/packages/flutter/test/widgets/slotted_render_object_widget_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/test_border.dart b/packages/flutter/test/widgets/test_border.dart index 9a1478b4312..e4d425bae83 100644 --- a/packages/flutter/test/widgets/test_border.dart +++ b/packages/flutter/test/widgets/test_border.dart @@ -2,7 +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/material.dart'; +import 'package:flutter/widgets.dart'; typedef Logger = void Function(String caller); diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index 577033fa033..5ee2f653180 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { @@ -667,10 +667,7 @@ void main() { final Animation animation = Tween(begin: 0.0, end: 1.0).animate(controller); final Widget widget = Localizations( locale: const Locale('en', 'us'), - delegates: const >[ - DefaultWidgetsLocalizations.delegate, - DefaultMaterialLocalizations.delegate, - ], + delegates: const >[DefaultWidgetsLocalizations.delegate], child: Directionality( textDirection: TextDirection.ltr, child: MediaQuery( diff --git a/packages/flutter/test/widgets/tree_shape_test.dart b/packages/flutter/test/widgets/tree_shape_test.dart index b78a198ec3e..662032bb70c 100644 --- a/packages/flutter/test/widgets/tree_shape_test.dart +++ b/packages/flutter/test/widgets/tree_shape_test.dart @@ -4,19 +4,23 @@ import 'dart:ui'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import 'multi_view_testing.dart'; void main() { + const red = Color(0xffffff00); + const green = Color(0xff00ff00); + const yellow = Color(0xfffffde7); + testWidgets('Providing a RenderObjectWidget directly to the RootWidget fails', ( WidgetTester tester, ) async { // No render tree exists to attach the RenderObjectWidget to. - await tester.pumpWidget(wrapWithView: false, const ColoredBox(color: Colors.red)); + await tester.pumpWidget(wrapWithView: false, const ColoredBox(color: red)); expect( tester.takeException(), @@ -33,7 +37,7 @@ void main() { testWidgets('Moving a RenderObjectWidget to the RootWidget via GlobalKey fails', ( WidgetTester tester, ) async { - final Widget globalKeyedWidget = ColoredBox(key: GlobalKey(), color: Colors.red); + final Widget globalKeyedWidget = ColoredBox(key: GlobalKey(), color: red); await tester.pumpWidget(wrapWithView: false, View(view: tester.view, child: globalKeyedWidget)); expect(tester.takeException(), isNull); @@ -102,7 +106,7 @@ void main() { final Widget globalKeyedView = View( key: GlobalKey(), view: FakeView(tester.view), - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ); await tester.pumpWidget(wrapWithView: false, globalKeyedView); @@ -126,7 +130,7 @@ void main() { ) async { await tester.pumpWidget( ViewAnchor( - view: const ColoredBox(color: Colors.red), + view: const ColoredBox(color: red), child: Container(), ), ); @@ -146,7 +150,7 @@ void main() { testWidgets( 'A RenderObject cannot be moved into the view property of a ViewAnchor via GlobalKey', (WidgetTester tester) async { - final Widget globalKeyedWidget = ColoredBox(key: GlobalKey(), color: Colors.red); + final Widget globalKeyedWidget = ColoredBox(key: GlobalKey(), color: red); await tester.pumpWidget(ViewAnchor(child: globalKeyedWidget)); expect(tester.takeException(), isNull); @@ -216,7 +220,7 @@ void main() { ) async { final Widget globalKeyView = View( view: FakeView(tester.view), - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ); await tester.pumpWidget( @@ -289,7 +293,7 @@ void main() { ) async { await tester.pumpWidget( wrapWithView: false, - const ViewCollection(views: [ColoredBox(color: Colors.red)]), + const ViewCollection(views: [ColoredBox(color: red)]), ); expect( @@ -310,12 +314,12 @@ void main() { final Widget greenView = View( key: GlobalKey(debugLabel: 'green'), view: tester.view, - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ); final Widget redView = View( key: GlobalKey(debugLabel: 'red'), view: FakeView(tester.view), - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ); await tester.pumpWidget( @@ -369,21 +373,21 @@ void main() { views: [ View( view: greenView, - child: ColoredBox(color: Colors.green, child: globalKeyChild), + child: ColoredBox(color: green, child: globalKeyChild), ), View( view: redView, - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsOneWidget, ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsNothing, ); final RenderObject boxWithGlobalKey = tester.renderObject(find.byKey(globalKeyChild.key!)); @@ -399,22 +403,22 @@ void main() { views: [ View( view: greenView, - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), View( view: redView, - child: ColoredBox(color: Colors.red, child: globalKeyChild), + child: ColoredBox(color: red, child: globalKeyChild), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsNothing, ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsOneWidget, ); expect(tester.renderObject(find.byKey(globalKeyChild.key!)), equals(boxWithGlobalKey)); @@ -450,21 +454,21 @@ void main() { views: [ View( view: greenView, - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), View( view: redView, - child: ColoredBox(color: Colors.red, child: globalKeyChild), + child: ColoredBox(color: red, child: globalKeyChild), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsOneWidget, ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsNothing, ); final RenderObject boxWithGlobalKey = tester.renderObject(find.byKey(globalKeyChild.key!)); @@ -480,22 +484,22 @@ void main() { views: [ View( view: greenView, - child: ColoredBox(color: Colors.green, child: globalKeyChild), + child: ColoredBox(color: green, child: globalKeyChild), ), View( view: redView, - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsNothing, ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsOneWidget, ); expect(tester.renderObject(find.byKey(globalKeyChild.key!)), equals(boxWithGlobalKey)); @@ -521,22 +525,22 @@ void main() { View( key: greenKey, view: greenView, - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), View( key: redKey, view: redView, - child: ColoredBox(color: Colors.red, child: globalKeyChild), + child: ColoredBox(color: red, child: globalKeyChild), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsOneWidget, ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsNothing, ); final RenderObject boxWithGlobalKey = tester.renderObject(find.byKey(globalKeyChild.key!)); @@ -549,15 +553,15 @@ void main() { View( key: greenKey, view: greenView, - child: ColoredBox(color: Colors.green, child: globalKeyChild), + child: ColoredBox(color: green, child: globalKeyChild), ), ], ), ); - expect(findsColoredBox(Colors.red), findsNothing); + expect(findsColoredBox(red), findsNothing); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsOneWidget, ); expect(tester.renderObject(find.byKey(globalKeyChild.key!)), equals(boxWithGlobalKey)); @@ -579,22 +583,22 @@ void main() { View( key: greenKey, view: greenView, - child: ColoredBox(color: Colors.green, child: globalKeyChild), + child: ColoredBox(color: green, child: globalKeyChild), ), View( key: redKey, view: redView, - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ], ), ); expect( - find.descendant(of: findsColoredBox(Colors.green), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(green), matching: find.byType(SizedBox)), findsOneWidget, ); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsNothing, ); final RenderObject boxWithGlobalKey = tester.renderObject(find.byKey(globalKeyChild.key!)); @@ -607,15 +611,15 @@ void main() { View( key: redKey, view: redView, - child: ColoredBox(color: Colors.red, child: globalKeyChild), + child: ColoredBox(color: red, child: globalKeyChild), ), ], ), ); - expect(findsColoredBox(Colors.green), findsNothing); + expect(findsColoredBox(green), findsNothing); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsOneWidget, ); expect(tester.renderObject(find.byKey(globalKeyChild.key!)), equals(boxWithGlobalKey)); @@ -642,7 +646,7 @@ void main() { key: viewKey, view: FakeView(tester.view), child: SizedBox( - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ), child: const SizedBox(), @@ -658,7 +662,7 @@ void main() { children: [ SizedBox( key: key1, - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ViewAnchor(key: key2, child: const SizedBox()), ViewAnchor( @@ -681,7 +685,7 @@ void main() { key: viewKey, view: FakeView(tester.view), child: SizedBox( - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ), child: const SizedBox(), @@ -714,7 +718,7 @@ void main() { key: viewKey, view: FakeView(tester.view), child: SizedBox( - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ), child: const SizedBox(), @@ -737,7 +741,7 @@ void main() { ), SizedBox( key: key4, - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ], ), @@ -753,7 +757,7 @@ void main() { key: viewKey, view: FakeView(tester.view), child: SizedBox( - child: ColoredBox(key: childKey, color: Colors.green), + child: ColoredBox(key: childKey, color: green), ), ), child: const SizedBox(), @@ -773,26 +777,26 @@ void main() { await tester.pumpWidget( ColoredBox( - color: Colors.green, + color: green, child: ViewAnchor( view: View( view: anchorView, - child: ColoredBox(color: Colors.yellow, child: globalKeyChild), + child: ColoredBox(color: yellow, child: globalKeyChild), ), - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ), ); - expect(findsColoredBox(Colors.green), findsOneWidget); - expect(findsColoredBox(Colors.yellow), findsOneWidget); + expect(findsColoredBox(green), findsOneWidget); + expect(findsColoredBox(yellow), findsOneWidget); expect( - find.descendant(of: findsColoredBox(Colors.yellow), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(yellow), matching: find.byType(SizedBox)), findsOneWidget, ); - expect(findsColoredBox(Colors.red), findsOneWidget); + expect(findsColoredBox(red), findsOneWidget); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsNothing, ); expect(find.byType(SizedBox), findsOneWidget); @@ -800,21 +804,21 @@ void main() { await tester.pumpWidget( ColoredBox( - color: Colors.green, + color: green, child: ViewAnchor( - child: ColoredBox(color: Colors.red, child: globalKeyChild), + child: ColoredBox(color: red, child: globalKeyChild), ), ), ); - expect(findsColoredBox(Colors.green), findsOneWidget); - expect(findsColoredBox(Colors.yellow), findsNothing); + expect(findsColoredBox(green), findsOneWidget); + expect(findsColoredBox(yellow), findsNothing); expect( - find.descendant(of: findsColoredBox(Colors.yellow), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(yellow), matching: find.byType(SizedBox)), findsNothing, ); - expect(findsColoredBox(Colors.red), findsOneWidget); + expect(findsColoredBox(red), findsOneWidget); expect( - find.descendant(of: findsColoredBox(Colors.red), matching: find.byType(SizedBox)), + find.descendant(of: findsColoredBox(red), matching: find.byType(SizedBox)), findsOneWidget, ); expect(find.byType(SizedBox), findsOneWidget); @@ -828,23 +832,23 @@ void main() { await tester.pumpWidget( ColoredBox( - color: Colors.green, + color: green, child: ViewAnchor( view: View( view: anchorView, - child: const ColoredBox(color: Colors.yellow), + child: const ColoredBox(color: yellow), ), - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ), ); - final RenderObject box = tester.renderObject(findsColoredBox(Colors.yellow)); + final RenderObject box = tester.renderObject(findsColoredBox(yellow)); await tester.pumpWidget( const ColoredBox( - color: Colors.green, - child: ViewAnchor(child: ColoredBox(color: Colors.red)), + color: green, + child: ViewAnchor(child: ColoredBox(color: red)), ), ); @@ -863,19 +867,19 @@ void main() { views: [ View( view: redView, - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), View( view: greenView, - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), ], ), ); - expect(findsColoredBox(Colors.green), findsOneWidget); - expect(findsColoredBox(Colors.red), findsOneWidget); - final RenderObject box = tester.renderObject(findsColoredBox(Colors.green)); + expect(findsColoredBox(green), findsOneWidget); + expect(findsColoredBox(red), findsOneWidget); + final RenderObject box = tester.renderObject(findsColoredBox(green)); await tester.pumpWidget( wrapWithView: false, @@ -883,14 +887,14 @@ void main() { views: [ View( view: redView, - child: const ColoredBox(color: Colors.red), + child: const ColoredBox(color: red), ), ], ), ); - expect(findsColoredBox(Colors.green), findsNothing); - expect(findsColoredBox(Colors.red), findsOneWidget); + expect(findsColoredBox(green), findsNothing); + expect(findsColoredBox(red), findsOneWidget); expect(box.debugDisposed, isTrue); }); @@ -916,7 +920,7 @@ void main() { testWidgets('ViewAnchor with View can be wrapped and unwrapped', (WidgetTester tester) async { final Widget viewAnchor = ViewAnchor( view: View(view: FakeView(tester.view), child: const SizedBox()), - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ); await tester.pumpWidget(viewAnchor); @@ -924,7 +928,7 @@ void main() { final List renderViews = tester.renderObjectList(find.byType(View)).toList(); final RenderObject renderSizedBox = tester.renderObject(find.byType(SizedBox)); - await tester.pumpWidget(ColoredBox(color: Colors.yellow, child: viewAnchor)); + await tester.pumpWidget(ColoredBox(color: yellow, child: viewAnchor)); expect(tester.renderObjectList(find.byType(View)), renderViews); expect(tester.renderObject(find.byType(SizedBox)), same(renderSizedBox)); diff --git a/packages/flutter/test/widgets/view_test.dart b/packages/flutter/test/widgets/view_test.dart index 4b0836a8355..495621fe907 100644 --- a/packages/flutter/test/widgets/view_test.dart +++ b/packages/flutter/test/widgets/view_test.dart @@ -4,15 +4,17 @@ import 'dart:ui'; -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import 'multi_view_testing.dart'; void main() { + const green = Color(0xff00ff00); + testWidgets('Widgets running with runApp can find View', (WidgetTester tester) async { FlutterView? viewOf; FlutterView? viewMaybeOf; @@ -197,7 +199,7 @@ void main() { ViewAnchor( view: View( view: FakeView(tester.view), - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), child: const SizedBox(), ), @@ -311,7 +313,7 @@ void main() { return ViewAnchor( view: View( view: FakeView(tester.view), - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), child: const SizedBox(), ); @@ -411,7 +413,7 @@ void main() { return View(key: viewKey, view: FakeView(tester.view), child: const SizedBox()); }, ), - child: const ColoredBox(color: Colors.green), + child: const ColoredBox(color: green), ), ); @@ -428,7 +430,7 @@ void main() { expect(children, contains(rawViewOwner)); // Remove that View from the tree. - await tester.pumpWidget(const ViewAnchor(child: ColoredBox(color: Colors.green))); + await tester.pumpWidget(const ViewAnchor(child: ColoredBox(color: green))); expect(rawView.owner, isNull); expect(RendererBinding.instance.renderViews, isNot(contains(rawView))); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index c43198107c9..c0e7de03f43 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -5457,6 +5457,8 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService { expect(crossAxisAlignment, equals('start')); }); + // TODO(justinmc): Don't test Cupertino interactions in Widgets tests. + // https://github.com/flutter/flutter/issues/177028 testWidgets('ext.flutter.inspector.getLayoutExplorerNode does not throw StackOverflowError', ( WidgetTester tester, ) async { diff --git a/packages/flutter/test/widgets/widget_inspector_test_utils.dart b/packages/flutter/test/widgets/widget_inspector_test_utils.dart index 6a9a556def7..9425a7b6825 100644 --- a/packages/flutter/test/widgets/widget_inspector_test_utils.dart +++ b/packages/flutter/test/widgets/widget_inspector_test_utils.dart @@ -5,7 +5,6 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/wrap_test.dart b/packages/flutter/test/widgets/wrap_test.dart index 51e6a369b88..13e00e840e9 100644 --- a/packages/flutter/test/widgets/wrap_test.dart +++ b/packages/flutter/test/widgets/wrap_test.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; void verify(WidgetTester tester, List answerKey) { @@ -15,6 +15,8 @@ void verify(WidgetTester tester, List answerKey) { } void main() { + const green = Color(0xff00ff00); + testWidgets('Basic Wrap test (LTR)', (WidgetTester tester) async { await tester.pumpWidget( const Wrap( @@ -976,7 +978,7 @@ void main() { child: Center( child: IntrinsicHeight( child: ColoredBox( - color: Colors.green, + color: green, child: Wrap( children: [ Text('Start', style: TextStyle(height: 1.0, fontSize: 16)), @@ -1004,7 +1006,7 @@ void main() { child: Center( child: IntrinsicWidth( child: ColoredBox( - color: Colors.green, + color: green, child: Wrap( direction: Axis.vertical, children: [