1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Update Material 3 Demo App (#1530)

This commit is contained in:
Qun Cheng
2022-12-20 10:49:23 -08:00
committed by GitHub
parent 019441374e
commit 405ebafe04
8 changed files with 1885 additions and 580 deletions

View File

@@ -16,43 +16,54 @@ void main() {
'selected on NavigationBar', (tester) async {
widgetSetup(tester, 449);
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
await tester.pumpWidget(const Material3Demo());
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
expect(find.text('Surface Tint only'), findsNothing);
expect(find.text('Surface Tint Color Only'), findsNothing);
expect(find.byType(NavigationBar), findsOneWidget);
Finder tintIconOnBar = find.byIcon(Icons.invert_colors_on_outlined);
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);
expect(find.byIcon(Icons.opacity), findsOneWidget);
expect(find.text('Surface Tint only'), findsOneWidget);
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);
});
testWidgets(
'Surface Tones screen shows correctly when the corresponding icon is '
'selected on NavigationRail', (tester) async {
widgetSetup(tester, 450); // NavigationRail shows only when width is >= 450.
widgetSetup(
tester, 1200); // NavigationRail shows only when width is > 1000.
addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
await tester.pumpWidget(const Material3Demo());
expect(find.text('Surface Tint only'), findsNothing);
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
expect(find.text('Surface Tint Color Only'), findsNothing);
expect(find.byType(NavigationRail), findsOneWidget);
Finder tintIconOnRail = find.byIcon(Icons.invert_colors_on_outlined);
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);
expect(find.byIcon(Icons.opacity), findsOneWidget);
expect(find.text('Surface Tint only'), findsOneWidget);
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(MaterialApp(
home: Scaffold(body: Row(children: const [ElevationScreen()])),
));
expect(find.text('Surface Tint only'), findsOneWidget);
expect(find.text('Surface Tint and Shadow'), findsOneWidget);
expect(find.text('Shadow only'), findsOneWidget);
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);
expect(find.byType(ElevationGrid), findsNWidgets(3));
expect(find.byType(ElevationCard), findsNWidgets(18));
});