diff options
author | Artur Signell <artur@vaadin.com> | 2014-05-12 23:46:52 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-05-13 17:57:09 +0300 |
commit | 1f44f464ad4e86475f00817de831b021ea49acfc (patch) | |
tree | 69157cbf8fbbc3d8da9a7aff220d9598e58793cf /uitest | |
parent | dd8528b5ce83aee4e9b4d44cad4ce3ad8d92d88d (diff) | |
download | vaadin-framework-1f44f464ad4e86475f00817de831b021ea49acfc.tar.gz vaadin-framework-1f44f464ad4e86475f00817de831b021ea49acfc.zip |
ShortcutAddAndRemove TB2 -> TB4
Change-Id: If899309eb1b05f4a519eed45df4e9cf1670a7740
Diffstat (limited to 'uitest')
3 files changed, 98 insertions, 220 deletions
diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.html b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.html deleted file mode 100644 index a7b8e24ae7..0000000000 --- a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.html +++ /dev/null @@ -1,203 +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="http://artur-laptop.office.itmill.com:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.abstractfield.ShortcutAddAndRemove?restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/domChild[0]</td> - <td>316,58</td> -</tr> -<!--Enter on background - should cause event--> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::</td> - <td>enter</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>1. Log button was clicked</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>102,51</td> -</tr> -<!--Enter in textfield - should cause event--> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>enter</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>2. Log button was clicked</td> -</tr> -<!--Remove shortcut--> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>110,62</td> -</tr> -<!--Enter in field - should not cause event--> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>97,26</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>up</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>down</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>down</td> -</tr> -<tr> - <td>enterCharacter</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>row1</td> -</tr> -<tr> - <td>keyPress</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>13</td> -</tr> -<tr> - <td>keyPress</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>r</td> -</tr> -<tr> - <td>keyPress</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>o</td> -</tr> -<tr> - <td>keyPress</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>w</td> -</tr> -<tr> - <td>keyPress</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>2</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>2. Log button was clicked</td> -</tr> -<!-- Commented out because TestBench does not enter the text correctly using keyPress in any browser except Firefox --> -<!-- <tr> - <td>assertValue</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>row1<br />row2</td> -</tr>--> -<!--Add shortcut again--> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>85,46</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VTextArea[0]</td> - <td>enter</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>3. Log button was clicked</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[2]/domChild[0]/domChild[0]</td> - <td>625,2</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::</td> - <td>enter</td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>4. Log button was clicked</td> -</tr> -<!--Remove shortcut once more--> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/VVerticalLayout[0]</td> - <td>631,52</td> -</tr> -<tr> - <td>pressSpecialKey</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::</td> - <td>enter</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsabstractfieldShortcutAddAndRemove::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>4. Log button was clicked</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java index 309e297374..d6e8d72297 100644 --- a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java +++ b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemove.java @@ -1,25 +1,22 @@ package com.vaadin.tests.components.abstractfield; import com.vaadin.event.ShortcutAction.KeyCode; -import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.Log; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; -public class ShortcutAddAndRemove extends TestBase { +public class ShortcutAddAndRemove extends AbstractTestUIWithLog { - private Log log; - private TextArea textArea; + private TextField textField; @Override - protected void setup() { - log = new Log(4); - + protected void setup(VaadinRequest request) { final Button logButton = new Button("Log a row (enter shortcut)"); logButton.setClickShortcut(KeyCode.ENTER); - logButton.addListener(new ClickListener() { + logButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.log("Log button was clicked"); @@ -27,7 +24,7 @@ public class ShortcutAddAndRemove extends TestBase { }); final Button removeShortcut = new Button("Remove shortcut"); - removeShortcut.addListener(new ClickListener() { + removeShortcut.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { logButton.removeClickShortcut(); @@ -35,7 +32,7 @@ public class ShortcutAddAndRemove extends TestBase { } }); final Button addShortcut = new Button("Add shortcut"); - addShortcut.addListener(new ClickListener() { + addShortcut.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { logButton.setClickShortcut(KeyCode.ENTER); @@ -44,17 +41,17 @@ public class ShortcutAddAndRemove extends TestBase { }); addComponent(log); addComponent(logButton); - textArea = new TextArea("Enter key does not break lines ..."); - textArea.setRows(5); - textArea.setColumns(20); - addComponent(textArea); + textField = new TextField("Enter key is a shortcut..."); + textField.setWidth("20em"); + addComponent(textField); addComponent(removeShortcut); addComponent(addShortcut); } @Override - protected String getDescription() { + protected String getTestDescription() { + // TODO Auto-generated method stub return null; } diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemoveTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemoveTest.java new file mode 100644 index 0000000000..edae0a24c2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutAddAndRemoveTest.java @@ -0,0 +1,84 @@ +/* + * 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.abstractfield; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.AbstractComponentElement; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.elements.VerticalLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ShortcutAddAndRemoveTest extends MultiBrowserTest { + + @Test + public void addAndRemoveShortcut() { + openTestURL(); + + VerticalLayoutElement mainLayout = $(VerticalLayoutElement.class) + .first(); + + TextFieldElement textField = $(TextFieldElement.class).first(); + // Enter in mainlayout -> should trigger shortcut + sendEnter(mainLayout); + assertLastLogRowIs("1. Log button was clicked"); + + // Enter in textfield -> should trigger shortcut + sendEnter(textField); + assertLastLogRowIs("2. Log button was clicked"); + + // Remove enter shortcut + removeEnterShortcut(); + + // Enter in field - should not trigger any shortcut anymore + sendEnter(textField); + assertLastLogRowIs("2. Log button was clicked"); + + // Add shortcut again + addEnterShortcut(); + sendEnter(textField); + assertLastLogRowIs("3. Log button was clicked"); + + sendEnter(mainLayout); + assertLastLogRowIs("4. Log button was clicked"); + + removeEnterShortcut(); + sendEnter(mainLayout); + assertLastLogRowIs("4. Log button was clicked"); + } + + private void removeEnterShortcut() { + $(ButtonElement.class).caption("Remove shortcut").first().click(); + } + + private void addEnterShortcut() { + $(ButtonElement.class).caption("Add shortcut").first().click(); + } + + private void assertLastLogRowIs(String expected) { + assertThat(getLogRow(0), is(expected)); + } + + private void sendEnter(AbstractComponentElement target) { + new Actions(getDriver()).click(target).sendKeys(Keys.ENTER).perform(); + } +} |