aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java42
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java57
2 files changed, 99 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
index 3a6aca11f2..792ef89d42 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -248,10 +248,25 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
addFilterActions();
+ addInternalActions();
+
this.grid = grid;
return grid;
}
+ private void addInternalActions() {
+ createClickAction("Update column order without updating client",
+ "Internals", new Command<Grid, Void>() {
+ @Override
+ public void execute(Grid grid, Void value, Object data) {
+ List<Column> columns = grid.getColumns();
+ grid.setColumnOrder(columns.get(1).getPropertyId(),
+ columns.get(0).getPropertyId());
+ grid.getUI().getConnectorTracker().markClean(grid);
+ }
+ }, null);
+ }
+
private void addFilterActions() {
createClickAction("Column 1 starts with \"(23\"", "Filter",
new Command<Grid, Void>() {
@@ -658,6 +673,33 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
}
}, null, c);
+ createClickAction("Move left", getColumnProperty(c),
+ new Command<Grid, String>() {
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ final String columnProperty = getColumnProperty((Integer) data);
+ List<Column> cols = grid.getColumns();
+ List<Object> reordered = new ArrayList<Object>();
+ boolean addAsLast = false;
+ for (int i = 0; i < cols.size(); i++) {
+ Column col = cols.get(i);
+ if (col.getPropertyId().equals(columnProperty)) {
+ if (i == 0) {
+ addAsLast = true;
+ } else {
+ reordered.add(i - 1, columnProperty);
+ }
+ } else {
+ reordered.add(col.getPropertyId());
+ }
+ }
+ if (addAsLast) {
+ reordered.add(columnProperty);
+ }
+ grid.setColumnOrder(reordered.toArray());
+ }
+ }, null, c);
createBooleanAction("Sortable", getColumnProperty(c), true,
new Command<Grid, Boolean>() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java
index 7b62ff85f9..7f4e9bb7e9 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnReorderTest.java
@@ -71,6 +71,26 @@ public class GridColumnReorderTest extends GridBasicFeaturesTest {
}
@Test
+ public void testColumnReordering_reorderingTwiceBackForth_reordered() {
+ // given
+ openTestURL();
+ assertColumnHeaderOrder(0, 1, 2);
+ toggleColumnReordering();
+
+ // when
+ dragDefaultColumnHeader(2, 0, 10);
+
+ // then
+ assertColumnHeaderOrder(2, 0, 1, 3);
+
+ // when
+ dragDefaultColumnHeader(1, 3, 110);
+
+ // then
+ assertColumnHeaderOrder(2, 1, 3, 0);
+ }
+
+ @Test
public void testColumnReordering_notEnabled_noReordering() {
// given
openTestURL();
@@ -83,10 +103,47 @@ public class GridColumnReorderTest extends GridBasicFeaturesTest {
assertColumnHeaderOrder(0, 1, 2);
}
+ @Test
+ public void testColumnReordering_userChangesRevertedByServer_columnsAreUpdated() {
+ // given
+ openTestURL();
+ assertColumnHeaderOrder(0, 1, 2);
+ toggleColumnReordering();
+
+ // when
+ dragDefaultColumnHeader(0, 2, 10);
+ assertColumnHeaderOrder(1, 0, 2);
+ moveColumnManuallyLeftByOne(0);
+
+ // then
+ assertColumnHeaderOrder(0, 1, 2);
+ }
+
+ @Test
+ public void testColumnReordering_concurrentUpdatesFromServer_columnOrderFromServerUsed() {
+ // given
+ openTestURL();
+ assertColumnHeaderOrder(0, 1, 2);
+ toggleColumnReordering();
+
+ // when
+ selectMenuPath(new String[] { "Component", "Internals",
+ "Update column order without updating client" });
+ dragDefaultColumnHeader(2, 0, 10);
+
+ // then
+ assertColumnHeaderOrder(1, 0, 2);
+ }
+
private void toggleColumnReordering() {
selectMenuPath(COLUMN_REORDERING_PATH);
}
+ private void moveColumnManuallyLeftByOne(int index) {
+ selectMenuPath(new String[] { "Component", "Columns",
+ "Column " + index, "Move left" });
+ }
+
private void assertColumnHeaderOrder(int... indices) {
List<TestBenchElement> headers = getGridHeaderRowCells();
for (int i = 0; i < indices.length; i++) {