summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-10-15 09:33:43 +0300
committerVaadin Code Review <review@vaadin.com>2013-10-15 13:20:54 +0000
commitc7ae45cc2404c2eab557866f310a2bb2130ddffe (patch)
tree936195bde7d85b83670653e44174af7d0385cfd1 /uitest
parentd461fb438f62b38d2082b41b0a3c7a1189927c3d (diff)
downloadvaadin-framework-c7ae45cc2404c2eab557866f310a2bb2130ddffe.tar.gz
vaadin-framework-c7ae45cc2404c2eab557866f310a2bb2130ddffe.zip
Validate that the connector is enabled before triggering actions for it (#12743)
Automated test enabled only for IE9-IE11 because of #12785 Change-Id: I265e5d1ead3fa56469861c5a98dcc9d0106d1051
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java76
-rw-r--r--uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java46
2 files changed, 122 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java
new file mode 100644
index 0000000000..0f4c179cee
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java
@@ -0,0 +1,76 @@
+package com.vaadin.tests.actions;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class ActionsOnInvisibleComponents extends AbstractTestUIWithLog {
+
+ private static final long serialVersionUID = -5993467736906948993L;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getContent().setId("test-root");
+ log("'A' triggers a click on an invisible button");
+ log("'B' triggers a click on a disabled button");
+ log("'C' triggers a click on a visible and enabled button");
+
+ Button invisibleButton = new Button("Invisible button with shortcut");
+ invisibleButton.setClickShortcut(KeyCode.A);
+ invisibleButton.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log("Click event for invisible button");
+ }
+ });
+
+ invisibleButton.setVisible(false);
+ addComponent(invisibleButton);
+
+ Button disabledButton = new Button("Disabled button with shortcut");
+ disabledButton.setClickShortcut(KeyCode.B);
+ disabledButton.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log("Click event for disabled button");
+ }
+ });
+
+ disabledButton.setEnabled(false);
+ addComponent(disabledButton);
+
+ Button enabledButton = new Button("Enabled button with shortcut");
+ enabledButton.setClickShortcut(KeyCode.C);
+ enabledButton.addClickListener(new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log("Click event for enabled button");
+ }
+ });
+
+ addComponent(enabledButton);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Test to ensure actions are not performed on disabled/invisible components";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 12743;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java
new file mode 100644
index 0000000000..bb2a7d0995
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java
@@ -0,0 +1,46 @@
+package com.vaadin.tests.actions;
+
+import java.util.Collection;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest {
+
+ private static final String LAST_INIT_LOG = "3. 'C' triggers a click on a visible and enabled button";
+
+ // This method should be removed once #12785 is fixed
+ @Override
+ public Collection<DesiredCapabilities> getBrowsersToTest() {
+ Collection<DesiredCapabilities> browsers = super.getBrowsersToTest();
+ // sendKeys does nothing on these browsers
+ browsers.remove(BrowserUtil.firefox(24));
+ browsers.remove(BrowserUtil.ie(8));
+ browsers.remove(BrowserUtil.opera(12));
+
+ // Causes 'cannot focus element'
+ browsers.remove(BrowserUtil.chrome(29));
+ return browsers;
+ }
+
+ @Test
+ public void testShortcutsOnInvisibleDisabledButtons() {
+ openTestURL();
+ Assert.assertEquals(LAST_INIT_LOG, getLogRow(0));
+ invokeShortcut("A");
+ Assert.assertEquals(LAST_INIT_LOG, getLogRow(0));
+ invokeShortcut("B");
+ Assert.assertEquals(LAST_INIT_LOG, getLogRow(0));
+ invokeShortcut("C");
+ Assert.assertEquals("4. Click event for enabled button", getLogRow(0));
+ }
+
+ private void invokeShortcut(CharSequence key) {
+ WebElement shortcutTarget = vaadinElementById("test-root");
+ shortcutTarget.sendKeys(key);
+ }
+}