aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithoutRowsOrHeaders.java
blob: cc74696636061d76e52919581d002225d809eaa4 (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.grid;

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

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.SelectionMode;

/**
 * There is no corresponding TB test as this problem can only be reproduced
 * using SuperDevMode.
 */
public class GridWithoutRowsOrHeaders extends AbstractTestUI {

    private int counter = 0;

    @Override
    protected void setup(VaadinRequest request) {
        List<Integer> data = new ArrayList<>();

        Grid<Integer> grid = new Grid<>();
        grid.addColumn(Integer::valueOf).setCaption("ID").setId("id")
                .setMaximumWidth(50d);
        grid.addColumn(Integer::valueOf).setCaption("FOO").setId("foo")
                .setMinimumWidth(50d);
        grid.removeHeaderRow(grid.getHeaderRow(0));
        grid.setItems(data);

        grid.setSelectionMode(SelectionMode.NONE);
        grid.setWidth("250px");
        grid.setHeightByRows(3);
        addComponent(grid);

        addComponent(new Button("Add header row", e -> {
            grid.addHeaderRowAt(0);
        }));
        addComponent(new Button("Add body row", e -> {
            data.add(counter);
            ++counter;
            grid.getDataProvider().refreshAll();
        }));
        addComponent(new Button("Add footer row", e -> {
            grid.addFooterRowAt(0);
        }));
    }

    @Override
    protected String getTestDescription() {
        return "There should be no client-side assertion error from "
                + "adding the Grid without contents (requires SuperDevMode).";
    }

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