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