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.

ReplaceDataProviderTest.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.vaadin.tests.data;
  2. import org.junit.Assert;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. import com.vaadin.testbench.elements.ButtonElement;
  6. import com.vaadin.testbench.elements.GridElement;
  7. import com.vaadin.tests.tb3.SingleBrowserTest;
  8. public class ReplaceDataProviderTest extends SingleBrowserTest {
  9. @Before
  10. public void setUp() {
  11. openTestURL();
  12. }
  13. @Test
  14. public void test_grid_data_communication_with_replaced_data_provider() {
  15. GridElement grid = $(GridElement.class).first();
  16. ButtonElement replaceDataProviderButton = $(ButtonElement.class)
  17. .first();
  18. Assert.assertEquals(20, grid.getRowCount());
  19. grid.getCell(0, 0).click();
  20. assertCellText("a", 0, 0);
  21. replaceDataProviderButton.click();
  22. Assert.assertEquals(10, grid.getRowCount());
  23. assertCellText("b", 0, 0);
  24. for (int i = 1; i < 10; i++) {
  25. assertCellText("a", i, 0);
  26. }
  27. Assert.assertFalse(grid.getRow(0).isSelected());
  28. grid.getCell(0, 0).click();
  29. assertCellText("b", 0, 0);
  30. // This button should replace the data provider and do a server side
  31. // select on the second item
  32. $(ButtonElement.class).get(1).click();
  33. grid.getRow(1).isSelected();
  34. }
  35. private void assertCellText(String text, int rowIndex, int colIndex) {
  36. String firstCellText = $(GridElement.class).first()
  37. .getCell(rowIndex, colIndex).getText();
  38. Assert.assertEquals(text, firstCellText);
  39. }
  40. }