aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/elements/combobox/SelectByText.java
blob: 24d87df67f7c6ef69e2f9dd6019f0cdfc12d2008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.vaadin.tests.elements.combobox;

import java.util.ArrayList;
import java.util.List;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

/**
 * UI used to validate ComboBox.selectByText(String s) works properly if input
 * String s contains parentheses
 */
@SuppressWarnings("serial")
public class SelectByText extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        addComponent(layout);

        ComboBox<String> combobox = new ComboBox<>();
        List<String> options = new ArrayList<String>();

        options.add("Value 1");
        options.add("(");
        options.add("(Value");
        options.add("Value 222");
        options.add("Value 22");
        options.add("Value 2");
        options.add("Value(");
        options.add("Value(i)");
        options.add("((Test ) selectByTest() method(with' parentheses)((");
        options.add("Value 3");

        combobox.setItems(options);

        layout.addComponent(combobox);
        combobox.addValueChangeListener(event -> layout.addComponent(
                new Label("Value is now '" + event.getValue() + "'")));
    }

    @Override
    protected String getTestDescription() {
        return "ComboBox's selectByText(String text) method should work if text contains parentheses";
    }

    @Override
    protected Integer getTicketNumber() {
        return 14048;
    }

}