diff options
author | Ansku <Ansku@users.noreply.github.com> | 2017-11-21 14:19:52 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-11-21 20:25:39 +0200 |
commit | 6c97259330d0453053367e8774331f1372dad074 (patch) | |
tree | 81277613f57612d58463ff29b2b866d5cf9f5a88 /uitest | |
parent | 62dd51bf5081c70a280184a34d85fbc741012174 (diff) | |
download | vaadin-framework-6c97259330d0453053367e8774331f1372dad074.tar.gz vaadin-framework-6c97259330d0453053367e8774331f1372dad074.zip |
Issue3922disableditem (#10259)
* Accessibility for MenuBar (#3922)
* TabIndex handling fix and an indexing tweak
* Make disabled MenuItems selectable for accessibility (#3922)
- It should be possible to navigate to a disabled MenuItem, even if
triggering the related command is disabled
* Refactor primary style name and aria attribute handling to own method
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarNavigation.java | 3 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarNavigation.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarNavigation.java index b7f2206979..134ccc998a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarNavigation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarNavigation.java @@ -40,6 +40,9 @@ public class MenuBarNavigation extends AbstractTestUIWithLog edit.addItem("Cut", this); edit.addItem("Paste", this); mb.addItem("Help", this); + MenuItem disabled = mb.addItem("Disabled", this); + disabled.setEnabled(false); + disabled.addItem("Can't reach", this); addComponent(mb); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java index 2f8c4f2e46..6bcb1a259a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarNavigationKeyboardTest.java @@ -9,6 +9,7 @@ import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.interactions.Actions; +import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.MenuBarElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -85,11 +86,38 @@ public class MenuBarNavigationKeyboardTest extends MultiBrowserTest { isElementPresent(By.className("v-menubar-popup"))); } + @Test + public void testNavigatingToDisabled() throws InterruptedException { + openTestURL(); + + openMenu("File"); + + getMenuBar().sendKeys(Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, + Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ENTER); + + assertTrue("Disabled menu not selected", + getFocusedElement().getText().contains("Disabled")); + + assertFalse("Disabled menu was triggered", + logContainsText("MenuItem Disabled selected")); + + getMenuBar().sendKeys(Keys.ARROW_DOWN, Keys.ENTER); + + assertFalse("Disabled submenu was opened", + logContainsText("MenuItem Disabled/Can't reach selected")); + + assertTrue("Disabled menu not selected", + getFocusedElement().getText().contains("Disabled")); + } + public MenuBarElement getMenuBar() { return $(MenuBarElement.class).first(); } public void openMenu(String name) { + // move hover focus outside the MenuBar to keep the behaviour stable + new Actions(driver).moveToElement($(LabelElement.class).first(), 10, 10) + .perform(); getMenuBar().clickItem(name); } } |