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 (limited to 'uitest') 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 (limited to 'uitest') 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 (limited to 'uitest') 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 From 63dd611503ff46392e59951377f501b94cd21f18 Mon Sep 17 00:00:00 2001 From: Marc Englund Date: Thu, 16 May 2013 16:17:17 +0300 Subject: Centers VOverlays in visual viewport on iOS, Android, fixes #11614 Change-Id: I21fc986b2f4253ad0491a49659db793acf77842d Ticket: 11614 --- client/src/com/vaadin/client/ui/VOverlay.java | 65 +++++++++++++++++++++ .../window/CenteredInVisualViewport.java | 66 ++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/window/CenteredInVisualViewport.java (limited to 'uitest') diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index d35201460e..9e809758ca 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -27,6 +27,7 @@ import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; @@ -689,4 +690,68 @@ public class VOverlay extends PopupPanel implements CloseHandler { return container; } + @Override + public void center() { + super.center(); + + // Some devices can be zoomed in, we should center to the visual + // viewport for those devices + BrowserInfo b = BrowserInfo.get(); + if (b.isAndroid() || b.isIOS()) { + int left = (getVisualViewportWidth() - getOffsetWidth()) >> 1; + int top = (getVisualViewportHeight() - getOffsetHeight()) >> 1; + setPopupPosition(Math.max(Window.getScrollLeft() + left, 0), + Math.max(Window.getScrollTop() + top, 0)); + } + + } + + /** + * Gets the visual viewport width, which is useful for e.g iOS where the + * view can be zoomed in while keeping the layout viewport intact. + * + * Falls back to layout viewport; for those browsers/devices the difference + * is that the scrollbar with is included (if there is a scrollbar). + * + * @since 7.0.7 + * @return + */ + private int getVisualViewportWidth() { + int w = (int) getSubpixelInnerWidth(); + if (w < 0) { + return Window.getClientWidth(); + } else { + return w; + } + } + + /** + * Gets the visual viewport height, which is useful for e.g iOS where the + * view can be zoomed in while keeping the layout viewport intact. + * + * Falls back to layout viewport; for those browsers/devices the difference + * is that the scrollbar with is included (if there is a scrollbar). + * + * @since 7.0.7 + * @return + */ + private int getVisualViewportHeight() { + int h = (int) getSubpixelInnerHeight(); + if (h < 0) { + return Window.getClientHeight(); + } else { + return h; + } + } + + private native double getSubpixelInnerWidth() + /*-{ + return $wnd.innerWidth !== undefined ? $wnd.innerWidth : -1; + }-*/; + + private native double getSubpixelInnerHeight() + /*-{ + return $wnd.innerHeight !== undefined ? $wnd.innerHeight :-1; + }-*/; + } diff --git a/uitest/src/com/vaadin/tests/components/window/CenteredInVisualViewport.java b/uitest/src/com/vaadin/tests/components/window/CenteredInVisualViewport.java new file mode 100644 index 0000000000..428b2ae3f9 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/CenteredInVisualViewport.java @@ -0,0 +1,66 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Window; + +public class CenteredInVisualViewport extends TestBase { + + @Override + protected String getDescription() { + return "Should open centered, even if zoomed in on one button (e.g zoom in iOS)"; + } + + @Override + protected Integer getTicketNumber() { + return 11614; + } + + @Override + protected void setup() { + GridLayout layout = new GridLayout(3, 3); + layout.setWidth("1000px"); + layout.setHeight("1000px"); + addComponent(layout); + + Button b = new Button("Open", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Window centered = new Window("A window", new Label( + "Centered window")); + centered.center(); + getMainWindow().addWindow(centered); + } + }); + layout.addComponent(b, 0, 0); + + b = new Button("Open", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Window centered = new Window("A window", new Label( + "Centered window")); + centered.center(); + getMainWindow().addWindow(centered); + } + }); + layout.addComponent(b, 1, 1); + + b = new Button("Open", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Window centered = new Window("A window", new Label( + "Centered window")); + centered.center(); + getMainWindow().addWindow(centered); + } + }); + layout.addComponent(b, 2, 2); + + } +} -- cgit v1.2.3 From 5a33d7df70bff3339501458991628d175ba83738 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 3 May 2013 18:17:21 +0300 Subject: Test for #11775 Change-Id: Ic2ff1a3b13e2d74bb9119b8336b8a83e0262833b --- .../gridlayout/GridLayoutWithNonIntegerWidth.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutWithNonIntegerWidth.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutWithNonIntegerWidth.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutWithNonIntegerWidth.java new file mode 100644 index 0000000000..8312b15ba7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutWithNonIntegerWidth.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.gridlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; + +/** + * Main UI class + */ +@SuppressWarnings("serial") +public class GridLayoutWithNonIntegerWidth extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Panel p1 = new Panel("Panel with GridLayout"); + GridLayout grid = new GridLayout(1, 1, new Label("A")); + grid.setWidth(100, Unit.PERCENTAGE); + p1.setContent(grid); + p1.setWidth("354.390625px"); + + Panel p2 = new Panel("Panel with HorizontalLayout"); + HorizontalLayout hl = new HorizontalLayout(new Label("A")); + hl.setWidth(100, Unit.PERCENTAGE); + p2.setContent(hl); + p2.setWidth("354.390625px"); + + setContent(new VerticalLayout(p1, p2)); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Neither of the panels should contain scrollbars"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 11775; + } +} \ No newline at end of file -- cgit v1.2.3