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.

GridMultiSortingTest.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2000-2014 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.server;
  17. import static org.junit.Assert.assertEquals;
  18. import static org.junit.Assert.assertTrue;
  19. import java.util.List;
  20. import org.junit.Test;
  21. import org.openqa.selenium.Keys;
  22. import org.openqa.selenium.interactions.Actions;
  23. import org.openqa.selenium.remote.DesiredCapabilities;
  24. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  25. import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
  26. public class GridMultiSortingTest extends GridBasicFeaturesTest {
  27. @Override
  28. public List<DesiredCapabilities> getBrowsersToTest() {
  29. return super.getBrowsersSupportingShiftClick();
  30. }
  31. @Test
  32. public void testUserMultiColumnSorting() {
  33. openTestURL();
  34. selectMenuPath("Component", "Columns", "Column 11", "Column 11 Width",
  35. "Auto");
  36. GridCellElement cell = getGridElement().getHeaderCell(0, 11);
  37. new Actions(driver).moveToElement(cell, 5, 5).click().perform();
  38. new Actions(driver).keyDown(Keys.SHIFT).perform();
  39. new Actions(driver)
  40. .moveToElement(getGridElement().getHeaderCell(0, 0), 5, 5)
  41. .click().perform();
  42. new Actions(driver).keyUp(Keys.SHIFT).perform();
  43. String prev = getGridElement().getCell(0, 11).getAttribute("innerHTML");
  44. for (int i = 1; i <= 6; ++i) {
  45. assertEquals("Column 11 should contain same values.", prev,
  46. getGridElement().getCell(i, 11).getAttribute("innerHTML"));
  47. }
  48. prev = getGridElement().getCell(0, 0).getText();
  49. for (int i = 1; i <= 6; ++i) {
  50. assertTrue(
  51. "Grid is not sorted by column 0.",
  52. prev.compareTo(getGridElement().getCell(i, 0).getText()) < 0);
  53. }
  54. }
  55. }