aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/grid
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2015-03-23 13:42:07 +0200
committerPekka Hyvönen <pekka@vaadin.com>2015-03-31 13:51:09 +0000
commit0e7755958b46434185cb1e6e2ec8aa6932b32f34 (patch)
tree4e39eb62bcab3c2a03a3cc5d7b98e60e1ab943fb /uitest/src/com/vaadin/tests/components/grid
parent844b2c6c41d57d4db1238eb6096f225c9fdb8314 (diff)
downloadvaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.tar.gz
vaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.zip
API for column hiding toggle caption in Grid (#17272)
Fixes column toggle not getting a caption when a hidable column is added. Fixes column toggle not getting a caption on columns with widget in header. Change-Id: Ie10ada793a3635302603f684f232cadaef74a982
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/grid')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java31
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java50
3 files changed, 70 insertions, 13 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 d3b1237cf9..6f4c7df38c 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -768,17 +768,23 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
new Command<Grid, String>() {
boolean wasHidable;
+ boolean wasHidden;
+ String wasColumnHidingToggleCaption;
@Override
public void execute(Grid grid, String value, Object data) {
String columnProperty = getColumnProperty((Integer) data);
- if (grid.getColumn(columnProperty) == null) {
- grid.addColumn(columnProperty);
- grid.getColumn(columnProperty).setHidable(
- wasHidable);
+ Column column = grid.getColumn(columnProperty);
+ if (column == null) {
+ column = grid.addColumn(columnProperty);
+ column.setHidable(wasHidable);
+ column.setHidden(wasHidden);
+ column.setHidingToggleCaption(wasColumnHidingToggleCaption);
} else {
- wasHidable = grid.getColumn(columnProperty)
- .isHidable();
+ wasHidable = column.isHidable();
+ wasHidden = column.isHidden();
+ wasColumnHidingToggleCaption = column
+ .getHidingToggleCaption();
grid.removeColumn(columnProperty);
}
}
@@ -840,6 +846,19 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
grid.getColumn(propertyId).setHidden(hidden);
}
}, getColumnProperty(c));
+ createClickAction("Change hiding toggle caption",
+ getColumnProperty(c), new Command<Grid, String>() {
+ int count = 0;
+
+ @Override
+ public void execute(Grid grid, String value, Object data) {
+ final String columnProperty = getColumnProperty((Integer) data);
+ grid.getColumn(columnProperty)
+ .setHidingToggleCaption(
+ columnProperty + " caption "
+ + count++);
+ }
+ }, null, c);
createCategory("Column " + c + " Width", getColumnProperty(c));
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
index 68ba5f5c54..d779a5c81a 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
@@ -369,7 +369,7 @@ public class GridColumnReorderTest extends GridBasicClientFeaturesTest {
assertColumnHeaderOrder(1, 3, 4, 5, 2);
// when then
- dragAndDropColumnHeader(0, 1, 3, CellSide.RIGHT);
+ dragAndDropColumnHeader(0, 1, 4, CellSide.LEFT);
assertColumnHeaderOrder(1, 4, 3, 5, 2);
dragAndDropColumnHeader(0, 2, 4, CellSide.LEFT);
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java
index 37eda1c28f..7942650576 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnVisibilityTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
@@ -139,12 +138,15 @@ public class GridColumnVisibilityTest extends GridBasicFeaturesTest {
}
@Test
- @Ignore
- // known issue, column caption not passed to toggle when added again
- public void testColumnHiding_whenHidableColumnAdded_toggleAdded() {
+ public void testColumnHiding_whenHidableColumnAdded_toggleWithCorrectCaptionAdded() {
selectMenuPath("Component", "Size", "Width", "100%");
toggleColumnHidable(0);
toggleColumnHidable(1);
+ toggleColumnHidingToggleCaptionChange(0);
+ getSidebarOpenButton().click();
+ assertEquals("Column 0 caption 0", getColumnHidingToggle(0).getText());
+ getSidebarOpenButton().click();
+
addRemoveColumn(0);
addRemoveColumn(4);
addRemoveColumn(5);
@@ -163,7 +165,43 @@ public class GridColumnVisibilityTest extends GridBasicFeaturesTest {
assertColumnHeaderOrder(1, 2, 3, 11, 0);
getSidebarOpenButton().click();
- assertNotNull(getColumnHidingToggle(0));
+ assertEquals("Column 0 caption 0", getColumnHidingToggle(0).getText());
+ }
+
+ @Test
+ public void testColumnHidingToggleCaption_settingToggleCaption_updatesToggle() {
+ toggleColumnHidable(1);
+ getSidebarOpenButton().click();
+ assertEquals("column 1", getGridElement().getHeaderCell(0, 1).getText()
+ .toLowerCase());
+ assertEquals("Column 1", getColumnHidingToggle(1).getText());
+
+ toggleColumnHidingToggleCaptionChange(1);
+ assertEquals("column 1", getGridElement().getHeaderCell(0, 1).getText()
+ .toLowerCase());
+ assertEquals("Column 1 caption 0", getColumnHidingToggle(1).getText());
+
+ toggleColumnHidingToggleCaptionChange(1);
+ assertEquals("Column 1 caption 1", getColumnHidingToggle(1).getText());
+ }
+
+ @Test
+ public void testColumnHidingToggleCaption_settingWidgetToHeader_toggleCaptionStays() {
+ toggleColumnHidable(1);
+ getSidebarOpenButton().click();
+ assertEquals("column 1", getGridElement().getHeaderCell(0, 1).getText()
+ .toLowerCase());
+ assertEquals("Column 1", getColumnHidingToggle(1).getText());
+
+ selectMenuPath("Component", "Columns", "Column 1", "Header Type",
+ "Widget Header");
+
+ assertEquals("Column 1", getColumnHidingToggle(1).getText());
+ }
+
+ private void toggleColumnHidingToggleCaptionChange(int index) {
+ selectMenuPath("Component", "Columns", "Column " + index,
+ "Change hiding toggle caption");
}
@Test
@@ -264,7 +302,7 @@ public class GridColumnVisibilityTest extends GridBasicFeaturesTest {
List<WebElement> elements = sidebar.findElements(By
.className("column-hiding-toggle"));
for (WebElement e : elements) {
- if (("Column " + columnIndex).equalsIgnoreCase(e.getText())) {
+ if ((e.getText().toLowerCase()).startsWith("column " + columnIndex)) {
return e;
}
}