diff options
author | Artur Signell <artur@vaadin.com> | 2013-11-11 15:56:06 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-11-11 15:56:07 +0200 |
commit | e75dc7e789940e6396538318dd0f1e490efeedb7 (patch) | |
tree | 376ca8bfc880b35fa0c1ded5ba96c7ed3e8430a1 | |
parent | bc0d55197a2b7fd8a6ac163688026d92203f2618 (diff) | |
parent | 049b9d99ff887e9408e23cbd169431140dd0afa9 (diff) | |
download | vaadin-framework-e75dc7e789940e6396538318dd0f1e490efeedb7.tar.gz vaadin-framework-e75dc7e789940e6396538318dd0f1e490efeedb7.zip |
Merge changes from origin/7.1
51a46a0 Recovering scroll position after regression problems. (#12727)
c464dcf Convert push test to TB3 so it has a chance to pass
2c6d010 Fixes test issues preventing it from passing
049b9d9 Remove out of order flush() (#12283)
Change-Id: I600294f41a4a1b7682f99bddb03042f84bee2702
11 files changed, 109 insertions, 64 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); } }); } - } } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index d34cd3bf0e..baf97d23d9 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -426,8 +426,6 @@ public class VaadinServlet extends HttpServlet implements Constants { outWriter.print(output); outWriter.flush(); outWriter.close(); - out.flush(); - } /** 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 @@ -<?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>PushErrorHandling</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">PushErrorHandling</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/PushErrorHandling?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runPushErrorHandling::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runPushErrorHandling::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]</td> - <td>An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=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]</td> - <td>26,7</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runPushErrorHandling::Root/VNotification[0]/HTML[0]/domChild[0]</td> - <td>Internal error</td> -</tr> -</tbody></table> -</body> -</html> 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()); + } +} 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 |