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.

GridDragSelectionWhileScrolledTest.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.grid;
  17. import static org.junit.Assert.assertFalse;
  18. import static org.junit.Assert.assertTrue;
  19. import java.io.IOException;
  20. import org.junit.Test;
  21. import org.openqa.selenium.JavascriptExecutor;
  22. import org.openqa.selenium.interactions.Actions;
  23. import com.vaadin.testbench.elements.GridElement;
  24. import com.vaadin.testbench.parallel.TestCategory;
  25. import com.vaadin.tests.tb3.MultiBrowserTest;
  26. @TestCategory("grid")
  27. public class GridDragSelectionWhileScrolledTest extends MultiBrowserTest {
  28. @Override
  29. protected boolean requireWindowFocusForIE() {
  30. return true;
  31. }
  32. @Test
  33. public void testDragSelect() throws IOException {
  34. openTestURL();
  35. // Scroll grid to view
  36. GridElement grid = $(LegacyGridElement.class).first();
  37. ((JavascriptExecutor) getDriver())
  38. .executeScript("arguments[0].scrollIntoView(true);", grid);
  39. // Drag select 2 rows
  40. new Actions(getDriver()).moveToElement(grid.getCell(3, 0), 5, 5)
  41. .clickAndHold().moveToElement(grid.getCell(2, 0), 5, 5)
  42. .release().perform();
  43. // Assert only those are selected.
  44. assertTrue("Row 3 should be selected", grid.getRow(3).isSelected());
  45. assertTrue("Row 2 should be selected", grid.getRow(2).isSelected());
  46. assertFalse("Row 4 should not be selected",
  47. grid.getRow(4).isSelected());
  48. assertFalse("Row 1 should not be selected",
  49. grid.getRow(1).isSelected());
  50. }
  51. }