From: John Alhroos Date: Mon, 19 Apr 2010 14:01:52 +0000 (+0000) Subject: Added test application + TestBench test + JUnit test for footer click handlers #4516 X-Git-Tag: 6.7.0.beta1~1718 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e47ac457e72ebff44a4757806f008e91a701250;p=vaadin-framework.git Added test application + TestBench test + JUnit test for footer click handlers #4516 svn changeset:12654/svn branch:6.4 --- diff --git a/tests/src/com/vaadin/tests/components/table/FooterClick.html b/tests/src/com/vaadin/tests/components/table/FooterClick.html new file mode 100644 index 0000000000..693c4ed525 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/FooterClick.html @@ -0,0 +1,72 @@ + + + + + + +FooterClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FooterClick
open/vaadin_6.4/run/com.vaadin.tests.components.table.FooterClick?restartApplication
waitForVaadin
mouseClickvaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]41,7
waitForVaadin
verifyValuevaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]col1
mouseClickvaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]69,12
waitForVaadin
verifyValuevaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]col2
mouseClickvaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]19,3
waitForVaadin
verifyValuevaadin=vaadin64runcomvaadintestscomponentstableFooterClick::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VTextField[0]col3
+ + diff --git a/tests/src/com/vaadin/tests/components/table/FooterClick.java b/tests/src/com/vaadin/tests/components/table/FooterClick.java new file mode 100644 index 0000000000..07c0b83142 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/FooterClick.java @@ -0,0 +1,71 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.data.Container; +import com.vaadin.data.Item; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Table.FooterClickEvent; + +@SuppressWarnings("serial") +public class FooterClick extends TestBase { + + private final String COLUMN1_PROPERTY_ID = "col1"; + private final String COLUMN2_PROPERTY_ID = "col2"; + private final String COLUMN3_PROPERTY_ID = "col3"; + + @Override + protected void setup() { + final Table table = new Table(); + table.setContainerDataSource(createContainer()); + table.setWidth("400px"); + table.setHeight("400px"); + table.setImmediate(true); + table.setFooterVisible(true); + + table.setColumnFooter(COLUMN1_PROPERTY_ID, "fuu"); + table.setColumnFooter(COLUMN2_PROPERTY_ID, "bar"); + table.setColumnFooter(COLUMN3_PROPERTY_ID, "fuubar"); + + final TextField columnField = new TextField( + "ProperyId of clicked column"); + + // Set the footer click handler + table.setFooterClickHandler(new Table.FooterClickHandler() { + public void handleFooterClick(FooterClickEvent event) { + columnField.setValue(event.getPropertyId()); + } + }); + + addComponent(table); + addComponent(columnField); + } + + @Override + protected String getDescription() { + return "Tests the footer click handler"; + } + + @Override + protected Integer getTicketNumber() { + return 4516; + } + + private Container createContainer() { + IndexedContainer container = new IndexedContainer(); + container.addContainerProperty(COLUMN1_PROPERTY_ID, String.class, ""); + container.addContainerProperty(COLUMN2_PROPERTY_ID, String.class, ""); + container.addContainerProperty(COLUMN3_PROPERTY_ID, String.class, ""); + + for (int i = 0; i < 100; i++) { + Item item = container.addItem("item " + i); + item.getItemProperty(COLUMN1_PROPERTY_ID).setValue("first" + i); + item.getItemProperty(COLUMN2_PROPERTY_ID).setValue("middle" + i); + item.getItemProperty(COLUMN3_PROPERTY_ID).setValue("last" + i); + } + + return container; + } + +} diff --git a/tests/src/com/vaadin/tests/server/component/table/TestFooterClickHandlers.java b/tests/src/com/vaadin/tests/server/component/table/TestFooterClickHandlers.java new file mode 100644 index 0000000000..70a2c4dda1 --- /dev/null +++ b/tests/src/com/vaadin/tests/server/component/table/TestFooterClickHandlers.java @@ -0,0 +1,83 @@ +package com.vaadin.tests.server.component.table; + +import junit.framework.TestCase; + +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.FooterClickEvent; +import com.vaadin.ui.Table.FooterClickHandler; + +/** + * Tests the footer click handler + */ +public class TestFooterClickHandlers extends TestCase { + + /** + * Tests setting the click handler + */ + public void testAddingClickHandler() { + final Table table = new Table(); + + // Create click handler + FooterClickHandler handler = new FooterClickHandler() { + public void handleFooterClick(FooterClickEvent event) { + } + }; + + // No predefined footer click listeners should be present + assertNull(table.getFooterClickHandler()); + + // Set the click handler + table.setFooterClickHandler(handler); + assertEquals(handler, table.getFooterClickHandler()); + } + + /** + * Tests changing the click handler to another one + */ + public void testChangingClickHandler() { + final Table table = new Table(); + + // Create 2 click handlers + FooterClickHandler handler1 = new FooterClickHandler() { + public void handleFooterClick(FooterClickEvent event) { + } + }; + + FooterClickHandler handler2 = new FooterClickHandler() { + public void handleFooterClick(FooterClickEvent event) { + } + }; + + // Set the click handler + table.setFooterClickHandler(handler1); + assertEquals(handler1, table.getFooterClickHandler()); + + // Change the click handler to another one + table.setFooterClickHandler(handler2); + assertEquals(handler2, table.getFooterClickHandler()); + } + + /** + * Tests if click handler is removed + */ + public void testRemovingClickHandler() { + final Table table = new Table(); + + // Create click handler + FooterClickHandler handler = new FooterClickHandler() { + public void handleFooterClick(FooterClickEvent event) { + } + }; + + // No predefined footer click listeners should be present + assertNull(table.getFooterClickHandler()); + + // Set the click handler + table.setFooterClickHandler(handler); + assertEquals(handler, table.getFooterClickHandler()); + + // Remove the click handler + table.setFooterClickHandler(null); + assertNull(table.getFooterClickHandler()); + } +}