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.

EscalatorBasicsTest.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.vaadin.tests.components.grid.basicfeatures.escalator;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertFalse;
  4. import static org.junit.Assert.assertNull;
  5. import static org.junit.Assert.assertTrue;
  6. import java.io.IOException;
  7. import org.junit.Before;
  8. import org.junit.Test;
  9. import org.openqa.selenium.By;
  10. import org.openqa.selenium.WebElement;
  11. import com.vaadin.testbench.TestBenchElement;
  12. import com.vaadin.testbench.elements.NotificationElement;
  13. import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
  14. public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest {
  15. @Before
  16. public void setUp() {
  17. setDebug(true);
  18. openTestURL();
  19. }
  20. @Test
  21. public void testDetachingAnEmptyEscalator() {
  22. selectMenuPath(GENERAL, DETACH_ESCALATOR);
  23. assertEscalatorIsRemovedCorrectly();
  24. }
  25. @Test
  26. public void testDetachingASemiPopulatedEscalator() throws IOException {
  27. selectMenuPath(COLUMNS_AND_ROWS, ADD_ONE_OF_EACH_ROW);
  28. selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
  29. selectMenuPath(GENERAL, DETACH_ESCALATOR);
  30. assertEscalatorIsRemovedCorrectly();
  31. }
  32. @Test
  33. public void testDetachingAPopulatedEscalator() {
  34. selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
  35. selectMenuPath(GENERAL, DETACH_ESCALATOR);
  36. assertEscalatorIsRemovedCorrectly();
  37. }
  38. @Test
  39. public void testDetachingAndReattachingAnEscalator() {
  40. selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
  41. scrollVerticallyTo(50);
  42. scrollHorizontallyTo(50);
  43. selectMenuPath(GENERAL, DETACH_ESCALATOR);
  44. waitForElementNotPresent(By.className("v-escalator"));
  45. selectMenuPath(GENERAL, ATTACH_ESCALATOR);
  46. waitForElementPresent(By.className("v-escalator"));
  47. assertEquals("Vertical scroll position", 50, getScrollTop());
  48. assertEquals("Horizontal scroll position", 50, getScrollLeft());
  49. TestBenchElement bodyCell = getBodyCell(2, 0);
  50. WebElement viewport = findElement(
  51. By.className("v-escalator-tablewrapper"));
  52. WebElement header = findElement(By.className("v-escalator-header"));
  53. // ensure this is the first (partially) visible cell
  54. assertTrue(
  55. viewport.getLocation().getX() > bodyCell.getLocation().getX());
  56. assertTrue(viewport.getLocation().getX() < bodyCell.getLocation().getX()
  57. + bodyCell.getSize().getWidth());
  58. assertTrue(header.getLocation().getY()
  59. + header.getSize().getHeight() > bodyCell.getLocation().getY());
  60. assertTrue(header.getLocation().getY()
  61. + header.getSize().getHeight() < bodyCell.getLocation().getY()
  62. + bodyCell.getSize().getHeight());
  63. assertEquals("First cell of first visible row", "Row 2: 0,2",
  64. bodyCell.getText());
  65. }
  66. private void assertEscalatorIsRemovedCorrectly() {
  67. assertFalse($(NotificationElement.class).exists());
  68. assertNull(getEscalator());
  69. }
  70. }