diff options
author | Heikki Ohinmaa <heikki@vaadin.com> | 2014-07-25 18:59:01 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-07 12:10:42 +0000 |
commit | bb2e224a79026b5085a09b38faedf8c9d62b448d (patch) | |
tree | bf5fff67c6058205d6314fbcd65bd3f27ff922f6 /uitest/src/com/vaadin | |
parent | 409a41ce44f577170f4c84211515dbb5815f5642 (diff) | |
download | vaadin-framework-bb2e224a79026b5085a09b38faedf8c9d62b448d.tar.gz vaadin-framework-bb2e224a79026b5085a09b38faedf8c9d62b448d.zip |
NotificationsWaiAria test rewrite to TB3.
Change-Id: Ifd83ec30c02e7c39eb8d3d4b1c1cf058da939ce1
Diffstat (limited to 'uitest/src/com/vaadin')
3 files changed, 144 insertions, 118 deletions
diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html deleted file mode 100644 index fb00953e48..0000000000 --- a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.html +++ /dev/null @@ -1,107 +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>NotificationsWaiAria</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">NotificationsWaiAria</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.notification.NotificationsWaiAria?restartApplication</td> - <td></td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTextField[0]</td> - <td>Prefix:</td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextField[0]</td> - <td>- press ESC to close</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VNativeSelect[0]/domChild[0]</td> - <td>label=ALERT</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> - <td></td> -</tr> -<tr> - <td>assertAttribute</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]@role</td> - <td>alert</td> -</tr> -<tr> - <td>assertText</td> - <td>xpath=//div[@class='v-Notification humanized v-Notification-humanized']//span[@class='v-assistive-device-only'][1]</td> - <td>Prefix:</td> -</tr> -<tr> - <td>assertText</td> - <td>xpath=//div[@class='v-Notification humanized v-Notification-humanized']//span[@class='v-assistive-device-only'][2]</td> - <td>- press ESC to close</td> -</tr> -<tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VNativeSelect[0]/domChild[0]</td> - <td>label=STATUS</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertAttribute</td> - <td>xpath=/html/body/div[2]/div@role</td> - <td>status</td> -</tr> -<tr> - <td>closeNotification</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTextField[0]</td> - <td></td> -</tr> -<tr> - <td>type</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VTextField[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertElementNotPresent</td> - <td>vaadin=runcomvaadintestscomponentsnotificationNotificationsWaiAria::Root/VNotification[0]/domChild[0]/domChild[0]/domChild[1]</td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java index 7a12168af4..e85d60d7c2 100644 --- a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java +++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAria.java @@ -2,8 +2,9 @@ package com.vaadin.tests.components.notification; import com.vaadin.data.Item; import com.vaadin.server.Page; +import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.NotificationRole; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; @@ -16,10 +17,15 @@ import com.vaadin.ui.TextArea; import com.vaadin.ui.TextField; import com.vaadin.ui.UI; -public class NotificationsWaiAria extends TestBase { +/** + * Test UI for different roles of Notifications. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class NotificationsWaiAria extends AbstractTestUI { private static final String CAPTION = "CAPTION"; - private static final String ROLE = "ROLE"; private TextField prefix; private TextField postfix; @@ -28,9 +34,9 @@ public class NotificationsWaiAria extends TestBase { private TextArea tf; private ComboBox type; - @SuppressWarnings("deprecation") + @SuppressWarnings("unchecked") @Override - protected void setup() { + protected void setup(VaadinRequest request) { prefix = new TextField("Prefix", "Info"); addComponent(prefix); @@ -53,16 +59,16 @@ public class NotificationsWaiAria extends TestBase { type.setItemCaptionPropertyId(CAPTION); - Item item = type.addItem(Notification.TYPE_HUMANIZED_MESSAGE); + Item item = type.addItem(Notification.Type.HUMANIZED_MESSAGE); item.getItemProperty(CAPTION).setValue("Humanized"); - item = type.addItem(Notification.TYPE_ERROR_MESSAGE); + item = type.addItem(Notification.Type.ERROR_MESSAGE); item.getItemProperty(CAPTION).setValue("Error"); - item = type.addItem(Notification.TYPE_WARNING_MESSAGE); + item = type.addItem(Notification.Type.WARNING_MESSAGE); item.getItemProperty(CAPTION).setValue("Warning"); - item = type.addItem(Notification.TYPE_TRAY_NOTIFICATION); + item = type.addItem(Notification.Type.TRAY_NOTIFICATION); item.getItemProperty(CAPTION).setValue("Tray"); item = type.addItem(Notification.Type.ASSISTIVE_NOTIFICATION); @@ -81,13 +87,12 @@ public class NotificationsWaiAria extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Generic test case for notifications"; } @Override protected Integer getTicketNumber() { - // TODO Auto-generated method stub return null; } @@ -97,6 +102,7 @@ public class NotificationsWaiAria extends TestBase { Type typeValue = (Type) type.getValue(); Notification n = new Notification(tf.getValue(), typeValue); + n.setDelayMsec(-1); n.setHtmlContentAllowed(true); NotificationConfiguration notificationConf = UI.getCurrent() .getNotificationConfiguration(); @@ -118,4 +124,5 @@ public class NotificationsWaiAria extends TestBase { n.show(Page.getCurrent()); } } + } diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java new file mode 100644 index 0000000000..6b517e9887 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java @@ -0,0 +1,126 @@ +/* + * 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.notification; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.shared.ui.ui.NotificationRole; +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.NativeSelectElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Unit test class for Notification ARIA (Accessible Rich Internet Applications) + * roles. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class NotificationsWaiAriaTest extends MultiBrowserTest { + + /** + * Checks if the ARIA roles are correctly applied to Notification. + * + * @since 7.2 + * @throws Exception + */ + @Test + public void notificationTest() throws Exception { + openTestURL(); + + TextFieldElement prefix = $(TextFieldElement.class).first(); + TextFieldElement postfix = $(TextFieldElement.class).get(1); + NativeSelectElement type = $(NativeSelectElement.class).first(); + ButtonElement show = $(ButtonElement.class).first(); + + prefix.clear(); + prefix.sendKeys("Prefix:"); + + postfix.clear(); + postfix.sendKeys("- press ESC to close"); + + type.selectByText(NotificationRole.ALERT.toString()); + + show.click(); + waitForElementPresent(By.className("v-Notification")); + + NotificationElement notification = $(NotificationElement.class).first(); + + String text = notification.getAttribute("role"); + Assert.assertTrue("Expected attribute 'role' to equal 'alert', found " + + text, text.equals("alert")); + + text = getHiddenText(notification.findElements( + By.className("v-assistive-device-only")).get(0)); + Assert.assertTrue("Expected 'Prefix:', found " + text, + text.equals("Prefix:")); + + text = getHiddenText(notification.findElements( + By.className("v-assistive-device-only")).get(1)); + Assert.assertTrue("Expected '- press ESC to close', found " + text, + text.equals("- press ESC to close")); + + try { + notification.closeNotification(); + } catch (Exception e) { + } + + type.selectByText("STATUS"); + + show.click(); + waitForElementPresent(By.className("v-Notification")); + + notification = $(NotificationElement.class).first(); + + text = notification.getAttribute("role"); + Assert.assertTrue("Expected attribute 'role' to equal 'status', found " + + text, text.equals("status")); + + try { + notification.closeNotification(); + } catch (Exception e) { + } + + prefix.clear(); + postfix.clear(); + + show.click(); + waitForElementPresent(By.className("v-Notification")); + + WebElement element; + try { + element = getDriver() + .findElement( + By.vaadin("Root/VNotification[0]/domChild[0]/domChild[0]/domChild[1]")); + } catch (Exception e) { + element = null; + } + Assert.assertNull( + "Notification shouldn't have assistive-device-only spans", + element); + + } + + private String getHiddenText(WebElement element) { + return (String) getTestBenchCommandExecutor().executeScript( + "return arguments[0].innerHTML", element); + } +} |