summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsku <Ansku@users.noreply.github.com>2017-11-22 10:29:42 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-11-23 16:13:29 +0200
commit0759a477130ab25198632b33664234b5d93178b0 (patch)
treecb52b87c2515013c4c63837f48306af74549bcca
parent5bc0a2f77183fcd0aaed8af7651fcbae553aeae9 (diff)
downloadvaadin-framework-0759a477130ab25198632b33664234b5d93178b0.tar.gz
vaadin-framework-0759a477130ab25198632b33664234b5d93178b0.zip
Test for MenuBar's WAI-ARIA attributes (#3922) (#10349)
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java5
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarsWithWaiAriaTest.java100
2 files changed, 105 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java
index 48199feeb4..bc7259e013 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarsWithNesting.java
@@ -90,6 +90,11 @@ public class MenuBarsWithNesting extends AbstractReindeerTestUI {
edit.addItem("Paste", selectionCommand);
menuBar.addItem("Help", selectionCommand);
+
+ MenuItem disabled = menuBar.addItem("Disabled", null);
+ disabled.setEnabled(false);
+ disabled.addItem("Can't reach", selectionCommand);
+
return menuBar;
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarsWithWaiAriaTest.java b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarsWithWaiAriaTest.java
new file mode 100644
index 0000000000..08a5e229ed
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuBarsWithWaiAriaTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.menubar;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.MenuBarElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * This class tests that MenuBar and its contents have all the required WAI-ARIA
+ * attributes.
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class MenuBarsWithWaiAriaTest extends MultiBrowserTest {
+ private MenuBarElement firstMenuBar;
+
+ @Override
+ protected Class<?> getUIClass() {
+ return MenuBarsWithNesting.class;
+ }
+
+ @Before
+ public void init() {
+ openTestURL();
+ firstMenuBar = $(MenuBarElement.class).first();
+ }
+
+ @Test
+ public void testMenuBar() {
+ assertEquals("menubar", firstMenuBar.getAttribute("role"));
+ assertNull(firstMenuBar.getAttribute("aria-haspopup"));
+ assertNull(firstMenuBar.getAttribute("aria-disabled"));
+ assertEquals("0", firstMenuBar.getAttribute("tabindex"));
+ }
+
+ @Test
+ public void testSubMenu() {
+ WebElement fileMenu = firstMenuBar.findElement(By.vaadin("#File"));
+ fileMenu.click();
+ WebElement submenu = findElement(By.className("v-menubar-submenu"));
+ assertEquals("menu", submenu.getAttribute("role"));
+ assertNull(submenu.getAttribute("aria-haspopup"));
+ assertNull(submenu.getAttribute("aria-disabled"));
+ assertEquals("-1", submenu.getAttribute("tabindex"));
+ }
+
+ @Test
+ public void testEnabledMenuItems() {
+ WebElement fileMenu = firstMenuBar.findElement(By.vaadin("#File"));
+ assertEquals("menuitem", fileMenu.getAttribute("role"));
+ assertEquals("true", fileMenu.getAttribute("aria-haspopup"));
+ assertNull(fileMenu.getAttribute("aria-disabled"));
+ assertEquals("-1", fileMenu.getAttribute("tabindex"));
+ fileMenu.click();
+
+ WebElement open = fileMenu.findElement(By.vaadin("#Open"));
+ assertEquals("menuitem", open.getAttribute("role"));
+ assertNull(open.getAttribute("aria-haspopup"));
+ assertNull(open.getAttribute("aria-disabled"));
+ assertEquals("-1", open.getAttribute("tabindex"));
+
+ WebElement separator = findElement(By.className("v-menubar-separator"));
+ assertEquals("separator", separator.getAttribute("role"));
+ assertNull(separator.getAttribute("aria-haspopup"));
+ assertNull(separator.getAttribute("aria-disabled"));
+ assertEquals("-1", separator.getAttribute("tabindex"));
+ }
+
+ @Test
+ public void testDisabledMenuItem() {
+ WebElement disabledMenu = firstMenuBar
+ .findElement(By.vaadin("#Disabled"));
+ assertEquals("menuitem", disabledMenu.getAttribute("role"));
+ assertEquals("true", disabledMenu.getAttribute("aria-haspopup"));
+ assertEquals("true", disabledMenu.getAttribute("aria-disabled"));
+ assertEquals("-1", disabledMenu.getAttribute("tabindex"));
+ }
+}