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.

TableWithPollingTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.vaadin.tests.components.table;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.interactions.Actions;
  7. import com.vaadin.testbench.elements.TableElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. public class TableWithPollingTest extends MultiBrowserTest {
  10. @Test
  11. public void testColumnResizing() throws Exception {
  12. openTestURL();
  13. int offset = -20;
  14. int headerCellWidth = getHeaderCell(0).getSize().width;
  15. int bodyCellWidth = getBodyCell(0).getSize().width;
  16. resizeColumn(0, offset);
  17. assertHeaderCellWidth(0, headerCellWidth + offset);
  18. assertBodyCellWidth(0, bodyCellWidth + offset);
  19. offset = 50;
  20. headerCellWidth = getHeaderCell(1).getSize().width;
  21. bodyCellWidth = getBodyCell(1).getSize().width;
  22. resizeColumn(1, offset);
  23. assertHeaderCellWidth(1, headerCellWidth + offset);
  24. assertBodyCellWidth(1, bodyCellWidth + offset);
  25. }
  26. private WebElement getHeaderCell(int column) {
  27. return $(TableElement.class).get(0).getHeaderCell(column);
  28. }
  29. private WebElement getBodyCell(int column) {
  30. return $(TableElement.class).get(0).getCell(0, column);
  31. }
  32. private WebElement getColumnResizer(int column) {
  33. return getHeaderCell(column)
  34. .findElement(By.className("v-table-resizer"));
  35. }
  36. private void resizeColumn(int column, int by) throws InterruptedException {
  37. new Actions(driver).clickAndHold(getColumnResizer(column))
  38. .moveByOffset(by, 0).perform();
  39. sleep(2000);
  40. new Actions(driver).release().perform();
  41. }
  42. private void assertHeaderCellWidth(int column, int width)
  43. throws AssertionError {
  44. assertEquals(width, getHeaderCell(column).getSize().width);
  45. }
  46. private void assertBodyCellWidth(int column, int width)
  47. throws AssertionError {
  48. assertEquals(width, getBodyCell(column).getSize().width);
  49. }
  50. }