aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboSelectedValueBeyondTheFirstDropdownPage.java
blob: 881d2e0bbf8e78e43c8540fd6fce7f33c4c42ac9 (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
package com.vaadin.tests.components.combobox;

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

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

@SuppressWarnings("serial")
public class ComboSelectedValueBeyondTheFirstDropdownPage
        extends AbstractReindeerTestUI {

    protected static final int ITEM_COUNT = 21;
    protected static final String ITEM_NAME_TEMPLATE = "Item %d";

    @Override
    protected void setup(VaadinRequest request) {
        Label value = getLabel();
        ComboBox<String> combobox = getComboBox(value);

        addComponent(combobox);
        addComponent(value);
    }

    private Label getLabel() {
        final Label value = new Label();
        value.setId("value");

        return value;
    }

    private ComboBox<String> getComboBox(final Label value) {
        final ComboBox<String> combobox = new ComboBox<>("MyCaption");
        combobox.setDescription(
                "ComboBox with more than 10 elements in it's dropdown list.");

        List<String> items = new ArrayList<>();
        for (int i = 1; i <= ITEM_COUNT; i++) {
            items.add(String.format(ITEM_NAME_TEMPLATE, i));
        }
        combobox.setItems(items);

        combobox.addValueChangeListener(
                event -> value.setValue(String.valueOf(event.getValue())));

        return combobox;
    }

    @Override
    protected String getTestDescription() {
        return "Test for ensuring that ComboBox shows selected value beyound the first dropdown page";
    }

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