summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeppo Kurki <teppo.kurki@vaadin.com>2015-07-02 16:37:01 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2015-07-15 09:41:08 +0000
commit80058d9429940c376c63c086b1cf79848fe1a699 (patch)
tree9a7a802ead6200f64a6effe3189de57a830dcd19 /uitest
parente288b0d159e4116b863836c4486a7bf289da16eb (diff)
downloadvaadin-framework-80058d9429940c376c63c086b1cf79848fe1a699.tar.gz
vaadin-framework-80058d9429940c376c63c086b1cf79848fe1a699.zip
Add row and cell description generators to Grid (#18481)
Change-Id: I940399d986eb6970df687880645fafc157dab432
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridDescriptionGeneratorTest.java74
2 files changed, 117 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 3154fd2a85..33a54b1c9a 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -52,6 +52,7 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Field;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.CellDescriptionGenerator;
import com.vaadin.ui.Grid.CellReference;
import com.vaadin.ui.Grid.CellStyleGenerator;
import com.vaadin.ui.Grid.Column;
@@ -68,6 +69,7 @@ import com.vaadin.ui.Grid.FooterCell;
import com.vaadin.ui.Grid.HeaderCell;
import com.vaadin.ui.Grid.HeaderRow;
import com.vaadin.ui.Grid.MultiSelectionModel;
+import com.vaadin.ui.Grid.RowDescriptionGenerator;
import com.vaadin.ui.Grid.RowReference;
import com.vaadin.ui.Grid.RowStyleGenerator;
import com.vaadin.ui.Grid.SelectionMode;
@@ -130,6 +132,27 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
};
+ private RowDescriptionGenerator rowDescriptionGenerator = new RowDescriptionGenerator() {
+
+ @Override
+ public String getDescription(RowReference row) {
+ return "Row tooltip for row " + row.getItemId();
+ }
+ };
+
+ private CellDescriptionGenerator cellDescriptionGenerator = new CellDescriptionGenerator() {
+
+ @Override
+ public String getDescription(CellReference cell) {
+ if ("Column 0".equals(cell.getPropertyId())) {
+ return "Cell tooltip for row " + cell.getItemId()
+ + ", column 0";
+ } else {
+ return null;
+ }
+ }
+ };
+
private ItemClickListener editorOpeningItemClickListener = new ItemClickListener() {
@Override
@@ -629,6 +652,25 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
});
+ createBooleanAction("Row description generator", "State", false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid c, Boolean value, Object data) {
+ c.setRowDescriptionGenerator(value ? rowDescriptionGenerator
+ : null);
+ }
+ });
+
+ createBooleanAction("Cell description generator", "State", false,
+ new Command<Grid, Boolean>() {
+ @Override
+ public void execute(Grid c, Boolean value, Object data) {
+ c.setCellDescriptionGenerator(value ? cellDescriptionGenerator
+ : null);
+ }
+ });
+
LinkedHashMap<String, Integer> frozenOptions = new LinkedHashMap<String, Integer>();
for (int i = -1; i <= COLUMNS; i++) {
frozenOptions.put(String.valueOf(i), Integer.valueOf(i));
@@ -673,6 +715,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
});
+
createBooleanAction("EditorOpeningItemClickListener", "State", false,
new Command<Grid, Boolean>() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridDescriptionGeneratorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridDescriptionGeneratorTest.java
new file mode 100644
index 0000000000..ed712361a6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridDescriptionGeneratorTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid.basicfeatures;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+public class GridDescriptionGeneratorTest extends GridBasicFeaturesTest {
+
+ @Test
+ public void testCellDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Cell description generator");
+
+ getGridElement().getCell(1, 0).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Cell tooltip for row 1, column 0",
+ tooltipText);
+
+ getGridElement().getCell(1, 1).showTooltip();
+ assertTrue("Tooltip should not be present in cell (1, 1) ",
+ findElement(By.className("v-tooltip-text")).getText().isEmpty());
+ }
+
+ @Test
+ public void testRowDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Row description generator");
+
+ getGridElement().getCell(5, 3).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Row tooltip for row 5", tooltipText);
+
+ getGridElement().getCell(15, 3).showTooltip();
+ tooltipText = findElement(By.className("v-tooltip-text")).getText();
+ assertEquals("Tooltip text", "Row tooltip for row 15", tooltipText);
+ }
+
+ @Test
+ public void testRowAndCellDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Row description generator");
+ selectMenuPath("Component", "State", "Cell description generator");
+
+ getGridElement().getCell(5, 0).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Cell tooltip for row 5, column 0",
+ tooltipText);
+
+ getGridElement().getCell(5, 3).showTooltip();
+ tooltipText = findElement(By.className("v-tooltip-text")).getText();
+ assertEquals("Tooltip text", "Row tooltip for row 5", tooltipText);
+ }
+
+}