2 * Copyright 2000-2014 Vaadin Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
16 package com.vaadin.tests.server.component.grid.declarative;
18 import org.junit.Test;
20 import com.vaadin.ui.Grid;
22 public class GridInlineDataDeclarativeTest extends GridDeclarativeTestBase {
25 public void testSimpleInlineData() {
26 String design = "<v-grid><table>"//
28 + " <col sortable='' property-id='Col1' />"
30 + "<thead />" // No headers read or written
32 + "<tr><td>Foo</tr>" //
33 + "<tr><td>Bar</tr>" //
34 + "<tr><td>Baz</tr>" //
35 + "</table></v-grid>";
37 Grid grid = new Grid();
38 grid.addColumn("Col1", String.class);
43 // Remove default header
44 grid.removeHeaderRow(grid.getDefaultHeaderRow());
46 testWrite(design, grid, true);
47 testRead(design, grid, true, true);
51 public void testMultipleColumnsInlineData() {
52 String design = "<v-grid><table>"//
54 + " <col sortable='' property-id='Col1' />"
55 + " <col sortable='' property-id='Col2' />"
56 + " <col sortable='' property-id='Col3' />" //
58 + "<thead />" // No headers read or written
60 + "<tr><td>Foo<td>Bar<td>Baz</tr>" //
61 + "<tr><td>My<td>Summer<td>Car</tr>" //
62 + "</table></v-grid>";
64 Grid grid = new Grid();
65 grid.addColumn("Col1", String.class);
66 grid.addColumn("Col2", String.class);
67 grid.addColumn("Col3", String.class);
68 grid.addRow("Foo", "Bar", "Baz");
69 grid.addRow("My", "Summer", "Car");
71 // Remove default header
72 grid.removeHeaderRow(grid.getDefaultHeaderRow());
74 testWrite(design, grid, true);
75 testRead(design, grid, true, true);
79 public void testMultipleColumnsInlineDataReordered() {
80 String design = "<v-grid><table>"//
82 + " <col sortable='' property-id='Col2' />"
83 + " <col sortable='' property-id='Col3' />"
84 + " <col sortable='' property-id='Col1' />" //
86 + "<thead />" // No headers read or written
88 + "<tr><td>Bar<td>Baz<td>Foo</tr>" //
89 + "<tr><td>Summer<td>Car<td>My</tr>" //
90 + "</table></v-grid>";
92 Grid grid = new Grid();
93 grid.addColumn("Col1", String.class);
94 grid.addColumn("Col2", String.class);
95 grid.addColumn("Col3", String.class);
96 grid.addRow("Foo", "Bar", "Baz");
97 grid.addRow("My", "Summer", "Car");
98 grid.setColumnOrder("Col2", "Col3", "Col1");
100 // Remove default header
101 grid.removeHeaderRow(grid.getDefaultHeaderRow());
103 testWrite(design, grid, true);
104 testRead(design, grid, true, true);