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

import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;

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

    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 combobox = getComboBox(value);

        addComponent(combobox);
        addComponent(value);
    }

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

        return value;
    }

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

        combobox.setImmediate(true);

        for (int i = 1; i <= ITEM_COUNT; i++) {
            combobox.addItem(String.format(ITEM_NAME_TEMPLATE, i));
        }

        combobox.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                value.setValue(String.valueOf(event.getProperty().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;
    }
}