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.

GridColspansTest.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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;
  17. import static org.junit.Assert.assertEquals;
  18. import static org.junit.Assert.assertTrue;
  19. import org.junit.Before;
  20. import org.junit.Test;
  21. import org.openqa.selenium.By;
  22. import com.vaadin.testbench.elements.ButtonElement;
  23. import com.vaadin.testbench.elements.GridElement;
  24. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  25. import com.vaadin.testbench.parallel.TestCategory;
  26. import com.vaadin.tests.tb3.MultiBrowserTest;
  27. @TestCategory("grid")
  28. public class GridColspansTest extends MultiBrowserTest {
  29. @Before
  30. public void setUp() {
  31. setDebug(true);
  32. }
  33. @Test
  34. public void testHeaderColSpans() {
  35. openTestURL();
  36. GridElement grid = $(GridElement.class).first();
  37. assertEquals("5", grid.getHeaderCell(0, 1).getAttribute("colspan"));
  38. assertEquals("2", grid.getHeaderCell(1, 1).getAttribute("colspan"));
  39. assertEquals("3", grid.getHeaderCell(1, 3).getAttribute("colspan"));
  40. }
  41. @Test
  42. public void testFooterColSpans() {
  43. openTestURL();
  44. GridElement grid = $(GridElement.class).first();
  45. assertEquals("5", grid.getFooterCell(1, 1).getAttribute("colspan"));
  46. assertEquals("2", grid.getFooterCell(0, 1).getAttribute("colspan"));
  47. assertEquals("3", grid.getFooterCell(0, 3).getAttribute("colspan"));
  48. }
  49. @Test
  50. public void testHideFirstColumnOfColspan() {
  51. openTestURL();
  52. GridElement grid = $(GridElement.class).first();
  53. assertEquals("Failed initial condition.", "all the stuff", grid
  54. .getHeaderCell(0, 1).getText().toLowerCase());
  55. assertEquals("Failed initial condition.", "first name", grid
  56. .getHeaderCell(2, 1).getText().toLowerCase());
  57. $(ButtonElement.class).caption("Show/Hide firstName").first().click();
  58. assertEquals("Header text changed on column hide.", "all the stuff",
  59. grid.getHeaderCell(0, 1).getText().toLowerCase());
  60. assertEquals("Failed initial condition.", "last name", grid
  61. .getHeaderCell(2, 1).getText().toLowerCase());
  62. }
  63. @Test
  64. public void testSplittingMergedHeaders() {
  65. openTestURL();
  66. GridElement grid = $(GridElement.class).first();
  67. GridCellElement headerCell = grid.getHeaderCell(1, 1);
  68. assertEquals("Failed initial condition.", "full name", headerCell
  69. .getText().toLowerCase());
  70. assertEquals("Failed initial condition.", "first name", grid
  71. .getHeaderCell(2, 1).getText().toLowerCase());
  72. $(ButtonElement.class).get(1).click();
  73. headerCell = grid.getHeaderCell(1, 1);
  74. assertEquals("Header text not changed on column reorder.", "address",
  75. headerCell.getText().toLowerCase());
  76. assertEquals("Unexpected colspan", "1",
  77. headerCell.getAttribute("colspan"));
  78. headerCell = grid.getHeaderCell(1, 2);
  79. assertEquals("Header text not changed on column reorder", "full name",
  80. headerCell.getText().toLowerCase());
  81. assertEquals("Unexpected colspan", "2",
  82. headerCell.getAttribute("colspan"));
  83. assertTrue("Error indicator not present",
  84. isElementPresent(By.className("v-errorindicator")));
  85. }
  86. }