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.

GridCellFocusOnResetSizeTest.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertTrue;
  3. import java.io.IOException;
  4. import org.junit.Test;
  5. import org.openqa.selenium.By;
  6. import com.vaadin.testbench.elements.GridElement;
  7. import com.vaadin.testbench.elementsbase.ServerClass;
  8. import com.vaadin.testbench.parallel.TestCategory;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. @TestCategory("grid")
  11. public class GridCellFocusOnResetSizeTest extends MultiBrowserTest {
  12. @ServerClass("com.vaadin.tests.widgetset.server.TestWidgetComponent")
  13. public static class MyGridElement extends GridElement {
  14. }
  15. @Test
  16. public void testCellFocusOnSizeReset() throws IOException {
  17. openTestURL();
  18. GridElement grid = $(MyGridElement.class).first();
  19. int rowIndex = 9;
  20. grid.getCell(rowIndex, 0).click();
  21. assertTrue("Row was not focused after click.",
  22. grid.getRow(rowIndex).isFocused());
  23. // Clicking the button decreases size until it is down to 5 rows.
  24. while (rowIndex > 4) {
  25. findElement(By.tagName("button")).click();
  26. assertTrue("Row focus was not moved when size decreased",
  27. grid.getRow(--rowIndex).isFocused());
  28. }
  29. // Next click increases size back to 10, this should not move focus.
  30. findElement(By.tagName("button")).click();
  31. assertTrue("Row focus should not have moved when size increased",
  32. grid.getRow(4).isFocused());
  33. }
  34. }