From 962ae8a3341515483a6f1b91ab3665bfb018983c Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 11 Jun 2024 22:22:23 -0700 Subject: [PATCH] Remove double MaterialApp wrap from api samples (#150055) The widget under test already contains a MaterialApp, so there's no need to wrap it again with one in the test. In fact, the additional MaterialApp could hide problems in the widget under test. --- .../action_icon_theme.0_test.dart | 9 +-------- .../dialog/adaptive_alert_dialog.0_test.dart | 6 +----- .../material/dialog/alert_dialog.0_test.dart | 6 +----- .../material/dialog/alert_dialog.1_test.dart | 6 +----- .../test/material/dialog/dialog.0_test.dart | 13 ++----------- .../material/dialog/show_dialog.0_test.dart | 6 +----- .../material/dialog/show_dialog.1_test.dart | 6 +----- .../material/dialog/show_dialog.2_test.dart | 6 +----- .../test/material/divider/divider.0_test.dart | 6 +----- .../test/material/divider/divider.1_test.dart | 6 +----- .../divider/vertical_divider.0_test.dart | 6 +----- .../divider/vertical_divider.1_test.dart | 6 +----- .../dropdown/dropdown_button.0_test.dart | 7 +------ ...wn_button.selected_item_builder.0_test.dart | 7 +------ .../dropdown/dropdown_button.style.0_test.dart | 7 +------ .../material/popup_menu/popup_menu.0_test.dart | 6 +----- .../material/popup_menu/popup_menu.1_test.dart | 6 +----- ...view.build_default_drag_handles.0_test.dart | 5 +---- ...w.reorderable_list_view_builder.0_test.dart | 5 +---- .../time_picker/show_time_picker.0_test.dart | 6 +----- .../toggle_buttons/toggle_buttons.0_test.dart | 18 +++--------------- .../custom_multi_child_layout.0_test.dart | 6 +----- .../widgets/basic/mouse_region.0_test.dart | 2 +- .../basic/mouse_region.on_exit.0_test.dart | 2 +- .../basic/mouse_region.on_exit.1_test.dart | 2 +- .../test/widgets/basic/offstage.0_test.dart | 3 +-- .../widgets/basic/physical_shape.0_test.dart | 2 +- 27 files changed, 30 insertions(+), 136 deletions(-) diff --git a/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart b/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart index a8cedc30026e..e2257c2c4330 100644 --- a/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart +++ b/examples/api/test/material/action_buttons/action_icon_theme.0_test.dart @@ -8,14 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Action Icon Buttons', (WidgetTester tester) async { - await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ActionIconThemeExampleApp(), - ), - ), - ); - + await tester.pumpWidget(const example.ActionIconThemeExampleApp()); expect(find.byType(DrawerButton), findsOneWidget); final Icon drawerButtonIcon = tester.widget( diff --git a/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart b/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart index b16048e12592..3d2d82d06d2e 100644 --- a/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart +++ b/examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show Adaptive Alert dialog', (WidgetTester tester) async { const String dialogTitle = 'AlertDialog Title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.AdaptiveAlertDialogApp(), - ), - ), + const example.AdaptiveAlertDialogApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/dialog/alert_dialog.0_test.dart b/examples/api/test/material/dialog/alert_dialog.0_test.dart index 550487b2feda..12cfbc0e1a32 100644 --- a/examples/api/test/material/dialog/alert_dialog.0_test.dart +++ b/examples/api/test/material/dialog/alert_dialog.0_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show Alert dialog', (WidgetTester tester) async { const String dialogTitle = 'AlertDialog Title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.AlertDialogExampleApp(), - ), - ), + const example.AlertDialogExampleApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/dialog/alert_dialog.1_test.dart b/examples/api/test/material/dialog/alert_dialog.1_test.dart index 6bf829e66056..22f287295c20 100644 --- a/examples/api/test/material/dialog/alert_dialog.1_test.dart +++ b/examples/api/test/material/dialog/alert_dialog.1_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show Alert dialog', (WidgetTester tester) async { const String dialogTitle = 'AlertDialog Title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.AlertDialogExampleApp(), - ), - ), + const example.AlertDialogExampleApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/dialog/dialog.0_test.dart b/examples/api/test/material/dialog/dialog.0_test.dart index 617c54667e52..8e2d4cfd739b 100644 --- a/examples/api/test/material/dialog/dialog.0_test.dart +++ b/examples/api/test/material/dialog/dialog.0_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_api_samples/material/dialog/dialog.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; @@ -11,11 +10,7 @@ void main() { const String dialogText = 'This is a typical dialog.'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DialogExampleApp(), - ), - ), + const example.DialogExampleApp(), ); expect(find.text(dialogText), findsNothing); @@ -33,11 +28,7 @@ void main() { const String dialogText = 'This is a fullscreen dialog.'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DialogExampleApp(), - ), - ), + const example.DialogExampleApp(), ); expect(find.text(dialogText), findsNothing); diff --git a/examples/api/test/material/dialog/show_dialog.0_test.dart b/examples/api/test/material/dialog/show_dialog.0_test.dart index 5bd4b3626bb7..8b791305b37d 100644 --- a/examples/api/test/material/dialog/show_dialog.0_test.dart +++ b/examples/api/test/material/dialog/show_dialog.0_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show dialog', (WidgetTester tester) async { const String dialogTitle = 'Basic dialog title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ShowDialogExampleApp(), - ), - ), + const example.ShowDialogExampleApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/dialog/show_dialog.1_test.dart b/examples/api/test/material/dialog/show_dialog.1_test.dart index 0cc8e83409b6..09b359c968b0 100644 --- a/examples/api/test/material/dialog/show_dialog.1_test.dart +++ b/examples/api/test/material/dialog/show_dialog.1_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show dialog', (WidgetTester tester) async { const String dialogTitle = 'Basic dialog title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ShowDialogExampleApp(), - ), - ), + const example.ShowDialogExampleApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/dialog/show_dialog.2_test.dart b/examples/api/test/material/dialog/show_dialog.2_test.dart index 06fe8ca4e2d1..4e26932ee73a 100644 --- a/examples/api/test/material/dialog/show_dialog.2_test.dart +++ b/examples/api/test/material/dialog/show_dialog.2_test.dart @@ -10,11 +10,7 @@ void main() { testWidgets('Show dialog', (WidgetTester tester) async { const String dialogTitle = 'Basic dialog title'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ShowDialogExampleApp(), - ), - ), + const example.ShowDialogExampleApp(), ); expect(find.text(dialogTitle), findsNothing); diff --git a/examples/api/test/material/divider/divider.0_test.dart b/examples/api/test/material/divider/divider.0_test.dart index ac135a18caa3..733839752deb 100644 --- a/examples/api/test/material/divider/divider.0_test.dart +++ b/examples/api/test/material/divider/divider.0_test.dart @@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Horizontal Divider', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DividerExampleApp(), - ), - ), + const example.DividerExampleApp(), ); expect(find.byType(Divider), findsOneWidget); diff --git a/examples/api/test/material/divider/divider.1_test.dart b/examples/api/test/material/divider/divider.1_test.dart index afd441ae6467..a89f1f95f869 100644 --- a/examples/api/test/material/divider/divider.1_test.dart +++ b/examples/api/test/material/divider/divider.1_test.dart @@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Horizontal Divider', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DividerExampleApp(), - ), - ), + const example.DividerExampleApp(), ); expect(find.byType(Divider), findsOneWidget); diff --git a/examples/api/test/material/divider/vertical_divider.0_test.dart b/examples/api/test/material/divider/vertical_divider.0_test.dart index 3b61173784c8..6f80337c733e 100644 --- a/examples/api/test/material/divider/vertical_divider.0_test.dart +++ b/examples/api/test/material/divider/vertical_divider.0_test.dart @@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Vertical Divider', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.VerticalDividerExampleApp(), - ), - ), + const example.VerticalDividerExampleApp(), ); expect(find.byType(VerticalDivider), findsOneWidget); diff --git a/examples/api/test/material/divider/vertical_divider.1_test.dart b/examples/api/test/material/divider/vertical_divider.1_test.dart index 8dbe5c1ac442..fcf36be57609 100644 --- a/examples/api/test/material/divider/vertical_divider.1_test.dart +++ b/examples/api/test/material/divider/vertical_divider.1_test.dart @@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Vertical Divider', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.VerticalDividerExampleApp(), - ), - ), + const example.VerticalDividerExampleApp(), ); expect(find.byType(VerticalDivider), findsOneWidget); diff --git a/examples/api/test/material/dropdown/dropdown_button.0_test.dart b/examples/api/test/material/dropdown/dropdown_button.0_test.dart index 9ceca884dbef..73e25f8b9b6a 100644 --- a/examples/api/test/material/dropdown/dropdown_button.0_test.dart +++ b/examples/api/test/material/dropdown/dropdown_button.0_test.dart @@ -2,18 +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_api_samples/material/dropdown/dropdown_button.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DropdownButtonApp(), - ), - ), + const example.DropdownButtonApp(), ); expect(find.text('One'), findsOneWidget); diff --git a/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart b/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart index b046d848727f..63222429f3c4 100644 --- a/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart +++ b/examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart @@ -2,18 +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_api_samples/material/dropdown/dropdown_button.selected_item_builder.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DropdownButtonApp(), - ), - ), + const example.DropdownButtonApp(), ); expect(find.text('NYC'), findsOneWidget); diff --git a/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart b/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart index b34e38ac9622..112160683604 100644 --- a/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart +++ b/examples/api/test/material/dropdown/dropdown_button.style.0_test.dart @@ -2,18 +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_api_samples/material/dropdown/dropdown_button.style.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Select an item from DropdownButton', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.DropdownButtonApp(), - ), - ), + const example.DropdownButtonApp(), ); expect(find.text('One'), findsOneWidget); diff --git a/examples/api/test/material/popup_menu/popup_menu.0_test.dart b/examples/api/test/material/popup_menu/popup_menu.0_test.dart index ea43a1975041..03cbed4e985b 100644 --- a/examples/api/test/material/popup_menu/popup_menu.0_test.dart +++ b/examples/api/test/material/popup_menu/popup_menu.0_test.dart @@ -11,11 +11,7 @@ void main() { const String menuItem = 'Item 1'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.PopupMenuApp(), - ), - ), + const example.PopupMenuApp(), ); expect(find.text(menuItem), findsNothing); diff --git a/examples/api/test/material/popup_menu/popup_menu.1_test.dart b/examples/api/test/material/popup_menu/popup_menu.1_test.dart index f68993449525..15238e442440 100644 --- a/examples/api/test/material/popup_menu/popup_menu.1_test.dart +++ b/examples/api/test/material/popup_menu/popup_menu.1_test.dart @@ -11,11 +11,7 @@ void main() { const String menuItem = 'Item 1'; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.PopupMenuApp(), - ), - ), + const example.PopupMenuApp(), ); expect(find.text(menuItem), findsNothing); diff --git a/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart b/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart index a95e4a8fced4..ce642130ae06 100644 --- a/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart +++ b/examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; @@ -19,9 +18,7 @@ void main() { testWidgets('Reorder list item', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: example.ReorderableApp(), - ), + const example.ReorderableApp(), ); expect(tester.getCenter(find.text('Item 3')).dy, 280.0); diff --git a/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart b/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart index b678d076f191..f8a2f7c3eadc 100644 --- a/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart +++ b/examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; @@ -19,9 +18,7 @@ void main() { testWidgets('Reorder list item', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: example.ReorderableApp(), - ), + const example.ReorderableApp(), ); expect(tester.getCenter(find.text('Item 3')).dy, 252.0); diff --git a/examples/api/test/material/time_picker/show_time_picker.0_test.dart b/examples/api/test/material/time_picker/show_time_picker.0_test.dart index 0c69ab952749..2cdbc2a214eb 100644 --- a/examples/api/test/material/time_picker/show_time_picker.0_test.dart +++ b/examples/api/test/material/time_picker/show_time_picker.0_test.dart @@ -30,11 +30,7 @@ void main() { ]; await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ShowTimePickerApp(), - ), - ), + const example.ShowTimePickerApp(), ); for (final String option in options) { diff --git a/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart b/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart index ccbc9192555f..a46c108c171e 100644 --- a/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart +++ b/examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart @@ -13,11 +13,7 @@ void main() { return tester.widget(find.widgetWithText(TextButton, text)); } await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ToggleButtonsExampleApp(), - ), - ), + const example.ToggleButtonsExampleApp(), ); TextButton firstButton = findButton('Apple'); @@ -51,11 +47,7 @@ void main() { return tester.widget(find.widgetWithText(TextButton, text)); } await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ToggleButtonsExampleApp(), - ), - ), + const example.ToggleButtonsExampleApp(), ); TextButton firstButton = findButton('Tomatoes'); @@ -90,11 +82,7 @@ void main() { return tester.widget(find.widgetWithIcon(TextButton, iconData)); } await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.ToggleButtonsExampleApp(), - ), - ), + const example.ToggleButtonsExampleApp(), ); TextButton firstButton = findButton(Icons.sunny); diff --git a/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart b/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart index acd087ba8e4a..afb6402778ae 100644 --- a/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart +++ b/examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart @@ -10,11 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('has four containers', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp( - home: Scaffold( - body: example.CustomMultiChildLayoutApp(), - ), - ), + const example.CustomMultiChildLayoutApp(), ); final Finder containerFinder = find.byType(Container); expect(containerFinder, findsNWidgets(4)); diff --git a/examples/api/test/widgets/basic/mouse_region.0_test.dart b/examples/api/test/widgets/basic/mouse_region.0_test.dart index 028210d862ca..9bc6abfae042 100644 --- a/examples/api/test/widgets/basic/mouse_region.0_test.dart +++ b/examples/api/test/widgets/basic/mouse_region.0_test.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('MouseRegion detects mouse entries, exists, and location', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp(home: example.MouseRegionApp()), + const example.MouseRegionApp(), ); expect(find.text('0 Entries\n0 Exits'), findsOneWidget); diff --git a/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart b/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart index 1f8ac60f0fa4..415e2b8be88f 100644 --- a/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart +++ b/examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('MouseRegion detects mouse hover', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp(home: example.MouseRegionApp()), + const example.MouseRegionApp(), ); Container container = tester.widget(find.byType(Container)); diff --git a/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart b/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart index 6025575e32a7..006fec1ca8fb 100644 --- a/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart +++ b/examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('MouseRegion update mouse hover with a delay', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp(home: example.MouseRegionApp()), + const example.MouseRegionApp(), ); expect(find.text('Not hovering'), findsOneWidget); diff --git a/examples/api/test/widgets/basic/offstage.0_test.dart b/examples/api/test/widgets/basic/offstage.0_test.dart index e459dee7e760..d6580c7d53e1 100644 --- a/examples/api/test/widgets/basic/offstage.0_test.dart +++ b/examples/api/test/widgets/basic/offstage.0_test.dart @@ -2,14 +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_api_samples/widgets/basic/offstage.0.dart' as example; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Can off/on stage Flutter logo widget', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp(home: example.OffstageApp()), + const example.OffstageApp(), ); // The Flutter logo is off stage and not visible. diff --git a/examples/api/test/widgets/basic/physical_shape.0_test.dart b/examples/api/test/widgets/basic/physical_shape.0_test.dart index db6e9aea5379..3b755ec7a387 100644 --- a/examples/api/test/widgets/basic/physical_shape.0_test.dart +++ b/examples/api/test/widgets/basic/physical_shape.0_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('PhysicalShape is an ancestor of the text widget', (WidgetTester tester) async { await tester.pumpWidget( - const MaterialApp(home: example.PhysicalShapeApp()), + const example.PhysicalShapeApp(), ); final PhysicalShape physicalShape = tester.widget(