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

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

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Grid;
import com.vaadin.ui.components.grid.FooterRow;

public class GridColumnsNoMinimumWidthFromContent extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        Random random = new Random();

        List<DummyGridRow> gridRows = new ArrayList<DummyGridRow>();
        gridRows.add(new DummyGridRow(random));

        Grid<DummyGridRow> grid = new Grid<DummyGridRow>();
        for (int i = 0; i < 20; i++) {
            grid.addColumn(DummyGridRow::getValue)
                    .setCaption("[" + i + "] Quite dummy column")
                    .setMinimumWidthFromContent(false);
        }

        grid.setItems(gridRows);
        FooterRow defaultFooter = grid.appendFooterRow();
        grid.getColumns().forEach(column -> defaultFooter.getCell(column)
                .setText(grid.getDefaultHeaderRow().getCell(column).getText()));
        grid.setFooterVisible(true);
        grid.setHeightByRows(gridRows.size());
        grid.setWidthFull();

        getLayout().addComponent(grid);
    }

    class DummyGridRow {
        private Random random = null;

        public DummyGridRow(Random random) {
            this.random = random;
        }

        public int getValue() {
            return random.nextInt(1000000000);
        }
    }

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

    @Override
    protected String getTestDescription() {
        return "Loading the UI should not get stuck in an eternal loop "
                + "and the columns should be narrow with ellipsis "
                + "until the page is resized small enough that "
                + "the resize handles alone force a scrollbar. "
                + "No overflowing of header cells should occur "
                + "when resized very near to the cutoff point "
                + "between no scrollbar and a scrollbar.";
    }
}