diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-13 17:40:31 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-10-14 13:45:11 +0000 |
commit | a2b1860c163a26b92b8e2ca3ae227a27b75ca55c (patch) | |
tree | f218ec383ee617eca5b7980d621fa62302769417 /uitest/src/com | |
parent | 0c54d540e679cce4dad71e0e8e9f3f7bc917cba3 (diff) | |
download | vaadin-framework-a2b1860c163a26b92b8e2ca3ae227a27b75ca55c.tar.gz vaadin-framework-a2b1860c163a26b92b8e2ca3ae227a27b75ca55c.zip |
Support Grid context click events in the empty areas of Grid (#19128)
Change-Id: Ia6aebc266c48fb284ebf8f7a89375390555d1bec
Diffstat (limited to 'uitest/src/com')
4 files changed, 53 insertions, 9 deletions
diff --git a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java index cff063db5f..272cbfdc0e 100644 --- a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java +++ b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickTest.java @@ -79,7 +79,9 @@ public abstract class AbstractContextClickTest extends MultiBrowserTest { AbstractComponentElement component = $(AbstractComponentElement.class) .id("testComponent"); - contextClick(component); + int x = 20; + int y = 20; + contextClick(component, x, y); Point l = component.getLocation(); @@ -91,8 +93,8 @@ public abstract class AbstractContextClickTest extends MultiBrowserTest { int xCoord = Integer.parseInt(matcher.group(1)); int yCoord = Integer.parseInt(matcher.group(2)); - int xExpected = l.getX() + 10; - int yExpected = l.getY() + 10; + int xExpected = l.getX() + x; + int yExpected = l.getY() + y; Assert.assertTrue( "X Coordinate differs too much from expected. Expected: " diff --git a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java index 9a0ef31692..e1d741ee88 100644 --- a/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java +++ b/uitest/src/com/vaadin/tests/contextclick/AbstractContextClickUI.java @@ -23,6 +23,7 @@ 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> @@ -79,14 +80,21 @@ public abstract class AbstractContextClickUI<T extends AbstractComponent, E exte testComponent.setId("testComponent"); addComponent(testComponent); - - addComponent(new Button("Add/Remove default listener", - new ListenerHandler(defaultListener))); - addComponent(new Button("Add/Remove typed listener", - new ListenerHandler(typedListener))); + 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/GridContextClick.java b/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java index a942a2ab0f..77009a0762 100644 --- a/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java +++ b/uitest/src/com/vaadin/tests/contextclick/GridContextClick.java @@ -18,8 +18,11 @@ 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> { @@ -34,7 +37,8 @@ public class GridContextClick extends "phoneNumber", "address.streetAddress", "address.postalCode", "address.city"); - grid.setSizeFull(); + grid.setWidth("100%"); + grid.setHeight("400px"); return grid; } @@ -58,4 +62,18 @@ public class GridContextClick extends 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 index 25847f8bf2..7b97de2be5 100644 --- a/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java +++ b/uitest/src/com/vaadin/tests/contextclick/GridContextClickTest.java @@ -19,9 +19,11 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; +import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridElement; public class GridContextClickTest extends AbstractContextClickTest { + @Test public void testBodyContextClickWithTypedListener() { addOrRemoveTypedListener(); @@ -73,4 +75,18 @@ public class GridContextClickTest extends AbstractContextClickTest { 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)); + + } + } |