summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-09 14:55:13 +0200
committerVaadin Code Review <review@vaadin.com>2015-01-14 10:25:13 +0000
commit35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d (patch)
tree9a387eeef20e858d9d586c7c02141f6273277945 /uitest
parentdcfebeb46143d8e9c21424c572c48d2217c80477 (diff)
downloadvaadin-framework-35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d.tar.gz
vaadin-framework-35372dc1d3ede9d2005ac8bda5d5a7e4f3aba98d.zip
Add ItemClickEvents to Grid (#15449)
Change-Id: I743f4de9fd11c5d81b11a3b8f2e0957293c5587c
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridItemClickTest.java57
2 files changed, 84 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 5912f2b5a5..7a625e2f25 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java
@@ -33,6 +33,8 @@ import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
import com.vaadin.data.sort.Sort;
import com.vaadin.data.sort.SortOrder;
import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.event.SelectionEvent;
import com.vaadin.event.SelectionEvent.SelectionListener;
import com.vaadin.event.SortEvent;
@@ -93,6 +95,16 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
}
};
+ private ItemClickListener itemClickListener = new ItemClickListener() {
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ log("Item " + (event.isDoubleClick() ? "double " : "")
+ + "click on " + event.getPropertyId() + ", item "
+ + event.getItemId());
+ }
+ };
+
@Override
@SuppressWarnings("unchecked")
protected Grid constructComponent() {
@@ -452,6 +464,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
containerDelayValues.put(String.valueOf(delay),
Integer.valueOf(delay));
}
+
createSelectAction("Container delay", "State", containerDelayValues,
"0", new Command<Grid, Integer>() {
@Override
@@ -459,6 +472,20 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> {
containerDelay = delay.intValue();
}
});
+
+ createBooleanAction("ItemClickListener", "State", false,
+ new Command<Grid, Boolean>() {
+
+ @Override
+ public void execute(Grid c, Boolean value, Object data) {
+ if (!value) {
+ c.removeItemClickListener(itemClickListener);
+ } else {
+ c.addItemClickListener(itemClickListener);
+ }
+ }
+
+ });
}
protected void createHeaderActions() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridItemClickTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridItemClickTest.java
new file mode 100644
index 0000000000..57fc56c995
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridItemClickTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.server;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
+import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest;
+
+public class GridItemClickTest extends GridBasicFeaturesTest {
+
+ @Test
+ public void testItemClick() {
+ openTestURL();
+
+ selectMenuPath("Component", "State", "ItemClickListener");
+
+ GridCellElement cell = getGridElement().getCell(3, 2);
+ new Actions(getDriver()).moveToElement(cell).click().perform();
+
+ assertTrue("No click in log", logContainsText(itemClickOn(3, 2, false)));
+ }
+
+ @Test
+ public void testItemDoubleClick() {
+ openTestURL();
+
+ selectMenuPath("Component", "State", "ItemClickListener");
+
+ GridCellElement cell = getGridElement().getCell(3, 2);
+ new Actions(getDriver()).moveToElement(cell).doubleClick().perform();
+
+ assertTrue("No double click in log",
+ logContainsText(itemClickOn(3, 2, true)));
+ }
+
+ private String itemClickOn(int row, int column, boolean dblClick) {
+ return "Item " + (dblClick ? "double " : "") + "click on Column "
+ + column + ", item " + row;
+ }
+}