]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test for #7731
authorArtur Signell <artur.signell@itmill.com>
Thu, 6 Oct 2011 12:50:40 +0000 (12:50 +0000)
committerArtur Signell <artur.signell@itmill.com>
Thu, 6 Oct 2011 12:50:40 +0000 (12:50 +0000)
svn changeset:21604/svn branch:6.7

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

diff --git a/tests/testbench/com/vaadin/tests/components/table/AddItemToEmptyTable.html b/tests/testbench/com/vaadin/tests/components/table/AddItemToEmptyTable.html
new file mode 100644 (file)
index 0000000..30c2520
--- /dev/null
@@ -0,0 +1,77 @@
+<?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>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.table.AddItemToEmptyTable?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>item-added-second-col-width-set</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VCheckBox[0]/domChild[0]</td>
+       <td>5,5</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>
+       <td>6,9</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>item-added-first-col-width-set</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VCheckBox[0]/domChild[0]</td>
+       <td>9,4</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentstable.AddItemToEmptyTableAddItemToEmptyTable::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>item-added-no-widths-set</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/table/AddItemToEmptyTable.java b/tests/testbench/com/vaadin/tests/components/table/AddItemToEmptyTable.java
new file mode 100644 (file)
index 0000000..e8445f8
--- /dev/null
@@ -0,0 +1,102 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Table;
+
+public class AddItemToEmptyTable extends TestBase {
+
+    private Table rightTable;
+
+    @Override
+    protected void setup() {
+        CheckBox cb = new CheckBox("Set first column width");
+        cb.setValue(false);
+        cb.setImmediate(true);
+        cb.addListener(new ValueChangeListener() {
+
+            public void valueChange(ValueChangeEvent event) {
+                if ((Boolean) event.getProperty().getValue()) {
+                    rightTable.setColumnWidth("name", 150);
+                } else {
+                    rightTable.setColumnWidth("name", -1);
+                }
+
+            }
+        });
+        addComponent(cb);
+
+        cb = new CheckBox("Set second column width");
+        cb.setValue(true);
+        cb.setImmediate(true);
+        cb.addListener(new ValueChangeListener() {
+
+            public void valueChange(ValueChangeEvent event) {
+                if ((Boolean) event.getProperty().getValue()) {
+                    rightTable.setColumnWidth("info", 20);
+                } else {
+                    rightTable.setColumnWidth("info", -1);
+                }
+
+            }
+        });
+        addComponent(cb);
+
+        rightTable = new Table();
+        rightTable.setSizeFull();
+        rightTable.setPageLength(7);
+
+        rightTable.setColumnReorderingAllowed(false);
+        rightTable.setColumnCollapsingAllowed(true);
+
+        rightTable.setSelectable(true);
+        rightTable.setMultiSelect(true);
+        rightTable.setImmediate(true); // react at once when something is
+                                       // selected
+
+        rightTable.addContainerProperty("name", String.class, null);
+        // rightTable.setColumnWidth("name", 150);
+        rightTable.setColumnAlignment("name", Table.ALIGN_LEFT);
+
+        rightTable.addContainerProperty("info", Button.class, null);
+        rightTable.setColumnWidth("info", 20);
+        rightTable.setColumnAlignment("info", Table.ALIGN_LEFT);
+
+        addComponent(rightTable);
+
+        Button b = new Button("Add item", new Button.ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                Object id = rightTable.addItem();
+                Item item = rightTable.getItem(id);
+                item.getItemProperty("name").setValue("Role");
+                item.getItemProperty("info").setValue(new Button("Button"));
+
+            }
+        });
+        addComponent(b);
+
+        b = new Button("Clear", new Button.ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                rightTable.removeAllItems();
+            }
+        });
+        addComponent(b);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Adding an item to a Table should work independent of column width settings...";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 7731;
+    }
+}