diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-14 11:45:19 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-04-14 17:11:05 +0300 |
commit | 7cb23bc63f794a7549dd79c37da2f8bb8e88e20d (patch) | |
tree | fa1412380e83cf279bf46ac1e4f6f85b2fec074f /server/tests | |
parent | cda732dd1f5110ef60cdc9f1848e83cea6ebd830 (diff) | |
download | vaadin-framework-7cb23bc63f794a7549dd79c37da2f8bb8e88e20d.tar.gz vaadin-framework-7cb23bc63f794a7549dd79c37da2f8bb8e88e20d.zip |
Fix Grid inline data declarative support (#16596)
Change-Id: Ief0238c04ff16674a4102d359381531ae30e9a9f
Diffstat (limited to 'server/tests')
2 files changed, 112 insertions, 1 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridDeclarativeTestBase.java b/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridDeclarativeTestBase.java index 0a32ec1734..2a4b3f01fc 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridDeclarativeTestBase.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridDeclarativeTestBase.java @@ -35,6 +35,11 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { } public Grid testRead(String design, Grid expected, boolean retestWrite) { + return testRead(design, expected, retestWrite, false); + } + + public Grid testRead(String design, Grid expected, boolean retestWrite, + boolean writeData) { Grid actual = super.testRead(design, expected); compareGridColumns(expected, actual); @@ -42,7 +47,7 @@ public class GridDeclarativeTestBase extends DeclarativeTestBase<Grid> { compareFooters(expected, actual); if (retestWrite) { - testWrite(design, actual); + testWrite(design, actual, writeData); } return actual; diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java new file mode 100644 index 0000000000..fefd49a587 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/grid/declarative/GridInlineDataDeclarativeTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.server.component.grid.declarative; + +import org.junit.Test; + +import com.vaadin.ui.Grid; + +public class GridInlineDataDeclarativeTest extends GridDeclarativeTestBase { + + @Test + public void testSimpleInlineData() { + String design = "<v-grid><table>"// + + "<colgroup>" + + " <col sortable=true property-id='Col1' />" + + "</colgroup>" // + + "<thead />" // No headers read or written + + "<tbody>" // + + "<tr><td>Foo</tr>" // + + "<tr><td>Bar</tr>" // + + "<tr><td>Baz</tr>" // + + "</table></v-grid>"; + + Grid grid = new Grid(); + grid.addColumn("Col1", String.class); + grid.addRow("Foo"); + grid.addRow("Bar"); + grid.addRow("Baz"); + + // Remove default header + grid.removeHeaderRow(grid.getDefaultHeaderRow()); + + testWrite(design, grid, true); + testRead(design, grid, true, true); + } + + @Test + public void testMultipleColumnsInlineData() { + String design = "<v-grid><table>"// + + "<colgroup>" + + " <col sortable=true property-id='Col1' />" + + " <col sortable=true property-id='Col2' />" + + " <col sortable=true property-id='Col3' />" // + + "</colgroup>" // + + "<thead />" // No headers read or written + + "<tbody>" // + + "<tr><td>Foo<td>Bar<td>Baz</tr>" // + + "<tr><td>My<td>Summer<td>Car</tr>" // + + "</table></v-grid>"; + + Grid grid = new Grid(); + grid.addColumn("Col1", String.class); + grid.addColumn("Col2", String.class); + grid.addColumn("Col3", String.class); + grid.addRow("Foo", "Bar", "Baz"); + grid.addRow("My", "Summer", "Car"); + + // Remove default header + grid.removeHeaderRow(grid.getDefaultHeaderRow()); + + testWrite(design, grid, true); + testRead(design, grid, true, true); + } + + @Test + public void testMultipleColumnsInlineDataReordered() { + String design = "<v-grid><table>"// + + "<colgroup>" + + " <col sortable=true property-id='Col2' />" + + " <col sortable=true property-id='Col3' />" + + " <col sortable=true property-id='Col1' />" // + + "</colgroup>" // + + "<thead />" // No headers read or written + + "<tbody>" // + + "<tr><td>Bar<td>Baz<td>Foo</tr>" // + + "<tr><td>Summer<td>Car<td>My</tr>" // + + "</table></v-grid>"; + + Grid grid = new Grid(); + grid.addColumn("Col1", String.class); + grid.addColumn("Col2", String.class); + grid.addColumn("Col3", String.class); + grid.addRow("Foo", "Bar", "Baz"); + grid.addRow("My", "Summer", "Car"); + grid.setColumnOrder("Col2", "Col3", "Col1"); + + // Remove default header + grid.removeHeaderRow(grid.getDefaultHeaderRow()); + + testWrite(design, grid, true); + testRead(design, grid, true, true); + } +} |