|
|
@ -10,15 +10,15 @@ import 'package:material_3_demo/main.dart';
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
void main() {
|
|
|
|
testWidgets('Default main page shows all M3 components', (tester) async {
|
|
|
|
testWidgets('Default main page shows all M3 components', (tester) async {
|
|
|
|
widgetSetup(tester, 800, windowHeight: 3500);
|
|
|
|
widgetSetup(tester, 800, windowHeight: 7000);
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
|
|
|
|
|
|
|
|
// Elements on the app bar
|
|
|
|
// Elements on the app bar
|
|
|
|
expect(find.text('Material 3'), findsOneWidget);
|
|
|
|
expect(find.text('Material 3'), findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(IconButton, Icons.wb_sunny_outlined),
|
|
|
|
expect(
|
|
|
|
findsOneWidget);
|
|
|
|
find.widgetWithIcon(AppBar, Icons.wb_sunny_outlined), findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(IconButton, Icons.filter_3), findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.filter_3), findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(IconButton, Icons.more_vert), findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.more_vert), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
// Elements on the component screen
|
|
|
|
// Elements on the component screen
|
|
|
|
// Buttons
|
|
|
|
// Buttons
|
|
|
@ -27,13 +27,14 @@ void main() {
|
|
|
|
expect(find.widgetWithText(FilledButton, 'Filled Tonal'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(FilledButton, 'Filled Tonal'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(OutlinedButton, 'Outlined'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(OutlinedButton, 'Outlined'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(TextButton, 'Text'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(TextButton, 'Text'), findsNWidgets(2));
|
|
|
|
expect(find.text('Icon'), findsNWidgets(5));
|
|
|
|
expect(find.widgetWithText(Buttons, 'Icon'), findsNWidgets(5));
|
|
|
|
|
|
|
|
|
|
|
|
// IconButtons
|
|
|
|
// IconButtons
|
|
|
|
expect(find.byType(IconToggleButton), findsNWidgets(8));
|
|
|
|
expect(find.byType(IconToggleButton), findsNWidgets(8));
|
|
|
|
|
|
|
|
|
|
|
|
// FABs
|
|
|
|
// FABs
|
|
|
|
expect(find.byType(FloatingActionButton), findsNWidgets(4));
|
|
|
|
expect(find.byType(FloatingActionButton),
|
|
|
|
|
|
|
|
findsNWidgets(6)); // 2 more shows up in the bottom app bar.
|
|
|
|
expect(find.widgetWithText(FloatingActionButton, 'Create'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(FloatingActionButton, 'Create'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
// Chips
|
|
|
|
// Chips
|
|
|
@ -43,9 +44,9 @@ void main() {
|
|
|
|
expect(find.byType(InputChip), findsNWidgets(4));
|
|
|
|
expect(find.byType(InputChip), findsNWidgets(4));
|
|
|
|
|
|
|
|
|
|
|
|
// Cards
|
|
|
|
// Cards
|
|
|
|
expect(find.widgetWithText(Card, 'Filled'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(Cards, 'Elevated'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(Card, 'Filled'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(Cards, 'Filled'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(Card, 'Outlined'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(Cards, 'Outlined'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
// TextFields
|
|
|
|
// TextFields
|
|
|
|
expect(find.widgetWithText(TextField, 'Disabled'), findsNWidgets(2));
|
|
|
|
expect(find.widgetWithText(TextField, 'Disabled'), findsNWidgets(2));
|
|
|
@ -76,68 +77,57 @@ void main() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'NavigationRail doesn\'t show when width value is small than 450 '
|
|
|
|
'NavigationRail doesn\'t show when width value is small than 1000 '
|
|
|
|
'(in Portrait mode or narrow screen)', (tester) async {
|
|
|
|
'(in Portrait mode or narrow screen)', (tester) async {
|
|
|
|
widgetSetup(tester, 449);
|
|
|
|
widgetSetup(tester, 999, windowHeight: 7000);
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
|
|
// When screen width is less than 450, NavigationBar will show. At the same
|
|
|
|
// When screen width is less than 1000, NavigationBar will show. At the same
|
|
|
|
// time, the NavigationRail and the NavigationBar example will NOT show.
|
|
|
|
// time, the NavigationBar example still show up in the navigation group.
|
|
|
|
expect(find.byType(NavigationBars), findsOneWidget);
|
|
|
|
expect(find.byType(NavigationBars),
|
|
|
|
|
|
|
|
findsNWidgets(3)); // The real navBar, badges example and navBar example
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Components'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Components'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Color'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Color'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Typography'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Typography'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Elevation'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Elevation'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.byType(NavigationRailSection), findsNothing);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Explore'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Explore'), findsNothing);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Pets'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Pets'), findsNothing);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Account'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Account'), findsNothing);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'NavigationRail shows when width value is greater than or equal '
|
|
|
|
'NavigationRail shows when width value is greater than or equal '
|
|
|
|
'to 450 (in Landscape mode or wider screen)', (tester) async {
|
|
|
|
'to 1000 (in Landscape mode or wider screen)', (tester) async {
|
|
|
|
widgetSetup(tester, 450);
|
|
|
|
widgetSetup(tester, 1001, windowHeight: 3000);
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
// When screen width is greater than or equal to 450, NavigationRail and
|
|
|
|
|
|
|
|
// NavigationBar example will show. At the same time, the NavigationBar
|
|
|
|
// When screen width is greater than or equal to 1000, NavigationRail will show.
|
|
|
|
// will NOT show.
|
|
|
|
// At the same time, the NavigationBar will NOT show.
|
|
|
|
expect(find.byType(NavigationRailSection), findsOneWidget);
|
|
|
|
expect(find.byType(NavigationRail), findsOneWidget);
|
|
|
|
expect(find.byType(Tooltip, skipOffstage: false), findsWidgets);
|
|
|
|
expect(find.byType(Tooltip, skipOffstage: false), findsWidgets);
|
|
|
|
expect(find.widgetWithText(NavigationRailSection, 'Components'),
|
|
|
|
expect(find.widgetWithText(NavigationRail, 'Components'), findsOneWidget);
|
|
|
|
findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationRail, 'Color'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationRailSection, 'Color'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationRail, 'Typography'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationRailSection, 'Typography'),
|
|
|
|
expect(find.widgetWithText(NavigationRail, 'Elevation'), findsOneWidget);
|
|
|
|
findsOneWidget);
|
|
|
|
|
|
|
|
expect(find.widgetWithText(NavigationRailSection, 'Elevation'),
|
|
|
|
|
|
|
|
findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final navbarExample = find.byType(NavigationBars);
|
|
|
|
|
|
|
|
await tester.scrollUntilVisible(
|
|
|
|
|
|
|
|
scrollable: find.byType(Scrollable).first,
|
|
|
|
|
|
|
|
navbarExample,
|
|
|
|
|
|
|
|
500.0,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(find.byType(NavigationBars), findsOneWidget);
|
|
|
|
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Explore'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Explore'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Pets'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Pets'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Account'), findsOneWidget);
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Account'), findsOneWidget);
|
|
|
|
|
|
|
|
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Components'), findsNothing);
|
|
|
|
// the Navigation bar should be out of screen.
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Colors'), findsNothing);
|
|
|
|
final RenderBox box =
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Typography'), findsNothing);
|
|
|
|
tester.renderObject(find.widgetWithText(NavigationBar, 'Components'));
|
|
|
|
expect(find.widgetWithText(NavigationBar, 'Elevation'), findsNothing);
|
|
|
|
expect(box.localToGlobal(Offset.zero), const Offset(0.0, 3080.0));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'Material version switches between Material3 and Material2 when'
|
|
|
|
'Material version switches between Material3 and Material2 when'
|
|
|
|
'the version icon is clicked', (tester) async {
|
|
|
|
'the version icon is clicked', (tester) async {
|
|
|
|
widgetSetup(tester, 450, windowHeight: 3000);
|
|
|
|
widgetSetup(tester, 450, windowHeight: 7000);
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
Finder m3Icon = find.widgetWithIcon(IconButton, Icons.filter_3);
|
|
|
|
|
|
|
|
Finder m2Icon = find.widgetWithIcon(IconButton, Icons.filter_2);
|
|
|
|
|
|
|
|
BuildContext defaultElevatedButton =
|
|
|
|
BuildContext defaultElevatedButton =
|
|
|
|
tester.firstElement(find.byType(ElevatedButton));
|
|
|
|
tester.firstElement(find.byType(ElevatedButton));
|
|
|
|
BuildContext defaultIconButton =
|
|
|
|
BuildContext defaultIconButton =
|
|
|
@ -157,8 +147,8 @@ void main() {
|
|
|
|
await tester.tap(dismiss);
|
|
|
|
await tester.tap(dismiss);
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
|
|
|
|
|
|
|
|
expect(m3Icon, findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.filter_3), findsOneWidget);
|
|
|
|
expect(m2Icon, findsNothing);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.filter_2), findsNothing);
|
|
|
|
expect(find.text('Material 3'), findsOneWidget);
|
|
|
|
expect(find.text('Material 3'), findsOneWidget);
|
|
|
|
expect(Theme.of(defaultElevatedButton).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultElevatedButton).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultIconButton).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultIconButton).useMaterial3, true);
|
|
|
@ -166,7 +156,10 @@ void main() {
|
|
|
|
expect(Theme.of(defaultCard).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultCard).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultChip).useMaterial3, true);
|
|
|
|
expect(Theme.of(defaultChip).useMaterial3, true);
|
|
|
|
|
|
|
|
|
|
|
|
await tester.tap(m3Icon);
|
|
|
|
Finder appbarM3Icon = find.descendant(
|
|
|
|
|
|
|
|
of: find.byType(AppBar),
|
|
|
|
|
|
|
|
matching: find.widgetWithIcon(IconButton, Icons.filter_3));
|
|
|
|
|
|
|
|
await tester.tap(appbarM3Icon);
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
BuildContext updatedElevatedButton =
|
|
|
|
BuildContext updatedElevatedButton =
|
|
|
|
tester.firstElement(find.byType(ElevatedButton));
|
|
|
|
tester.firstElement(find.byType(ElevatedButton));
|
|
|
@ -187,8 +180,8 @@ void main() {
|
|
|
|
await tester.tap(updatedDismiss);
|
|
|
|
await tester.tap(updatedDismiss);
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
|
|
|
|
|
|
|
|
expect(m3Icon, findsNothing);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.filter_2), findsOneWidget);
|
|
|
|
expect(m2Icon, findsOneWidget);
|
|
|
|
expect(find.widgetWithIcon(AppBar, Icons.filter_3), findsNothing);
|
|
|
|
expect(find.text('Material 2'), findsOneWidget);
|
|
|
|
expect(find.text('Material 2'), findsOneWidget);
|
|
|
|
expect(Theme.of(updatedElevatedButton).useMaterial3, false);
|
|
|
|
expect(Theme.of(updatedElevatedButton).useMaterial3, false);
|
|
|
|
expect(Theme.of(updatedIconButton).useMaterial3, false);
|
|
|
|
expect(Theme.of(updatedIconButton).useMaterial3, false);
|
|
|
@ -200,17 +193,32 @@ void main() {
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'Other screens become Material2 mode after changing mode from '
|
|
|
|
'Other screens become Material2 mode after changing mode from '
|
|
|
|
'main screen', (tester) async {
|
|
|
|
'main screen', (tester) async {
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
await tester.tap(find.widgetWithIcon(IconButton, Icons.filter_3));
|
|
|
|
Finder appbarM3Icon = find.descendant(
|
|
|
|
await tester.tap(find.byIcon(Icons.format_paint_outlined));
|
|
|
|
of: find.byType(AppBar),
|
|
|
|
|
|
|
|
matching: find.widgetWithIcon(IconButton, Icons.filter_3));
|
|
|
|
|
|
|
|
await tester.tap(appbarM3Icon);
|
|
|
|
|
|
|
|
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));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
BuildContext lightThemeText = tester.element(find.text('Light Theme'));
|
|
|
|
BuildContext lightThemeText = tester.element(find.text('Light Theme'));
|
|
|
|
expect(Theme.of(lightThemeText).useMaterial3, false);
|
|
|
|
expect(Theme.of(lightThemeText).useMaterial3, false);
|
|
|
|
await tester.tap(find.byIcon(Icons.text_snippet_outlined));
|
|
|
|
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));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
BuildContext displayLargeText = tester.element(find.text('Display Large'));
|
|
|
|
BuildContext displayLargeText = tester.element(find.text('Display Large'));
|
|
|
|
expect(Theme.of(displayLargeText).useMaterial3, false);
|
|
|
|
expect(Theme.of(displayLargeText).useMaterial3, false);
|
|
|
|
await tester.tap(find.byIcon(Icons.invert_colors_on_outlined));
|
|
|
|
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));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
BuildContext material = tester.firstElement(find.byType(Material));
|
|
|
|
BuildContext material = tester.firstElement(find.byType(Material));
|
|
|
|
expect(Theme.of(material).useMaterial3, false);
|
|
|
|
expect(Theme.of(material).useMaterial3, false);
|
|
|
@ -219,12 +227,17 @@ void main() {
|
|
|
|
testWidgets(
|
|
|
|
testWidgets(
|
|
|
|
'Brightness mode switches between dark and light when'
|
|
|
|
'Brightness mode switches between dark and light when'
|
|
|
|
'the brightness icon is clicked', (tester) async {
|
|
|
|
'the brightness icon is clicked', (tester) async {
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
Finder lightIcon = find.widgetWithIcon(IconButton, Icons.wb_sunny_outlined);
|
|
|
|
Finder lightIcon = find.descendant(
|
|
|
|
Finder darkIcon = find.widgetWithIcon(IconButton, Icons.wb_sunny);
|
|
|
|
of: find.byType(AppBar),
|
|
|
|
BuildContext appBar = tester.element(find.byType(AppBar));
|
|
|
|
matching: find.widgetWithIcon(IconButton, Icons.wb_sunny_outlined));
|
|
|
|
BuildContext body = tester.element(find.byType(Scaffold));
|
|
|
|
Finder darkIcon = find.descendant(
|
|
|
|
BuildContext navigationRail = tester.element(find.byType(NavigationRail));
|
|
|
|
of: find.byType(AppBar),
|
|
|
|
|
|
|
|
matching: find.widgetWithIcon(IconButton, Icons.wb_sunny));
|
|
|
|
|
|
|
|
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(lightIcon, findsOneWidget);
|
|
|
|
expect(lightIcon, findsOneWidget);
|
|
|
|
expect(darkIcon, findsNothing);
|
|
|
|
expect(darkIcon, findsNothing);
|
|
|
|
expect(Theme.of(appBar).brightness, Brightness.light);
|
|
|
|
expect(Theme.of(appBar).brightness, Brightness.light);
|
|
|
@ -233,8 +246,8 @@ void main() {
|
|
|
|
await tester.tap(lightIcon);
|
|
|
|
await tester.tap(lightIcon);
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
await tester.pumpAndSettle(const Duration(microseconds: 500));
|
|
|
|
|
|
|
|
|
|
|
|
BuildContext appBar2 = tester.element(find.byType(AppBar));
|
|
|
|
BuildContext appBar2 = tester.element(find.byType(AppBar).first);
|
|
|
|
BuildContext body2 = tester.element(find.byType(Scaffold));
|
|
|
|
BuildContext body2 = tester.element(find.byType(Scaffold).first);
|
|
|
|
BuildContext navigationRail2 = tester.element(find.byType(NavigationRail));
|
|
|
|
BuildContext navigationRail2 = tester.element(find.byType(NavigationRail));
|
|
|
|
expect(lightIcon, findsNothing);
|
|
|
|
expect(lightIcon, findsNothing);
|
|
|
|
expect(darkIcon, findsOneWidget);
|
|
|
|
expect(darkIcon, findsOneWidget);
|
|
|
@ -245,10 +258,15 @@ void main() {
|
|
|
|
|
|
|
|
|
|
|
|
testWidgets('Color theme changes when a color is selected from menu',
|
|
|
|
testWidgets('Color theme changes when a color is selected from menu',
|
|
|
|
(tester) async {
|
|
|
|
(tester) async {
|
|
|
|
await tester.pumpWidget(const Material3Demo());
|
|
|
|
Color m3BaseColor = const Color(0xff6750a4);
|
|
|
|
Finder menuIcon = find.widgetWithIcon(IconButton, Icons.more_vert);
|
|
|
|
await tester.pumpWidget(Container());
|
|
|
|
BuildContext appBar = tester.element(find.byType(AppBar));
|
|
|
|
await tester.pumpWidget(const MaterialApp(home: Material3Demo()));
|
|
|
|
BuildContext body = tester.element(find.byType(Scaffold));
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
Finder menuIcon = find.descendant(
|
|
|
|
|
|
|
|
of: find.byType(AppBar),
|
|
|
|
|
|
|
|
matching: find.widgetWithIcon(IconButton, Icons.more_vert));
|
|
|
|
|
|
|
|
BuildContext appBar = tester.element(find.byType(AppBar).first);
|
|
|
|
|
|
|
|
BuildContext body = tester.element(find.byType(Scaffold).first);
|
|
|
|
BuildContext navigationRail = tester.element(find.byType(NavigationRail));
|
|
|
|
BuildContext navigationRail = tester.element(find.byType(NavigationRail));
|
|
|
|
|
|
|
|
|
|
|
|
expect(Theme.of(appBar).primaryColor, m3BaseColor);
|
|
|
|
expect(Theme.of(appBar).primaryColor, m3BaseColor);
|
|
|
@ -256,11 +274,11 @@ void main() {
|
|
|
|
expect(Theme.of(navigationRail).primaryColor, m3BaseColor);
|
|
|
|
expect(Theme.of(navigationRail).primaryColor, m3BaseColor);
|
|
|
|
await tester.tap(menuIcon);
|
|
|
|
await tester.tap(menuIcon);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.text('Blue'));
|
|
|
|
await tester.tap(find.text('Blue').last);
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
|
|
BuildContext appBar2 = tester.element(find.byType(AppBar));
|
|
|
|
BuildContext appBar2 = tester.element(find.byType(AppBar).first);
|
|
|
|
BuildContext body2 = tester.element(find.byType(Scaffold));
|
|
|
|
BuildContext body2 = tester.element(find.byType(Scaffold).first);
|
|
|
|
BuildContext navigationRail2 = tester.element(find.byType(NavigationRail));
|
|
|
|
BuildContext navigationRail2 = tester.element(find.byType(NavigationRail));
|
|
|
|
ThemeData expectedTheme = ThemeData(colorSchemeSeed: Colors.blue);
|
|
|
|
ThemeData expectedTheme = ThemeData(colorSchemeSeed: Colors.blue);
|
|
|
|
expect(Theme.of(appBar2).primaryColor, expectedTheme.primaryColor);
|
|
|
|
expect(Theme.of(appBar2).primaryColor, expectedTheme.primaryColor);
|
|
|
|