From 049e6f39aadab1785d78bceaac575d25ea56dad4 Mon Sep 17 00:00:00 2001 From: Anastasia Smirnova Date: Thu, 4 Apr 2019 10:00:46 +0300 Subject: Read-only combobox should not handle PASTE event (#11529) Fixes 11528 --- .../components/combobox/ComboboxReadOnlyPaste.java | 25 ++++++++++++++++++++++ .../combobox/ComboboxReadOnlyPasteTest.java | 22 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPaste.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPasteTest.java (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPaste.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPaste.java new file mode 100644 index 0000000000..d2e7126604 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPaste.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class ComboboxReadOnlyPaste extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + ComboBox nameComboBox = new ComboBox<>("Name"); + nameComboBox.setId("readOnlyCB"); + nameComboBox.setEmptySelectionAllowed(true); + nameComboBox.setItems( + Stream.of("A", "B", "C", "D").collect(Collectors.toList())); + nameComboBox.setValue("B"); + nameComboBox.setReadOnly(true); + + addComponent(nameComboBox); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPasteTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPasteTest.java new file mode 100644 index 0000000000..07e73bd95c --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxReadOnlyPasteTest.java @@ -0,0 +1,22 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.Keys; + +import static org.junit.Assert.assertFalse; + +public class ComboboxReadOnlyPasteTest extends MultiBrowserTest { + + @Test + public void popupNotOpened() { + openTestURL(); + ComboBoxElement cb = $(ComboBoxElement.class).first(); + cb.click(); + String paste = Keys.chord(Keys.CONTROL, "v"); + cb.sendKeys(paste); + assertFalse("Pop-up should not be opened in read-only mode", + cb.isPopupOpen()); + } +} -- cgit v1.2.3