Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

GridSortIndicatorTest.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertEquals;
  3. import static org.junit.Assert.assertFalse;
  4. import static org.junit.Assert.assertTrue;
  5. import org.junit.Test;
  6. import com.vaadin.testbench.elements.ButtonElement;
  7. import com.vaadin.testbench.elements.GridElement;
  8. import com.vaadin.testbench.parallel.TestCategory;
  9. import com.vaadin.tests.tb3.SingleBrowserTest;
  10. @TestCategory("grid")
  11. public class GridSortIndicatorTest extends SingleBrowserTest {
  12. @Test
  13. public void testIndicators() throws InterruptedException {
  14. openTestURL();
  15. GridElement grid = $(GridElement.class).first();
  16. $(ButtonElement.class).caption("Sort both").first().click();
  17. assertTrue("First column should be sorted ascending",
  18. grid.getHeaderCell(0, 0).getAttribute("class")
  19. .contains("sort-asc"));
  20. assertEquals("First column should have aria-sort other", "other",
  21. grid.getHeaderCell(0, 0).getAttribute("aria-sort"));
  22. assertEquals("First column should be first in sort order", "1",
  23. grid.getHeaderCell(0, 0).getAttribute("sort-order"));
  24. assertTrue("Second column should be sorted ascending",
  25. grid.getHeaderCell(0, 1).getAttribute("class")
  26. .contains("sort-asc"));
  27. assertEquals("Second column should have aria-sort other", "other",
  28. grid.getHeaderCell(0, 1).getAttribute("aria-sort"));
  29. assertEquals("Second column should be also sorted", "2",
  30. grid.getHeaderCell(0, 1).getAttribute("sort-order"));
  31. $(ButtonElement.class).caption("Sort first").first().click();
  32. assertEquals("First column should have aria-sort ascending",
  33. "ascending",
  34. grid.getHeaderCell(0, 0).getAttribute("aria-sort"));
  35. assertTrue("First column should be sorted ascending",
  36. grid.getHeaderCell(0, 0).getAttribute("class")
  37. .contains("sort-asc"));
  38. assertEquals("Second column should have aria-sort none", "none",
  39. grid.getHeaderCell(0, 1).getAttribute("aria-sort"));
  40. assertFalse("Second column should not be sorted",
  41. grid.getHeaderCell(0, 1).getAttribute("class")
  42. .contains("sort-asc"));
  43. }
  44. }