diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 11:06:18 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-15 14:00:58 +0300 |
commit | 6b8412033e680ce6e5c7827ac504adf132305726 (patch) | |
tree | 0df05d16c324b285610af8910c126b58f4c490c5 /uitest/src/com/vaadin/tests/contextclick | |
parent | 9192b0bb5e5e699b506b3d3e7df4cf295fbea44a (diff) | |
download | vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.tar.gz vaadin-framework-6b8412033e680ce6e5c7827ac504adf132305726.zip |
Build uitest war with maven
Change-Id: I32625901ca27a282253df44c6e776cf9632bacda
Diffstat (limited to 'uitest/src/com/vaadin/tests/contextclick')
13 files changed, 0 insertions, 985 deletions
diff --git a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java deleted file mode 100644 index 7544caaf0a..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.Point; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.remote.DesiredCapabilities; - -import com.vaadin.testbench.elements.AbstractComponentElement; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.parallel.TestCategory; -import com.vaadin.tests.tb3.MultiBrowserTest; - -@TestCategory("contextclick") -public abstract class AbstractContextClickTest extends MultiBrowserTest { - - private Pattern defaultLog = Pattern - .compile("[0-9]+. ContextClickEvent: [(]([0-9]+), ([0-9]+)[)]"); - - @Override - protected boolean useNativeEventsForIE() { - return false; - } - - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - return getBrowsersSupportingContextMenu(); - } - - @Before - public void setUp() { - openTestURL(); - } - - @Test - public void testDefaultListener() { - addOrRemoveDefaultListener(); - - assertDefaultContextClickListener(1); - } - - protected void assertNoContextClickHandler() { - AbstractComponentElement component = $(AbstractComponentElement.class) - .id("testComponent"); - - String log = getLogRow(0); - - contextClick(component); - - assertEquals("Log entry without a context click listener.", log, - getLogRow(0)); - - } - - protected void assertDefaultContextClickListener(int index) { - AbstractComponentElement component = $(AbstractComponentElement.class) - .id("testComponent"); - - int x = 20; - int y = 20; - contextClick(component, x, y); - - Point l = component.getLocation(); - - Matcher matcher = defaultLog.matcher(getLogRow(0)); - Assert.assertTrue( - "Log row content did not match default listener output: " - + getLogRow(0), matcher.find()); - - int xCoord = Integer.parseInt(matcher.group(1)); - int yCoord = Integer.parseInt(matcher.group(2)); - - int xExpected = l.getX() + x; - int yExpected = l.getY() + y; - - Assert.assertTrue( - "X Coordinate differs too much from expected. Expected: " - + xExpected + ", actual: " + xCoord, - Math.abs(xExpected - xCoord) <= 1); - Assert.assertTrue( - "Y Coordinate differs too much from expected. Expected: " - + yExpected + ", actual: " + yCoord, - Math.abs(yExpected - yCoord) <= 1); - } - - protected void addOrRemoveDefaultListener() { - $(ButtonElement.class).caption("Add/Remove default listener").first() - .click(); - } - - protected void addOrRemoveTypedListener() { - $(ButtonElement.class).caption("Add/Remove typed listener").first() - .click(); - } - - /** - * Performs a context click on given element at coordinates 10, 10 followed - * by a regular click. This prevents browser context menu from blocking - * future operations. - * - * @param e - * web element - */ - protected void contextClick(WebElement e) { - contextClick(e, 10, 10); - } - - /** - * Performs a context click on given element at given coordinates followed - * by a regular click. This prevents browser context menu from blocking - * future operations. - * - * @param e - * web element - * @param xCoord - * x coordinate - * @param yCoord - * y coordinate - */ - protected void contextClick(WebElement e, int xCoord, int yCoord) { - new Actions(getDriver()).moveToElement(e, xCoord, yCoord) - .contextClick().moveByOffset(-5, -5).click().perform(); - } - -} diff --git a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java deleted file mode 100644 index e1d741ee88..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.annotations.Theme; -import com.vaadin.event.ContextClickEvent; -import com.vaadin.event.ContextClickEvent.ContextClickListener; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.HorizontalLayout; - -@Theme("valo") -public abstract class AbstractContextClickUI<T extends AbstractComponent, E extends ContextClickEvent> - extends AbstractTestUIWithLog { - - private final class ListenerHandler implements Button.ClickListener { - private boolean hasListener = false; - private final ContextClickListener listener; - - public ListenerHandler(ContextClickListener listener) { - this.listener = listener; - } - - @Override - public void buttonClick(ClickEvent event) { - if (!hasListener) { - testComponent.addContextClickListener(listener); - event.getButton().setDescription("Remove listener"); - hasListener = true; - } else { - testComponent.removeContextClickListener(listener); - event.getButton().setDescription("Add listener"); - hasListener = false; - } - } - } - - protected T testComponent; - private ContextClickListener defaultListener = new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - log("ContextClickEvent: (" + event.getClientX() + ", " - + event.getClientY() + ")"); - } - }; - - private ContextClickListener typedListener = new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - try { - E typedEvent = (E) event; - handleContextClickEvent(typedEvent); - } catch (Exception e) { - log("UNEXPECTED EVENT TYPE!"); - } - } - }; - - @Override - protected void setup(VaadinRequest request) { - testComponent = createTestComponent(); - testComponent.setId("testComponent"); - - addComponent(testComponent); - addComponent(createContextClickControls()); - } - - protected abstract T createTestComponent(); - - protected abstract void handleContextClickEvent(E event); - - protected HorizontalLayout createContextClickControls() { - HorizontalLayout contextClickControls = new HorizontalLayout(); - contextClickControls.addComponent(new Button( - "Add/Remove default listener", new ListenerHandler( - defaultListener))); - contextClickControls - .addComponent(new Button("Add/Remove typed listener", - new ListenerHandler(typedListener))); - return contextClickControls; - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java b/uitest/src/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java deleted file mode 100644 index d3edf0ba43..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/BrowserContextMenuInSubComponent.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.annotations.Widgetset; -import com.vaadin.event.ContextClickEvent; -import com.vaadin.event.ContextClickEvent.ContextClickListener; -import com.vaadin.server.AbstractExtension; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.widgetset.TestingWidgetSet; -import com.vaadin.ui.AbstractComponent; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Notification; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextArea; -import com.vaadin.ui.VerticalLayout; - -@Widgetset(TestingWidgetSet.NAME) -public class BrowserContextMenuInSubComponent extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - Panel panel = new Panel(); - - VerticalLayout layout = new VerticalLayout(); - final TextArea textArea = new TextArea(); - // Make TextArea show regular context menu instead of firing the - // server-side event. - BrowserContextMenuExtension.extend(textArea); - final Button button = new Button("Submit", new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - Notification.show(textArea.getValue()); - } - }); - - layout.addComponent(textArea); - layout.addComponent(button); - - panel.setContent(layout); - - panel.addContextClickListener(new ContextClickListener() { - - @Override - public void contextClick(ContextClickEvent event) { - button.click(); - } - }); - - addComponent(panel); - } - - /** - * A simple extension for making extended component stop propagation of the - * context click events, so the browser will handle the context click and - * show its own context menu. - */ - public static class BrowserContextMenuExtension extends AbstractExtension { - private BrowserContextMenuExtension(AbstractComponent c) { - super(c); - } - - public static BrowserContextMenuExtension extend(AbstractComponent c) { - return new BrowserContextMenuExtension(c); - } - } - -} diff --git a/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java b/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java deleted file mode 100644 index 77009a0762..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Grid; -import com.vaadin.ui.Grid.GridContextClickEvent; -import com.vaadin.ui.HorizontalLayout; - -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.setWidth("100%"); - grid.setHeight("400px"); - - 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()); - } - - @Override - protected HorizontalLayout createContextClickControls() { - HorizontalLayout controls = super.createContextClickControls(); - controls.addComponent(new Button("Remove all content", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.getContainerDataSource().removeAllItems(); - } - })); - return controls; - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java deleted file mode 100644 index 6ee7a89178..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 org.openqa.selenium.WebElement; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.GridElement; - -public class GridContextClickTest extends AbstractContextClickTest { - - @Test - public void testBodyContextClickWithTypedListener() { - 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() { - 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() { - 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)); - } - - @Test - public void testContextClickInEmptyGrid() { - addOrRemoveTypedListener(); - - $(ButtonElement.class).caption("Remove all content").first().click(); - - contextClick($(GridElement.class).first(), 100, 100); - - assertEquals( - "1. ContextClickEvent value: , propertyId: null, section: BODY", - getLogRow(0)); - - } - - /** - * Performs a context click on given element at coordinates 20, 10 followed - * by a regular click. This prevents browser context menu from blocking - * future operations. - * - * A smaller X offset might hit the resize handle of the previous cell that - * overlaps with the next header cell. - * - * @param e - * web element - */ - @Override - protected void contextClick(WebElement e) { - contextClick(e, 20, 10); - } - -} diff --git a/uitest/src/com/vaadin/tests/contextclick/ListenerAddAndRemoveTest.java b/uitest/src/com/vaadin/tests/contextclick/ListenerAddAndRemoveTest.java deleted file mode 100644 index dd1d3ebd53..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/ListenerAddAndRemoveTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.junit.Test; - -public class ListenerAddAndRemoveTest extends TableContextClickTestBase { - - @Test - public void testAddAndRemoveListeners() { - // Add typed listener - addOrRemoveTypedListener(); - - // Add default listener - addOrRemoveDefaultListener(); - - // Remove the default listener - addOrRemoveDefaultListener(); - - // Check that typed listener is still working - assertTypedContextClickListener(1); - - // Re-add the default listener - addOrRemoveDefaultListener(); - - // Remove typed listener - addOrRemoveTypedListener(); - - // Check that default listener still works - assertDefaultContextClickListener(3); - - // Remove default listener - addOrRemoveDefaultListener(); - - // Assert no listeners present. - assertNoContextClickHandler(); - - // Re-add typed listener - addOrRemoveTypedListener(); - - assertTypedContextClickListener(4); - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java deleted file mode 100644 index 95fa85dc90..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Table; -import com.vaadin.ui.Table.TableContextClickEvent; - -public class TableContextClick extends - AbstractContextClickUI<Table, TableContextClickEvent> { - - @Override - protected Table createTestComponent() { - Table table = new Table(); - table.setContainerDataSource(PersonContainer.createWithTestData()); - table.setFooterVisible(true); - table.setHeight("400px"); - return table; - } - - @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()); - } - - @Override - protected HorizontalLayout createContextClickControls() { - HorizontalLayout controls = super.createContextClickControls(); - controls.addComponent(new Button("Remove all content", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.getContainerDataSource().removeAllItems(); - } - })); - return controls; - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java deleted file mode 100644 index bfd8862440..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.ButtonElement; -import com.vaadin.testbench.elements.TableElement; - -public class TableContextClickTest extends TableContextClickTestBase { - - @Test - public void testBodyContextClickWithTypedListener() { - addOrRemoveTypedListener(); - - assertTypedContextClickListener(1); - } - - @Test - public void testHeaderContextClickWithTypedListener() { - addOrRemoveTypedListener(); - - contextClick($(TableElement.class).first().getHeaderCell(0)); - - assertEquals( - "1. ContextClickEvent value: address, propertyId: address, section: HEADER", - getLogRow(0)); - - contextClick($(TableElement.class).first().getHeaderCell(3)); - - assertEquals( - "2. ContextClickEvent value: lastName, propertyId: lastName, section: HEADER", - getLogRow(0)); - } - - @Test - public void testFooterContextClickWithTypedListener() { - addOrRemoveTypedListener(); - - contextClick($(TableElement.class).first().getFooterCell(0)); - - assertEquals( - "1. ContextClickEvent value: null, propertyId: address, section: FOOTER", - getLogRow(0)); - - contextClick($(TableElement.class).first().getFooterCell(3)); - - assertEquals( - "2. ContextClickEvent value: null, propertyId: lastName, section: FOOTER", - getLogRow(0)); - } - - @Test - public void testContextClickInEmptyTable() { - addOrRemoveTypedListener(); - - $(ButtonElement.class).caption("Remove all content").first().click(); - - contextClick($(TableElement.class).first(), 100, 100); - - assertEquals( - "1. ContextClickEvent value: , propertyId: null, section: BODY", - getLogRow(0)); - } - -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TableContextClickTestBase.java b/uitest/src/com/vaadin/tests/contextclick/TableContextClickTestBase.java deleted file mode 100644 index e3f4647c33..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TableContextClickTestBase.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 com.vaadin.testbench.elements.TableElement; - -public abstract class TableContextClickTestBase extends - AbstractContextClickTest { - - @Override - protected Class<?> getUIClass() { - return TableContextClick.class; - } - - protected void assertTypedContextClickListener(int startIndex) { - contextClick($(TableElement.class).first().getCell(0, 0)); - - assertEquals( - (startIndex++) - + ". ContextClickEvent value: Lisa Schneider, propertyId: address, section: BODY", - getLogRow(0)); - - contextClick($(TableElement.class).first().getCell(0, 3)); - - assertEquals( - startIndex - + ". ContextClickEvent value: Lisa Schneider, propertyId: lastName, section: BODY", - getLogRow(0)); - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TreeContextClick.java deleted file mode 100644 index 6b58138ab2..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TreeContextClick.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.ui.Tree; -import com.vaadin.ui.Tree.TreeContextClickEvent; - -public class TreeContextClick extends - AbstractContextClickUI<Tree, TreeContextClickEvent> { - - @Override - protected Tree createTestComponent() { - Tree tree = new Tree(); - tree.addItem("Foo"); - tree.addItem("Bar"); - tree.addItem("Baz"); - tree.setParent("Baz", "Bar"); - tree.setHeight("200px"); - return tree; - } - - @Override - protected void handleContextClickEvent(TreeContextClickEvent event) { - log("ContextClickEvent: " + event.getItemId()); - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/TreeContextClickTest.java deleted file mode 100644 index 180349af63..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TreeContextClickTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 java.util.List; - -import org.junit.Test; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.TreeElement; - -public class TreeContextClickTest extends AbstractContextClickTest { - - @Test - public void testContextClickOnItem() { - openTestURL(); - - addOrRemoveTypedListener(); - - List<WebElement> nodes = $(TreeElement.class).first().findElements( - By.className("v-tree-node")); - - contextClick(nodes.get(1)); - - assertEquals("1. ContextClickEvent: Bar", getLogRow(0)); - - contextClick(nodes.get(0)); - - assertEquals("2. ContextClickEvent: Foo", getLogRow(0)); - } - - @Test - public void testContextClickOnSubItem() { - openTestURL(); - - addOrRemoveTypedListener(); - - List<WebElement> nodes = $(TreeElement.class).first().findElements( - By.className("v-tree-node")); - - new Actions(getDriver()).moveToElement(nodes.get(1), 10, 10).click() - .perform(); - - nodes = $(TreeElement.class).first().findElements( - By.className("v-tree-node")); - contextClick(nodes.get(2)); - - assertEquals("1. ContextClickEvent: Baz", getLogRow(0)); - } - - @Test - public void testContextClickOnEmptyArea() { - openTestURL(); - - addOrRemoveTypedListener(); - - contextClick($(TreeElement.class).first(), 20, 100); - - assertEquals("1. ContextClickEvent: null", getLogRow(0)); - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java deleted file mode 100644 index 406f5d589e..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Table.TableContextClickEvent; -import com.vaadin.ui.TreeTable; - -public class TreeTableContextClick extends - AbstractContextClickUI<TreeTable, TableContextClickEvent> { - - @Override - protected TreeTable createTestComponent() { - TreeTable treeTable = new TreeTable(); - treeTable.setContainerDataSource(PersonContainer.createWithTestData()); - treeTable.setFooterVisible(true); - treeTable.setHeight("400px"); - treeTable.setWidth("100%"); - 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()); - } - - @Override - protected HorizontalLayout createContextClickControls() { - HorizontalLayout controls = super.createContextClickControls(); - controls.addComponent(new Button("Remove all content", - new Button.ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - testComponent.getContainerDataSource().removeAllItems(); - } - })); - return controls; - } -} diff --git a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java deleted file mode 100644 index f91750ce91..0000000000 --- a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClickTest.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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; - - -public class TreeTableContextClickTest extends TableContextClickTest { - - @Override - protected Class<?> getUIClass() { - return TreeTableContextClick.class; - } -} |