diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-11-23 06:54:27 +0100 |
---|---|---|
committer | caalador <mikael.grankvist@gmail.com> | 2017-11-23 07:54:27 +0200 |
commit | acfd75ee2ec8ad97f8dd54e2ae454257e7284159 (patch) | |
tree | 420846e20f0ca84121549b851f6b26018518fd99 /uitest | |
parent | e38ad29499328ddbf995d64612d932832d5bd628 (diff) | |
download | vaadin-framework-acfd75ee2ec8ad97f8dd54e2ae454257e7284159.tar.gz vaadin-framework-acfd75ee2ec8ad97f8dd54e2ae454257e7284159.zip |
DateField not to fire focus/blur event when going to sub-components (#10246)
Fixes `DateField blur event fires when focus gets to the "calendar button"` #1008
Diffstat (limited to 'uitest')
3 files changed, 82 insertions, 2 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java index b1e5f2ef59..d34eadf7f6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java +++ b/uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java @@ -43,7 +43,7 @@ public class FocusAndBlurListeners extends TestBase { AbstractDateField<?, ?> df = new TestDateField("DateField"); l.addComponent(df); - ComboBox cb = new ComboBox("ComboBox"); + ComboBox<String> cb = new ComboBox<>("ComboBox"); l.addComponent(cb); Button btn = new Button("Button"); @@ -91,7 +91,6 @@ public class FocusAndBlurListeners extends TestBase { ogm.addBlurListener(blurListener); l.addComponent(messages); - } private OptionGroup createOptionGroup(String caption) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldFocus.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldFocus.java new file mode 100644 index 0000000000..2edfa0ab9f --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldFocus.java @@ -0,0 +1,47 @@ +/* + * 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.datefield; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.DateField; +import com.vaadin.ui.TextField; + +public class DateFieldFocus extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + DateField dateField = new DateField(); + dateField.addFocusListener(e -> log("focused")); + dateField.addBlurListener(e -> log("blurred")); + addComponent(dateField); + + TextField textField = new TextField(); + textField.setCaption("second"); + addComponent(textField); + } + + @Override + protected String getTestDescription() { + return "DateField should not trigger events when nagivating between sub-components."; + } + + @Override + protected Integer getTicketNumber() { + return 1008; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFocusTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFocusTest.java new file mode 100644 index 0000000000..423ff2e71c --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldFocusTest.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.components.datefield; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.testbench.elements.DateFieldElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class DateFieldFocusTest extends MultiBrowserTest { + + @Test + public void focus() { + openTestURL(); + + assertEquals(" ", getLogRow(0)); + DateFieldElement dateField = $(DateFieldElement.class).first(); + TextFieldElement textField = $(TextFieldElement.class).caption("second") + .first(); + + dateField.openPopup(); + dateField.openPopup(); + + dateField.openPopup(); + dateField.openPopup(); + + assertEquals("1. focused", getLogRow(0)); + + textField.focus(); + + waitUntil(input -> "2. blurred".equals(getLogRow(0))); + } +} |