diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2019-10-31 13:48:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-31 13:48:17 +0200 |
commit | 1b55d3668bc067a266c6a1b128b978c43418b812 (patch) | |
tree | d84af71ae15a58f15f9719ef5fb050ceb8182f25 /uitest | |
parent | 7e44bb38e1c4b0166e78697da74f33517cd1e4f3 (diff) | |
download | vaadin-framework-1b55d3668bc067a266c6a1b128b978c43418b812.tar.gz vaadin-framework-1b55d3668bc067a266c6a1b128b978c43418b812.zip |
Fix a timing issue in ComboBox filtering via paste using mouse. (#11780)
The filtering needs to be delayed, otherwise it's performed before the
new filter text is available and the old filter text is used instead.
Fixes #11779
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java new file mode 100644 index 0000000000..ba36c69d73 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPasteFilter.java @@ -0,0 +1,66 @@ +package com.vaadin.tests.components.combobox; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.vaadin.data.provider.ListDataProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; + +public class ComboBoxPasteFilter extends AbstractTestUI { + + private static final String WORDS = "loutish offer popcorn bitter buzz " + + "change mass boy erect aquatic donkey gentle colorful zippy " + + "soup pocket bathe fear supreme pan present knife quartz shy " + + "conscious tested thumb snow evasive reason dusty bridge giddy " + + "smooth bomb endurable tiger red gun fix regret quizzical income " + + "careless owe sleet loss silent serious play consider messy " + + "retire reduce shaky shiny low suggest preach bleach drunk " + + "talk instruct peck hungry improve meat chop title encourage " + + "marry island romantic fabulous kneel guarantee dock complain " + + "mate tour intend geese hole swing mine superb level slip " + + "spoon sky live nine open playground guard possible hate " + + "spotless apparatus bow"; + + @Override + protected void setup(VaadinRequest request) { + ComboBox<String> box = new ComboBox<String>("Paste a word from below"); + Collection<String> massiveData = massiveData(); + box.setDataProvider(new ListDataProvider<String>(massiveData)); + addComponent(box); + + Label label = new Label(WORDS); + label.setSizeFull(); + addComponent(label); + } + + private Collection<String> massiveData() { + return find(WORDS, "([\\w]+)"); + } + + public List<String> find(String text, String patternStr) { + Pattern pattern = Pattern.compile(patternStr); + Matcher matcher = pattern.matcher(text); + List<String> result = new ArrayList<>(); + while (matcher.find()) { + result.add(matcher.group()); + } + return result; + } + + @Override + protected Integer getTicketNumber() { + return 11779; + } + + @Override + protected String getTestDescription() { + return "ComboBox should filter regardless of whether the value is " + + "pasted with keyboard or with mouse"; + } +} |