aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-10-07 18:12:06 +0300
committerVaadin Code Review <review@vaadin.com>2013-10-08 12:25:17 +0000
commitf488825d46c984cea841534178b094be3a562eea (patch)
tree2fe8898d4bb7a520ddfdb7b81e0392abe7a505da /uitest/src
parent63e16e6547b4a7c067a9a1fa53dcecb9d704016b (diff)
downloadvaadin-framework-f488825d46c984cea841534178b094be3a562eea.tar.gz
vaadin-framework-f488825d46c984cea841534178b094be3a562eea.zip
Update TB3+ convention to use a separate *Test file
For any issue there should be a UI class, e.g. LabelSomething and a Test class which has the name of the UI + Test, e.g. LabelSomethingTest. The LabelSomethingTest contains ALL tests which depend on LabelSomething and are named accordingly to what they test. For special and legacy cases also LegacyApplication and UIProvider are supported in addition to UI classes Change-Id: Ifc0180b377284bbd029202494ad194d324f8213b
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/VerifyBrowserVersion.java48
-rw-r--r--uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java66
-rw-r--r--uitest/src/com/vaadin/tests/components/label/LabelModes.java10
-rw-r--r--uitest/src/com/vaadin/tests/components/label/LabelModesTest.java30
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java34
-rw-r--r--uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java49
-rw-r--r--uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java (renamed from uitest/src/com/vaadin/tests/push/PushReattachedComponent.java)14
-rw-r--r--uitest/src/com/vaadin/tests/components/slider/SliderDisable.java19
-rw-r--r--uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java36
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIAccess.java28
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java45
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDL.java28
-rw-r--r--uitest/src/com/vaadin/tests/push/BarInUIDLTest.java45
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPush.java75
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushStreaming.java3
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushStreamingTest.java19
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushTest.java92
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java12
-rw-r--r--uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java29
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfiguration.java117
-rw-r--r--uitest/src/com/vaadin/tests/push/PushConfigurationTest.java246
-rw-r--r--uitest/src/com/vaadin/tests/push/PushFromInit.java33
-rw-r--r--uitest/src/com/vaadin/tests/push/PushFromInitTest.java50
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePush.java95
-rw-r--r--uitest/src/com/vaadin/tests/push/TogglePushTest.java112
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java (renamed from uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java)14
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUITest.java30
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java43
28 files changed, 837 insertions, 585 deletions
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
index 47c09bdfd7..1b21f08aa7 100644
--- a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
@@ -1,59 +1,11 @@
package com.vaadin.tests;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
import com.vaadin.server.WebBrowser;
import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Label;
public class VerifyBrowserVersion extends TestBase {
- public static class BrowserVersionTest extends MultiBrowserTest {
-
- private Map<DesiredCapabilities, String> expectedUserAgent = new HashMap<DesiredCapabilities, String>();
-
- {
- expectedUserAgent
- .put(BrowserUtil.firefox(24),
- "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0");
- expectedUserAgent
- .put(BrowserUtil.ie(8),
- "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");
- expectedUserAgent
- .put(BrowserUtil.ie(9),
- "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
- expectedUserAgent
- .put(BrowserUtil.ie(10),
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
- expectedUserAgent
- .put(BrowserUtil.ie(11),
- "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko");
- expectedUserAgent
- .put(BrowserUtil.chrome(29),
- "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36");
- expectedUserAgent
- .put(BrowserUtil.opera(12),
- "Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.15");
-
- }
-
- @Test
- public void verifyUserAgent() {
- openTestURL();
- Assert.assertEquals(
- expectedUserAgent.get(getDesiredCapabilities()),
- vaadinElementById("userAgent").getText());
- Assert.assertEquals("Touch device? No",
- vaadinElementById("touchDevice").getText());
- }
- }
-
@Override
protected void setup() {
WebBrowser browser = getBrowser();
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
new file mode 100644
index 0000000000..6704f55226
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil;
+
+public class VerifyBrowserVersionTest extends MultiBrowserTest {
+
+ private Map<DesiredCapabilities, String> expectedUserAgent = new HashMap<DesiredCapabilities, String>();
+
+ {
+ expectedUserAgent
+ .put(BrowserUtil.firefox(24),
+ "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0");
+ expectedUserAgent
+ .put(BrowserUtil.ie(8),
+ "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");
+ expectedUserAgent
+ .put(BrowserUtil.ie(9),
+ "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
+ expectedUserAgent
+ .put(BrowserUtil.ie(10),
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
+ expectedUserAgent
+ .put(BrowserUtil.ie(11),
+ "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko");
+ expectedUserAgent
+ .put(BrowserUtil.chrome(29),
+ "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36");
+ expectedUserAgent
+ .put(BrowserUtil.opera(12),
+ "Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.15");
+
+ }
+
+ @Test
+ public void verifyUserAgent() {
+ openTestURL();
+ Assert.assertEquals(
+ expectedUserAgent.get(getDesiredCapabilities()),
+ vaadinElementById("userAgent").getText());
+ Assert.assertEquals("Touch device? No",
+ vaadinElementById("touchDevice").getText());
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/label/LabelModes.java b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
index 9e51978743..e5bc539f36 100644
--- a/uitest/src/com/vaadin/tests/components/label/LabelModes.java
+++ b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
@@ -2,20 +2,10 @@ package com.vaadin.tests.components.label;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.ComponentTestCase;
-import com.vaadin.tests.tb3.SimpleMultiBrowserTest;
import com.vaadin.ui.Label;
public class LabelModes extends ComponentTestCase<Label> {
- public static class LabelModesTest extends SimpleMultiBrowserTest {
- @Override
- public void test() throws Exception {
- openTestURL();
- compareScreen("labelmodes");
- }
-
- }
-
@Override
protected Class<Label> getTestClass() {
return Label.class;
diff --git a/uitest/src/com/vaadin/tests/components/label/LabelModesTest.java b/uitest/src/com/vaadin/tests/components/label/LabelModesTest.java
new file mode 100644
index 0000000000..efad615510
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/label/LabelModesTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.label;
+
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class LabelModesTest extends MultiBrowserTest {
+
+ @Test
+ public void testLabelModes() throws Exception {
+ openTestURL();
+ compareScreen("labelmodes");
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
index 25675e07c5..030bfa693e 100644
--- a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
@@ -1,15 +1,8 @@
package com.vaadin.tests.components.orderedlayout;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Point;
-import org.openqa.selenium.WebElement;
-
import com.vaadin.server.UserError;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -19,8 +12,8 @@ import com.vaadin.ui.TextField;
public class HorizontalLayoutFullsizeContentWithErrorMsg extends AbstractTestUI {
- private static final String FIELD_ID = "f";
- private static final String BUTTON_ID = "b";
+ static final String FIELD_ID = "f";
+ static final String BUTTON_ID = "b";
private TextField tf;
@Override
@@ -70,27 +63,4 @@ public class HorizontalLayoutFullsizeContentWithErrorMsg extends AbstractTestUI
return "TextField should remain at same level vertically, horizontally width should adjust to fit error indicator.";
}
- public static class TbTest extends MultiBrowserTest {
-
- @Test
- public void test() {
- openTestURL();
- WebElement element = getDriver().findElement(By.id(FIELD_ID));
- Point location = element.getLocation();
-
- WebElement errorToggleButton = getDriver().findElement(
- By.id(BUTTON_ID));
-
- errorToggleButton.click();
-
- Assert.assertEquals(location, element.getLocation());
-
- errorToggleButton.click();
-
- Assert.assertEquals(location, element.getLocation());
-
- }
-
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java
new file mode 100644
index 0000000000..24ebf24688
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.orderedlayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Point;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class HorizontalLayoutFullsizeContentWithErrorMsgTest extends
+ MultiBrowserTest {
+
+ @Test
+ public void test() {
+ openTestURL();
+ WebElement element = getDriver().findElement(
+ By.id(HorizontalLayoutFullsizeContentWithErrorMsg.FIELD_ID));
+ Point location = element.getLocation();
+
+ WebElement errorToggleButton = getDriver().findElement(
+ By.id(HorizontalLayoutFullsizeContentWithErrorMsg.BUTTON_ID));
+
+ errorToggleButton.click();
+
+ Assert.assertEquals(location, element.getLocation());
+
+ errorToggleButton.click();
+
+ Assert.assertEquals(location, element.getLocation());
+
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java
index 0bc796e0ee..5bc505dbc8 100644
--- a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
+++ b/uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java
@@ -13,24 +13,14 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-
-/**
- *
- */
-package com.vaadin.tests.push;
+package com.vaadin.tests.components.panel;
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.tests.components.panel.PanelChangeContents;
import com.vaadin.tests.tb3.MultiBrowserTest;
-public class PushReattachedComponent extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return PanelChangeContents.class;
- }
+public class PanelChangeContentsTest extends MultiBrowserTest {
@Test
public void testReattachComponentUsingPush() {
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
index ea29a1657c..bd1d175119 100644
--- a/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
@@ -15,15 +15,8 @@
*/
package com.vaadin.tests.components.slider;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
@@ -32,18 +25,6 @@ import com.vaadin.ui.VerticalLayout;
public class SliderDisable extends AbstractTestUI {
- public static class SliderDisableTest extends MultiBrowserTest {
- @Test
- public void disableSlider() throws IOException {
- openTestURL();
- WebElement element = vaadinElement("/VVerticalLayout[0]/Slot[0]/VSlider[0]/domChild[2]/domChild[0]");
- new Actions(driver).dragAndDropBy(element, 112, 0).perform();
- compareScreen("enabled");
- vaadinElementById("disableButton").click();
- compareScreen("disabled");
- }
- }
-
@Override
protected void setup(VaadinRequest request) {
VerticalLayout content = new VerticalLayout();
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
new file mode 100644
index 0000000000..f6ec3dac3b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.slider;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class SliderDisableTest extends MultiBrowserTest {
+ @Test
+ public void disableSlider() throws IOException {
+ openTestURL();
+ WebElement element = vaadinElement("/VVerticalLayout[0]/Slot[0]/VSlider[0]/domChild[2]/domChild[0]");
+ new Actions(driver).dragAndDropBy(element, 112, 0).perform();
+ compareScreen("enabled");
+ vaadinElementById("disableButton").click();
+ compareScreen("disabled");
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
index 7515b3ede8..d036827159 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
@@ -21,17 +21,11 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.locks.ReentrantLock;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.UI;
@@ -39,28 +33,6 @@ import com.vaadin.util.CurrentInstance;
public class UIAccess extends AbstractTestUIWithLog {
- public static class UIAccessTest extends MultiBrowserTest {
- @Test
- public void testThreadLocals() {
- setPush(true);
- openTestURL();
- getCurrentInstanceWhenPushingButton().click();
- waitUntil(ExpectedConditions.textToBePresentInElement(
- vaadinLocatorById("Log_row_0"), "1."));
- Assert.assertEquals(
- "0. Current UI matches in beforeResponse? true",
- vaadinElementById("Log_row_1").getText());
- Assert.assertEquals(
- "1. Current session matches in beforeResponse? true",
- vaadinElementById("Log_row_0").getText());
-
- }
-
- private WebElement getCurrentInstanceWhenPushingButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]");
- }
- }
-
private volatile boolean checkCurrentInstancesBeforeResponse = false;
private Future<Void> checkFromBeforeClientResponse;
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java b/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
new file mode 100644
index 0000000000..8d04ceae71
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class UIAccessTest extends MultiBrowserTest {
+ @Test
+ public void testThreadLocals() {
+ setPush(true);
+ openTestURL();
+ getCurrentInstanceWhenPushingButton().click();
+ waitUntil(ExpectedConditions.textToBePresentInElement(
+ vaadinLocatorById("Log_row_0"), "1."));
+ Assert.assertEquals(
+ "0. Current UI matches in beforeResponse? true",
+ vaadinElementById("Log_row_1").getText());
+ Assert.assertEquals(
+ "1. Current session matches in beforeResponse? true",
+ vaadinElementById("Log_row_0").getText());
+
+ }
+
+ private WebElement getCurrentInstanceWhenPushingButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]");
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index ebf349683d..bc05f7c306 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -16,15 +16,10 @@
package com.vaadin.tests.push;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
@@ -32,29 +27,6 @@ import com.vaadin.ui.Label;
@Push(transport = Transport.STREAMING)
public class BarInUIDL extends AbstractTestUI {
- public static class BarInUIDLTest extends MultiBrowserTest {
- @Test
- public void sendBarInUIDL() {
- openTestURL();
- getButton().click();
- Assert.assertEquals(
- "Thank you for clicking | bar",
- vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]")
- .getText());
- getButton().click();
- Assert.assertEquals(
- "Thank you for clicking | bar",
- vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]")
- .getText());
- }
-
- private WebElement getButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
- }
- }
-
/*
* (non-Javadoc)
*
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDLTest.java b/uitest/src/com/vaadin/tests/push/BarInUIDLTest.java
new file mode 100644
index 0000000000..840d653e1e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDLTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class BarInUIDLTest extends MultiBrowserTest {
+ @Test
+ public void sendBarInUIDL() {
+ openTestURL();
+ getButton().click();
+ Assert.assertEquals(
+ "Thank you for clicking | bar",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]")
+ .getText());
+ getButton().click();
+ Assert.assertEquals(
+ "Thank you for clicking | bar",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]")
+ .getText());
+ }
+
+ private WebElement getButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java
index d1a9fb575f..d6c45a2ed0 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPush.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPush.java
@@ -18,16 +18,11 @@ package com.vaadin.tests.push;
import java.util.Timer;
import java.util.TimerTask;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
import com.vaadin.annotations.Push;
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.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
@@ -35,76 +30,6 @@ import com.vaadin.ui.Label;
@Push
public class BasicPush extends AbstractTestUI {
- public static abstract class BasicPushTest extends MultiBrowserTest {
-
- @Test
- public void testPush() {
- openTestURL();
-
- // Test client initiated push
- Assert.assertEquals(0, getClientCounter());
- getIncrementButton().click();
- Assert.assertEquals(
- "Client counter not incremented by button click", 1,
- getClientCounter());
- getIncrementButton().click();
- getIncrementButton().click();
- getIncrementButton().click();
- Assert.assertEquals(
- "Four clicks should have incremented counter to 4", 4,
- getClientCounter());
-
- // Test server initiated push
- getServerCounterStartButton().click();
- try {
- Assert.assertEquals(0, getServerCounter());
- sleep(3000);
- int serverCounter = getServerCounter();
- if (serverCounter < 1) {
- // No push has happened
- Assert.fail("No push has occured within 3s");
- }
- sleep(3000);
- if (getServerCounter() <= serverCounter) {
- // No push has happened
- Assert.fail("Only one push took place within 6s");
-
- }
- } finally {
- // Avoid triggering push assertions
- getServerCounterStopButton().click();
- }
- }
-
- private int getServerCounter() {
- return Integer.parseInt(getServerCounterElement().getText());
- }
-
- private int getClientCounter() {
- return Integer.parseInt(getClientCounterElement().getText());
- }
-
- private WebElement getServerCounterElement() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]");
- }
-
- private WebElement getServerCounterStartButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]");
- }
-
- private WebElement getServerCounterStopButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]");
- }
-
- private WebElement getIncrementButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
- }
-
- private WebElement getClientCounterElement() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]");
- }
- }
-
private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
index b63f782cc9..f9dc78dd43 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
@@ -28,7 +28,4 @@ public class BasicPushStreaming extends BasicPush {
getPushConfiguration().setFallbackTransport(Transport.STREAMING);
}
-
- public static class BasicPushStreamingTest extends BasicPushTest {
- }
}
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreamingTest.java b/uitest/src/com/vaadin/tests/push/BasicPushStreamingTest.java
new file mode 100644
index 0000000000..67730f72c8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/BasicPushStreamingTest.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+public class BasicPushStreamingTest extends BasicPushTest {
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java
new file mode 100644
index 0000000000..57af8524bc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public abstract class BasicPushTest extends MultiBrowserTest {
+
+ @Test
+ public void testPush() {
+ openTestURL();
+
+ // Test client initiated push
+ Assert.assertEquals(0, getClientCounter());
+ getIncrementButton().click();
+ Assert.assertEquals(
+ "Client counter not incremented by button click", 1,
+ getClientCounter());
+ getIncrementButton().click();
+ getIncrementButton().click();
+ getIncrementButton().click();
+ Assert.assertEquals(
+ "Four clicks should have incremented counter to 4", 4,
+ getClientCounter());
+
+ // Test server initiated push
+ getServerCounterStartButton().click();
+ try {
+ Assert.assertEquals(0, getServerCounter());
+ sleep(3000);
+ int serverCounter = getServerCounter();
+ if (serverCounter < 1) {
+ // No push has happened
+ Assert.fail("No push has occured within 3s");
+ }
+ sleep(3000);
+ if (getServerCounter() <= serverCounter) {
+ // No push has happened
+ Assert.fail("Only one push took place within 6s");
+
+ }
+ } finally {
+ // Avoid triggering push assertions
+ getServerCounterStopButton().click();
+ }
+ }
+
+ private int getServerCounter() {
+ return Integer.parseInt(getServerCounterElement().getText());
+ }
+
+ private int getClientCounter() {
+ return Integer.parseInt(getClientCounterElement().getText());
+ }
+
+ private WebElement getServerCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]");
+ }
+
+ private WebElement getServerCounterStartButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getServerCounterStopButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getIncrementButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getClientCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]");
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
index 4765183fca..96793a90f8 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
@@ -15,14 +15,9 @@
*/
package com.vaadin.tests.push;
-import java.util.Collection;
-
-import org.openqa.selenium.remote.DesiredCapabilities;
-
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
-import com.vaadin.tests.tb3.WebsocketTest;
@Push(transport = Transport.WEBSOCKET)
public class BasicPushWebsocket extends BasicPush {
@@ -34,11 +29,4 @@ public class BasicPushWebsocket extends BasicPush {
getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
}
- public static class BasicPushWebsocketTest extends BasicPushTest {
- @Override
- public Collection<DesiredCapabilities> getBrowsersToTest() {
- return WebsocketTest.getWebsocketBrowsers();
- }
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
new file mode 100644
index 0000000000..ae4e64ad6b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
@@ -0,0 +1,29 @@
+/*
+ * 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.Collection;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.WebsocketTest;
+
+public class BasicPushWebsocketTest extends BasicPushTest {
+ @Override
+ public Collection<DesiredCapabilities> getBrowsersToTest() {
+ return WebsocketTest.getWebsocketBrowsers();
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.java b/uitest/src/com/vaadin/tests/push/PushConfiguration.java
new file mode 100644
index 0000000000..a7ba4e43ba
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushConfiguration.java
@@ -0,0 +1,117 @@
+/*
+ * 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 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.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class PushConfiguration extends AbstractTestUI {
+
+ private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
+
+ private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0);
+
+ private final Timer timer = new Timer(true);
+
+ private final TimerTask task = new TimerTask() {
+
+ @Override
+ public void run() {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ counter2.setValue(counter2.getValue() + 1);
+ }
+ });
+ }
+ };
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new PushConfigurator(this));
+ spacer();
+
+ /*
+ * Client initiated push.
+ */
+ Label lbl = new Label(counter);
+ lbl.setCaption("Client counter (click 'increment' to update):");
+ addComponent(lbl);
+
+ addComponent(new Button("Increment", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ counter.setValue(counter.getValue() + 1);
+ }
+ }));
+
+ spacer();
+
+ /*
+ * Server initiated push.
+ */
+ lbl = new Label(counter2);
+ lbl.setCaption("Server counter (updates each 1s by server thread) :");
+ addComponent(lbl);
+
+ addComponent(new Button("Reset", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ counter2.setValue(0);
+ }
+ }));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "This test tests the very basic operations of push. "
+ + "It tests that client initiated changes are "
+ + "recieved back to the client as well as server "
+ + "initiated changes are correctly updated to the client.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11494;
+ }
+
+ private void spacer() {
+ addComponent(new Label("<hr/>", ContentMode.HTML));
+ }
+
+ @Override
+ public void attach() {
+ super.attach();
+ timer.scheduleAtFixedRate(task, new Date(), 1000);
+ }
+
+ @Override
+ public void detach() {
+ super.detach();
+ timer.cancel();
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
index 5100e8a4ea..d23c48e14a 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
@@ -15,198 +15,98 @@
*/
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 {
-
- @Test
- public void testWebsocketAndStreaming() {
- setDebug(true);
- openTestURL();
- // 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) {
- }
+public class PushConfigurationTest extends WebsocketTest {
+
+ @Test
+ public void testWebsocketAndStreaming() {
+ setDebug(true);
+ openTestURL();
+ // 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.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);
-
- private final Timer timer = new Timer(true);
-
- private final TimerTask task = new TimerTask() {
-
- @Override
- public void run() {
- access(new Runnable() {
- @Override
- public void run() {
- counter2.setValue(counter2.getValue() + 1);
- }
- });
}
- };
-
- @Override
- protected void setup(VaadinRequest request) {
- addComponent(new PushConfigurator(this));
- spacer();
-
- /*
- * Client initiated push.
- */
- Label lbl = new Label(counter);
- lbl.setCaption("Client counter (click 'increment' to update):");
- addComponent(lbl);
-
- addComponent(new Button("Increment", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- counter.setValue(counter.getValue() + 1);
+ // 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");
}
- }));
-
- spacer();
-
- /*
- * Server initiated push.
- */
- lbl = new Label(counter2);
- lbl.setCaption("Server counter (updates each 1s by server thread) :");
- addComponent(lbl);
-
- addComponent(new Button("Reset", new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- counter2.setValue(0);
+ 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"));
- @Override
- protected String getTestDescription() {
- return "This test tests the very basic operations of push. "
- + "It tests that client initiated changes are "
- + "recieved back to the client as well as server "
- + "initiated changes are correctly updated to the client.";
}
- @Override
- protected Integer getTicketNumber() {
- return 11494;
+ 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 void spacer() {
- addComponent(new Label("<hr/>", ContentMode.HTML));
+ 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]");
}
- @Override
- public void attach() {
- super.attach();
- timer.scheduleAtFixedRate(task, new Date(), 1000);
+ private int getServerCounter() {
+ return Integer.parseInt(getServerCounterElement().getText());
}
- @Override
- public void detach() {
- super.detach();
- timer.cancel();
+ private WebElement getServerCounterElement() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]");
}
-}
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java
index de3334f707..cb084f1232 100644
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.java
+++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java
@@ -15,45 +15,12 @@
*/
package com.vaadin.tests.push;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
public class PushFromInit extends AbstractTestUIWithLog {
- public static class PushFromInitTB3 extends MultiBrowserTest {
- @Test
- public void testPushFromInit() {
- openTestURL();
-
- for (int second = 0;; second++) {
- if (second >= 30) {
- Assert.fail("timeout");
- }
- try {
- if ("1. Logged in init".equals(vaadinElementById(
- "Log_row_1").getText())) {
- break;
- }
- } catch (Exception e) {
- }
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- }
- }
-
- Assert.assertEquals(
- "2. Logged from background thread started in init",
- vaadinElementById("Log_row_0").getText());
-
- }
- }
-
@Override
protected void setup(VaadinRequest request) {
new Thread() {
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInitTest.java b/uitest/src/com/vaadin/tests/push/PushFromInitTest.java
new file mode 100644
index 0000000000..3c1bc1b610
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushFromInitTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PushFromInitTest extends MultiBrowserTest {
+ @Test
+ public void testPushFromInit() {
+ openTestURL();
+
+ for (int second = 0;; second++) {
+ if (second >= 30) {
+ Assert.fail("timeout");
+ }
+ try {
+ if ("1. Logged in init".equals(vaadinElementById(
+ "Log_row_1").getText())) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ Assert.assertEquals(
+ "2. Logged from background thread started in init",
+ vaadinElementById("Log_row_0").getText());
+
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java
index 3ef369b408..6ec8903d65 100644
--- a/uitest/src/com/vaadin/tests/push/TogglePush.java
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.java
@@ -18,112 +18,17 @@ package com.vaadin.tests.push;
import java.util.Timer;
import java.util.TimerTask;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
public class TogglePush extends AbstractTestUI {
- public static class TogglePushTB3 extends MultiBrowserTest {
-
- @Test
- public void togglePushInInit() {
- setPush(true);
- String url = getTestUrl();
-
- // Open with push disabled
- driver.get(addParameter(url, "push=disabled"));
-
- Assert.assertFalse(getPushToggle().isSelected());
-
- getDelayedCounterUpdateButton().click();
- sleep(2000);
- Assert.assertEquals("Counter has been updated 0 times",
- getCounterText());
-
- // Open with push enabled
- driver.get(addParameter(url, "push=enabled"));
- Assert.assertTrue(getPushToggle().isSelected());
-
- getDelayedCounterUpdateButton().click();
- sleep(2000);
- Assert.assertEquals("Counter has been updated 1 times",
- getCounterText());
-
- }
-
- private String addParameter(String url, String queryParameter) {
- if (url.contains("?")) {
- return url + "&" + queryParameter;
- } else {
- return url + "?" + queryParameter;
- }
- }
-
- @Test
- public void togglePush() {
- setPush(true);
- openTestURL();
- getDelayedCounterUpdateButton().click();
- sleep(2000);
-
- // Push is enabled, so text gets updated
- Assert.assertEquals("Counter has been updated 1 times",
- getCounterText());
-
- // Disable push
- getPushToggle().click();
- getDelayedCounterUpdateButton().click();
- sleep(2000);
- // Push is disabled, so text is not updated
- Assert.assertEquals("Counter has been updated 1 times",
- getCounterText());
-
- getDirectCounterUpdateButton().click();
- // Direct update is visible, and includes previous update
- Assert.assertEquals("Counter has been updated 3 times",
- getCounterText());
-
- // Re-enable push
- getPushToggle().click();
- getDelayedCounterUpdateButton().click();
- sleep(2000);
-
- // Push is enabled again, so text gets updated
- Assert.assertEquals("Counter has been updated 4 times",
- getCounterText());
- }
-
- private WebElement getDirectCounterUpdateButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
- }
-
- private WebElement getPushToggle() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
- }
-
- private WebElement getDelayedCounterUpdateButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
- }
-
- private String getCounterText() {
- return vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
- .getText();
- }
-
- }
-
private final Label counterLabel = new Label();
private int counter = 0;
diff --git a/uitest/src/com/vaadin/tests/push/TogglePushTest.java b/uitest/src/com/vaadin/tests/push/TogglePushTest.java
new file mode 100644
index 0000000000..68d6f52b9f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/TogglePushTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TogglePushTest extends MultiBrowserTest {
+
+ @Test
+ public void togglePushInInit() {
+ setPush(true);
+ String url = getTestUrl();
+
+ // Open with push disabled
+ driver.get(addParameter(url, "push=disabled"));
+
+ Assert.assertFalse(getPushToggle().isSelected());
+
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ Assert.assertEquals("Counter has been updated 0 times",
+ getCounterText());
+
+ // Open with push enabled
+ driver.get(addParameter(url, "push=enabled"));
+ Assert.assertTrue(getPushToggle().isSelected());
+
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ }
+
+ private String addParameter(String url, String queryParameter) {
+ if (url.contains("?")) {
+ return url + "&" + queryParameter;
+ } else {
+ return url + "?" + queryParameter;
+ }
+ }
+
+ @Test
+ public void togglePush() {
+ setPush(true);
+ openTestURL();
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+
+ // Push is enabled, so text gets updated
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ // Disable push
+ getPushToggle().click();
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+ // Push is disabled, so text is not updated
+ Assert.assertEquals("Counter has been updated 1 times",
+ getCounterText());
+
+ getDirectCounterUpdateButton().click();
+ // Direct update is visible, and includes previous update
+ Assert.assertEquals("Counter has been updated 3 times",
+ getCounterText());
+
+ // Re-enable push
+ getPushToggle().click();
+ getDelayedCounterUpdateButton().click();
+ sleep(2000);
+
+ // Push is enabled again, so text gets updated
+ Assert.assertEquals("Counter has been updated 4 times",
+ getCounterText());
+ }
+
+ private WebElement getDirectCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private WebElement getPushToggle() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]");
+ }
+
+ private WebElement getDelayedCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+ }
+
+ private String getCounterText() {
+ return vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText();
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
index cb3033aa58..67715339da 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
@@ -25,29 +25,17 @@ import javax.servlet.ServletContext;
import org.apache.commons.io.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
-import org.junit.Assert;
-import org.junit.Test;
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServletService;
import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.JavaScriptFunction;
// Load vaadinPush.js so that jQueryVaadin is defined
@JavaScript("vaadin://vaadinPush.js")
-public class TrackMessageSizeUnitTests extends AbstractTestUIWithLog {
-
- public static class TrackMessageSizeUnitTestsTB3 extends MultiBrowserTest {
- @Test
- public void runTests() {
- openTestURL();
- Assert.assertEquals("1. All tests run",
- vaadinElementById("Log_row_0").getText());
- }
- }
+public class TrackMessageSizeUI extends AbstractTestUIWithLog {
private String testMethod = "function testSequence(expected, data) {\n"
+ " var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUITest.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUITest.java
new file mode 100644
index 0000000000..f904675b5e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUITest.java
@@ -0,0 +1,30 @@
+/*
+ * 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 com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class TrackMessageSizeUITest extends MultiBrowserTest {
+ @Test
+ public void runTests() {
+ openTestURL();
+ Assert.assertEquals("1. All tests run",
+ vaadinElementById("Log_row_0").getText());
+ }
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 5d5f5fae31..5c4ee01d5f 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -19,6 +19,7 @@ package com.vaadin.tests.tb3;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
+import java.util.logging.Logger;
import org.junit.After;
import org.junit.Before;
@@ -35,6 +36,7 @@ import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.vaadin.server.LegacyApplication;
+import com.vaadin.server.UIProvider;
import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchTestCase;
import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -344,8 +346,9 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
/**
- * Returns the UI class the current test is connected to. Uses the enclosing
- * class if the test class is a static inner class to a UI class.
+ * Returns the UI class the current test is connected to (or in special
+ * cases UIProvider or LegacyApplication). Uses the enclosing class if the
+ * test class is a static inner class to a UI class.
*
* Test which are not enclosed by a UI class must implement this method and
* return the UI class they want to test.
@@ -356,11 +359,43 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return the UI class the current test is connected to
*/
protected Class<?> getUIClass() {
+ try {
+ // Convention: SomeUITest uses the SomeUI UI class
+ String uiClassName = getClass().getName().replaceFirst("Test$", "");
+ Class<?> cls = Class.forName(uiClassName);
+ if (isSupportedRunnerClass(cls)) {
+ return cls;
+ }
+ } catch (Exception e) {
+ }
Class<?> enclosingClass = getClass().getEnclosingClass();
if (enclosingClass != null) {
- return enclosingClass;
+ if (UI.class.isAssignableFrom(enclosingClass)) {
+ Logger.getLogger(getClass().getName())
+ .severe("Test is an static inner class to the UI. This will no longer be supported in the future. The test should be named UIClassTest and reside in the same package as the UI");
+ return enclosingClass;
+ }
+ }
+ throw new RuntimeException(
+ "Could not determine UI class. Ensure the test is named UIClassTest and is in the same package as the UIClass");
+ }
+
+ /**
+ * @return true if the given class is supported by ApplicationServletRunner
+ */
+ @SuppressWarnings("deprecation")
+ private boolean isSupportedRunnerClass(Class<?> cls) {
+ if (UI.class.isAssignableFrom(cls)) {
+ return true;
}
- return null;
+ if (UIProvider.class.isAssignableFrom(cls)) {
+ return true;
+ }
+ if (LegacyApplication.class.isAssignableFrom(cls)) {
+ return true;
+ }
+
+ return false;
}
/**