From 51a46a038fe0353f4babfd8218153eb68e2602ca Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Wed, 23 Oct 2013 11:23:02 +0300 Subject: Recovering scroll position after regression problems. (#12727) The fix for "Panels get unnecessary scroll bars in WebKit when content is 100% wide (#12727)" introduced side effects to #6731. This fix solves the problem. Change-Id: I15ca926c0ee4cad49e9eea0c578c9cc73c850588 --- client/src/com/vaadin/client/ui/VPanel.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VPanel.java b/client/src/com/vaadin/client/ui/VPanel.java index 1a87362fea..15c3883b11 100644 --- a/client/src/com/vaadin/client/ui/VPanel.java +++ b/client/src/com/vaadin/client/ui/VPanel.java @@ -218,7 +218,7 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, * Don't touch it unless you know what you're doing! Fixes ticket * #12727. * - * This solution comes from ticket #11994: Windows get unnecessary + * This solution comes from the ticket #11994: Windows get unnecessary * scroll bars in WebKit when content is 100% wide. */ if (BrowserInfo.get().isWebkit()) { @@ -227,6 +227,10 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, public void execute() { final com.google.gwt.dom.client.Element scrollable = contentNode .getFirstChildElement(); + + int contentNodeScrollTop = contentNode.getScrollTop(); + int contentNodeScrollLeft = contentNode.getScrollLeft(); + final String oldWidth = scrollable.getStyle().getWidth(); final String oldHeight = scrollable.getStyle().getHeight(); @@ -237,9 +241,12 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, scrollable.getStyle().setHeight(110, Unit.PCT); scrollable.getOffsetHeight(); scrollable.getStyle().setProperty("height", oldHeight); + + // Recovering scroll position: + contentNode.setScrollTop(contentNodeScrollTop); + contentNode.setScrollLeft(contentNodeScrollLeft); } }); } - } } -- cgit v1.2.3 From c464dcf9217ac6763e4bf7aec18fbf13dff29308 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 23 Oct 2013 00:51:44 +0300 Subject: Convert push test to TB3 so it has a chance to pass Change-Id: I6381ea4bd61b3df19599f2f9d3a303a50c810460 --- .../com/vaadin/tests/push/PushErrorHandling.html | 41 ------------------- .../com/vaadin/tests/push/PushErrorHandling.java | 2 + .../vaadin/tests/push/PushErrorHandlingTest.java | 47 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 41 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/push/PushErrorHandling.html create mode 100644 uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandling.html b/uitest/src/com/vaadin/tests/push/PushErrorHandling.html deleted file mode 100644 index afd3e70771..0000000000 --- a/uitest/src/com/vaadin/tests/push/PushErrorHandling.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - -PushErrorHandling - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PushErrorHandling
open/run/PushErrorHandling?restartApplication
clickvaadin=runPushErrorHandling::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
assertTextvaadin=runPushErrorHandling::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc
mouseClickvaadin=runPushErrorHandling::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]26,7
assertTextvaadin=runPushErrorHandling::Root/VNotification[0]/HTML[0]/domChild[0]Internal error
- - diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/com/vaadin/tests/push/PushErrorHandling.java index 3074bd3851..a1182c0daf 100644 --- a/uitest/src/com/vaadin/tests/push/PushErrorHandling.java +++ b/uitest/src/com/vaadin/tests/push/PushErrorHandling.java @@ -42,9 +42,11 @@ public class PushErrorHandling extends AbstractTestUI { ((String) null).length(); // Null-pointer exception } }); + button.setId("npeButton"); addComponent(button); final Table view = new Table("testtable"); + view.setId("testtable"); view.setSelectable(true); view.setMultiSelect(false); view.setImmediate(true); diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java new file mode 100644 index 0000000000..a4b94b0573 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 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.push; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PushErrorHandlingTest extends MultiBrowserTest { + + @Test + public void testErrorHandling() { + setPush(true); + openTestURL(); + vaadinElementById("npeButton").click(); + Assert.assertEquals( + "An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", + vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]") + .getText()); + + WebElement table = vaadinElementById("testtable"); + WebElement row = table.findElement(By + .xpath("//div[text()='Click for NPE']")); + row.click(); + + Assert.assertEquals("Internal error", + vaadinElement("Root/VNotification[0]/HTML[0]/domChild[0]") + .getText()); + } +} -- cgit v1.2.3 From 2c6d010d90b96b0a087af589af27d9dd11ceca33 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 22 Oct 2013 23:24:44 +0300 Subject: Fixes test issues preventing it from passing Ensure push is enabled correctly without a fallback and made test more stable Change-Id: I6c653a96375e05c6ad18e1f5b697c6a584c6c53f --- uitest/src/com/vaadin/tests/push/PushLargeData.java | 18 +++++++++++++++--- .../vaadin/tests/push/PushLargeDataStreaming.java | 6 +++++- .../tests/push/PushLargeDataStreamingTest.java | 20 +++++++++++++------- .../vaadin/tests/push/PushLargeDataWebsocket.java | 7 ++++--- .../tests/push/PushLargeDataWebsocketTest.java | 14 +++++++++----- uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 5 +++++ 6 files changed, 51 insertions(+), 19 deletions(-) diff --git a/uitest/src/com/vaadin/tests/push/PushLargeData.java b/uitest/src/com/vaadin/tests/push/PushLargeData.java index 8ad005df81..1a9bf16de6 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeData.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeData.java @@ -34,6 +34,18 @@ import com.vaadin.ui.UI; public abstract class PushLargeData extends AbstractTestUIWithLog { + // 1MB + static final int DEFAULT_SIZE_BYTES = 1000 * 1000; + + // Every other second + static final int DEFAULT_DELAY_MS = 2000; + + // 20 MB is enough for streaming to reconnect + static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000; + + static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH + / DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS; + private Label dataLabel = new Label(); private final ExecutorService executor = Executors @@ -49,9 +61,9 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { final TextField duration = new TextField("Duration (ms)"); duration.setConverter(Integer.class); - dataSize.setValue((1000 * 1000) + ""); - interval.setValue(2000 + ""); - duration.setValue(40 * 1000 + ""); + dataSize.setValue(DEFAULT_SIZE_BYTES + ""); + interval.setValue(DEFAULT_DELAY_MS + ""); + duration.setValue(DEFAULT_DURATION_MS + ""); addComponent(dataSize); addComponent(interval); diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java index 464cbcc757..7706aa90c6 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java @@ -15,15 +15,19 @@ */ package com.vaadin.tests.push; +import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; +@Push(transport = Transport.STREAMING) public class PushLargeDataStreaming extends PushLargeData { @Override protected void setup(VaadinRequest request) { super.setup(request); getPushConfiguration().setTransport(Transport.STREAMING); - getPushConfiguration().setFallbackTransport(Transport.STREAMING); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java index c716a6fc7e..8f10f0fbba 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java @@ -19,12 +19,12 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.support.ui.ExpectedConditions; -import com.vaadin.tests.tb3.WebsocketTest; +import com.vaadin.tests.tb3.MultiBrowserTest; -public class PushLargeDataStreamingTest extends WebsocketTest { +public class PushLargeDataStreamingTest extends MultiBrowserTest { @Test - public void testWebsocketLargeData() { + public void testStreamingLargeData() { openTestURL(); // Without this there is a large chance that we will wait for all pushes @@ -39,17 +39,23 @@ public class PushLargeDataStreamingTest extends WebsocketTest { } private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + String logRow0Id = "Log_row_0"; By logRow0 = vaadinLocatorById(logRow0Id); vaadinElementById("startButton").click(); - waitUntil(ExpectedConditions.not(ExpectedConditions - .textToBePresentInElement(logRow0, "Push complete"))); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package ")); - // Pushes each 2000ms for 40s - sleep(40000); + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + // Wait until push is actually done waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, "Push complete")); } + } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java index 974dc880f9..4115a825d1 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java @@ -19,14 +19,15 @@ package com.vaadin.tests.push; import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; -@Push +@Push(transport = Transport.WEBSOCKET) public class PushLargeDataWebsocket extends PushLargeData { @Override protected void setup(VaadinRequest request) { super.setup(request); - getPushConfiguration().setTransport(Transport.WEBSOCKET); - getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } } diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java index 83f9efc8dd..70a94f743e 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java @@ -39,17 +39,21 @@ public class PushLargeDataWebsocketTest extends WebsocketTest { } private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + String logRow0Id = "Log_row_0"; By logRow0 = vaadinLocatorById(logRow0Id); - testBench(driver).waitForVaadin(); vaadinElementById("startButton").click(); - waitUntil(ExpectedConditions.not(ExpectedConditions - .textToBePresentInElement(logRow0, "Push complete"))); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package")); - // Pushes each 2000ms for 40s - sleep(40000); + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + // Wait until push is actually done waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, "Push complete")); } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 712ef94397..218c532beb 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -328,6 +328,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition)); } + protected void waitForElementToBePresent(By by) { + waitUntil(ExpectedConditions.not(ExpectedConditions + .invisibilityOfElementLocated(by))); + } + /** * For tests extending {@link AbstractTestUIWithLog}, returns the element * for the Nth log row -- cgit v1.2.3 From 049b9d99ff887e9408e23cbd169431140dd0afa9 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 18 Oct 2013 14:08:50 +0300 Subject: Remove out of order flush() (#12283) Writer.flush() is specified as: "Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams." Change-Id: Iecafdbb13a7a26a48300d2967c25c705f5bf1e38 --- server/src/com/vaadin/server/VaadinServlet.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index c16be33de2..7c0f9599f3 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -427,8 +427,6 @@ public class VaadinServlet extends HttpServlet implements Constants { outWriter.print(output); outWriter.flush(); outWriter.close(); - out.flush(); - } /** -- cgit v1.2.3