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.

GridColumnResizeModeTest.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.basicfeatures;
  17. import java.util.List;
  18. import org.junit.Assert;
  19. import org.junit.Before;
  20. import org.junit.Test;
  21. import org.openqa.selenium.WebElement;
  22. import org.openqa.selenium.interactions.Actions;
  23. import com.vaadin.testbench.By;
  24. import com.vaadin.testbench.customelements.GridElement;
  25. import com.vaadin.testbench.parallel.TestCategory;
  26. import com.vaadin.tests.components.grid.basics.GridBasicsTest;
  27. @TestCategory("grid")
  28. public class GridColumnResizeModeTest extends GridBasicsTest {
  29. @Before
  30. public void before() {
  31. openTestURL();
  32. }
  33. @Test
  34. public void testSimpleResizeModeToggle() throws Exception {
  35. GridElement grid = getGridElement();
  36. List<WebElement> handles = grid
  37. .findElements(By.className("v-grid-column-resize-handle"));
  38. WebElement handle = handles.get(1);
  39. Actions drag1 = new Actions(getDriver()).moveToElement(handle)
  40. .clickAndHold();
  41. Actions drag2 = new Actions(getDriver()).moveByOffset(-50, 0);
  42. Actions drag3 = new Actions(getDriver()).moveByOffset(100, 0);
  43. Actions dragEndAction = new Actions(getDriver()).release()
  44. .moveToElement(grid);
  45. selectMenuPath("Component", "Columns", "Simple resize mode");
  46. sleep(250);
  47. drag1.perform();
  48. sleep(500);
  49. drag2.perform();
  50. sleep(500);
  51. drag3.perform();
  52. sleep(500);
  53. // Make sure we find at least one simple resize mode splitter
  54. assertElementPresent(
  55. By.className("v-grid-column-resize-simple-indicator"));
  56. dragEndAction.perform();
  57. // Make sure it went away
  58. assertElementNotPresent(
  59. By.className("v-grid-column-resize-simple-indicator"));
  60. // See that we got a resize event
  61. sleep(500);
  62. Assert.assertTrue("Log shows resize event", getLogRow(0)
  63. .contains("ColumnResizeEvent: isUserOriginated? true"));
  64. }
  65. }