diff options
author | Jonatan Kronqvist <jonatan@vaadin.com> | 2014-02-07 14:46:31 +0200 |
---|---|---|
committer | Jonatan Kronqvist <jonatan@vaadin.com> | 2014-02-07 14:46:31 +0200 |
commit | 4a027d600fb2c1f0cfa1e4d6660e6a5645912c70 (patch) | |
tree | 9ccf14b094ef0a3b25bf065a6f9d70ac6ca238cb /uitest/src/com/vaadin/tests/components/ui | |
parent | 1ca6d0e39bbe2223404df0c275e80c7afa4fd136 (diff) | |
parent | d45785d6763f269b4e00460ace07ab47c712b5ca (diff) | |
download | vaadin-framework-4a027d600fb2c1f0cfa1e4d6660e6a5645912c70.tar.gz vaadin-framework-4a027d600fb2c1f0cfa1e4d6660e6a5645912c70.zip |
Merge changes from origin/7.1
74dcb6f Correct assertion message which changed due to #12915
12b6a8b Test for broken Webkit feature which causes extra scrollbars (#12736, #12727)
ea46029 Allow excluding test from the standard test suite
c171850 Disable client timeout so websockets are not disconnected when idle (#13015)
36fce65 Test for pushing for an extended period of time (24h)
54a5667 Fix compilation error
25fc48c Do not throw NPE if conversion messages is null (#12962)
26b5b67 Timeout redirect timer is reset on server activity (#12446)
d45785d Fixes right click selection focus issues in Tree. (#12618)
Change-Id: I3cef915ee46b77ca0f188296cfa343cde1ad59e6
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/ui')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java | 74 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java | 85 |
2 files changed, 159 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java new file mode 100644 index 0000000000..2c649c9ca8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java @@ -0,0 +1,74 @@ +/* + * 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.components.ui; + +import com.vaadin.server.CustomizedSystemMessages; +import com.vaadin.server.SystemMessages; +import com.vaadin.server.SystemMessagesInfo; +import com.vaadin.server.SystemMessagesProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class TimeoutRedirectResetsOnActivity extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + setupTimout(request); + + addComponent(new Button("clicky", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // NOOP + } + })); + } + + private void setupTimout(VaadinRequest request) { + request.getService().setSystemMessagesProvider( + new SystemMessagesProvider() { + @Override + public SystemMessages getSystemMessages( + SystemMessagesInfo systemMessagesInfo) { + CustomizedSystemMessages msgs = new CustomizedSystemMessages(); + msgs.setSessionExpiredMessage(null); + msgs.setSessionExpiredCaption(null); + msgs.setSessionExpiredNotificationEnabled(true); + msgs.setSessionExpiredURL("http://example.com/"); + return msgs; + } + }); + /* + * NOTE: in practice, this means a timeout after 25 seconds, because of + * implementation details in + * com.vaadin.server.communication.MetadataWriter + */ + getSession().getSession().setMaxInactiveInterval(10); + } + + @Override + protected String getTestDescription() { + return "The timeout redirect timer should reset if there's activity between the client and server."; + } + + @Override + @SuppressWarnings("boxing") + protected Integer getTicketNumber() { + return 12446; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java new file mode 100644 index 0000000000..272bacb8d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java @@ -0,0 +1,85 @@ +/* + * 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.components.ui; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TimeoutRedirectResetsOnActivityTest extends MultiBrowserTest { + @Test + public void verifyRedirectWorks() throws Exception { + setDebug(true); + openTestURL(); + + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < 30000) { + clickTheButton(); + Thread.sleep(1000); + } + + assertTrue("button disappeared before timeout", buttonIsStillThere()); + + Thread.sleep(30000); + assertTrue("no redirection occurred within 30 seconds", + !buttonIsStillThere()); + } + + private boolean buttonIsStillThere() { + try { + return getButton() != null; + } catch (NoSuchElementException e) { + return false; + } + } + + private void clickTheButton() { + getButton().click(); + } + + private WebElement getButton() { + /* + * For some reason, the vaadinElement() method doesn't work when tests + * are run outside of "/run/" and "/run-push/" contexts. The given error + * message says that the generated Vaadin path doesn't match any + * elements, but when that selector is put into the recorder, the + * recorder finds it. + * + * XPath works fine. + */ + /*- + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]"); + */ + return getDriver().findElement( + By.xpath("//div[contains(@class,'v-button')]")); + } + + @Override + protected String getDeploymentPath() { + /* + * AbstractTB3Test assumes only /run/ and /run-push/ contexts, so this + * method needs some overriding. + */ + return "/12446/" + + TimeoutRedirectResetsOnActivity.class.getCanonicalName() + + "?restartApplication&debug"; + } +} |