From a42fe556c27397c606183864909c9dd0e012d35a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 18 May 2015 21:39:06 +0300 Subject: Handle generated empty string style names properly (#17335) Change-Id: I1adce18f238fd4357b0eb1be68ebf7a3aaa6dd6e --- .../components/grid/GridHeaderStyleNames.java | 2 +- .../grid/basicfeatures/GridBasicFeatures.java | 34 ++++++++++++++++++++++ .../server/GridCellStyleGeneratorTest.java | 22 ++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java index 765cd01812..019850dabb 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java @@ -46,7 +46,7 @@ public class GridHeaderStyleNames extends AbstractTestUIWithLog { .createContainer(100)); ageHeaderCell = grid.getDefaultHeaderRow().getCell("age"); - + grid.getDefaultHeaderRow().setStyleName("foo"); headerRow = grid.prependHeaderRow(); mergedCityCountryCell = headerRow.join("city", "country"); mergedCityCountryCell.setText("Merged cell"); 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 18f2d02e93..ecf3d53385 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -83,9 +83,13 @@ public class GridBasicFeatures extends AbstractComponentTest { public static final String ROW_STYLE_GENERATOR_ROW_NUMBERS_FOR_3_OF_4 = "Row numbers for 3/4"; public static final String ROW_STYLE_GENERATOR_NONE = "None"; public static final String ROW_STYLE_GENERATOR_ROW_NUMBERS = "Row numbers"; + public static final String ROW_STYLE_GENERATOR_EMPTY = "Empty string"; + public static final String ROW_STYLE_GENERATOR_NULL = "Null"; public static final String CELL_STYLE_GENERATOR_NONE = "None"; public static final String CELL_STYLE_GENERATOR_PROPERTY_TO_STRING = "Property to string"; public static final String CELL_STYLE_GENERATOR_SPECIAL = "Special for 1/4 Column 1"; + public static final String CELL_STYLE_GENERATOR_EMPTY = "Empty string"; + public static final String CELL_STYLE_GENERATOR_NULL = "Null"; private static final int MANUALLY_FORMATTED_COLUMNS = 5; public static final int COLUMNS = 12; public static final int EDITABLE_COLUMNS = COLUMNS - 1; @@ -514,6 +518,22 @@ public class GridBasicFeatures extends AbstractComponentTest { } } }); + rowStyleGenerators.put(ROW_STYLE_GENERATOR_EMPTY, + new RowStyleGenerator() { + + @Override + public String getStyle(RowReference rowReference) { + return ""; + } + }); + rowStyleGenerators.put(ROW_STYLE_GENERATOR_NULL, + new RowStyleGenerator() { + + @Override + public String getStyle(RowReference rowReference) { + return null; + } + }); cellStyleGenerators.put(CELL_STYLE_GENERATOR_NONE, null); cellStyleGenerators.put(CELL_STYLE_GENERATOR_PROPERTY_TO_STRING, new CellStyleGenerator() { @@ -539,6 +559,20 @@ public class GridBasicFeatures extends AbstractComponentTest { return propertyId.toString().replace(' ', '_'); } }); + cellStyleGenerators.put(CELL_STYLE_GENERATOR_EMPTY, + new CellStyleGenerator() { + @Override + public String getStyle(CellReference cellReference) { + return ""; + } + }); + cellStyleGenerators.put(CELL_STYLE_GENERATOR_NULL, + new CellStyleGenerator() { + @Override + public String getStyle(CellReference cellReference) { + return null; + } + }); createSelectAction("Row style generator", "State", rowStyleGenerators, CELL_STYLE_GENERATOR_NONE, diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java index 643c61d90a..f013b76075 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridCellStyleGeneratorTest.java @@ -118,4 +118,26 @@ public class GridCellStyleGeneratorTest extends GridBasicFeaturesTest { private void selectCellStyleNameGenerator(String name) { selectMenuPath("Component", "State", "Cell style generator", name); } + + @Test + public void testEmptyStringStyleGenerator() { + setDebug(true); + openTestURL(); + selectCellStyleNameGenerator(GridBasicFeatures.CELL_STYLE_GENERATOR_EMPTY); + selectRowStyleNameGenerator(GridBasicFeatures.ROW_STYLE_GENERATOR_EMPTY); + + assertFalse("Error notification was present", + isElementPresent(NotificationElement.class)); + } + + @Test + public void testNullStringStyleGenerator() { + setDebug(true); + openTestURL(); + selectCellStyleNameGenerator(GridBasicFeatures.CELL_STYLE_GENERATOR_NULL); + selectRowStyleNameGenerator(GridBasicFeatures.ROW_STYLE_GENERATOR_NULL); + + assertFalse("Error notification was present", + isElementPresent(NotificationElement.class)); + } } -- cgit v1.2.3