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.

CompatibilityGridInDetailsRowTest.java 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.vaadin.tests.components.grid;
  2. import static org.hamcrest.Matchers.greaterThan;
  3. import static org.junit.Assert.assertEquals;
  4. import static org.junit.Assert.assertNotNull;
  5. import static org.junit.Assert.assertThat;
  6. import java.util.List;
  7. import org.junit.Test;
  8. import org.openqa.selenium.By;
  9. import org.openqa.selenium.WebElement;
  10. import com.vaadin.testbench.elements.GridElement;
  11. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  12. import com.vaadin.testbench.elements.GridElement.GridRowElement;
  13. import com.vaadin.tests.tb3.MultiBrowserTest;
  14. public class CompatibilityGridInDetailsRowTest extends MultiBrowserTest {
  15. @Test
  16. public void testNestedGridMultiRowHeaderPositions() {
  17. openTestURL();
  18. GridElement grid = $(GridElement.class).first();
  19. GridRowElement row = grid.getRow(1);
  20. row.doubleClick();
  21. waitForElementPresent(By.className("v-grid-spacer"));
  22. GridElement nestedGrid = $(GridElement.class).id("grid2");
  23. assertEquals("Incorrect header row count.", 2,
  24. nestedGrid.getHeaderCount());
  25. GridCellElement headerCell00 = nestedGrid.getHeaderCell(0, 0);
  26. GridCellElement headerCell11 = nestedGrid.getHeaderCell(1, 1);
  27. assertThat("Incorrect X-position.", headerCell11.getLocation().getX(),
  28. greaterThan(headerCell00.getLocation().getX()));
  29. assertThat("Incorrect Y-position.", headerCell11.getLocation().getY(),
  30. greaterThan(headerCell00.getLocation().getY()));
  31. }
  32. @Test
  33. public void testNestedGridRowHeights() {
  34. openTestURL();
  35. GridElement grid = $(GridElement.class).first();
  36. GridRowElement row = grid.getRow(1);
  37. row.doubleClick();
  38. waitForElementPresent(By.className("v-grid-spacer"));
  39. GridElement nestedGrid = $(GridElement.class).id("grid2");
  40. grid.findElement(By.className("v-grid-sidebar-button")).click();
  41. assertNotNull(
  42. "There are no options for toggling column visibility but there should be.",
  43. getColumnHidingToggle(nestedGrid));
  44. }
  45. /**
  46. * Returns the first toggle inside the sidebar for hiding a column, or null
  47. * if not found.
  48. */
  49. protected WebElement getColumnHidingToggle(GridElement grid) {
  50. WebElement sidebar = findElement(By.className("v-grid-sidebar-popup"));
  51. List<WebElement> elements = sidebar
  52. .findElements(By.className("column-hiding-toggle"));
  53. for (WebElement e : elements) {
  54. return e;
  55. }
  56. return null;
  57. }
  58. }