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.

GridHeaderFooterTest.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.basics;
  17. import static org.junit.Assert.assertEquals;
  18. import java.util.List;
  19. import org.junit.Test;
  20. import com.vaadin.testbench.By;
  21. import com.vaadin.testbench.elements.GridElement.GridCellElement;
  22. public class GridHeaderFooterTest extends GridBasicsTest {
  23. @Test
  24. public void initialState_defaultHeaderPresent() {
  25. assertEquals(1, getGridElement().getHeaderCount());
  26. final String[] captions = GridBasics.COLUMN_CAPTIONS;
  27. List<GridCellElement> headerCells = getGridElement().getHeaderCells(0);
  28. assertEquals(captions.length, headerCells.size());
  29. for (int i = 0; i < headerCells.size(); i++) {
  30. assertText(captions[i], headerCells.get(i));
  31. }
  32. }
  33. @Test
  34. public void appendHeaderRow_addedToBottom() {
  35. selectMenuPath("Component", "Header", "Append header row");
  36. assertEquals(2, getGridElement().getHeaderCount());
  37. }
  38. @Test
  39. public void prependHeaderRow_addedToBottom() {
  40. selectMenuPath("Component", "Header", "Prepend header row");
  41. assertEquals(2, getGridElement().getHeaderCount());
  42. }
  43. @Test
  44. public void removeDefaultHeaderRow_noHeaderRows() {
  45. selectMenuPath("Component", "Header", "Remove first header row");
  46. assertEquals(0, getGridElement().getHeaderCount());
  47. }
  48. protected static void assertText(String expected, GridCellElement e) {
  49. // TBE.getText returns "" if the element is scrolled out of view
  50. String actual = e.findElement(By.tagName("div")).getAttribute(
  51. "innerHTML");
  52. assertEquals(expected, actual);
  53. }
  54. }