123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /*
- * Copyright 2000-2016 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 com.vaadin.ui.LegacyGrid;
- import org.junit.Test;
-
- public class GridColumnDeclarativeTest extends GridDeclarativeTestBase {
-
- @Test
- public void testSimpleGridColumns() {
- String design = "<vaadin-legacy-grid><table>"//
- + "<colgroup>"
- + " <col sortable width='100' property-id='Column1'>"
- + " <col sortable=false max-width='200' expand='2' property-id='Column2'>"
- + " <col sortable editable=false resizable=false min-width='15' expand='1' property-id='Column3'>"
- + " <col sortable hidable hiding-toggle-caption='col 4' property-id='Column4'>"
- + " <col sortable hidden property-id='Column5'>"
- + "</colgroup>" //
- + "<thead />" //
- + "</table></vaadin-legacy-grid>";
- LegacyGrid grid = new LegacyGrid();
- grid.addColumn("Column1", String.class).setWidth(100);
- grid.addColumn("Column2", String.class).setMaximumWidth(200)
- .setExpandRatio(2).setSortable(false);
- grid.addColumn("Column3", String.class).setMinimumWidth(15)
- .setExpandRatio(1).setEditable(false).setResizable(false);
- grid.addColumn("Column4", String.class).setHidable(true)
- .setHidingToggleCaption("col 4").setResizable(true);
- grid.addColumn("Column5", String.class).setHidden(true);
-
- // Remove the default header
- grid.removeHeaderRow(grid.getDefaultHeaderRow());
-
- // Use the read grid component to do another pass on write.
- testRead(design, grid, true);
- testWrite(design, grid);
- }
-
- @Test
- public void testReadColumnsWithoutPropertyId() {
- String design = "<vaadin-legacy-grid><table>"//
- + "<colgroup>"
- + " <col sortable=true width='100' property-id='Column1'>"
- + " <col sortable=true max-width='200' expand='2'>" // property-id="property-1"
- + " <col sortable=true min-width='15' expand='1' property-id='Column3'>"
- + " <col sortable=true hidden=true hidable=true hiding-toggle-caption='col 4'>" // property-id="property-3"
- + "</colgroup>" //
- + "</table></vaadin-legacy-grid>";
- LegacyGrid grid = new LegacyGrid();
- grid.addColumn("Column1", String.class).setWidth(100);
- grid.addColumn("property-1", String.class).setMaximumWidth(200)
- .setExpandRatio(2);
- grid.addColumn("Column3", String.class).setMinimumWidth(15)
- .setExpandRatio(1);
- grid.addColumn("property-3", String.class).setHidable(true)
- .setHidden(true).setHidingToggleCaption("col 4");
-
- testRead(design, grid);
- }
-
- @Test
- public void testReadEmptyExpand() {
- String design = "<vaadin-legacy-grid><table>"//
- + "<colgroup>" + " <col sortable=true expand />"
- + "</colgroup>" //
- + "</table></vaadin-legacy-grid>";
-
- LegacyGrid grid = new LegacyGrid();
- grid.addColumn("property-0", String.class).setExpandRatio(1);
-
- testRead(design, grid);
- }
-
- @Test
- public void testReadColumnWithNoAttributes() {
- String design = "<vaadin-legacy-grid><table>"//
- + "<colgroup>" //
- + " <col />" //
- + "</colgroup>" //
- + "</table></vaadin-legacy-grid>";
-
- LegacyGrid grid = new LegacyGrid();
- grid.addColumn("property-0", String.class);
-
- testRead(design, grid);
- }
- }
|