Skip to content

Commit 14d9648

Browse files
auto-submit[bot]auto-submit[bot]
authored andcommitted
Reverts "refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter#182697)" (flutter#182879)
<!-- start_original_pr_link --> Reverts: flutter#182697 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: dkwingsmt <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: I think this PR is causing redness, possibly by forgetting to import `button_tester.dart`. ``` error • Undefined name 'testTextSelectionHandleControls' • packages/flutter/test/widgets/context_menu_controller_test.dart:205:36 • undefined_identifier error • The function 'TestButton' isn't defined • packages/flutter/test/widgets/media_query_test.dart:1700:17 • undefined_function error • <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: rkishan516 <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {victorsanni} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: This PR removes Material imports from context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test. part of: flutter#177415 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
1 parent b524e6e commit 14d9648

6 files changed

Lines changed: 139 additions & 129 deletions

File tree

dev/bots/check_tests_cross_imports.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,22 @@ class TestsCrossImportChecker {
151151
'packages/flutter/test/widgets/router_test.dart',
152152
'packages/flutter/test/widgets/scroll_notification_test.dart',
153153
'packages/flutter/test/widgets/editable_text_test.dart',
154+
'packages/flutter/test/widgets/icon_test.dart',
154155
'packages/flutter/test/widgets/sliver_cross_axis_group_test.dart',
156+
'packages/flutter/test/widgets/list_wheel_scroll_view_test.dart',
155157
'packages/flutter/test/widgets/pop_scope_test.dart',
156158
'packages/flutter/test/widgets/scrollbar_test.dart',
157159
'packages/flutter/test/widgets/scroll_physics_test.dart',
158160
'packages/flutter/test/widgets/obscured_animated_image_test.dart',
161+
'packages/flutter/test/widgets/platform_menu_bar_test.dart',
159162
'packages/flutter/test/widgets/inherited_test.dart',
160163
'packages/flutter/test/widgets/heroes_test.dart',
161164
'packages/flutter/test/widgets/container_test.dart',
162165
'packages/flutter/test/widgets/drawer_test.dart',
163166
'packages/flutter/test/widgets/framework_test.dart',
164167
'packages/flutter/test/widgets/absorb_pointer_test.dart',
165168
'packages/flutter/test/widgets/semantics_role_checks_test.dart',
169+
'packages/flutter/test/widgets/media_query_test.dart',
166170
'packages/flutter/test/widgets/editable_text_cursor_test.dart',
167171
'packages/flutter/test/widgets/sliver_fill_remaining_test.dart',
168172
'packages/flutter/test/widgets/editable_text_show_on_screen_test.dart',
@@ -184,6 +188,7 @@ class TestsCrossImportChecker {
184188
'packages/flutter/test/widgets/navigator_test.dart',
185189
'packages/flutter/test/widgets/page_view_test.dart',
186190
'packages/flutter/test/widgets/page_forward_transitions_test.dart',
191+
'packages/flutter/test/widgets/context_menu_controller_test.dart',
187192
'packages/flutter/test/widgets/slivers_test.dart',
188193
'packages/flutter/test/widgets/navigator_restoration_test.dart',
189194
'packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart',

packages/flutter/test/widgets/context_menu_controller_test.dart

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/material.dart';
56
import 'package:flutter/services.dart';
6-
import 'package:flutter/widgets.dart';
77
import 'package:flutter_test/flutter_test.dart';
88

99
import 'clipboard_utils.dart';
1010
import 'editable_text_utils.dart';
11-
import 'widgets_app_tester.dart';
1211

1312
void main() {
14-
const kGreyColor = Color(0xFFAAAAAA);
15-
const kRedColor = Color(0xFFFF0000);
1613
final mockClipboard = MockClipboard();
1714
TestWidgetsFlutterBinding.ensureInitialized().defaultBinaryMessenger.setMockMethodCallHandler(
1815
SystemChannels.platform,
@@ -31,12 +28,14 @@ void main() {
3128
late final BuildContext context;
3229

3330
await tester.pumpWidget(
34-
TestWidgetsApp(
35-
home: Builder(
36-
builder: (BuildContext localContext) {
37-
context = localContext;
38-
return const SizedBox.shrink();
39-
},
31+
MaterialApp(
32+
home: Scaffold(
33+
body: Builder(
34+
builder: (BuildContext localContext) {
35+
context = localContext;
36+
return const SizedBox.shrink();
37+
},
38+
),
4039
),
4140
),
4241
);
@@ -98,12 +97,14 @@ void main() {
9897
late final BuildContext context;
9998

10099
await tester.pumpWidget(
101-
TestWidgetsApp(
102-
home: Builder(
103-
builder: (BuildContext localContext) {
104-
context = localContext;
105-
return const SizedBox.shrink();
106-
},
100+
MaterialApp(
101+
home: Scaffold(
102+
body: Builder(
103+
builder: (BuildContext localContext) {
104+
context = localContext;
105+
return const SizedBox.shrink();
106+
},
107+
),
107108
),
108109
),
109110
);
@@ -148,12 +149,14 @@ void main() {
148149
late final BuildContext context;
149150

150151
await tester.pumpWidget(
151-
TestWidgetsApp(
152-
home: Builder(
153-
builder: (BuildContext localContext) {
154-
context = localContext;
155-
return const SizedBox.shrink();
156-
},
152+
MaterialApp(
153+
home: Scaffold(
154+
body: Builder(
155+
builder: (BuildContext localContext) {
156+
context = localContext;
157+
return const SizedBox.shrink();
158+
},
159+
),
157160
),
158161
),
159162
);
@@ -192,22 +195,24 @@ void main() {
192195
addTearDown(focusNode.dispose);
193196

194197
await tester.pumpWidget(
195-
TestWidgetsApp(
196-
home: Builder(
197-
builder: (BuildContext localContext) {
198-
context = localContext;
199-
return EditableText(
200-
controller: textEditingController,
201-
backgroundCursorColor: kGreyColor,
202-
focusNode: focusNode,
203-
style: const TextStyle(),
204-
cursorColor: kRedColor,
205-
selectionControls: testTextSelectionHandleControls,
206-
contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
207-
return Placeholder(key: builtInKey);
208-
},
209-
);
210-
},
198+
MaterialApp(
199+
home: Scaffold(
200+
body: Builder(
201+
builder: (BuildContext localContext) {
202+
context = localContext;
203+
return EditableText(
204+
controller: textEditingController,
205+
backgroundCursorColor: Colors.grey,
206+
focusNode: focusNode,
207+
style: const TextStyle(),
208+
cursorColor: Colors.red,
209+
selectionControls: materialTextSelectionHandleControls,
210+
contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
211+
return Placeholder(key: builtInKey);
212+
},
213+
);
214+
},
215+
),
211216
),
212217
),
213218
);

packages/flutter/test/widgets/icon_test.dart

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/widgets.dart';
5+
import 'package:flutter/material.dart';
66
import 'package:flutter_test/flutter_test.dart';
77

88
import 'semantics_tester.dart';
99

1010
void main() {
11-
const kTimeToLeaveIcon = IconData(0xe65f, fontFamily: 'MaterialIcons');
12-
const kAbcIcon = IconData(0xf04b6, fontFamily: 'MaterialIcons');
13-
const kSaveIcon = IconData(0xe550, fontFamily: 'MaterialIcons');
14-
1511
testWidgets('Can set opacity for an Icon', (WidgetTester tester) async {
1612
await tester.pumpWidget(
1713
const Directionality(
@@ -245,9 +241,7 @@ void main() {
245241
await tester.pumpWidget(
246242
const Directionality(
247243
textDirection: TextDirection.ltr,
248-
child: Center(
249-
child: Icon(IconData(0xe668, fontFamily: 'MaterialIcons'), semanticLabel: 'a label'),
250-
),
244+
child: Center(child: Icon(Icons.title, semanticLabel: 'a label')),
251245
),
252246
);
253247

@@ -277,7 +271,7 @@ void main() {
277271
await tester.pumpWidget(
278272
const Directionality(
279273
textDirection: TextDirection.ltr,
280-
child: Center(child: Icon(kTimeToLeaveIcon)),
274+
child: Center(child: Icon(Icons.time_to_leave)),
281275
),
282276
);
283277

@@ -286,7 +280,7 @@ void main() {
286280
await tester.pumpWidget(
287281
const Directionality(
288282
textDirection: TextDirection.ltr,
289-
child: Center(child: Icon(kTimeToLeaveIcon, semanticLabel: 'a label')),
283+
child: Center(child: Icon(Icons.time_to_leave, semanticLabel: 'a label')),
290284
),
291285
);
292286

@@ -316,7 +310,7 @@ void main() {
316310
WidgetTester tester,
317311
) async {
318312
await tester.pumpWidget(
319-
const Directionality(textDirection: TextDirection.ltr, child: Icon(kAbcIcon)),
313+
const Directionality(textDirection: TextDirection.ltr, child: Icon(Icons.abc)),
320314
);
321315

322316
RichText text = tester.widget(find.byType(RichText));
@@ -330,7 +324,7 @@ void main() {
330324
await tester.pumpWidget(
331325
const Directionality(
332326
textDirection: TextDirection.ltr,
333-
child: Icon(kAbcIcon, fill: 0.5, weight: 300, grade: 200, opticalSize: 48),
327+
child: Icon(Icons.abc, fill: 0.5, weight: 300, grade: 200, opticalSize: 48),
334328
),
335329
);
336330

@@ -352,7 +346,7 @@ void main() {
352346
textDirection: TextDirection.ltr,
353347
child: IconTheme(
354348
data: IconThemeData(fill: 0.2, weight: 3.0, grade: 4.0, opticalSize: 5.0),
355-
child: Icon(kAbcIcon),
349+
child: Icon(Icons.abc),
356350
),
357351
),
358352
);
@@ -374,7 +368,7 @@ void main() {
374368
textDirection: TextDirection.ltr,
375369
child: IconTheme(
376370
data: IconThemeData(fill: 0.2, weight: 3.0, grade: 4.0, opticalSize: 5.0),
377-
child: Icon(kAbcIcon, fill: 0.6, weight: 7.0, grade: 8.0, opticalSize: 9.0),
371+
child: Icon(Icons.abc, fill: 0.6, weight: 7.0, grade: 8.0, opticalSize: 9.0),
378372
),
379373
),
380374
);
@@ -410,19 +404,19 @@ void main() {
410404
});
411405

412406
test('Throws if given invalid values', () {
413-
expect(() => Icon(kAbcIcon, fill: -0.1), throwsAssertionError);
414-
expect(() => Icon(kAbcIcon, fill: 1.1), throwsAssertionError);
415-
expect(() => Icon(kAbcIcon, weight: -0.1), throwsAssertionError);
416-
expect(() => Icon(kAbcIcon, weight: 0.0), throwsAssertionError);
417-
expect(() => Icon(kAbcIcon, opticalSize: -0.1), throwsAssertionError);
418-
expect(() => Icon(kAbcIcon, opticalSize: 0), throwsAssertionError);
407+
expect(() => Icon(Icons.abc, fill: -0.1), throwsAssertionError);
408+
expect(() => Icon(Icons.abc, fill: 1.1), throwsAssertionError);
409+
expect(() => Icon(Icons.abc, weight: -0.1), throwsAssertionError);
410+
expect(() => Icon(Icons.abc, weight: 0.0), throwsAssertionError);
411+
expect(() => Icon(Icons.abc, opticalSize: -0.1), throwsAssertionError);
412+
expect(() => Icon(Icons.abc, opticalSize: 0), throwsAssertionError);
419413
});
420414

421415
testWidgets('Icon does not crash at zero area', (WidgetTester tester) async {
422416
await tester.pumpWidget(
423417
const Directionality(
424418
textDirection: TextDirection.ltr,
425-
child: Center(child: SizedBox.shrink(child: Icon(kSaveIcon))),
419+
child: Center(child: SizedBox.shrink(child: Icon(Icons.save))),
426420
),
427421
);
428422
expect(tester.getSize(find.byType(Icon)), Size.zero);

packages/flutter/test/widgets/list_wheel_scroll_view_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
library;
99

1010
import 'package:flutter/foundation.dart';
11+
import 'package:flutter/material.dart';
1112
import 'package:flutter/rendering.dart';
12-
import 'package:flutter/widgets.dart';
1313
import 'package:flutter_test/flutter_test.dart';
1414

1515
import '../rendering/rendering_tester.dart' show TestCallbackPainter, TestClipPaintingContext;
16-
import 'widgets_app_tester.dart';
1716

1817
void main() {
1918
testWidgets('ListWheelScrollView respects clipBehavior', (WidgetTester tester) async {
@@ -2046,9 +2045,9 @@ void main() {
20462045
'ListWheelScrollView in an AnimatedContainer with zero width and height does not throw an error',
20472046
(WidgetTester tester) async {
20482047
await tester.pumpWidget(
2049-
TestWidgetsApp(
2050-
home: Align(
2051-
child: AnimatedContainer(
2048+
MaterialApp(
2049+
home: Scaffold(
2050+
body: AnimatedContainer(
20522051
width: 0,
20532052
height: 0,
20542053
duration: Duration.zero,

packages/flutter/test/widgets/media_query_test.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ import 'dart:ui'
66
show Brightness, DisplayFeature, DisplayFeatureState, DisplayFeatureType, GestureSettings;
77

88
import 'package:flutter/gestures.dart';
9-
import 'package:flutter/widgets.dart';
9+
import 'package:flutter/material.dart';
1010
import 'package:flutter_test/flutter_test.dart';
1111

12-
import 'utils.dart';
13-
import 'widgets_app_tester.dart';
14-
1512
class _MediaQueryAspectCase {
1613
const _MediaQueryAspectCase(this.method, this.data);
1714
final void Function(BuildContext) method;
@@ -1697,15 +1694,15 @@ void main() {
16971694
children: <Widget>[
16981695
showSize,
16991696
showTextScaler,
1700-
TestButton(
1697+
ElevatedButton(
17011698
onPressed: () {
17021699
setState(() {
17031700
data = data.copyWith(size: Size(data.size.width + 100, data.size.height));
17041701
});
17051702
},
17061703
child: const Text('Increase width by 100'),
17071704
),
1708-
TestButton(
1705+
ElevatedButton(
17091706
onPressed: () {
17101707
setState(() {
17111708
data = data.copyWith(textScaler: TextScaler.noScaling);
@@ -1720,7 +1717,7 @@ void main() {
17201717
},
17211718
);
17221719

1723-
await tester.pumpWidget(TestWidgetsApp(home: page));
1720+
await tester.pumpWidget(MaterialApp(home: page));
17241721
expect(find.text('size: Size(800.0, 600.0)'), findsOneWidget);
17251722
expect(find.text('textScaler: linear (1.1x)'), findsOneWidget);
17261723
expect(sizeBuildCount, 1);
@@ -1763,15 +1760,15 @@ void main() {
17631760
child: ListView(
17641761
children: <Widget>[
17651762
builder,
1766-
TestButton(
1763+
ElevatedButton(
17671764
onPressed: () {
17681765
setState(() {
17691766
data = _MediaQueryAspectVariant.aspect!.data;
17701767
});
17711768
},
17721769
child: const Text('Change data'),
17731770
),
1774-
TestButton(
1771+
ElevatedButton(
17751772
onPressed: () {
17761773
setState(() {
17771774
data = data.copyWith();
@@ -1785,7 +1782,7 @@ void main() {
17851782
},
17861783
);
17871784

1788-
await tester.pumpWidget(TestWidgetsApp(home: page));
1785+
await tester.pumpWidget(MaterialApp(home: page));
17891786
expect(buildCount, 1);
17901787

17911788
await tester.tap(find.text('Copy data'));
@@ -2012,15 +2009,15 @@ void main() {
20122009
children: <Widget>[
20132010
showWidth,
20142011
showHeight,
2015-
TestButton(
2012+
ElevatedButton(
20162013
onPressed: () {
20172014
setState(() {
20182015
data = data.copyWith(size: Size(data.size.width + 100, data.size.height));
20192016
});
20202017
},
20212018
child: const Text('Increase width by 100'),
20222019
),
2023-
TestButton(
2020+
ElevatedButton(
20242021
onPressed: () {
20252022
setState(() {
20262023
data = data.copyWith(size: Size(data.size.width, data.size.height + 100));
@@ -2035,7 +2032,7 @@ void main() {
20352032
},
20362033
);
20372034

2038-
await tester.pumpWidget(TestWidgetsApp(home: page));
2035+
await tester.pumpWidget(MaterialApp(home: page));
20392036
expect(find.text('width: 800.0'), findsOneWidget);
20402037
expect(find.text('height: 600.0'), findsOneWidget);
20412038
expect(widthBuildCount, 1);

0 commit comments

Comments
 (0)