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

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

import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Notification;

public class ComboBoxScrollingToPageDisabled
        extends ComponentTestCase<ComboBox> {

    private static final Object CAPTION = "caption";

    @Override
    protected Class<ComboBox> getTestClass() {
        return ComboBox.class;
    }

    @Override
    protected void initializeComponents() {
        ComboBox<String> s = createSelect(null);
        s.setScrollToSelectedItem(false);
        populate(s, 100);
        s.setValue("Item 50");
        addTestComponent(s);
    }

    private void populate(ComboBox s, int nr) {
        List<String> items = new ArrayList<>();
        for (int i = 0; i < nr; i++) {
            items.add("Item " + i);
        }
        s.setItems(items);
    }

    private ComboBox<String> createSelect(String caption) {
        final ComboBox<String> cb = new ComboBox<>();
        cb.setCaption(caption);
        cb.addValueChangeListener(event -> Notification
                .show("Value now:" + cb.getValue() + " " + cb.getValue()));
        return cb;
    }

    @Override
    protected String getTestDescription() {
        return "Test that selected value appears on the client "
                + "side even though setScrollToSelectedItem(false) "
                + "has been called. Textbox should contain 'Item 50'.";
    }

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

}