mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 23:08:59 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -12,54 +12,69 @@ import 'component_screen_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Surface Tones screen shows correctly when the corresponding icon is '
|
||||
'selected on NavigationBar', (tester) async {
|
||||
widgetSetup(tester, 449);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
await tester.pumpWidget(const App());
|
||||
'Surface Tones screen shows correctly when the corresponding icon is '
|
||||
'selected on NavigationBar',
|
||||
(tester) async {
|
||||
widgetSetup(tester, 449);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
await tester.pumpWidget(const App());
|
||||
|
||||
expect(find.text('Surface Tint Color Only'), findsNothing);
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
Finder tintIconOnBar = find.descendant(
|
||||
expect(find.text('Surface Tint Color Only'), findsNothing);
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
Finder tintIconOnBar = find.descendant(
|
||||
of: find.byType(NavigationBar),
|
||||
matching: find.widgetWithIcon(
|
||||
NavigationDestination, Icons.invert_colors_on_outlined));
|
||||
expect(tintIconOnBar, findsOneWidget);
|
||||
await tester.tap(tintIconOnBar);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
expect(tintIconOnBar, findsNothing);
|
||||
Finder selectedTintIconOnBar = find.descendant(
|
||||
NavigationDestination,
|
||||
Icons.invert_colors_on_outlined,
|
||||
),
|
||||
);
|
||||
expect(tintIconOnBar, findsOneWidget);
|
||||
await tester.tap(tintIconOnBar);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
expect(tintIconOnBar, findsNothing);
|
||||
Finder selectedTintIconOnBar = find.descendant(
|
||||
of: find.byType(NavigationBar),
|
||||
matching: find.widgetWithIcon(NavigationDestination, Icons.opacity));
|
||||
expect(selectedTintIconOnBar, findsOneWidget);
|
||||
expect(find.text('Surface Tint Color Only'), findsOneWidget);
|
||||
});
|
||||
matching: find.widgetWithIcon(NavigationDestination, Icons.opacity),
|
||||
);
|
||||
expect(selectedTintIconOnBar, findsOneWidget);
|
||||
expect(find.text('Surface Tint Color Only'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Surface Tones screen shows correctly when the corresponding icon is '
|
||||
'selected on NavigationRail', (tester) async {
|
||||
widgetSetup(
|
||||
tester, 1200); // NavigationRail shows only when width is > 1000.
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
await tester.pumpWidget(const App());
|
||||
expect(find.text('Surface Tint Color Only'), findsNothing);
|
||||
Finder tintIconOnRail = find.descendant(
|
||||
'Surface Tones screen shows correctly when the corresponding icon is '
|
||||
'selected on NavigationRail',
|
||||
(tester) async {
|
||||
widgetSetup(
|
||||
tester,
|
||||
1200,
|
||||
); // NavigationRail shows only when width is > 1000.
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
await tester.pumpWidget(const App());
|
||||
expect(find.text('Surface Tint Color Only'), findsNothing);
|
||||
Finder tintIconOnRail = find.descendant(
|
||||
of: find.byType(NavigationRail),
|
||||
matching: find.byIcon(Icons.invert_colors_on_outlined));
|
||||
expect(tintIconOnRail, findsOneWidget);
|
||||
await tester.tap(tintIconOnRail);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
expect(tintIconOnRail, findsNothing);
|
||||
Finder selectedTintIconOnRail = find.descendant(
|
||||
of: find.byType(NavigationRail), matching: find.byIcon(Icons.opacity));
|
||||
expect(selectedTintIconOnRail, findsOneWidget);
|
||||
expect(find.text('Surface Tint Color Only'), findsOneWidget);
|
||||
});
|
||||
matching: find.byIcon(Icons.invert_colors_on_outlined),
|
||||
);
|
||||
expect(tintIconOnRail, findsOneWidget);
|
||||
await tester.tap(tintIconOnRail);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
expect(tintIconOnRail, findsNothing);
|
||||
Finder selectedTintIconOnRail = find.descendant(
|
||||
of: find.byType(NavigationRail),
|
||||
matching: find.byIcon(Icons.opacity),
|
||||
);
|
||||
expect(selectedTintIconOnRail, findsOneWidget);
|
||||
expect(find.text('Surface Tint Color Only'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Surface Tones screen shows correct content', (tester) async {
|
||||
await tester.pumpWidget(const MaterialApp(
|
||||
home: Scaffold(body: Row(children: [ElevationScreen()])),
|
||||
));
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(body: Row(children: [ElevationScreen()])),
|
||||
),
|
||||
);
|
||||
expect(find.text('Surface Tint Color Only'), findsOneWidget);
|
||||
expect(find.text('Surface Tint Color and Shadow Color'), findsOneWidget);
|
||||
expect(find.text('Shadow Color Only'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user