From 4ba478da044a688c5ab5f806e2953c051dd8ae7c Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Thu, 16 Jun 2011 10:24:03 +0000 Subject: [PATCH] Added TestBench test for #7026 svn changeset:19420/svn branch:6.6 --- .../TableClickAndDragOnIconAndComponents.html | 132 ++++++++++++++++ .../TableClickAndDragOnIconAndComponents.java | 142 ++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html create mode 100644 tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java diff --git a/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html b/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html new file mode 100644 index 0000000000..7ad0873c0f --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html @@ -0,0 +1,132 @@ + + + + + + +TableClickAndDragOnIconAndComponents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TableClickAndDragOnIconAndComponents
open/run/com.vaadin.tests.components.table.TableClickAndDragOnIconAndComponents?restartApplication
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]38,13
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]1,1
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VLabel[0]30,9
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]71,11
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VTextField[1]34,9
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
mouseClickvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VEmbedded[0]/domChild[0]9,8
assertCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]v-selected
assertNotCSSClassvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]v-selected
dragvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]2,16
dropvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]22,18
assertTextvaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[1]/domChild[0]foo 4foo
+ + diff --git a/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java b/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java new file mode 100644 index 0000000000..ee04813ce6 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java @@ -0,0 +1,142 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.data.Item; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.event.DataBoundTransferable; +import com.vaadin.event.dd.DragAndDropEvent; +import com.vaadin.event.dd.DropHandler; +import com.vaadin.event.dd.acceptcriteria.AcceptAll; +import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; +import com.vaadin.terminal.Resource; +import com.vaadin.terminal.ThemeResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; +import com.vaadin.ui.Component; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.ColumnGenerator; +import com.vaadin.ui.Table.TableDragMode; +import com.vaadin.ui.TextField; + +public class TableClickAndDragOnIconAndComponents extends TestBase { + + private static final long serialVersionUID = -2534880024131980135L; + private Table table; + + @Override + protected void setup() { + table = new Table(); + table.addContainerProperty("foo", String.class, "foo"); + table.addContainerProperty("red", String.class, "red"); + table.addContainerProperty("icon", Resource.class, null); + table.setSelectable(true); + table.setRowHeaderMode(Table.ROW_HEADER_MODE_ICON_ONLY); + table.setItemIconPropertyId("icon"); + table.setDebugId("testable-table"); + addComponent(table); + for (int i = 0; i < 5; i++) { + addItemAfter(i + "foo", null); + } + + table.addGeneratedColumn("Label", new ColumnGenerator() { + + private static final long serialVersionUID = -5042109683675242407L; + + public Component generateCell(Table source, Object itemId, + Object columnId) { + Item item = source.getItem(itemId); + return new Label("" + item.getItemProperty("foo").getValue()); + } + }); + table.addGeneratedColumn("textField", new ColumnGenerator() { + + private static final long serialVersionUID = -5042109683675242407L; + + public Component generateCell(Table source, Object itemId, + Object columnId) { + Item item = source.getItem(itemId); + TextField textfield = new TextField(); + textfield.setValue(String.valueOf(item.getItemProperty("foo") + .getValue())); + return textfield; + } + }); + table.addGeneratedColumn("readOnlyTextField", new ColumnGenerator() { + + private static final long serialVersionUID = -5042109683675242407L; + + public Component generateCell(Table source, Object itemId, + Object columnId) { + Item item = source.getItem(itemId); + TextField textfield = new TextField(); + textfield.setValue(String.valueOf(item.getItemProperty("foo") + .getValue())); + textfield.setReadOnly(true); + return textfield; + } + }); + table.addGeneratedColumn("embedded", new ColumnGenerator() { + + private static final long serialVersionUID = -5042109683675242407L; + + public Component generateCell(Table source, Object itemId, + Object columnId) { + Embedded embedded = new Embedded(null, new ThemeResource( + "../runo/icons/16/ok.png")); + return embedded; + } + }); + + table.setDragMode(TableDragMode.ROW); + table.setDropHandler(new DropHandler() { + + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + public void drop(DragAndDropEvent event) { + DataBoundTransferable t = (DataBoundTransferable) event + .getTransferable(); + Object dragged = t.getItemId(); + + AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event + .getTargetDetails()); + Object target = dropData.getItemIdOver(); + + if (dragged == target || target == null) { + return; + } + + IndexedContainer container = (IndexedContainer) table + .getContainerDataSource(); + container.removeItem(dragged); + addItemAfter(dragged, target); + } + }); + } + + private void addItemAfter(Object itemId, Object afterItemId) { + Item item; + if (afterItemId != null) { + item = table.addItemAfter(afterItemId, itemId); + } else { + item = table.addItem(itemId); + } + item.getItemProperty("foo").setValue("foo " + itemId); + item.getItemProperty("red").setValue("red " + itemId); + item.getItemProperty("icon").setValue( + new ThemeResource("../runo/icons/16/ok.png")); + } + + @Override + protected String getDescription() { + return "Tests that you can click on a row icon in a table to select the row, or to drag the row. Verifies also that the table doesn't capture the click events meant for components inside the table"; + } + + @Override + protected Integer getTicketNumber() { + return 7026; + } + +} -- 2.39.5