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.

DisallowedDeselectionTest.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.ButtonElement;
  6. import com.vaadin.testbench.elements.GridElement;
  7. import com.vaadin.testbench.elements.GridElement.GridRowElement;
  8. import com.vaadin.tests.tb3.MultiBrowserTest;
  9. /**
  10. * @author Vaadin Ltd
  11. *
  12. */
  13. public class DisallowedDeselectionTest extends MultiBrowserTest {
  14. @Test
  15. public void checkDeselection() {
  16. openTestURL();
  17. GridRowElement row = $(GridElement.class).first().getRow(0);
  18. assertFalse(row.isSelected());
  19. select(row);
  20. assertTrue(row.isSelected());
  21. // deselection is disallowed
  22. select(row);
  23. assertTrue(row.isSelected());
  24. // select another row
  25. GridRowElement oldRow = row;
  26. row = $(GridElement.class).first().getRow(1);
  27. select(row);
  28. assertTrue(row.isSelected());
  29. assertFalse(oldRow.isSelected());
  30. $(ButtonElement.class).first().click();
  31. select(row);
  32. assertFalse(row.isSelected());
  33. }
  34. private void select(GridRowElement row) {
  35. row.getCell(0).click();
  36. }
  37. }