summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2015-02-24 23:51:31 +0200
committerLeif Åstrand <leif@vaadin.com>2015-03-03 08:30:47 +0000
commitf79b9788842cefc50a58aafd476eaa7b817c92f1 (patch)
tree328a9cd69c0ccd9dafeffb4183ac2cb180e6e9d4 /uitest
parent2ad8f945b2b4847a539d82b6593aee42095c8c56 (diff)
downloadvaadin-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')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientColumnPropertiesTest.java35
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java9
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() {