mirror of
https://github.com/flutter/samples.git
synced 2026-03-22 04:17:50 +00:00
Fixes CI ahead of next release
This commit is contained in:
@@ -261,205 +261,6 @@ void main() {
|
||||
expect(box.localToGlobal(Offset.zero), const Offset(0.0, 3080.0));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Material version switches between Material3 and Material2 when '
|
||||
'the version icon is clicked',
|
||||
(tester) async {
|
||||
widgetSetup(tester, 450, windowHeight: 7000);
|
||||
await tester.pumpWidget(const App());
|
||||
BuildContext defaultElevatedButton = tester.firstElement(
|
||||
find.byType(ElevatedButton),
|
||||
);
|
||||
BuildContext defaultIconButton = tester.firstElement(
|
||||
find.byType(IconButton),
|
||||
);
|
||||
BuildContext defaultFAB = tester.firstElement(
|
||||
find.byType(FloatingActionButton),
|
||||
);
|
||||
BuildContext defaultCard = tester.firstElement(
|
||||
find.widgetWithText(Card, 'Elevated'),
|
||||
);
|
||||
BuildContext defaultChip = tester.firstElement(
|
||||
find.widgetWithText(ActionChip, 'Assist'),
|
||||
);
|
||||
Finder dialog = find.text('Show dialog');
|
||||
await tester.tap(dialog);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext defaultAlertDialog = tester.element(
|
||||
find.byType(AlertDialog),
|
||||
);
|
||||
expect(Theme.of(defaultAlertDialog).useMaterial3, true);
|
||||
Finder dismiss = find.text('Okay');
|
||||
await tester.tap(dismiss);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
|
||||
expect(find.widgetWithIcon(AppBar, Icons.filter_2), findsOneWidget);
|
||||
expect(find.widgetWithIcon(AppBar, Icons.filter_3), findsNothing);
|
||||
expect(find.text('Material 3'), findsOneWidget);
|
||||
expect(Theme.of(defaultElevatedButton).useMaterial3, true);
|
||||
expect(Theme.of(defaultIconButton).useMaterial3, true);
|
||||
expect(Theme.of(defaultFAB).useMaterial3, true);
|
||||
expect(Theme.of(defaultCard).useMaterial3, true);
|
||||
expect(Theme.of(defaultChip).useMaterial3, true);
|
||||
|
||||
Finder appbarM3Icon = find.descendant(
|
||||
of: find.byType(AppBar),
|
||||
matching: find.widgetWithIcon(IconButton, Icons.filter_2),
|
||||
);
|
||||
await tester.tap(appbarM3Icon);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext updatedElevatedButton = tester.firstElement(
|
||||
find.byType(ElevatedButton),
|
||||
);
|
||||
BuildContext updatedIconButton = tester.firstElement(
|
||||
find.byType(IconButton),
|
||||
);
|
||||
BuildContext updatedFAB = tester.firstElement(
|
||||
find.byType(FloatingActionButton),
|
||||
);
|
||||
BuildContext updatedCard = tester.firstElement(find.byType(Card));
|
||||
BuildContext updatedChip = tester.firstElement(
|
||||
find.widgetWithText(ActionChip, 'Assist'),
|
||||
);
|
||||
Finder updatedDialog = find.text('Show dialog');
|
||||
await tester.tap(updatedDialog);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext updatedAlertDialog = tester.firstElement(
|
||||
find.byType(AlertDialog),
|
||||
);
|
||||
expect(Theme.of(updatedAlertDialog).useMaterial3, false);
|
||||
Finder updatedDismiss = find.text('Dismiss');
|
||||
await tester.tap(updatedDismiss);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
|
||||
expect(find.widgetWithIcon(AppBar, Icons.filter_3), findsOneWidget);
|
||||
expect(find.widgetWithIcon(AppBar, Icons.filter_2), findsNothing);
|
||||
expect(find.text('Material 2'), findsOneWidget);
|
||||
expect(Theme.of(updatedElevatedButton).useMaterial3, false);
|
||||
expect(Theme.of(updatedIconButton).useMaterial3, false);
|
||||
expect(Theme.of(updatedFAB).useMaterial3, false);
|
||||
expect(Theme.of(updatedCard).useMaterial3, false);
|
||||
expect(Theme.of(updatedChip).useMaterial3, false);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Other screens become Material2 mode after changing mode from '
|
||||
'main screen',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(const App());
|
||||
Finder appbarM2Icon = find.descendant(
|
||||
of: find.byType(AppBar),
|
||||
matching: find.widgetWithIcon(IconButton, Icons.filter_2),
|
||||
);
|
||||
await tester.tap(appbarM2Icon);
|
||||
Finder secondScreenIcon = find.descendant(
|
||||
of: find.byType(NavigationBar),
|
||||
matching: find.widgetWithIcon(
|
||||
NavigationDestination,
|
||||
Icons.format_paint_outlined,
|
||||
),
|
||||
);
|
||||
await tester.tap(secondScreenIcon);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext lightThemeText = tester.element(
|
||||
find.text('Light ColorScheme'),
|
||||
);
|
||||
expect(Theme.of(lightThemeText).useMaterial3, false);
|
||||
Finder thirdScreenIcon = find.descendant(
|
||||
of: find.byType(NavigationBar),
|
||||
matching: find.widgetWithIcon(
|
||||
NavigationDestination,
|
||||
Icons.text_snippet_outlined,
|
||||
),
|
||||
);
|
||||
await tester.tap(thirdScreenIcon);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext displayLargeText = tester.element(
|
||||
find.text('Display Large'),
|
||||
);
|
||||
expect(Theme.of(displayLargeText).useMaterial3, false);
|
||||
Finder fourthScreenIcon = find.descendant(
|
||||
of: find.byType(NavigationBar),
|
||||
matching: find.widgetWithIcon(
|
||||
NavigationDestination,
|
||||
Icons.invert_colors_on_outlined,
|
||||
),
|
||||
);
|
||||
await tester.tap(fourthScreenIcon);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
BuildContext material = tester.firstElement(find.byType(Material));
|
||||
expect(Theme.of(material).useMaterial3, false);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Brightness mode switches between dark and light when'
|
||||
'the brightness icon is clicked', (tester) async {
|
||||
await tester.pumpWidget(const App());
|
||||
Finder lightIcon = find.descendant(
|
||||
of: find.byType(AppBar),
|
||||
matching: find.widgetWithIcon(IconButton, Icons.light_mode_outlined),
|
||||
);
|
||||
Finder darkIcon = find.descendant(
|
||||
of: find.byType(AppBar),
|
||||
matching: find.widgetWithIcon(IconButton, Icons.dark_mode_outlined),
|
||||
);
|
||||
BuildContext appBar = tester.element(find.byType(AppBar).first);
|
||||
BuildContext body = tester.firstElement(find.byType(Scaffold).first);
|
||||
BuildContext navigationRail = tester.element(
|
||||
find.widgetWithIcon(NavigationRail, Icons.format_paint_outlined),
|
||||
);
|
||||
expect(darkIcon, findsOneWidget);
|
||||
expect(lightIcon, findsNothing);
|
||||
expect(Theme.of(appBar).brightness, Brightness.light);
|
||||
expect(Theme.of(body).brightness, Brightness.light);
|
||||
expect(Theme.of(navigationRail).brightness, Brightness.light);
|
||||
await tester.tap(darkIcon);
|
||||
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
||||
|
||||
BuildContext appBar2 = tester.element(find.byType(AppBar).first);
|
||||
BuildContext body2 = tester.element(find.byType(Scaffold).first);
|
||||
BuildContext navigationRail2 = tester.element(
|
||||
find.widgetWithIcon(NavigationRail, Icons.format_paint_outlined),
|
||||
);
|
||||
|
||||
expect(darkIcon, findsNothing);
|
||||
expect(lightIcon, findsOneWidget);
|
||||
expect(Theme.of(appBar2).brightness, Brightness.dark);
|
||||
expect(Theme.of(body2).brightness, Brightness.dark);
|
||||
expect(Theme.of(navigationRail2).brightness, Brightness.dark);
|
||||
});
|
||||
|
||||
testWidgets('Color theme changes when a color is selected from menu', (
|
||||
tester,
|
||||
) async {
|
||||
Color m3BaseColor = const Color(0xff65558f);
|
||||
await tester.pumpWidget(Container());
|
||||
await tester.pumpWidget(const App());
|
||||
await tester.pump();
|
||||
Finder menuIcon = find.descendant(
|
||||
of: find.byType(AppBar),
|
||||
matching: find.widgetWithIcon(IconButton, Icons.palette_outlined),
|
||||
);
|
||||
BuildContext appBar = tester.element(
|
||||
find.widgetWithIcon(AppBar, Icons.palette_outlined).first,
|
||||
);
|
||||
BuildContext body = tester.element(find.byType(Scaffold).first);
|
||||
|
||||
expect(Theme.of(appBar).primaryColor, m3BaseColor);
|
||||
expect(Theme.of(body).primaryColor, m3BaseColor);
|
||||
await tester.tap(menuIcon);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Blue').last);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
BuildContext appBar2 = tester.element(find.byType(AppBar).first);
|
||||
BuildContext body2 = tester.element(find.byType(Scaffold).first);
|
||||
ThemeData expectedTheme = ThemeData(colorSchemeSeed: Colors.blue);
|
||||
expect(Theme.of(appBar2).primaryColor, expectedTheme.primaryColor);
|
||||
expect(Theme.of(body2).primaryColor, expectedTheme.primaryColor);
|
||||
});
|
||||
}
|
||||
|
||||
void widgetSetup(
|
||||
|
||||
Reference in New Issue
Block a user