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.

GridLayoutExpandWithManyRowsTest.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.vaadin.tests.components.gridlayout;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import java.util.List;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import org.openqa.selenium.WebElement;
  8. import com.vaadin.testbench.elements.GridLayoutElement;
  9. import com.vaadin.tests.tb3.SingleBrowserTest;
  10. public class GridLayoutExpandWithManyRowsTest extends SingleBrowserTest {
  11. @Test
  12. public void equalRowHeights() {
  13. openTestURL();
  14. GridLayoutElement gridlayout = $(GridLayoutElement.class).first();
  15. // Rows are expanded using integer pixels and leftover pixels are added
  16. // to the first N rows.
  17. // The tests uses rowspan=2 so one row in the DOM should be max 2 pixels
  18. // lower than the first row
  19. List<WebElement> slots = gridlayout
  20. .findElements(By.className("v-gridlayout-slot"));
  21. assertEquals(GridLayoutExpandWithManyRows.POPULATED_ROWS, slots.size());
  22. int firstRowHeight = slots.get(0).getSize().height;
  23. int lastRowHeight = firstRowHeight;
  24. for (int i = 1; i < GridLayoutExpandWithManyRows.POPULATED_ROWS; i++) {
  25. int rowHeight = slots.get(i).getSize().height;
  26. assertTrue(rowHeight <= firstRowHeight);
  27. assertTrue(rowHeight >= firstRowHeight - 2);
  28. assertTrue(rowHeight <= lastRowHeight);
  29. lastRowHeight = rowHeight;
  30. }
  31. }
  32. }