diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-08-17 16:20:32 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-25 14:24:53 +0000 |
commit | 0ec671619a9cfa6c69c2cb63adcae4c8020ce876 (patch) | |
tree | 54b744cc349d82c1bbe06ac82811e3bfd6b2d9c0 /uitest/src | |
parent | 9ea4409bbe7079887a5a3c497494d4986ddabefd (diff) | |
download | vaadin-framework-0ec671619a9cfa6c69c2cb63adcae4c8020ce876.tar.gz vaadin-framework-0ec671619a9cfa6c69c2cb63adcae4c8020ce876.zip |
Postpone shortcut action handler initialization in PopupView (#14275).
Change-Id: I233a63fac4f1afe3f99105ac6dfbbbb38f9b9fad
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java | 79 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java | 79 |
2 files changed, 158 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java new file mode 100644 index 0000000000..ca91597aa2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandler.java @@ -0,0 +1,79 @@ +/* + * 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.popupview; + +import com.vaadin.event.ShortcutAction; +import com.vaadin.event.ShortcutListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.PopupView; +import com.vaadin.ui.TextField; + +/** + * Test UI to check availability of shortcut action listener in the popup view + * oeverlay component. + * + * @author Vaadin Ltd + */ +public class PopupViewShortcutActionHandler extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + addComponent(new PopupView(new DemoPoupView())); + } + + @Override + protected String getTestDescription() { + return "Shortcut listener search should be executed in the end " + + "of request (after legacy UIDL request handling)."; + } + + @Override + protected Integer getTicketNumber() { + return 14275; + } + + private class DemoPoupView implements PopupView.Content { + + @Override + public String getMinimizedValueAsHTML() { + return "Click Me"; + } + + @Override + public Component getPopupComponent() { + TextField field = new TextField("Enter text"); + field.setImmediate(true); + field.addShortcutListener(new ShortcutListener("SearchAction", + ShortcutAction.KeyCode.ENTER, null) { + private static final long serialVersionUID = 1L; + + @Override + public void handleAction(Object sender, Object target) { + Label label = new Label( + "shortcut addedEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); + label.addStyleName("shortcut-result"); + addComponent(label); + } + }); + return field; + } + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java new file mode 100644 index 0000000000..f122e1a415 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewShortcutActionHandlerTest.java @@ -0,0 +1,79 @@ +/* + * 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.popupview; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.phantomjs.PhantomJSDriver; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.TestBench; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Check availability of shortcut action listener in the popup view. + * + * @author Vaadin Ltd + */ +public class PopupViewShortcutActionHandlerTest extends MultiBrowserTest { + + @Test + public void testShortcutHandling() { + openTestURL(); + + getDriver().findElement(By.className("v-popupview")).click(); + WebElement textField = getDriver().findElement( + By.className("v-textfield")); + textField.sendKeys("a", Keys.ENTER); + + Assert.assertTrue( + "Unable to find label component which is the result of" + + " shortcut action handling.", + isElementPresent(By.className("shortcut-result"))); + } + + @Override + protected void setupDriver() throws Exception { + System.setProperty("phantomjs.binary.path", + "C:\\tmp\\phantom\\phantomjs.exe"); + WebDriver dr = TestBench.createDriver(new PhantomJSDriver()); + setDriver(dr); + } + + @Override + protected String getScreenshotDirectory() { + return "C:\\tmp\\a"; + } + + @Override + protected void openTestURL() { + driver.get("http://localhost:8080/vaadin/run/PopupViewShortcutActionHandler"); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(Browser.FIREFOX + .getDesiredCapabilities()); + } + +} |