diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2015-02-24 23:51:31 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2015-03-03 08:30:47 +0000 |
commit | f79b9788842cefc50a58aafd476eaa7b817c92f1 (patch) | |
tree | 328a9cd69c0ccd9dafeffb4183ac2cb180e6e9d4 /uitest | |
parent | 2ad8f945b2b4847a539d82b6593aee42095c8c56 (diff) | |
download | vaadin-framework-f79b9788842cefc50a58aafd476eaa7b817c92f1.tar.gz vaadin-framework-f79b9788842cefc50a58aafd476eaa7b817c92f1.zip |
Reapplying column width on Grid actually reapplies the width (#16900)
Change-Id: I8a0bc92294004411782c6ee5b0e460b892570aa3
Diffstat (limited to 'uitest')
2 files changed, 44 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java index 82bf349096..2ba1dbc311 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java @@ -19,9 +19,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.List; + import org.junit.Test; import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; import com.vaadin.tests.widgetset.client.grid.GridBasicClientFeaturesWidget; @@ -122,6 +126,37 @@ public class GridClientColumnPropertiesTest extends GridBasicClientFeaturesTest .getCell(1, 0).getText()); } + @Test + public void testColumnWidths_onColumnReorder_columnWidthsKeptTheSame() { + // given + openTestURL(); + GridElement gridElement = getGridElement(); + List<GridCellElement> headerCells = gridElement.getHeaderCells(0); + + final List<Integer> columnWidths = new ArrayList<Integer>(); + for (GridCellElement cell : headerCells) { + columnWidths.add(cell.getSize().getWidth()); + } + + // when + selectMenuPath("Component", "State", "Reverse grid columns"); + + // then + gridElement = getGridElement(); + headerCells = gridElement.getHeaderCells(0); + final int size = headerCells.size(); + // skip last column since there is a bug in the width of the last column + for (int i = 0; i < size - 1; i++) { + assertEquals( + "Column widths don't match after reset, index after flip " + + i, + columnWidths.get(i), + Integer.valueOf(headerCells.get(size - 1 - i).getSize() + .getWidth())); + } + + } + private boolean cellIsFrozen(int row, int col) { return getGridElement().getCell(row, col).isFrozen(); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 0452aa65d1..4dc0195f22 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -649,6 +649,15 @@ public class GridBasicClientFeaturesWidget extends grid.setEnabled(!grid.isEnabled()); } }, "Component", "State"); + addMenuCommand("Reverse grid columns", new ScheduledCommand() { + + @Override + public void execute() { + List<Column> columns = new ArrayList<Column>(grid.getColumns()); + Collections.reverse(columns); + grid.setColumnOrder(columns.toArray(new Column[columns.size()])); + } + }, "Component", "State"); } private void createColumnsMenu() { |