]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added TestBench test for #7026
authorJohn Alhroos <john.ahlroos@itmill.com>
Thu, 16 Jun 2011 10:24:03 +0000 (10:24 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Thu, 16 Jun 2011 10:24:03 +0000 (10:24 +0000)
svn changeset:19420/svn branch:6.6

tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.html [new file with mode: 0644]
tests/src/com/vaadin/tests/components/table/TableClickAndDragOnIconAndComponents.java [new file with mode: 0644]

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 (file)
index 0000000..7ad0873
--- /dev/null
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>TableClickAndDragOnIconAndComponents</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TableClickAndDragOnIconAndComponents</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.table.TableClickAndDragOnIconAndComponents?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
+       <td>38,13</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]/domChild[0]/domChild[0]</td>
+       <td>1,1</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VLabel[0]</td>
+       <td>30,9</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td>
+       <td>71,11</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]/VTextField[1]</td>
+       <td>34,9</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VEmbedded[0]/domChild[0]</td>
+       <td>9,8</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[2]</td>
+       <td>v-selected</td>
+</tr>
+<tr>
+       <td>drag</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]</td>
+       <td>2,16</td>
+</tr>
+<tr>
+       <td>drop</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td>
+       <td>22,18</td>
+</tr>
+<tr>
+       <td>assertText</td>
+       <td>vaadin=runcomvaadintestscomponentstableTableClickAndDragOnIconAndComponents::PID_Stestable-table/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[1]/domChild[0]</td>
+       <td>foo 4foo</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
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 (file)
index 0000000..ee04813
--- /dev/null
@@ -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;
+    }
+
+}