summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-09-29 13:59:06 +0300
committerHenri Sara <hesara@vaadin.com>2015-10-05 07:38:40 +0000
commitdd029323df6d7ec11b85716601ad9c446c720602 (patch)
tree729230f82ed9a672416a1e9c50926fcf4ab670b9 /uitest
parenta97534f4c2588e68ecc2584d77db482a5277d599 (diff)
downloadvaadin-framework-dd029323df6d7ec11b85716601ad9c446c720602.tar.gz
vaadin-framework-dd029323df6d7ec11b85716601ad9c446c720602.zip
Add GridContextClickEvent with item ids, properties and section (#16855)
Change-Id: I03091a3a7a22a921c127ed0b37fe792871ba5edd
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/contextclick/GridContextClick.java61
-rw-r--r--uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java82
2 files changed, 143 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java b/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java
new file mode 100644
index 0000000000..a942a2ab0f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java
@@ -0,0 +1,61 @@
+/*
+ * 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.contextclick;
+
+import com.vaadin.data.Item;
+import com.vaadin.shared.ui.grid.GridConstants.Section;
+import com.vaadin.tests.util.PersonContainer;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.GridContextClickEvent;
+
+public class GridContextClick extends
+ AbstractContextClickUI<Grid, GridContextClickEvent> {
+
+ @Override
+ protected Grid createTestComponent() {
+ Grid grid = new Grid(PersonContainer.createWithTestData());
+ grid.setFooterVisible(true);
+ grid.appendFooterRow();
+
+ grid.setColumnOrder("address", "email", "firstName", "lastName",
+ "phoneNumber", "address.streetAddress", "address.postalCode",
+ "address.city");
+
+ grid.setSizeFull();
+
+ return grid;
+ }
+
+ @Override
+ protected void handleContextClickEvent(GridContextClickEvent event) {
+ String value = "";
+ Object propertyId = event.getPropertyId();
+ if (event.getItemId() != null) {
+ Item item = event.getComponent().getContainerDataSource()
+ .getItem(event.getItemId());
+ value += item.getItemProperty("firstName").getValue();
+ value += " " + item.getItemProperty("lastName").getValue();
+ } else if (event.getSection() == Section.HEADER) {
+ value = event.getComponent().getHeaderRow(event.getRowIndex())
+ .getCell(propertyId).getText();
+ } else if (event.getSection() == Section.FOOTER) {
+ value = event.getComponent().getFooterRow(event.getRowIndex())
+ .getCell(propertyId).getText();
+ }
+ log("ContextClickEvent value: " + value + ", propertyId: " + propertyId
+ + ", section: " + event.getSection());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java
new file mode 100644
index 0000000000..c4a67f5fc8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.contextclick;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridElement;
+
+public class GridContextClickTest extends AbstractContextClickTest {
+ @Test
+ public void testBodyContextClickWithTypedListener() {
+ openTestURL();
+
+ addOrRemoveTypedListener();
+
+ contextClick($(GridElement.class).first().getCell(0, 0));
+
+ assertEquals(
+ "1. ContextClickEvent value: Lisa Schneider, propertyId: address, section: BODY",
+ getLogRow(0));
+
+ contextClick($(GridElement.class).first().getCell(0, 3));
+
+ assertEquals(
+ "2. ContextClickEvent value: Lisa Schneider, propertyId: lastName, section: BODY",
+ getLogRow(0));
+ }
+
+ @Test
+ public void testHeaderContextClickWithTypedListener() {
+ openTestURL();
+
+ addOrRemoveTypedListener();
+
+ contextClick($(GridElement.class).first().getHeaderCell(0, 0));
+
+ assertEquals(
+ "1. ContextClickEvent value: Address, propertyId: address, section: HEADER",
+ getLogRow(0));
+
+ contextClick($(GridElement.class).first().getHeaderCell(0, 3));
+
+ assertEquals(
+ "2. ContextClickEvent value: Last Name, propertyId: lastName, section: HEADER",
+ getLogRow(0));
+ }
+
+ @Test
+ public void testFooterContextClickWithTypedListener() {
+ openTestURL();
+
+ addOrRemoveTypedListener();
+
+ contextClick($(GridElement.class).first().getFooterCell(0, 0));
+
+ assertEquals(
+ "1. ContextClickEvent value: , propertyId: address, section: FOOTER",
+ getLogRow(0));
+
+ contextClick($(GridElement.class).first().getFooterCell(0, 3));
+
+ assertEquals(
+ "2. ContextClickEvent value: , propertyId: lastName, section: FOOTER",
+ getLogRow(0));
+ }
+
+}