From 904ae72ed3ca7f9477d59bd7fd284bb254895f8b Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 1 Oct 2015 17:48:40 +0300 Subject: Fix TreeTableContextClick support (#19056) Change-Id: Ib6bac73ba96c4919df2e1bf5c9c83160707530bb --- .../tests/contextclick/TreeTableContextClick.java | 53 ++++++++++++++++++++++ .../contextclick/TreeTableContextClickTest.java | 32 +++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java create mode 100644 uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java (limited to 'uitest/src') diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java new file mode 100644 index 0000000000..7d995710c9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java @@ -0,0 +1,53 @@ +/* + * 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.table.TableConstants.Section; +import com.vaadin.tests.util.PersonContainer; +import com.vaadin.ui.Table.TableContextClickEvent; +import com.vaadin.ui.TreeTable; + +public class TreeTableContextClick extends + AbstractContextClickUI { + + @Override + protected TreeTable createTestComponent() { + TreeTable treeTable = new TreeTable(); + treeTable.setContainerDataSource(PersonContainer.createWithTestData()); + treeTable.setFooterVisible(true); + return treeTable; + } + + @Override + protected void handleContextClickEvent(TableContextClickEvent 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 = testComponent.getColumnHeader(propertyId); + } else if (event.getSection() == Section.FOOTER) { + value = testComponent.getColumnFooter(propertyId); + } + log("ContextClickEvent value: " + value + ", propertyId: " + propertyId + + ", section: " + event.getSection()); + } + +} diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java new file mode 100644 index 0000000000..fa3a34be06 --- /dev/null +++ b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java @@ -0,0 +1,32 @@ +/* + * 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 org.openqa.selenium.interactions.Actions; + +public class TreeTableContextClickTest extends TableContextClickTest { + + @Override + protected Class getUIClass() { + return TreeTableContextClick.class; + } + + @Override + protected void contextClick(org.openqa.selenium.WebElement e) { + new Actions(getDriver()).moveToElement(e, 10, 10).contextClick() + .perform(); + }; +} -- cgit v1.2.3