aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-05-17 16:45:12 +0300
committerLeif Åstrand <leif@vaadin.com>2013-05-17 16:45:12 +0300
commita1abfac2ac96c17e134e8d2e814842637e9cb689 (patch)
tree65be77fe3b0aa5b10457b8882906d816735a8ee0
parent541a3ce8a7e81ab289d3b3815aca1e55be80704c (diff)
parent611e5f9030d4d783a53ce99150680008b1ec4065 (diff)
downloadvaadin-framework-a1abfac2ac96c17e134e8d2e814842637e9cb689.tar.gz
vaadin-framework-a1abfac2ac96c17e134e8d2e814842637e9cb689.zip
Merge changes from origin/7.1
1a6200e Merge #6880 test from 6.8; fix itself is not needed in Vaadin 7 67696f3 SQLContainer.indexOfId() also searches backwards (#11849, #10376) 0a437a5 Revert "Replaced css inject hack in TestUtils with Page.Styles.add() #11798" 611e5f9 Test for #11267 adapted from 6.8. Change-Id: Idb91964c495a7d46ebf468896ff968a35c417397
-rw-r--r--WebContent/VAADIN/themes/tests-tickets/styles.css13
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java8
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.html52
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.html37
-rw-r--r--uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.java79
-rw-r--r--uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java34
-rw-r--r--uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java47
8 files changed, 309 insertions, 4 deletions
diff --git a/WebContent/VAADIN/themes/tests-tickets/styles.css b/WebContent/VAADIN/themes/tests-tickets/styles.css
index c1dd89d6b8..b96fcbb23d 100644
--- a/WebContent/VAADIN/themes/tests-tickets/styles.css
+++ b/WebContent/VAADIN/themes/tests-tickets/styles.css
@@ -1,6 +1,17 @@
@import url(../runo/legacy-styles.css);
-/* DO NOT ADD GENERIC RULES LIKE .v-table IN THIS FILE */
+/* DO NOT ADD GENERIC RULES LIKE .v-table IN THIS FILE */
+/* Instead prefix with e.g .v-app-<TestClass> or other unique selectors */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* com.vaadin.tests.components.combobox.ComboBoxBorder */
+/*****************************************************************************/
+.v-slot-ComboBoxBorder .v-filterselect-error {
+ /* Ticket 11267 */
+ border: 1px solid #FF0000 ;
+ height: 25px; /* runo: 23+2, reindeer: 24+2 */
+}
/*****************************************************************************/
/* Ticket 1904 */
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index 987466cdb7..e9a1a2d98f 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -648,23 +648,25 @@ public class SQLContainer implements Container, Container.Filterable,
getPage();
}
int size = size();
- boolean wrappedAround = false;
- while (!wrappedAround) {
+ // this protects against infinite looping
+ int counter = 0;
+ while (counter < size) {
for (Integer i : itemIndexes.keySet()) {
if (itemIndexes.get(i).equals(itemId)) {
return i;
}
+ counter++;
}
// load in the next page.
int nextIndex = (currentOffset / (pageLength * CACHE_RATIO) + 1)
* (pageLength * CACHE_RATIO);
if (nextIndex >= size) {
// Container wrapped around, start from index 0.
- wrappedAround = true;
nextIndex = 0;
}
updateOffsetAndCache(nextIndex);
}
+ // safeguard in case item not found
return -1;
}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.html b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.html
new file mode 100644
index 0000000000..7e7bb7722d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.html
@@ -0,0 +1,52 @@
+<?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:8888/" />
+<title>ComboBoxBorder</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ComboBoxBorder</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/ComboBoxBorder?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>53,10</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>down</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>down</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>down</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.java
new file mode 100644
index 0000000000..731e23188e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.combobox;
+
+import java.util.Arrays;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.UserError;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.ComboBox;
+
+public class ComboBoxBorder extends TestBase {
+
+ @Override
+ protected void setup() {
+ setTheme("tests-tickets");
+
+ final ComboBox cb = new ComboBox("All errors", Arrays.asList("Error",
+ "Error 2"));
+ cb.setStyleName("ComboBoxBorder");
+ cb.setImmediate(true);
+ cb.setWidth("200px"); // must have with to reproduce
+
+ cb.addListener(new ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ cb.setComponentError(new UserError("Error"));
+ }
+ });
+
+ addComponent(cb);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Adding a border as a result of styleName change should not break the ComboBox";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11267;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.html b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.html
new file mode 100644
index 0000000000..e98c8bd41c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.html
@@ -0,0 +1,37 @@
+<?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>DragAndDropWrapperInPanel</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">DragAndDropWrapperInPanel</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.draganddropwrapper.DragAndDropWrapperInPanel?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>no-scrollbars</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperInPanel::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>resized-no-scrollbars</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.java
new file mode 100644
index 0000000000..6a680abdf0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.java
@@ -0,0 +1,79 @@
+/*
+ * 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.draganddropwrapper;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.DragAndDropWrapper;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextArea;
+
+public class DragAndDropWrapperInPanel extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ addComponent(new Button("Click to resize", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ for (int i = 1; i < getLayout().getComponentCount(); ++i) {
+ Component c = getLayout().getComponent(i);
+ c.setWidth("400px");
+ c.setHeight("200px");
+ }
+ }
+ }));
+
+ Component content;
+
+ content = new Button("Undefined-sized Button");
+ content.setSizeUndefined();
+ addDnDPanel(content);
+
+ content = new Label("Full-sized Label");
+ content.setSizeFull();
+ addDnDPanel(content);
+
+ content = new TextArea(null, "200x100px TextArea");
+ content.setWidth("200px");
+ content.setHeight("100px");
+ addDnDPanel(content);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A full-sized DragAndDropWrapper causes scrollbars inside Panel";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 6880;
+ }
+
+ private void addDnDPanel(Component content) {
+ Panel panel = new Panel();
+ panel.setSizeUndefined();
+ panel.setWidth("300px");
+ panel.setHeight("150px");
+ DragAndDropWrapper dndWrapper = new DragAndDropWrapper(content);
+ dndWrapper.setSizeFull();
+ panel.setContent(dndWrapper);
+ addComponent(panel);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
index 287d772901..7e95a41742 100644
--- a/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
+++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
@@ -15,6 +15,8 @@ class DatabaseHelper {
private JDBCConnectionPool connectionPool = null;
private SQLContainer testContainer = null;
private static final String TABLENAME = "testtable";
+ private SQLContainer largeContainer = null;
+ private static final String LARGE_TABLENAME = "largetable";
public DatabaseHelper() {
initConnectionPool();
@@ -32,24 +34,42 @@ class DatabaseHelper {
// Will fail if table doesn't exist, which is OK.
conn.rollback();
}
+ try {
+ statement.execute("drop table " + LARGE_TABLENAME);
+ } catch (SQLException e) {
+ // Will fail if table doesn't exist, which is OK.
+ conn.rollback();
+ }
switch (SQLTestsConstants.db) {
case HSQLDB:
statement
.execute("create table "
+ TABLENAME
+ " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), field2 boolean, primary key(id))");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), primary key(id))");
break;
case MYSQL:
statement
.execute("create table "
+ TABLENAME
+ " (id integer auto_increment not null, field1 varchar(100), field2 boolean, primary key(id))");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (id integer auto_increment not null, field1 varchar(100), primary key(id))");
break;
case POSTGRESQL:
statement
.execute("create table "
+ TABLENAME
+ " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)");
+ statement
+ .execute("create table "
+ + LARGE_TABLENAME
+ + " (\"id\" serial primary key, \"field1\" varchar(100))");
break;
}
statement.executeUpdate("insert into " + TABLENAME
@@ -58,6 +78,12 @@ class DatabaseHelper {
+ " values(default, 'Ville', 'true')");
statement.executeUpdate("insert into " + TABLENAME
+ " values(default, 'Jussi', 'true')");
+
+ for (int i = 0; i < 400; ++i) {
+ statement.executeUpdate("insert into " + LARGE_TABLENAME
+ + " values(default, 'User " + i + "')");
+ }
+
statement.close();
conn.commit();
connectionPool.releaseConnection(conn);
@@ -71,6 +97,10 @@ class DatabaseHelper {
TableQuery q1 = new TableQuery(TABLENAME, connectionPool);
q1.setVersionColumn("id");
testContainer = new SQLContainer(q1);
+
+ TableQuery q2 = new TableQuery(LARGE_TABLENAME, connectionPool);
+ q2.setVersionColumn("id");
+ largeContainer = new SQLContainer(q2);
} catch (SQLException e) {
e.printStackTrace();
}
@@ -89,4 +119,8 @@ class DatabaseHelper {
public SQLContainer getTestContainer() {
return testContainer;
}
+
+ public SQLContainer getLargeContainer() {
+ return largeContainer;
+ }
} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java b/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java
new file mode 100644
index 0000000000..8d4f1c5842
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java
@@ -0,0 +1,47 @@
+package com.vaadin.tests.containers.sqlcontainer;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.LegacyApplication;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.Table;
+
+public class SqlcontainertableApplication extends LegacyApplication {
+ private LegacyWindow mainWindow;
+ private Table table;
+ private HorizontalSplitPanel panel;
+ private Label label = new Label();
+
+ @Override
+ public void init() {
+ mainWindow = new LegacyWindow("SQLContainer Test");
+ setMainWindow(mainWindow);
+ mainWindow.getContent().setSizeFull();
+
+ panel = new HorizontalSplitPanel();
+ panel.setSecondComponent(label);
+
+ final DatabaseHelper helper = new DatabaseHelper();
+ table = new Table();
+ table.setSizeFull();
+ table.setContainerDataSource(helper.getLargeContainer());
+ table.setSelectable(true);
+ table.setImmediate(true);
+ table.setMultiSelect(true);
+ table.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ label.setValue(table.getValue().toString());
+ }
+ });
+
+ panel.setSizeFull();
+ panel.addComponent(table);
+
+ mainWindow.addComponent(panel);
+
+ }
+
+} \ No newline at end of file