diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-09-30 18:04:51 +0300 |
---|---|---|
committer | Henrik Paul <henrik@vaadin.com> | 2014-10-02 06:05:01 +0000 |
commit | f46063daa196f11399e15ed68cb1ba57dc8e5f94 (patch) | |
tree | 60c44919e178c157ec5d6a3fea1a2991156e0354 /uitest | |
parent | d1e1ecef82adc47882dc5fe3636bf48c8ed6dcc1 (diff) | |
download | vaadin-framework-f46063daa196f11399e15ed68cb1ba57dc8e5f94.tar.gz vaadin-framework-f46063daa196f11399e15ed68cb1ba57dc8e5f94.zip |
Add support for Grid column reordering (#13334)
Change-Id: I685cf0455810520e801cccdd46d8af838c8a3917
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java | 20 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java | 23 |
2 files changed, 43 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 ae8a0d5eb8..cdf3508bea 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -18,6 +18,7 @@ package com.vaadin.tests.components.grid.basicfeatures; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; @@ -255,6 +256,25 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { grid.setSortOrder(sortOrder); } }); + + createBooleanAction("Reverse Grid Columns", "State", false, + new Command<Grid, Boolean>() { + + @Override + public void execute(Grid c, Boolean value, Object data) { + List<Object> ids = new ArrayList<Object>(); + ids.addAll(ds.getContainerPropertyIds()); + if (!value) { + c.setColumnOrder(ids.toArray()); + } else { + Object[] idsArray = new Object[ids.size()]; + for (int i = 0; i < ids.size(); ++i) { + idsArray[i] = ids.get((ids.size() - 1) - i); + } + c.setColumnOrder(idsArray); + } + } + }); } protected void createHeaderActions() { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java index 0359a95756..b771185167 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridStructureTest.java @@ -29,6 +29,7 @@ import org.openqa.selenium.WebElement; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.tests.components.grid.GridElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; @@ -242,6 +243,28 @@ public class GridStructureTest extends GridBasicFeaturesTest { isElementPresent(By.xpath("//th[text()='" + columnName + "']"))); } + @Test + public void testReverseColumns() { + openTestURL(); + + String[] gridData = new String[GridBasicFeatures.COLUMNS]; + GridElement grid = getGridElement(); + for (int i = 0; i < gridData.length; ++i) { + gridData[i] = grid.getCell(0, i).getAttribute("innerHTML"); + } + + selectMenuPath("Component", "State", "Reverse Grid Columns"); + + // Compare with reversed order + for (int i = 0; i < gridData.length; ++i) { + final int column = gridData.length - 1 - i; + final String newText = grid.getCell(0, column).getAttribute( + "innerHTML"); + assertEquals("Grid contained unexpected values. (0, " + column + + ")", gridData[i], newText); + } + } + private boolean verticalScrollbarIsPresent() { return "scroll".equals(getGridVerticalScrollbar().getCssValue( "overflow-y")); |