You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridColumnWidthWithoutHeaderTest.java 912B

123456789101112131415161718192021222324252627282930
  1. package com.vaadin.tests.components.grid;
  2. import com.vaadin.testbench.elements.GridElement;
  3. import com.vaadin.tests.tb3.SingleBrowserTest;
  4. import org.junit.Test;
  5. import static org.junit.Assert.assertTrue;
  6. public class GridColumnWidthWithoutHeaderTest extends SingleBrowserTest {
  7. public static final int THRESHOLD = 3;
  8. @Test
  9. public void testWidthWithoutHeader() {
  10. openTestURL();
  11. GridElement grid = $(GridElement.class).first();
  12. int columnsWidth = getColWidthsRounded(grid);
  13. assertTrue(Math
  14. .abs(columnsWidth - grid.getSize().getWidth()) <= THRESHOLD);
  15. }
  16. private int getColWidthsRounded(GridElement grid) {
  17. GridElement.GridRowElement firstRow = grid.getRow(0);
  18. int width = 0;
  19. for (int i = 0; i < 3; i++) {
  20. width = width + firstRow.getCell(i).getSize().getWidth();
  21. }
  22. return width;
  23. }
  24. }