aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/table/TableScrollUpOnSelect.java
blob: 3736ece9074976b5f5361d8482994008ecd7f014 (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
65
66
67
package com.vaadin.tests.components.table;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.TextField;

/**
 * Test to see if Table appears to scroll up under an obscure set of conditions
 * (Scrolled down, set to expand, selecting updates a TextField that precedes
 * the Table in a VerticalLayout.) (#10106)
 *
 * @author Vaadin Ltd
 */
public class TableScrollUpOnSelect extends AbstractReindeerTestUI {
    public TextField text = null;

    @Override
    protected void setup(VaadinRequest request) {
        text = new TextField();
        text.setImmediate(true);

        final Table table = new Table(null);
        table.addContainerProperty("value", Integer.class, 0);
        for (int i = 0; i < 50; ++i) {
            table.addItem(new Object[] { i }, i);
        }
        table.setSizeFull();
        table.setSelectable(true);
        table.setImmediate(true);
        table.setEditable(false);

        final VerticalLayout layout = new VerticalLayout();

        table.addValueChangeListener(event -> {
            if (table.getValue() != null) {
                text.setValue(table.getValue().toString());
            }
        });

        table.setCurrentPageFirstItemIndex(49);

        layout.setSizeFull();
        layout.addComponent(text);
        layout.addComponent(table);
        layout.setExpandRatio(table, 1.0f);
        Window window = new Window();
        window.setHeight("600px");
        window.setWidth("400px");
        window.setModal(true);
        window.setContent(layout);
        getUI().addWindow(window);
    }

    @Override
    protected String getTestDescription() {
        return "Table scrolls up when selecting a row";
    }

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

}