@@ -26,11 +26,26 @@ void main() {
2626 await tester.pump ();
2727 }
2828
29- group ('ThemeSetting' , () {
30- Finder findRadioListTileWithTitle (String title) => find.ancestor (
31- of: find.text (title),
32- matching: find.byType (RadioListTile <ThemeSetting ?>));
29+ Finder findRadioListTileWithTitle <T >(String title) => find.ancestor (
30+ of: find.text (title),
31+ matching: find.byType (RadioListTile <T >));
32+
33+ void checkRadioButtonAppearsChecked <T >(WidgetTester tester, String title, bool expectedIsChecked) {
34+ check (tester.semantics.find (findRadioListTileWithTitle <T >(title)))
35+ // `.legacyMatcher()` wrapper just because flutter_checks's
36+ // `matchesSemantics` doesn't yet have a `hasSelectedState` param
37+ .legacyMatcher (matchesSemantics (
38+ label: title,
39+ isFocusable: true ,
40+ hasEnabledState: true , isEnabled: true ,
41+ isInMutuallyExclusiveGroup: true ,
42+ hasCheckedState: true , isChecked: expectedIsChecked,
43+ hasSelectedState: true ,
44+ hasTapAction: true ,
45+ hasFocusAction: true ));
46+ }
3347
48+ group ('ThemeSetting' , () {
3449 void checkThemeSetting (WidgetTester tester, {
3550 required ThemeSetting ? expectedThemeSetting,
3651 }) {
@@ -40,19 +55,7 @@ void main() {
4055 ThemeSetting .dark => 'Dark' ,
4156 };
4257 for (final title in ['System' , 'Light' , 'Dark' ]) {
43- final expectedIsChecked = title == expectedCheckedTitle;
44- check (tester.semantics.find (findRadioListTileWithTitle (title)))
45- // `.legacyMatcher()` wrapper just because flutter_checks's
46- // `matchesSemantics` doesn't yet have a `hasSelectedState` param
47- .legacyMatcher (matchesSemantics (
48- label: title,
49- isFocusable: true ,
50- hasEnabledState: true , isEnabled: true ,
51- isInMutuallyExclusiveGroup: true ,
52- hasCheckedState: true , isChecked: expectedIsChecked,
53- hasSelectedState: true ,
54- hasTapAction: true ,
55- hasFocusAction: true ));
58+ checkRadioButtonAppearsChecked <ThemeSetting ?>(tester, title, title == expectedCheckedTitle);
5659 }
5760 check (testBinding.globalStore)
5861 .settings.themeSetting.equals (expectedThemeSetting);
@@ -67,13 +70,13 @@ void main() {
6770 check (Theme .of (element)).brightness.equals (Brightness .light);
6871 checkThemeSetting (tester, expectedThemeSetting: ThemeSetting .light);
6972
70- await tester.tap (findRadioListTileWithTitle ('Dark' ));
73+ await tester.tap (findRadioListTileWithTitle < ThemeSetting ?> ('Dark' ));
7174 await tester.pump ();
7275 await tester.pump (Duration (milliseconds: 250 )); // wait for transition
7376 check (Theme .of (element)).brightness.equals (Brightness .dark);
7477 checkThemeSetting (tester, expectedThemeSetting: ThemeSetting .dark);
7578
76- await tester.tap (findRadioListTileWithTitle ('System' ));
79+ await tester.tap (findRadioListTileWithTitle < ThemeSetting ?> ('System' ));
7780 await tester.pump ();
7881 await tester.pump (Duration (milliseconds: 250 )); // wait for transition
7982 check (Theme .of (element)).brightness.equals (Brightness .light);
0 commit comments