diff options
author | John Ahlroos <john@vaadin.com> | 2013-12-03 10:54:53 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-12-04 14:48:59 +0200 |
commit | 428c5801da9f2d9248ad35c385b329a2f80c33b9 (patch) | |
tree | 0f20d27025679c5333dc70e1684219256d6e27fd /uitest/src/com | |
parent | 3e64013806a9e4f06babe33d1f0c66a5ff371798 (diff) | |
download | vaadin-framework-428c5801da9f2d9248ad35c385b329a2f80c33b9.tar.gz vaadin-framework-428c5801da9f2d9248ad35c385b329a2f80c33b9.zip |
Support custom column widths in Grid #13024
Change-Id: Ib0c1701346dc6b8b9ef5b5290fc6ffaff68d9f96
Diffstat (limited to 'uitest/src/com')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java | 34 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java | 52 |
2 files changed, 79 insertions, 7 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java index 82e8d5d908..10c8a76920 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java @@ -142,8 +142,40 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { } }, null, c); - } + createCategory("Column" + c + " Width", "Column" + c); + + createClickAction("Auto", "Column" + c + " Width", + new Command<Grid, Integer>() { + @Override + public void execute(Grid grid, Integer value, + Object columnIndex) { + Object propertyId = (new ArrayList(grid + .getContainerDatasource() + .getContainerPropertyIds()) + .get((Integer) columnIndex)); + GridColumn column = grid.getColumn(propertyId); + column.setWidthUndefined(); + } + }, -1, c); + + for (int w = 50; w < 300; w += 50) { + createClickAction(w + "px", "Column" + c + " Width", + new Command<Grid, Integer>() { + + @Override + public void execute(Grid grid, Integer value, + Object columnIndex) { + Object propertyId = (new ArrayList(grid + .getContainerDatasource() + .getContainerPropertyIds()) + .get((Integer) columnIndex)); + GridColumn column = grid.getColumn(propertyId); + column.setWidth(value); + } + }, w, c); + } + } } protected void createColumnGroupActions() { diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java index 7d0e840390..203171137e 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java @@ -188,17 +188,57 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { // Freeze column 2 selectMenuPath("Component", "Columns", "Column2", "Freeze"); - WebElement cell = getDriver() - .findElement( - By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[1]/td[1]")); + WebElement cell = getBodyCellByRowAndColumn(1, 1); assertTrue(cell.getAttribute("class").contains("frozen")); - cell = getDriver() - .findElement( - By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[1]/td[2]")); + cell = getBodyCellByRowAndColumn(1, 2); assertTrue(cell.getAttribute("class").contains("frozen")); } + @Test + public void testColumnWidths() throws Exception { + openTestURL(); + + // Default borders and margins implemented by escalator + int cellBorder = 1 + 1; + int cellMargin = 2 + 2; + + // Default column width is 100px + WebElement cell = getBodyCellByRowAndColumn(1, 1); + assertEquals((100 - cellBorder - cellMargin) + "px", + cell.getCssValue("width")); + + // Set first column to be 200px wide + selectMenuPath("Component", "Columns", "Column0", "Column0 Width", + "200px"); + + cell = getBodyCellByRowAndColumn(1, 1); + assertEquals((200 - cellBorder - cellMargin) + "px", + cell.getCssValue("width")); + + // Set second column to be 150px wide + selectMenuPath("Component", "Columns", "Column1", "Column1 Width", + "150px"); + cell = getBodyCellByRowAndColumn(1, 2); + assertEquals((150 - cellBorder - cellMargin) + "px", + cell.getCssValue("width")); + + // Set first column to be auto sized (defaults to 100px currently) + selectMenuPath("Component", "Columns", "Column0", "Column0 Width", + "Auto"); + + cell = getBodyCellByRowAndColumn(1, 1); + assertEquals((100 - cellBorder - cellMargin) + "px", + cell.getCssValue("width")); + + } + + private WebElement getBodyCellByRowAndColumn(int row, int column) { + return getDriver().findElement( + By.xpath("//tbody[contains(@class, 'v-escalator-body')]/tr[" + + row + "]/td[" + column + "]")); + } + private void selectSubMenu(String menuCaption) { selectMenu(menuCaption); new Actions(getDriver()).moveByOffset(100, 0).build().perform(); |