diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-13 18:07:55 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-10-14 13:46:13 +0000 |
commit | e6165e8e18f0aeea35071db60f82e7b1122c8253 (patch) | |
tree | 36dd2387c155f6b1237f18d5373de24d13fc97b7 /uitest | |
parent | a2b1860c163a26b92b8e2ca3ae227a27b75ca55c (diff) | |
download | vaadin-framework-e6165e8e18f0aeea35071db60f82e7b1122c8253.tar.gz vaadin-framework-e6165e8e18f0aeea35071db60f82e7b1122c8253.zip |
Support ContextClicks in empty areas of Table and TreeTable (#19130)
When the user clicks an empty area, the TableContextClickEvent will still
fire, but will have a null property.
Change-Id: I39303f1a72d072db09c4fe6df8141d6caf0764c2
Diffstat (limited to 'uitest')
3 files changed, 48 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java index d8816f4bdc..95fa85dc90 100644 --- a/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java +++ b/uitest/src/com/vaadin/tests/contextclick/TableContextClick.java @@ -18,6 +18,9 @@ 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; @@ -50,4 +53,18 @@ public class TableContextClick 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/TableContextClickTest.java b/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java index e7e716a02f..bfd8862440 100644 --- a/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java +++ b/uitest/src/com/vaadin/tests/contextclick/TableContextClickTest.java @@ -19,6 +19,7 @@ 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 { @@ -64,4 +65,17 @@ public class TableContextClickTest extends TableContextClickTestBase { 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/TreeTableContextClick.java b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java index 7d995710c9..431f231cca 100644 --- a/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java +++ b/uitest/src/com/vaadin/tests/contextclick/TreeTableContextClick.java @@ -18,6 +18,9 @@ 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; @@ -29,6 +32,7 @@ public class TreeTableContextClick extends TreeTable treeTable = new TreeTable(); treeTable.setContainerDataSource(PersonContainer.createWithTestData()); treeTable.setFooterVisible(true); + treeTable.setHeight("400px"); return treeTable; } @@ -50,4 +54,17 @@ public class TreeTableContextClick extends + ", 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; + } } |