aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxValueInput.java
blob: b2406c87748c93fd73e7cd6a18f9c690a6c27ca9 (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
56
57
58
59
60
61
62
63
64
package com.vaadin.tests.components.combobox;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.v7.shared.ui.combobox.FilteringMode;
import com.vaadin.v7.ui.ComboBox;

public class ComboBoxValueInput extends AbstractReindeerTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        (getLayout()).setSpacing(true);

        ComboBox cb = getComboBox("A combobox", false, "default");
        addComponent(cb);

        cb = getComboBox("A combobox with input prompt", false,
                "default-prompt");
        cb.setInputPrompt("Please select");
        addComponent(cb);

        cb = getComboBox("A combobox with null item", true, "null");
        addComponent(cb);

        cb = getComboBox("A combobox with null item and input prompt", true,
                "null-prompt");
        cb.setInputPrompt("Please select");
        addComponent(cb);

        cb = getComboBox("A combobox with filteringMode off", false,
                "filtering-off");
        cb.setFilteringMode(FilteringMode.OFF);
        addComponent(cb);

    }

    @Override
    protected String getTestDescription() {
        return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";
    }

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

    private ComboBox getComboBox(String caption, boolean addNullItem,
            String id) {
        ComboBox cb = new ComboBox(caption);
        cb.setImmediate(true);
        if (addNullItem) {
            cb.addItem("Null item");
            cb.setNullSelectionItemId("Null item");
        }
        cb.addItem("Value 1");
        cb.addItem("Value 2");
        cb.addItem("Value 3");

        cb.setId(id);

        return cb;
    }

}