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.

EscalatorRemoveAndAddRowsTest.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.vaadin.tests.components.grid.basicfeatures.escalator;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertTrue;
  4. import java.io.IOException;
  5. import org.junit.Before;
  6. import org.junit.Test;
  7. import org.openqa.selenium.By;
  8. import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeaturesTest;
  9. /**
  10. * Test class to test the escalator level issue for ticket #16832
  11. */
  12. public class EscalatorRemoveAndAddRowsTest
  13. extends EscalatorBasicClientFeaturesTest {
  14. @Before
  15. public void open() {
  16. openTestURL("theme=reindeer");
  17. }
  18. @Test
  19. public void testRemoveAllRowsAndAddThirtyThenScroll() throws IOException {
  20. selectMenuPath(GENERAL, POPULATE_COLUMN_ROW);
  21. scrollVerticallyTo(99999);
  22. waitUntilLoadingIndicatorNotVisible();
  23. assertTrue("Escalator is not scrolled to bottom.",
  24. isElementPresent(By.xpath("//td[text() = 'Row 99: 0,99']")));
  25. selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_ALL_INSERT_SCROLL);
  26. scrollVerticallyTo(99999);
  27. waitUntilLoadingIndicatorNotVisible();
  28. assertTrue("Escalator is not scrolled to bottom.",
  29. isElementPresent(By.xpath("//td[text() = 'Row 29: 0,129']")));
  30. }
  31. @Test
  32. public void testRemoveRowsFromMiddle() {
  33. selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING);
  34. selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS, ADD_ONE_ROW_TO_BEGINNING);
  35. selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_22_ROWS_TO_TOP);
  36. // remove enough rows from middle, so that the total size of escalator
  37. // rows drops to below the size of the rows shown, forcing the escalator
  38. // to remove & move & update rows
  39. selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_15_ROWS_FROM_MIDDLE);
  40. // first there was rows 0-21, then removed 15 rows 3-18, thus the rows
  41. // should be 0,1,2,18,19,20,21
  42. verifyRow(0, 0);
  43. verifyRow(1, 1);
  44. verifyRow(2, 2);
  45. verifyRow(3, 18);
  46. verifyRow(4, 19);
  47. verifyRow(5, 20);
  48. verifyRow(6, 21);
  49. }
  50. private void verifyRow(int escalatorIndex, int rowIndexInText) {
  51. // the format of text in cells is
  52. // Row: <index_when_updated>: <cell_index>,<index_when_inserted>
  53. assertEquals("Invalid row present in index " + escalatorIndex,
  54. "Row " + escalatorIndex + ": 0," + rowIndexInText,
  55. getBodyCell(escalatorIndex, 0).getText());
  56. }
  57. }