summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.html72
-rw-r--r--uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java166
-rw-r--r--uitest/src/com/vaadin/tests/components/table/PopupViewInTable.java61
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.html36
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.java63
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html61
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java73
7 files changed, 532 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.html b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.html
new file mode 100644
index 0000000000..8ee0bad9ec
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.html
@@ -0,0 +1,72 @@
+<?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="http://localhost:8068/" />
+<title>LargeSelectionCausesNPE</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">LargeSelectionCausesNPE</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.LargeSelectionCausesNPE?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>8519-2</td>
+ <td>92,9</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstableLargeSelectionCausesNPE::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
+ <td>5257</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>8519-262</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>8519-262</td>
+ <td>61,-5248:shift</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentstableLargeSelectionCausesNPE::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>8519-0</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>8519-button</td>
+ <td>23,10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>8519-0</td>
+ <td>0-version2</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>8519-button</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>8519-0</td>
+ <td>0</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java
new file mode 100644
index 0000000000..fb782b8ded
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/LargeSelectionCausesNPE.java
@@ -0,0 +1,166 @@
+package com.vaadin.tests.components.table;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.Align;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.VerticalLayout;
+
+public class LargeSelectionCausesNPE extends TestBase {
+
+ @AutoGenerated
+ private Table table;
+
+ private static final String ID = "id";
+ private static final String NAME = "name";
+ private static final String CODE = "code";
+
+ @Override
+ protected void setup() {
+ addComponent(new SelectionExample());
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Attempting to update table contents while selection reaches beyond cache limits causes a NPE.<br>"
+ + " Select a large amount of rows, e.g. from name2 to name262, return to the top of the table,"
+ + " then try to update the first item twice.<br>"
+ + " Test is broken if the original values don't reappear on the second click of the button.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8519;
+ }
+
+ public class SelectionExample extends VerticalLayout {
+
+ Table table = new Table();
+ Button button = new Button("Update the first item");
+ Label nameLabel = new Label();
+
+ HashSet<Object> markedRows = new HashSet<Object>();
+ Label selected = new Label();
+
+ public SelectionExample() {
+ addComponent(table);
+ addComponent(button);
+ setMargin(new MarginInfo(true, false, false, false));
+
+ // Label to indicate current selection
+ selected.setValue("No selection");
+ addComponent(selected);
+
+ // set a style name, so we can style rows and cells
+ table.setStyleName("iso3166");
+
+ // size
+ table.setWidth("100%");
+ table.setPageLength(5);
+
+ // selectable
+ table.setSelectable(true);
+ table.setMultiSelect(true);
+ table.setImmediate(true);
+
+ // connect data source
+ table.setContainerDataSource(getContainer());
+
+ table.addGeneratedColumn(CODE, columnGenerator);
+
+ // turn on column reordering and collapsing
+ table.setColumnReorderingAllowed(true);
+ table.setColumnCollapsingAllowed(true);
+
+ // set column headers
+ table.setVisibleColumns(new String[] { CODE, NAME, ID });
+ table.setColumnHeaders(new String[] { "DummyCode", "DummyName",
+ "DummyId" });
+
+ // Column alignment
+ table.setColumnAlignment(ID, Align.CENTER);
+
+ // Column width
+ table.setColumnWidth(CODE, 70);
+ table.setColumnExpandRatio(NAME, 1);
+ table.setColumnWidth(ID, 70);
+
+ // listen for valueChange, a.k.a 'select' and update the label
+ table.addValueChangeListener(valueChangeListener);
+
+ button.setId(getTicketNumber() + "-button");
+ button.addClickListener(clickListener);
+ }
+
+ Table.ValueChangeListener valueChangeListener = new Table.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ // in multiselect mode, a Set of itemIds is returned,
+ // in singleselect mode the itemId is returned directly
+ Set<?> value = (Set<?>) event.getProperty().getValue();
+ if (null == value || value.size() == 0) {
+ selected.setValue("No selection");
+ } else {
+ selected.setValue("Selected: " + table.getValue());
+ }
+ }
+ };
+
+ Button.ClickListener clickListener = new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ Property nameProperty = table.getContainerProperty(0, NAME);
+ if (("0").equals(nameLabel.getValue())) {
+ nameProperty.setValue(NAME + "0-version2");
+ nameLabel.setValue("0-version2");
+ } else {
+ nameProperty.setValue(NAME + 0);
+ nameLabel.setValue("0");
+ }
+ }
+ };
+
+ public IndexedContainer getContainer() {
+ IndexedContainer container = new IndexedContainer();
+ container.addContainerProperty(NAME, String.class, null);
+ container.addContainerProperty(ID, Integer.class, null);
+ for (int i = 0; i < 264; i++) {
+ String name = NAME + i;
+ int id = i;
+ Item item = container.addItem(id);
+ item.getItemProperty(NAME).setValue(name);
+ item.getItemProperty(ID).setValue(id);
+ }
+ container.sort(new Object[] { ID }, new boolean[] { true });
+ return container;
+ }
+
+ ColumnGenerator columnGenerator = new ColumnGenerator() {
+
+ public Object generateCell(Table source, Object itemId,
+ Object columnId) {
+ Label label = new Label();
+ label.setSizeUndefined();
+ label.setValue(itemId.toString());
+ label.setId(getTicketNumber() + "-" + itemId);
+ if (0 == (Integer) itemId) {
+ nameLabel = label;
+ }
+ return label;
+ }
+
+ };
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/PopupViewInTable.java b/uitest/src/com/vaadin/tests/components/table/PopupViewInTable.java
new file mode 100644
index 0000000000..f070d28aa8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/PopupViewInTable.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.table;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class PopupViewInTable extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Table t = new Table();
+ t.addContainerProperty("text", String.class, "");
+ t.addContainerProperty("pv", Component.class, null);
+ t.addItem(new Object[] { "Foo", createPopupView() }, "foo");
+ addComponent(t);
+ }
+
+ private PopupView createPopupView() {
+ PopupView pv = new PopupView("Click me", createContent());
+ return pv;
+ }
+
+ private Component createContent() {
+ VerticalLayout vl = new VerticalLayout(new Label("Hello"), new Button(
+ "World"));
+ return vl;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.html b/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.html
new file mode 100644
index 0000000000..a234594b8f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.html
@@ -0,0 +1,36 @@
+<?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>TooManySetColumnCollapsedCalls</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">TooManySetColumnCollapsedCalls</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.TooManySetColumnCollapsedCalls?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTooManySetColumnCollapsedCalls::PID_Stable/domChild[0]/domChild[1]</td>
+ <td>5,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTooManySetColumnCollapsedCalls::Root/VContextMenu[0]#option1</td>
+ <td>2,7</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>label</td>
+ <td>2</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.java b/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.java
new file mode 100644
index 0000000000..30921392e8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TooManySetColumnCollapsedCalls.java
@@ -0,0 +1,63 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+
+public class TooManySetColumnCollapsedCalls extends TestBase {
+
+ private int counter = 0;
+ private Label label;
+ private Table table;
+
+ @Override
+ protected void setup() {
+ label = new Label(String.valueOf(counter));
+ label.setId("label");
+ table = createTable();
+ table.setId("table");
+ addComponent(table);
+ addComponent(label);
+ getLayout().setSpacing(true);
+ table.setColumnCollapsed("p2", true);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table.setColumnCollapsed is called too many times in Table.changeVariables."
+ + " Collapsing column 'P3' should only increase the counter by one.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5681;
+ }
+
+ private Table createTable() {
+ Table table = new Table() {
+ @Override
+ public void setColumnCollapsed(Object propertyId, boolean collapsed)
+ throws IllegalStateException {
+ ++counter;
+ label.setValue(String.valueOf(counter));
+ super.setColumnCollapsed(propertyId, collapsed);
+ }
+ };
+ table.setWidth("400px");
+ table.setHeight("100px");
+ table.setPageLength(100);
+ table.setColumnCollapsingAllowed(true);
+ table.setImmediate(true);
+ table.addContainerProperty("p1", String.class, null);
+ table.addContainerProperty("p2", String.class, null);
+ table.addContainerProperty("p3", String.class, null);
+ table.addContainerProperty("p4", String.class, null);
+
+ for (int i = 0; i < 10; i++) {
+ table.addItem(new Object[] { "a" + i, "b" + i, "c" + i, "X" + i },
+ "" + i);
+ }
+ return table;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html
new file mode 100644
index 0000000000..aa2b29b3b7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.html
@@ -0,0 +1,61 @@
+<?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>ViewPortCalculation</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ViewPortCalculation</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.ViewPortCalculation?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>doubleClickAt</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[2]/domChild[0]</td>
+ <td>25,7</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]</td>
+ <td>v-table-focus</td>
+</tr>
+<tr>
+ <td>doubleClickAt</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[2]/domChild[0]</td>
+ <td>22,7</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]</td>
+ <td>v-table-focus</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[2]/domChild[0]</td>
+ <td>15,9</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]</td>
+ <td>v-table-focus</td>
+</tr>
+<tr>
+ <td>doubleClickAt</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]/domChild[2]</td>
+ <td>23,7</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentstableViewPortCalculation::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[9]</td>
+ <td>v-table-focus</td>
+</tr>
+</tbody></table>
+</body>
+</html> \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java
new file mode 100644
index 0000000000..878dd0d3c4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ViewPortCalculation.java
@@ -0,0 +1,73 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Item;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.CellStyleGenerator;
+
+public class ViewPortCalculation extends TestBase {
+
+ private Object lastDoubleClickedItemId;
+
+ @Override
+ protected void setup() {
+ getLayout().setSpacing(true);
+ addComponent(createTestTable(10));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table rows that are too far down (but still visible) don't get focus after refreshRowCache/select (double-click)."
+ + "<br> Double-clicking on the seventh (or any further) row of causes focus to jump to the first row.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8298;
+ }
+
+ private Table createTestTable(int rows) {
+ final Table table = new Table();
+ table.setId("table");
+ table.setSelectable(true);
+ table.setPageLength(0);
+
+ table.addContainerProperty("col1", String.class, null);
+ table.addContainerProperty("col2", String.class, null);
+ table.addContainerProperty("col3", String.class, null);
+
+ for (int i = 1; i <= rows; ++i) {
+ testData(table.addItem("row" + i), i);
+ }
+
+ table.setCellStyleGenerator(new CellStyleGenerator() {
+ public String getStyle(Table source, Object itemId,
+ Object propertyId) {
+ if (itemId.equals(lastDoubleClickedItemId)) {
+ return "bold";
+ }
+ return null;
+ }
+ });
+
+ table.addItemClickListener(new ItemClickListener() {
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ lastDoubleClickedItemId = event.getItemId();
+ table.refreshRowCache();
+ table.select(event.getItemId());
+ }
+ }
+ });
+ return table;
+ }
+
+ private void testData(Item item, int i) {
+ item.getItemProperty("col1").setValue("test1-" + i);
+ item.getItemProperty("col2").setValue("test2-" + i);
+ item.getItemProperty("col3").setValue("test3-" + i);
+ }
+
+}