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.

GridDefaultSelectionModeTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertFalse;
  3. import static org.junit.Assert.assertTrue;
  4. import org.junit.Test;
  5. import com.vaadin.testbench.elements.GridElement;
  6. import com.vaadin.testbench.elements.ButtonElement;
  7. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. public class GridDefaultSelectionModeTest extends MultiBrowserTest {
  10. @Test
  11. public void testSelectionFromServer() {
  12. setDebug(true);
  13. openTestURL();
  14. $(ButtonElement.class).caption("Select on server").first().click();
  15. assertTrue("Row should be selected.",
  16. $(GridElement.class).first().getRow(0).isSelected());
  17. $(ButtonElement.class).caption("Deselect on server").first().click();
  18. assertFalse("Row should not be selected.",
  19. $(GridElement.class).first().getRow(0).isSelected());
  20. assertNoErrorNotifications();
  21. }
  22. @Test
  23. public void testSelectionWithSort() {
  24. setDebug(true);
  25. openTestURL();
  26. GridElement grid = $(GridElement.class).first();
  27. grid.getCell(0, 0).click();
  28. GridCellElement header = grid.getHeaderCell(0, 1);
  29. header.click();
  30. header.click();
  31. assertTrue("Row should be selected.", grid.getRow(1).isSelected());
  32. assertNoErrorNotifications();
  33. }
  34. @Test
  35. public void testReselectDeselectedRow() {
  36. setDebug(true);
  37. openTestURL();
  38. $(ButtonElement.class).caption("Select on server").first().click();
  39. GridElement grid = $(GridElement.class).first();
  40. assertTrue("Row should be selected.", grid.getRow(0).isSelected());
  41. $(ButtonElement.class).caption("Deselect on server").first().click();
  42. assertFalse("Row should not be selected.", grid.getRow(0).isSelected());
  43. grid.getCell(0, 0).click();
  44. assertTrue("Row should be selected.", grid.getRow(0).isSelected());
  45. assertNoErrorNotifications();
  46. }
  47. }