Unverified Commit dcb47f62 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

A11y fixes and tests for PopUpMenu (#17446)

parent 5d8d14b7
...@@ -262,13 +262,11 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> { ...@@ -262,13 +262,11 @@ class PopupMenuItemState<T, W extends PopupMenuItem<T>> extends State<W> {
return new InkWell( return new InkWell(
onTap: widget.enabled ? handleTap : null, onTap: widget.enabled ? handleTap : null,
child: new MergeSemantics(
child: new Container( child: new Container(
height: widget.height, height: widget.height,
padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding), padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding),
child: item, child: item,
), ),
),
); );
} }
} }
......
...@@ -430,15 +430,18 @@ void main() { ...@@ -430,15 +430,18 @@ void main() {
expect(MediaQuery.of(popupContext).padding, EdgeInsets.zero); expect(MediaQuery.of(popupContext).padding, EdgeInsets.zero);
}); });
testWidgets('PopupMenu includes route semantics', (WidgetTester tester) async { testWidgets('open PopupMenu has correct semantics', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(new MaterialApp( await tester.pumpWidget(new MaterialApp(
home: new Material( home: new Material(
child: new PopupMenuButton<int>( child: new PopupMenuButton<int>(
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return <PopupMenuItem<int>>[ return <PopupMenuItem<int>>[
const PopupMenuItem<int>(value: 1, child: const Text('1')),
const PopupMenuItem<int>(value: 2, child: const Text('2')), const PopupMenuItem<int>(value: 2, child: const Text('2')),
const PopupMenuItem<int>(value: 3, child: const Text('3')), const PopupMenuItem<int>(value: 3, child: const Text('3')),
const PopupMenuItem<int>(value: 4, child: const Text('4')),
const PopupMenuItem<int>(value: 5, child: const Text('5')),
]; ];
}, },
child: const SizedBox( child: const SizedBox(
...@@ -452,12 +455,56 @@ void main() { ...@@ -452,12 +455,56 @@ void main() {
await tester.tap(find.text('XXX')); await tester.tap(find.text('XXX'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(semantics, includesNodeWith( expect(semantics, hasSemantics(
label: 'Popup menu', new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.namesRoute,
SemanticsFlag.scopesRoute, SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
], ],
label: 'Popup menu',
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap],
label: '1',
textDirection: TextDirection.ltr,
),
new TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap],
label: '2',
textDirection: TextDirection.ltr,
),
new TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap],
label: '3',
textDirection: TextDirection.ltr,
),
new TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap],
label: '4',
textDirection: TextDirection.ltr,
),
new TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap],
label: '5',
textDirection: TextDirection.ltr,
),
],
),
],
),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
)); ));
semantics.dispose(); semantics.dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment