From 1a6200e19b1e366383286dfa7074c4183d8dcfb9 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 10 May 2013 13:38:48 +0000 Subject: Merge #6880 test from 6.8; fix itself is not needed in Vaadin 7 svn changeset:25925/svn branch:6.8 svn changeset:25928/svn branch:6.8 Change-Id: I89e6f30d7d04f9511e26121f860f846bef7ec17d --- .../DragAndDropWrapperInPanel.html | 37 ++++++++++ .../DragAndDropWrapperInPanel.java | 79 ++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.html create mode 100644 uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropWrapperInPanel.java 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 @@ + + + + + + +DragAndDropWrapperInPanel + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DragAndDropWrapperInPanel
open/run/com.vaadin.tests.components.draganddropwrapper.DragAndDropWrapperInPanel?restartApplication
screenCaptureno-scrollbars
clickvaadin=runcomvaadintestscomponentsdraganddropwrapperDragAndDropWrapperInPanel::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
screenCaptureresized-no-scrollbars
+ + 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); + } +} -- cgit v1.2.3 From 67696f3dcb968bde52bee4bb841b642c41fc6009 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 14 May 2013 15:25:58 +0300 Subject: SQLContainer.indexOfId() also searches backwards (#11849, #10376) Change-Id: Iea3f832cd50314f747b82b774c3be57797f9ac1d --- .../data/util/sqlcontainer/SQLContainer.java | 8 ++-- .../containers/sqlcontainer/DatabaseHelper.java | 34 ++++++++++++++++ .../sqlcontainer/SqlcontainertableApplication.java | 47 ++++++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/containers/sqlcontainer/SqlcontainertableApplication.java diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index 64c16b2798..aa8234ebb9 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -629,23 +629,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/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 -- cgit v1.2.3 From 611e5f9030d4d783a53ce99150680008b1ec4065 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Fri, 10 May 2013 12:51:12 +0000 Subject: Test for #11267 adapted from 6.8. The problem is not present in 7, but you need to use a slightly different css to acieve the same result. Change-Id: Iee6907a15fd9b0674dcb490f9110fc762c56deb6 Ticket: 11267 --- WebContent/VAADIN/themes/tests-tickets/styles.css | 13 +++++- .../tests/components/combobox/ComboBoxBorder.html | 52 ++++++++++++++++++++++ .../tests/components/combobox/ComboBoxBorder.java | 43 ++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.html create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxBorder.java 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- 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/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 @@ + + + + + + +ComboBoxBorder + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ComboBoxBorder
open/run/ComboBoxBorder?restartApplication
mouseClickvaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox53,10
pressSpecialKeyvaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textboxdown
pressSpecialKeyvaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textboxdown
pressSpecialKeyvaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textboxdown
pressSpecialKeyvaadin=runComboBoxBorder::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textboxenter
screenCapture
+ + 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; + } + +} -- cgit v1.2.3