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.
This commit is contained in:
Michael Goderbauer
2024-06-11 22:22:23 -07:00
committed by GitHub
parent 1f93809ad2
commit 962ae8a334
27 changed files with 30 additions and 136 deletions

View File

@@ -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));

View File

@@ -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);

View File

@@ -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<Container>(find.byType(Container));

View File

@@ -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);

View File

@@ -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.

View File

@@ -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<PhysicalShape>(