Reland "Update PopupMenuButton to match Material Design spec" (#74620)

This commit is contained in:
xubaolin
2021-02-02 06:46:03 +08:00
committed by GitHub
parent 76be55813b
commit 12016e4145
4 changed files with 306 additions and 92 deletions

View File

@@ -409,8 +409,14 @@ void main() {
});
test('Popup Menu has correct Android semantics', () async {
final SerializableFinder button = find.descendant(
of: find.byValueKey(popupButtonKeyValue),
matching: find.byType('Semantics'),
firstMatchOnly: true,
);
expect(
await getSemantics(find.byValueKey(popupButtonKeyValue)),
await getSemantics(button),
hasAndroidSemantics(
className: AndroidClassName.button,
isChecked: false,
@@ -432,20 +438,21 @@ void main() {
for (final String item in popupItems) {
expect(
await getSemantics(find.byValueKey('$popupKeyValue.$item')),
hasAndroidSemantics(
className: AndroidClassName.button,
isChecked: false,
isCheckable: false,
isEnabled: true,
isFocusable: true,
actions: <AndroidSemanticsAction>[
if (item == popupItems.first) AndroidSemanticsAction.clearAccessibilityFocus,
if (item != popupItems.first) AndroidSemanticsAction.accessibilityFocus,
AndroidSemanticsAction.click,
],
),
reason: "Popup $item doesn't have the right semantics");
await getSemantics(find.byValueKey('$popupKeyValue.$item')),
hasAndroidSemantics(
className: AndroidClassName.button,
isChecked: false,
isCheckable: false,
isEnabled: true,
isFocusable: true,
actions: <AndroidSemanticsAction>[
if (item == popupItems.first) AndroidSemanticsAction.clearAccessibilityFocus,
if (item != popupItems.first) AndroidSemanticsAction.accessibilityFocus,
AndroidSemanticsAction.click,
],
),
reason: "Popup $item doesn't have the right semantics",
);
}
await driver.tap(find.byValueKey('$popupKeyValue.${popupItems.first}'));