Skip to content

Commit bef11d2

Browse files
authored
Some cleanup of cross library test imports (#177029)
There is a lot of cross-library importing in the framework unit tests that I'd like to clean up, see the design doc for more: https://docs.google.com/document/d/1UHxALQqCbmgjnM1RNV9xE2pK3IGyx-UktGX1D7hYCjs/edit?tab=t.0 This PR cleans up a few obvious instances and adds TODOs for others. I created this while doing an investigation for the design doc linked above. I hope that we'll be able to follow up with fixes for all of the problematic tests (tracked in the issue below). Part of flutter/flutter#177028
1 parent b5b5935 commit bef11d2

76 files changed

Lines changed: 236 additions & 297 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev/bots/check_tests_cross_imports.dart

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -111,96 +111,67 @@ class TestsCrossImportChecker {
111111
'packages/flutter/test/widgets/text_test.dart',
112112
'packages/flutter/test/widgets/reorderable_list_test.dart',
113113
'packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart',
114-
'packages/flutter/test/widgets/async_lifecycle_test.dart',
115114
'packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart',
116115
'packages/flutter/test/widgets/scrollable_restoration_test.dart',
117116
'packages/flutter/test/widgets/text_golden_test.dart',
118-
'packages/flutter/test/widgets/multi_view_parent_data_test.dart',
119-
'packages/flutter/test/widgets/view_test.dart',
120117
'packages/flutter/test/widgets/two_dimensional_viewport_test.dart',
121118
'packages/flutter/test/widgets/list_view_viewporting_test.dart',
122119
'packages/flutter/test/widgets/table_test.dart',
123120
'packages/flutter/test/widgets/shortcuts_test.dart',
124121
'packages/flutter/test/widgets/ticker_provider_test.dart',
125-
'packages/flutter/test/widgets/slotted_render_object_widget_test.dart',
126-
'packages/flutter/test/widgets/semantics_2_test.dart',
127122
'packages/flutter/test/widgets/semantics_clipping_test.dart',
128-
'packages/flutter/test/widgets/reparent_state_test.dart',
129-
'packages/flutter/test/widgets/transitions_test.dart',
130123
'packages/flutter/test/widgets/restoration_scopes_moving_test.dart',
131124
'packages/flutter/test/widgets/linked_scroll_view_test.dart',
132125
'packages/flutter/test/widgets/sliver_floating_header_test.dart',
133126
'packages/flutter/test/widgets/page_transitions_test.dart',
134-
'packages/flutter/test/widgets/parent_data_test.dart',
135127
'packages/flutter/test/widgets/editable_text_scribble_test.dart',
136128
'packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart',
137129
'packages/flutter/test/widgets/autofill_group_test.dart',
138130
'packages/flutter/test/widgets/box_decoration_test.dart',
139131
'packages/flutter/test/widgets/range_maintaining_scroll_physics_test.dart',
140132
'packages/flutter/test/widgets/scroll_position_test.dart',
141133
'packages/flutter/test/widgets/sliver_tree_test.dart',
142-
'packages/flutter/test/widgets/binding_live_test.dart',
143134
'packages/flutter/test/widgets/interactive_viewer_test.dart',
144-
'packages/flutter/test/widgets/list_view_fling_test.dart',
145135
'packages/flutter/test/widgets/selectable_region_test.dart',
146-
'packages/flutter/test/widgets/selectable_text_test.dart',
147136
'packages/flutter/test/widgets/editable_text_scribe_test.dart',
148-
'packages/flutter/test/widgets/semantics_7_test.dart',
149137
'packages/flutter/test/widgets/scrollable_test.dart',
150138
'packages/flutter/test/widgets/semantics_debugger_test.dart',
151139
'packages/flutter/test/widgets/semantics_test.dart',
152140
'packages/flutter/test/widgets/page_route_builder_test.dart',
153-
'packages/flutter/test/widgets/opacity_repaint_test.dart',
154141
'packages/flutter/test/widgets/two_dimensional_scroll_view_test.dart',
155142
'packages/flutter/test/widgets/routes_test.dart',
156143
'packages/flutter/test/widgets/listener_test.dart',
157144
'packages/flutter/test/widgets/text_selection_test.dart',
158-
'packages/flutter/test/widgets/list_view_relayout_test.dart',
159-
'packages/flutter/test/widgets/semantics_4_test.dart',
160-
'packages/flutter/test/widgets/multi_view_binding_test.dart',
161145
'packages/flutter/test/widgets/app_test.dart',
162146
'packages/flutter/test/widgets/widget_inspector_test.dart',
163147
'packages/flutter/test/widgets/radio_group_test.dart',
164148
'packages/flutter/test/widgets/list_view_test.dart',
165-
'packages/flutter/test/widgets/binding_deferred_first_frame_test.dart',
166149
'packages/flutter/test/widgets/sliver_resizing_header_test.dart',
167150
'packages/flutter/test/widgets/navigator_replacement_test.dart',
168-
'packages/flutter/test/widgets/scroll_delegate_test.dart',
169151
'packages/flutter/test/widgets/implicit_animations_test.dart',
170-
'packages/flutter/test/widgets/list_view_correction_test.dart',
171152
'packages/flutter/test/widgets/default_text_editing_shortcuts_test.dart',
172153
'packages/flutter/test/widgets/page_storage_test.dart',
173154
'packages/flutter/test/widgets/sliver_main_axis_group_test.dart',
174-
'packages/flutter/test/widgets/semantics_zero_surface_size_test.dart',
175155
'packages/flutter/test/widgets/color_filter_test.dart',
176156
'packages/flutter/test/widgets/semantics_merge_test.dart',
177-
'packages/flutter/test/widgets/semantics_9_test.dart',
178157
'packages/flutter/test/widgets/modal_barrier_test.dart',
179158
'packages/flutter/test/widgets/sliver_semantics_test.dart',
180159
'packages/flutter/test/widgets/slivers_padding_test.dart',
181160
'packages/flutter/test/widgets/sliver_constraints_test.dart',
182161
'packages/flutter/test/widgets/autocomplete_test.dart',
183-
'packages/flutter/test/widgets/icon_data_test.dart',
184162
'packages/flutter/test/widgets/expansible_test.dart',
185163
'packages/flutter/test/widgets/decorated_sliver_test.dart',
186164
'packages/flutter/test/widgets/shape_decoration_test.dart',
187-
'packages/flutter/test/widgets/semantics_refactor_regression_test.dart',
188165
'packages/flutter/test/widgets/run_app_test.dart',
189-
'packages/flutter/test/widgets/animated_opacity_repaint_test.dart',
190-
'packages/flutter/test/widgets/semantics_6_test.dart',
191166
'packages/flutter/test/widgets/shadow_test.dart',
192167
'packages/flutter/test/widgets/routes_transition_test.dart',
193168
'packages/flutter/test/widgets/placeholder_test.dart',
194-
'packages/flutter/test/widgets/animated_image_filtered_repaint_test.dart',
195169
'packages/flutter/test/widgets/route_notification_messages_test.dart',
196170
'packages/flutter/test/widgets/animated_cross_fade_test.dart',
197171
'packages/flutter/test/widgets/editable_text_shortcuts_test.dart',
198172
'packages/flutter/test/widgets/gesture_detector_test.dart',
199-
'packages/flutter/test/widgets/tree_shape_test.dart',
200-
'packages/flutter/test/widgets/rich_text_test.dart',
201173
'packages/flutter/test/widgets/router_test.dart',
202174
'packages/flutter/test/widgets/scroll_notification_test.dart',
203-
'packages/flutter/test/widgets/sensitive_content_error_handling_test.dart',
204175
'packages/flutter/test/widgets/magnifier_test.dart',
205176
'packages/flutter/test/widgets/backdrop_filter_test.dart',
206177
'packages/flutter/test/widgets/editable_text_test.dart',
@@ -209,11 +180,6 @@ class TestsCrossImportChecker {
209180
'packages/flutter/test/widgets/scrollable_helpers_test.dart',
210181
'packages/flutter/test/widgets/slivers_appbar_stretch_test.dart',
211182
'packages/flutter/test/widgets/sliver_cross_axis_group_test.dart',
212-
'packages/flutter/test/widgets/drag_boundary_test.dart',
213-
'packages/flutter/test/widgets/semantics_traversal_test.dart',
214-
'packages/flutter/test/widgets/sensitive_content_unknown_test.dart',
215-
'packages/flutter/test/widgets/overlay_test.dart',
216-
'packages/flutter/test/widgets/semantics_8_test.dart',
217183
'packages/flutter/test/widgets/list_wheel_scroll_view_test.dart',
218184
'packages/flutter/test/widgets/scrollable_dispose_test.dart',
219185
'packages/flutter/test/widgets/pop_scope_test.dart',
@@ -223,33 +189,23 @@ class TestsCrossImportChecker {
223189
'packages/flutter/test/widgets/obscured_animated_image_test.dart',
224190
'packages/flutter/test/widgets/platform_menu_bar_test.dart',
225191
'packages/flutter/test/widgets/inherited_test.dart',
226-
'packages/flutter/test/widgets/sliver_fill_viewport_test.dart',
227-
'packages/flutter/test/widgets/wrap_test.dart',
228192
'packages/flutter/test/widgets/heroes_test.dart',
229-
'packages/flutter/test/widgets/overlay_portal_test.dart',
230193
'packages/flutter/test/widgets/slivers_evil_test.dart',
231-
'packages/flutter/test/widgets/semantics_11_test.dart',
232194
'packages/flutter/test/widgets/container_test.dart',
233195
'packages/flutter/test/widgets/drawer_test.dart',
234196
'packages/flutter/test/widgets/framework_test.dart',
235197
'packages/flutter/test/widgets/ticker_mode_test.dart',
236198
'packages/flutter/test/widgets/absorb_pointer_test.dart',
237199
'packages/flutter/test/widgets/semantics_role_checks_test.dart',
238-
'packages/flutter/test/widgets/binding_first_frame_rasterized_test.dart',
239200
'packages/flutter/test/widgets/media_query_test.dart',
240201
'packages/flutter/test/widgets/editable_text_cursor_test.dart',
241202
'packages/flutter/test/widgets/sliver_fill_remaining_test.dart',
242-
'packages/flutter/test/widgets/router_restoration_test.dart',
243203
'packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart',
244204
'packages/flutter/test/widgets/editable_text_show_on_screen_test.dart',
245205
'packages/flutter/test/widgets/system_context_menu_test.dart',
246-
'packages/flutter/test/widgets/error_widget_test.dart',
247-
'packages/flutter/test/widgets/semantics_checks_test.dart',
248206
'packages/flutter/test/widgets/scrollable_fling_test.dart',
249207
'packages/flutter/test/widgets/debug_test.dart',
250208
'packages/flutter/test/widgets/banner_test.dart',
251-
'packages/flutter/test/widgets/sensitive_content_test.dart',
252-
'packages/flutter/test/widgets/semantics_10_test.dart',
253209
'packages/flutter/test/widgets/sliver_persistent_header_test.dart',
254210
'packages/flutter/test/widgets/transformed_scrollable_test.dart',
255211
'packages/flutter/test/widgets/run_app_async_test.dart',
@@ -263,42 +219,30 @@ class TestsCrossImportChecker {
263219
'packages/flutter/test/widgets/spell_check_test.dart',
264220
'packages/flutter/test/widgets/slivers_appbar_floating_test.dart',
265221
'packages/flutter/test/widgets/toggleable_test.dart',
266-
'packages/flutter/test/widgets/semantics_1_test.dart',
267-
'packages/flutter/test/widgets/sensitive_content_host_test.dart',
268222
'packages/flutter/test/widgets/mouse_region_test.dart',
269223
'packages/flutter/test/widgets/draggable_test.dart',
270224
'packages/flutter/test/widgets/page_transitions_builder_test.dart',
271225
'packages/flutter/test/widgets/selectable_region_context_menu_test.dart',
272-
'packages/flutter/test/widgets/default_colors_test.dart',
273-
'packages/flutter/test/widgets/multi_view_tree_updates_test.dart',
274226
'packages/flutter/test/widgets/sliversemantics_test.dart',
275227
'packages/flutter/test/widgets/scroll_activity_test.dart',
276228
'packages/flutter/test/widgets/tap_region_test.dart',
277229
'packages/flutter/test/widgets/lookup_boundary_test.dart',
278230
'packages/flutter/test/widgets/reassemble_test.dart',
279-
'packages/flutter/test/widgets/semantics_5_test.dart',
280-
'packages/flutter/test/widgets/clip_test.dart',
281-
'packages/flutter/test/widgets/independent_widget_layout_test.dart',
282-
'packages/flutter/test/widgets/binding_first_frame_developer_test.dart',
283231
'packages/flutter/test/widgets/html_element_view_test.dart',
284232
'packages/flutter/test/widgets/navigator_test.dart',
285-
'packages/flutter/test/widgets/multi_view_no_implicit_view_binding_test.dart',
286233
'packages/flutter/test/widgets/text_semantics_test.dart',
287234
'packages/flutter/test/widgets/safe_area_test.dart',
288235
'packages/flutter/test/widgets/page_view_test.dart',
289236
'packages/flutter/test/widgets/undo_history_test.dart',
290237
'packages/flutter/test/widgets/scroll_view_test.dart',
291238
'packages/flutter/test/widgets/focus_traversal_test.dart',
292239
'packages/flutter/test/widgets/sliver_list_test.dart',
293-
'packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart',
294240
'packages/flutter/test/widgets/page_forward_transitions_test.dart',
295241
'packages/flutter/test/widgets/context_menu_controller_test.dart',
296-
'packages/flutter/test/widgets/semantics_3_test.dart',
297242
'packages/flutter/test/widgets/slivers_test.dart',
298243
'packages/flutter/test/widgets/navigator_restoration_test.dart',
299244
'packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart',
300245
'packages/flutter/test/widgets/simple_semantics_test.dart',
301-
'packages/flutter/test/widgets/sliver_appbar_opacity_test.dart',
302246
'packages/flutter/test/widgets/image_filter_test.dart',
303247
'packages/flutter/test/widgets/navigator_on_did_remove_page_test.dart',
304248
'packages/flutter/test/widgets/opacity_test.dart',
@@ -307,15 +251,11 @@ class TestsCrossImportChecker {
307251
'packages/flutter/test/widgets/scrollable_semantics_test.dart',
308252
'packages/flutter/test/widgets/sliver_visibility_test.dart',
309253
'packages/flutter/test/widgets/rotated_box_test.dart',
310-
'packages/flutter/test/widgets/sliver_constrained_cross_axis_test.dart',
311254
'packages/flutter/test/widgets/single_child_scroll_view_test.dart',
312255
'packages/flutter/test/widgets/pinned_header_sliver_test.dart',
313-
'packages/flutter/test/widgets/focus_manager_test.dart',
314256
'packages/flutter/test/widgets/raw_radio_test.dart',
315257
'packages/flutter/test/widgets/syncing_test.dart',
316258
'packages/flutter/test/widgets/form_test.dart',
317-
'packages/flutter/test/widgets/implicit_semantics_test.dart',
318-
'packages/flutter/test/widgets/shrink_wrapping_viewport_test.dart',
319259
};
320260

321261
/// These Cupertino tests are known to have cross imports. These cross imports
@@ -341,7 +281,6 @@ class TestsCrossImportChecker {
341281
'packages/flutter/test/cupertino/magnifier_test.dart',
342282
'packages/flutter/test/cupertino/text_field_restoration_test.dart',
343283
'packages/flutter/test/cupertino/sheet_test.dart',
344-
'packages/flutter/test/cupertino/action_sheet_test.dart',
345284
'packages/flutter/test/cupertino/form_row_test.dart',
346285
'packages/flutter/test/cupertino/colors_test.dart',
347286
'packages/flutter/test/cupertino/text_form_field_row_restoration_test.dart',

packages/flutter/test/cupertino/action_sheet_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'dart:ui';
1111

1212
import 'package:flutter/cupertino.dart';
1313
import 'package:flutter/foundation.dart';
14-
import 'package:flutter/material.dart';
1514
import 'package:flutter/rendering.dart';
1615
import 'package:flutter/services.dart';
1716

@@ -1845,9 +1844,8 @@ void main() {
18451844
await tester.tap(find.text('Go'));
18461845
await tester.pump();
18471846

1848-
// The inherited ScrollBehavior should not apply Scrollbars since they are
1847+
// The inherited ScrollBehavior should not apply scrollbars since they are
18491848
// already built in to the widget.
1850-
expect(find.byType(Scrollbar), findsNothing);
18511849
expect(find.byType(RawScrollbar), findsNothing);
18521850
// Built in CupertinoScrollbars should only number 2: one for the actions,
18531851
// one for the content.
@@ -2450,7 +2448,7 @@ void main() {
24502448

24512449
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
24522450

2453-
const Color focusColor = Colors.orange;
2451+
const focusColor = Color(0xffffaaaa);
24542452

24552453
final Color defaultDarkFocusColor = HSLColor.fromColor(
24562454
focusColor.withOpacity(kCupertinoButtonTintedOpacityDark),

packages/flutter/test/cupertino/app_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ void main() {
579579
debugBrightnessOverride = null;
580580
});
581581

582+
// TODO(justinmc): Cupertino tests should not import Material.
583+
// https://github.com/flutter/flutter/issues/177028
582584
testWidgets('CupertinoApp creates a Material theme with colors based off of Cupertino theme', (
583585
WidgetTester tester,
584586
) async {

packages/flutter/test/cupertino/colors_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ void main() {
532532
expect(color.value, dynamicColor.darkHighContrastElevatedColor.value);
533533
});
534534

535+
// TODO(justinmc): Don't test Material interactions in Cupertino tests.
536+
// https://github.com/flutter/flutter/issues/177028
535537
group('MaterialApp:', () {
536538
Color? color;
537539
setUp(() {

packages/flutter/test/cupertino/date_picker_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,8 @@ void main() {
21402140
handle.dispose();
21412141
});
21422142

2143+
// TODO(justinmc): Don't test Material interactions in Cupertino tests.
2144+
// https://github.com/flutter/flutter/issues/177028
21432145
testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
21442146
Widget buildDatePicker(Brightness brightness) {
21452147
return MaterialApp(
@@ -2167,6 +2169,8 @@ void main() {
21672169
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
21682170
});
21692171

2172+
// TODO(justinmc): Don't test Material interactions in Cupertino tests.
2173+
// https://github.com/flutter/flutter/issues/177028
21702174
testWidgets('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
21712175
Widget buildTimerPicker(Brightness brightness) {
21722176
return MaterialApp(

packages/flutter/test/cupertino/dialog_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,9 +1846,8 @@ void main() {
18461846
await tester.tap(find.text('Go'));
18471847
await tester.pump();
18481848

1849-
// The inherited ScrollBehavior should not apply Scrollbars since they are
1849+
// The inherited ScrollBehavior should not apply scrollbars since they are
18501850
// already built in to the widget.
1851-
expect(find.byType(Scrollbar), findsNothing);
18521851
expect(find.byType(RawScrollbar), findsNothing);
18531852
// Built in CupertinoScrollbars should only number 2: one for the actions,
18541853
// one for the content.

packages/flutter/test/cupertino/form_row_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ void main() {
148148
expect(errorTextStyle.style.color, CupertinoColors.destructiveRed);
149149
});
150150

151+
// TODO(justinmc): Don't test Material interactions in Cupertino tests.
152+
// https://github.com/flutter/flutter/issues/177028
151153
testWidgets('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async {
152154
const Widget prefix = Text('Prefix');
153155
const Widget helper = Text('Helper');

packages/flutter/test/cupertino/picker_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ void main() {
697697
);
698698
});
699699

700+
// TODO(justinmc): Don't test Material interactions in Cupertino tests.
701+
// https://github.com/flutter/flutter/issues/177028
700702
testWidgets('Picker adapts to MaterialApp dark mode', (WidgetTester tester) async {
701703
Widget buildCupertinoPicker(Brightness brightness) {
702704
return MaterialApp(

packages/flutter/test/cupertino/text_selection_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ void main() {
555555
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
556556
_LongCupertinoLocalizations.delegate,
557557
DefaultWidgetsLocalizations.delegate,
558-
DefaultMaterialLocalizations.delegate,
559558
],
560559
home: Directionality(
561560
textDirection: TextDirection.ltr,

packages/flutter/test/widgets/selectable_text_test.dart renamed to packages/flutter/test/material/selectable_text_test.dart

File renamed without changes.

0 commit comments

Comments
 (0)