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.

GridInlineDataDeclarativeTest.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.server.component.grid.declarative;
  17. import org.junit.Test;
  18. import com.vaadin.ui.Grid;
  19. public class GridInlineDataDeclarativeTest extends GridDeclarativeTestBase {
  20. @Test
  21. public void testSimpleInlineData() {
  22. String design = "<v-grid><table>"//
  23. + "<colgroup>"
  24. + " <col sortable='' property-id='Col1' />"
  25. + "</colgroup>" //
  26. + "<thead />" // No headers read or written
  27. + "<tbody>" //
  28. + "<tr><td>Foo</tr>" //
  29. + "<tr><td>Bar</tr>" //
  30. + "<tr><td>Baz</tr>" //
  31. + "</table></v-grid>";
  32. Grid grid = new Grid();
  33. grid.addColumn("Col1", String.class);
  34. grid.addRow("Foo");
  35. grid.addRow("Bar");
  36. grid.addRow("Baz");
  37. // Remove default header
  38. grid.removeHeaderRow(grid.getDefaultHeaderRow());
  39. testWrite(design, grid, true);
  40. testRead(design, grid, true, true);
  41. }
  42. @Test
  43. public void testMultipleColumnsInlineData() {
  44. String design = "<v-grid><table>"//
  45. + "<colgroup>"
  46. + " <col sortable='' property-id='Col1' />"
  47. + " <col sortable='' property-id='Col2' />"
  48. + " <col sortable='' property-id='Col3' />" //
  49. + "</colgroup>" //
  50. + "<thead />" // No headers read or written
  51. + "<tbody>" //
  52. + "<tr><td>Foo<td>Bar<td>Baz</tr>" //
  53. + "<tr><td>My<td>Summer<td>Car</tr>" //
  54. + "</table></v-grid>";
  55. Grid grid = new Grid();
  56. grid.addColumn("Col1", String.class);
  57. grid.addColumn("Col2", String.class);
  58. grid.addColumn("Col3", String.class);
  59. grid.addRow("Foo", "Bar", "Baz");
  60. grid.addRow("My", "Summer", "Car");
  61. // Remove default header
  62. grid.removeHeaderRow(grid.getDefaultHeaderRow());
  63. testWrite(design, grid, true);
  64. testRead(design, grid, true, true);
  65. }
  66. @Test
  67. public void testMultipleColumnsInlineDataReordered() {
  68. String design = "<v-grid><table>"//
  69. + "<colgroup>"
  70. + " <col sortable='' property-id='Col2' />"
  71. + " <col sortable='' property-id='Col3' />"
  72. + " <col sortable='' property-id='Col1' />" //
  73. + "</colgroup>" //
  74. + "<thead />" // No headers read or written
  75. + "<tbody>" //
  76. + "<tr><td>Bar<td>Baz<td>Foo</tr>" //
  77. + "<tr><td>Summer<td>Car<td>My</tr>" //
  78. + "</table></v-grid>";
  79. Grid grid = new Grid();
  80. grid.addColumn("Col1", String.class);
  81. grid.addColumn("Col2", String.class);
  82. grid.addColumn("Col3", String.class);
  83. grid.addRow("Foo", "Bar", "Baz");
  84. grid.addRow("My", "Summer", "Car");
  85. grid.setColumnOrder("Col2", "Col3", "Col1");
  86. // Remove default header
  87. grid.removeHeaderRow(grid.getDefaultHeaderRow());
  88. testWrite(design, grid, true);
  89. testRead(design, grid, true, true);
  90. }
  91. }