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.

GridIndexedContainerInsertSelectTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.v7.tests.components.grid.basicfeatures.server;
  2. import com.vaadin.testbench.elements.ButtonElement;
  3. import com.vaadin.testbench.elements.GridElement;
  4. import com.vaadin.testbench.parallel.TestCategory;
  5. import com.vaadin.tests.tb3.SingleBrowserTest;
  6. import org.junit.Assert;
  7. import org.junit.Test;
  8. import org.openqa.selenium.By;
  9. @TestCategory("grid")
  10. public class GridIndexedContainerInsertSelectTest extends SingleBrowserTest {
  11. @Override
  12. public void setup() throws Exception {
  13. super.setup();
  14. openTestURL();
  15. waitForElementPresent(By.className("v-grid"));
  16. }
  17. /**
  18. * Test asserting that issue
  19. * https://github.com/vaadin/framework/issues/11477 is fixed.
  20. */
  21. @Test
  22. public void test_insertRowAfterSelected_newRowIsSelected() {
  23. openTestURL();
  24. // Assert that first row is already selected when ui loaded
  25. Assert.assertTrue(
  26. "First row should be selected to continue with the test!",
  27. isRowSelected(0));
  28. // Add new row after the selected one
  29. $(ButtonElement.class).first().click();
  30. // Assert that the new row is added correctly
  31. Assert.assertEquals("Item 4",
  32. $(GridElement.class).first().getRow(1).getCell(0).getText());
  33. // Assert that the new added row is selected
  34. Assert.assertTrue("Newly inserted row should be selected!",
  35. isRowSelected(1));
  36. // Select row at index 2
  37. $(GridElement.class).first().getRow(2).click();
  38. // Add new row after the selected one
  39. $(ButtonElement.class).first().click();
  40. // Assert that the new row is added correctly
  41. Assert.assertEquals("Item 5",
  42. $(GridElement.class).first().getRow(3).getCell(0).getText());
  43. // Assert that the new added row is selected
  44. Assert.assertTrue("Newly inserted row should be selected!",
  45. isRowSelected(3));
  46. }
  47. protected boolean isRowSelected(int index) {
  48. return $(GridElement.class).first().getRow(index).isSelected();
  49. }
  50. }