diff options
author | Artur Signell <artur@vaadin.com> | 2013-09-26 09:28:50 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-09-26 09:28:50 +0300 |
commit | c18b20050d6b04a2c69b3fdfc75ca901b78edc0a (patch) | |
tree | 1d91200782aa20a4fcf331bb0f773070c7cd080a /uitest/src/com/vaadin/tests/push/PushConfigurationTest.java | |
parent | 7c5bdce3b4c76e7f19bc46bcaed135d67a94f06a (diff) | |
parent | bd0ae0581f265be57374b236cfe1b71043ab69aa (diff) | |
download | vaadin-framework-c18b20050d6b04a2c69b3fdfc75ca901b78edc0a.tar.gz vaadin-framework-c18b20050d6b04a2c69b3fdfc75ca901b78edc0a.zip |
Merge changes from origin/7.1
7f7dc31 Base files for TB3 tests (#12572)
6b17abe Make it possible to override web driver in tests (#12572)
a682e3b Refactored build scripts to support TB2, TB3 + integration tests (#12572)
e556642 Converted servlet integration tests to TB3 (#12573)
21af0c3 Updated TB3 tests to use Firefox 24 (#12604)
a7583c6 TB3 test for browsers (#12572)
37b8543 Do not add empty package javadoc for new classes
0248b8f Fixes browser detection for IE11 (#12638)
1df28c3 Run TB3 tests also on IE11 (#12631)
a2daf65 Converted TB2 push tests to TB3 (#12580)
d3261d7 Fixes issue with Table not scrolling completely to the end #12651
bd0ae05 Limit the number of tests run concurrently (#12572)
Change-Id: Idb4389aac388b728490a4ffd57d30aee20ea9fe8
Diffstat (limited to 'uitest/src/com/vaadin/tests/push/PushConfigurationTest.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/push/PushConfigurationTest.java | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java index b57e9732cc..f4a537392d 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java @@ -1,19 +1,132 @@ +/* + * 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 java.util.Date; import java.util.Timer; import java.util.TimerTask; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + import com.vaadin.data.util.ObjectProperty; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.tb3.WebsocketTest; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; public class PushConfigurationTest extends AbstractTestUI { + public static class PushConfigurationWebsocket extends WebsocketTest { + + @Override + protected boolean isDebug() { + return true; + } + + @Test + public void testWebsocketAndStreaming() { + // Websocket + Assert.assertEquals(1, getServerCounter()); + new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET"); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + Assert.assertTrue(vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]") + .getText() + .matches( + "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$")); + int counter = getServerCounter(); + + for (int second = 0;; second++) { + if (second >= 5) { + Assert.fail("timeout"); + } + if (getServerCounter() >= (counter + 2)) { + break; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + + // Use debug console to verify we used the correct transport type + Assert.assertTrue(driver.getPageSource().contains( + "Push connection established using websocket")); + Assert.assertFalse(driver.getPageSource().contains( + "Push connection established using streaming")); + + new Select(getPushModeSelect()).selectByVisibleText("DISABLED"); + + // Streaming + driver.get(getTestUrl()); + Assert.assertEquals(1, getServerCounter()); + + new Select(getTransportSelect()).selectByVisibleText("STREAMING"); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + Assert.assertTrue(vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]") + .getText() + .matches( + "^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: streaming[\\s\\S]*$")); + + counter = getServerCounter(); + for (int second = 0;; second++) { + if (second >= 5) { + Assert.fail("timeout"); + } + if (getServerCounter() >= (counter + 2)) { + break; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + + // Use debug console to verify we used the correct transport type + Assert.assertFalse(driver.getPageSource().contains( + "Push connection established using websocket")); + Assert.assertTrue(driver.getPageSource().contains( + "Push connection established using streaming")); + + } + + private WebElement getPushModeSelect() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]"); + } + + private WebElement getTransportSelect() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]"); + } + + private int getServerCounter() { + return Integer.parseInt(getServerCounterElement().getText()); + } + + private WebElement getServerCounterElement() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]"); + } + } + private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); |