@@ -765,31 +765,175 @@ void main() {
765
765
],
766
766
children: < TestSemantics > [
767
767
TestSemantics (
768
- flags: < SemanticsFlag > [SemanticsFlag .isFocusable],
768
+ flags: < SemanticsFlag > [
769
+ SemanticsFlag .isButton,
770
+ SemanticsFlag .hasEnabledState,
771
+ SemanticsFlag .isEnabled,
772
+ SemanticsFlag .isFocusable,
773
+ ],
769
774
actions: < SemanticsAction > [SemanticsAction .tap],
770
775
label: '1' ,
771
776
textDirection: TextDirection .ltr,
772
777
),
773
778
TestSemantics (
774
- flags: < SemanticsFlag > [SemanticsFlag .isFocusable],
779
+ flags: < SemanticsFlag > [
780
+ SemanticsFlag .isButton,
781
+ SemanticsFlag .hasEnabledState,
782
+ SemanticsFlag .isEnabled,
783
+ SemanticsFlag .isFocusable,
784
+ ],
775
785
actions: < SemanticsAction > [SemanticsAction .tap],
776
786
label: '2' ,
777
787
textDirection: TextDirection .ltr,
778
788
),
779
789
TestSemantics (
780
- flags: < SemanticsFlag > [SemanticsFlag .isFocusable],
790
+ flags: < SemanticsFlag > [
791
+ SemanticsFlag .isButton,
792
+ SemanticsFlag .hasEnabledState,
793
+ SemanticsFlag .isEnabled,
794
+ SemanticsFlag .isFocusable,
795
+ ],
781
796
actions: < SemanticsAction > [SemanticsAction .tap],
782
797
label: '3' ,
783
798
textDirection: TextDirection .ltr,
784
799
),
785
800
TestSemantics (
786
- flags: < SemanticsFlag > [SemanticsFlag .isFocusable],
801
+ flags: < SemanticsFlag > [
802
+ SemanticsFlag .isButton,
803
+ SemanticsFlag .hasEnabledState,
804
+ SemanticsFlag .isEnabled,
805
+ SemanticsFlag .isFocusable,
806
+ ],
787
807
actions: < SemanticsAction > [SemanticsAction .tap],
788
808
label: '4' ,
789
809
textDirection: TextDirection .ltr,
790
810
),
791
811
TestSemantics (
792
- flags: < SemanticsFlag > [SemanticsFlag .isFocusable],
812
+ flags: < SemanticsFlag > [
813
+ SemanticsFlag .isButton,
814
+ SemanticsFlag .hasEnabledState,
815
+ SemanticsFlag .isEnabled,
816
+ SemanticsFlag .isFocusable,
817
+ ],
818
+ actions: < SemanticsAction > [SemanticsAction .tap],
819
+ label: '5' ,
820
+ textDirection: TextDirection .ltr,
821
+ ),
822
+ ],
823
+ ),
824
+ ],
825
+ ),
826
+ ],
827
+ ),
828
+ TestSemantics (),
829
+ ],
830
+ ),
831
+ ],
832
+ ),
833
+ ignoreId: true , ignoreTransform: true , ignoreRect: true ,
834
+ ));
835
+
836
+ semantics.dispose ();
837
+ });
838
+
839
+ testWidgets ('disabled PopupMenuItem has correct semantics' , (WidgetTester tester) async {
840
+ // Regression test for https://github.com/flutter/flutter/issues/45044.
841
+ final SemanticsTester semantics = SemanticsTester (tester);
842
+ await tester.pumpWidget (
843
+ MaterialApp (
844
+ home: Material (
845
+ child: PopupMenuButton <int >(
846
+ itemBuilder: (BuildContext context) {
847
+ return < PopupMenuItem <int >> [
848
+ const PopupMenuItem <int >(value: 1 , child: Text ('1' )),
849
+ const PopupMenuItem <int >(value: 2 , enabled: false ,child: Text ('2' )),
850
+ const PopupMenuItem <int >(value: 3 , child: Text ('3' )),
851
+ const PopupMenuItem <int >(value: 4 , child: Text ('4' )),
852
+ const PopupMenuItem <int >(value: 5 , child: Text ('5' )),
853
+ ];
854
+ },
855
+ child: const SizedBox (
856
+ height: 100.0 ,
857
+ width: 100.0 ,
858
+ child: Text ('XXX' ),
859
+ ),
860
+ ),
861
+ ),
862
+ ),
863
+ );
864
+ await tester.tap (find.text ('XXX' ));
865
+ await tester.pumpAndSettle ();
866
+
867
+ expect (semantics, hasSemantics (
868
+ TestSemantics .root (
869
+ children: < TestSemantics > [
870
+ TestSemantics (
871
+ textDirection: TextDirection .ltr,
872
+ children: < TestSemantics > [
873
+ TestSemantics (
874
+ children: < TestSemantics > [
875
+ TestSemantics (
876
+ flags: < SemanticsFlag > [
877
+ SemanticsFlag .scopesRoute,
878
+ SemanticsFlag .namesRoute,
879
+ ],
880
+ label: 'Popup menu' ,
881
+ textDirection: TextDirection .ltr,
882
+ children: < TestSemantics > [
883
+ TestSemantics (
884
+ flags: < SemanticsFlag > [
885
+ SemanticsFlag .hasImplicitScrolling,
886
+ ],
887
+ children: < TestSemantics > [
888
+ TestSemantics (
889
+ flags: < SemanticsFlag > [
890
+ SemanticsFlag .isButton,
891
+ SemanticsFlag .hasEnabledState,
892
+ SemanticsFlag .isEnabled,
893
+ SemanticsFlag .isFocusable,
894
+ ],
895
+ actions: < SemanticsAction > [SemanticsAction .tap],
896
+ label: '1' ,
897
+ textDirection: TextDirection .ltr,
898
+ ),
899
+ TestSemantics (
900
+ flags: < SemanticsFlag > [
901
+ SemanticsFlag .isButton,
902
+ SemanticsFlag .hasEnabledState,
903
+ ],
904
+ actions: < SemanticsAction > [],
905
+ label: '2' ,
906
+ textDirection: TextDirection .ltr,
907
+ ),
908
+ TestSemantics (
909
+ flags: < SemanticsFlag > [
910
+ SemanticsFlag .isButton,
911
+ SemanticsFlag .hasEnabledState,
912
+ SemanticsFlag .isEnabled,
913
+ SemanticsFlag .isFocusable,
914
+ ],
915
+ actions: < SemanticsAction > [SemanticsAction .tap],
916
+ label: '3' ,
917
+ textDirection: TextDirection .ltr,
918
+ ),
919
+ TestSemantics (
920
+ flags: < SemanticsFlag > [
921
+ SemanticsFlag .isButton,
922
+ SemanticsFlag .hasEnabledState,
923
+ SemanticsFlag .isEnabled,
924
+ SemanticsFlag .isFocusable,
925
+ ],
926
+ actions: < SemanticsAction > [SemanticsAction .tap],
927
+ label: '4' ,
928
+ textDirection: TextDirection .ltr,
929
+ ),
930
+ TestSemantics (
931
+ flags: < SemanticsFlag > [
932
+ SemanticsFlag .isButton,
933
+ SemanticsFlag .hasEnabledState,
934
+ SemanticsFlag .isEnabled,
935
+ SemanticsFlag .isFocusable,
936
+ ],
793
937
actions: < SemanticsAction > [SemanticsAction .tap],
794
938
label: '5' ,
795
939
textDirection: TextDirection .ltr,
0 commit comments