]> source.dussan.org Git - vaadin-framework.git/commitdiff
ExtraWindowShownWaiAria test upgrade (#14292)
authorAnna Koskinen <anna@vaadin.com>
Tue, 29 Jul 2014 13:02:56 +0000 (16:02 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 15 Aug 2014 11:34:21 +0000 (11:34 +0000)
Change-Id: I83f0d08850d2e03008601f10043314c00818bdaa

uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html [deleted file]
uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAria.html
deleted file mode 100644 (file)
index f5f89d1..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>ExtraWindowShownWaiAria</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">ExtraWindowShownWaiAria</td></tr>
-</thead><tbody>
-<tr>
-    <td>open</td>
-    <td>/run/com.vaadin.tests.components.window.ExtraWindowShownWaiAria?restartApplication</td>
-    <td></td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>assertElementPresent</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td>
-    <td></td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@role</td>
-    <td>dialog</td>
-</tr>
-<tr>
-    <td>storeAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]@id</td>
-    <td>headerid</td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-labelledby</td>
-    <td>${headerid}</td>
-</tr>
-<tr>
-    <td>storeAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@id</td>
-    <td>descriptionid</td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby</td>
-    <td>${descriptionid}</td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[2]@role</td>
-    <td>button</td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/domChild[0]/domChild[0]/domChild[3]@role</td>
-    <td>button</td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>assertElementNotPresent</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td>
-    <td></td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VCheckBox[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>storeAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[0]@id</td>
-    <td>descriptionid</td>
-</tr>
-<tr>
-    <td>storeAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VLabel[1]@id</td>
-    <td>description2id</td>
-</tr>
-<tr>
-    <td>assertAttribute</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/@aria-describedby</td>
-    <td>${descriptionid} ${description2id}</td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/FocusableScrollPanel[0]/VCssLayout[0]/VButton[0]/domChild[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>assertElementNotPresent</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VWindow[0]/</td>
-    <td></td>
-</tr>
-<tr>
-    <td>type</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VTextField[0]</td>
-    <td>Important</td>
-</tr>
-<tr>
-    <td>type</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[7]/VTextField[0]</td>
-    <td> - do ASAP</td>
-</tr>
-<tr>
-    <td>click</td>
-    <td>vaadin=runcomvaadintestscomponentswindowExtraWindowShownWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-    <td></td>
-</tr>
-<tr>
-    <td>assertText</td>
-    <td>xpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][1]</td>
-    <td>Important</td>
-</tr>
-<tr>
-    <td>assertText</td>
-    <td>xpath=//div[@class='v-window-header']/span[@class='v-assistive-device-only'][2]</td>
-    <td>- do ASAP</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java b/uitest/src/com/vaadin/tests/components/window/ExtraWindowShownWaiAriaTest.java
new file mode 100644 (file)
index 0000000..44aea35
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2000-2014 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.window;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.testbench.elements.WindowElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests dialogs with WAI-ARIA.
+ * 
+ * @since
+ * @author Vaadin Ltd
+ */
+public class ExtraWindowShownWaiAriaTest extends MultiBrowserTest {
+
+    @Test
+    public void testDialogs() throws InterruptedException {
+        openTestURL();
+
+        List<ButtonElement> buttons = $(ButtonElement.class).all();
+        assertFalse(buttons.isEmpty());
+
+        // open alert dialog
+        buttons.get(0).click();
+
+        // ensure dialog opened
+        List<WindowElement> windows = $(WindowElement.class).all();
+        assertFalse(windows.isEmpty());
+
+        // ensure correct attributes
+        assertEquals("alertdialog", windows.get(0).getAttribute("role"));
+
+        WebElement header = windows.get(0).findElement(
+                By.className("v-window-header"));
+        assertEquals(header.getAttribute("id"),
+                windows.get(0).getAttribute("aria-labelledby"));
+
+        WebElement label = windows.get(0).findElement(By.className("v-label"));
+        assertEquals(label.getAttribute("id"),
+                windows.get(0).getAttribute("aria-describedby"));
+
+        List<WebElement> wButtons = windows.get(0).findElements(
+                By.className("v-button"));
+        assertEquals("button", wButtons.get(0).getAttribute("role"));
+        assertEquals("button", wButtons.get(1).getAttribute("role"));
+
+        // close dialog
+        wButtons.get(0).click();
+
+        // ensure dialog closed
+        windows = $(WindowElement.class).all();
+        assertTrue(windows.isEmpty());
+
+        // check additional description (second checkbox on the page)
+        List<CheckBoxElement> checkBoxes = $(CheckBoxElement.class).all();
+        WebElement input = checkBoxes.get(1).findElement(By.tagName("input"));
+        // ensure that not checked yet
+        assertEquals(null, input.getAttribute("checked"));
+        input.click();
+        // ensure that checked now
+        assertEquals("true", input.getAttribute("checked"));
+
+        // open alert dialog
+        buttons = $(ButtonElement.class).all();
+        buttons.get(0).click();
+
+        // ensure correct attributes
+        windows = $(WindowElement.class).all();
+        List<WebElement> labels = windows.get(0).findElements(
+                By.className("v-label"));
+        assertEquals(labels.get(0).getAttribute("id") + " "
+                + labels.get(1).getAttribute("id"), windows.get(0)
+                .getAttribute("aria-describedby"));
+
+        // close dialog
+        wButtons = windows.get(0).findElements(By.className("v-button"));
+        wButtons.get(0).click();
+
+        // ensure dialog closed
+        windows = $(WindowElement.class).all();
+        assertTrue(windows.isEmpty());
+
+        // add prefix and postfix
+        List<TextFieldElement> textFields = $(TextFieldElement.class).all();
+        textFields.get(0).sendKeys("Important");
+        textFields.get(1).sendKeys(" - do ASAP");
+
+        // open alert dialog
+        buttons = $(ButtonElement.class).all();
+        buttons.get(0).click();
+
+        // ensure the assistive spans have been added to the header
+        windows = $(WindowElement.class).all();
+        header = windows.get(0).findElement(By.className("v-window-header"));
+        List<WebElement> assistiveElements = header.findElements(By
+                .className("v-assistive-device-only"));
+        assertEquals("Important",
+                assistiveElements.get(0).getAttribute("innerHTML"));
+        assertEquals(" - do ASAP",
+                assistiveElements.get(1).getAttribute("innerHTML"));
+    }
+}