diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index f318574c1d..2edf5dc14b 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -262,12 +262,10 @@ class PopupMenuItemState> extends State { return new InkWell( onTap: widget.enabled ? handleTap : null, - child: new MergeSemantics( - child: new Container( - height: widget.height, - padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding), - child: item, - ), + child: new Container( + height: widget.height, + padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding), + child: item, ), ); } diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 5be9fc605f..c00bcb8cfa 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -430,15 +430,18 @@ void main() { 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); await tester.pumpWidget(new MaterialApp( home: new Material( child: new PopupMenuButton( itemBuilder: (BuildContext context) { return >[ + const PopupMenuItem(value: 1, child: const Text('1')), const PopupMenuItem(value: 2, child: const Text('2')), const PopupMenuItem(value: 3, child: const Text('3')), + const PopupMenuItem(value: 4, child: const Text('4')), + const PopupMenuItem(value: 5, child: const Text('5')), ]; }, child: const SizedBox( @@ -452,12 +455,56 @@ void main() { await tester.tap(find.text('XXX')); await tester.pumpAndSettle(); - expect(semantics, includesNodeWith( - label: 'Popup menu', - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.scopesRoute, - ], + expect(semantics, hasSemantics( + new TestSemantics.root( + children: [ + new TestSemantics( + textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Popup menu', + textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + children: [ + new TestSemantics( + actions: [SemanticsAction.tap], + label: '1', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + actions: [SemanticsAction.tap], + label: '2', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + actions: [SemanticsAction.tap], + label: '3', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + actions: [SemanticsAction.tap], + label: '4', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + actions: [SemanticsAction.tap], + label: '5', + textDirection: TextDirection.ltr, + ), + ], + ), + ], + ), + ], + ), + ], + ), + ignoreId: true, ignoreTransform: true, ignoreRect: true, )); semantics.dispose();