aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-05-26 11:39:18 +0300
committerHenri Sara <henri.sara@gmail.com>2017-05-26 11:39:18 +0300
commit3d6a25c2f17311126e96c8f68c6741412ca318a9 (patch)
treebbe1a79cd1bf2802e9db32a0d367628856f15af6 /uitest
parent791658f3534bcdbc754f82f1e21091e85a87c52a (diff)
downloadvaadin-framework-3d6a25c2f17311126e96c8f68c6741412ca318a9.tar.gz
vaadin-framework-3d6a25c2f17311126e96c8f68c6741412ca318a9.zip
Find active connector anywhere in the DOM (#9429)
Fixes #9419
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/ShortcutInWindow.java64
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java34
2 files changed, 98 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/ShortcutInWindow.java b/uitest/src/main/java/com/vaadin/tests/components/window/ShortcutInWindow.java
new file mode 100644
index 0000000000..983a30a8d2
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/ShortcutInWindow.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2000-2016 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 com.vaadin.annotations.Widgetset;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ValueChangeMode;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class ShortcutInWindow extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout content = new VerticalLayout();
+ HorizontalLayout buttons = new HorizontalLayout();
+ final TextField name = new TextField("Name");
+ name.setValueChangeMode(ValueChangeMode.BLUR);
+ name.setValueChangeTimeout(1000);
+ name.addValueChangeListener(
+ (e) -> log("Value Changed: " + e.getValue()));
+ final Button toggle = new Button(name.getValueChangeMode().toString());
+ toggle.addClickListener((e) -> {
+ int o = name.getValueChangeMode().ordinal();
+ int i = ValueChangeMode.values().length <= o + 1 ? 0 : o + 1;
+ ValueChangeMode m = ValueChangeMode.values()[i];
+ toggle.setCaption(m.toString());
+ name.setValueChangeMode(m);
+ log("New ValueChangeMode: " + m.toString());
+ });
+ final Button submit = new Button("Submit",
+ (e) -> log("Submitted value: " + name.getValue()));
+ submit.setClickShortcut(KeyCode.ENTER);
+ buttons.addComponent(toggle);
+ buttons.addComponent(submit);
+ content.addComponent(name);
+ content.addComponent(buttons);
+ Window popup = new Window();
+ popup.center();
+ popup.setContent(content);
+ getUI().addWindow(popup);
+
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java
new file mode 100644
index 0000000000..26041d8531
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/window/ShortcutInWindowTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2016 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 org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ShortcutInWindowTest extends SingleBrowserTest {
+
+ @Test
+ public void shortcutFlushesActiveField() {
+ openTestURL();
+ TextFieldElement tf = $(TextFieldElement.class).first();
+ tf.sendKeys("foo" + Keys.ENTER);
+ Assert.assertEquals("2. Submitted value: foo", getLogRow(0));
+ }
+}