From 0e048a5ba6cf734485fc83cb3b264b8ff104ecb9 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 15:49:35 +0300
Subject: Clarified error message (#12583)
Change-Id: I542046158f6e78c8bb26aaee110bd5b123ae13e6
---
server/src/com/vaadin/ui/UI.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 0746431302..27f04c39e1 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -402,9 +402,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* @see #getSession()
*/
public void setSession(VaadinSession session) {
- if ((session == null) == (this.session == null)) {
+ if (session == null && this.session == null) {
throw new IllegalStateException(
- "VaadinServiceSession has already been set. Old session: "
+ "Session should never be set to null when UI.session is already null");
+ } else if (session != null && this.session != null) {
+ throw new IllegalStateException(
+ "Session has already been set. Old session: "
+ getSessionDetails(this.session)
+ ". New session: " + getSessionDetails(session)
+ ".");
--
cgit v1.2.3
From d0af7d103a94cc7c7817b2fd7cb7cc2ba3bcd519 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 4 Sep 2013 20:07:54 +0300
Subject: Add async-supported to all servlets to enable push testing (#12573)
Change-Id: I8025c7d032f1a76244dbf085e76cb231c1a4459c
---
WebContent/WEB-INF/web.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
index ba948968e2..b93e0670fc 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/WebContent/WEB-INF/web.xml
@@ -24,6 +24,7 @@
application
com.vaadin.tests.components.button.Buttons
+ true
Embed App 2
@@ -32,6 +33,7 @@
UI
com.vaadin.tests.components.label.MarginsInLabels
+ true
UI provider app
@@ -44,6 +46,7 @@
UI
com.vaadin.tests.VerifyAssertionsEnabled
+ true
@@ -70,6 +73,7 @@
testParam
42
+ true
--
cgit v1.2.3
From 1de438915468e92ad0657ac4f22dc3e1b1580e63 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 4 Sep 2013 15:58:26 +0300
Subject: Use JUnit 4.11 in all modules (#12572)
Change-Id: I244f4afdebe956166a9158d85dc69fd7746c5a47
---
client/ivy.xml | 2 +-
server/ivy.xml | 2 +-
theme-compiler/ivy.xml | 2 +-
uitest/ivy.xml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/client/ivy.xml b/client/ivy.xml
index 5d079537b9..ccc304be3d 100644
--- a/client/ivy.xml
+++ b/client/ivy.xml
@@ -32,7 +32,7 @@
-
-
diff --git a/theme-compiler/ivy.xml b/theme-compiler/ivy.xml
index 5bcdbb54cb..7b99b2cdaa 100644
--- a/theme-compiler/ivy.xml
+++ b/theme-compiler/ivy.xml
@@ -40,7 +40,7 @@
rev="2.4" conf="build-provided->default" />
-
diff --git a/uitest/ivy.xml b/uitest/ivy.xml
index 7ff83324ae..e737165288 100644
--- a/uitest/ivy.xml
+++ b/uitest/ivy.xml
@@ -61,7 +61,7 @@
-
Date: Mon, 10 Jun 2013 21:32:57 +0300
Subject: Include TestBench 3.1.1 in the project (#12572)
* Jetty is updated to 8.1.9.v20130131 to avoid conflicts with TestBench dependencies
* The new jetty dependens on servlet 3.0
Change-Id: Ibbbc8f5838feb4c132ee2b6f7d7f3f630e95dd68
---
ivysettings.xml | 4 +++
uitest/ivy.xml | 38 ++++++++++++++--------
.../vaadin/launcher/DevelopmentServerLauncher.java | 8 +++--
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/ivysettings.xml b/ivysettings.xml
index fa08f3d0bb..e18b2233d1 100644
--- a/ivysettings.xml
+++ b/ivysettings.xml
@@ -11,6 +11,8 @@
+
@@ -23,6 +25,8 @@
+
+
+]>
-
+
@@ -23,9 +26,6 @@
-
-
@@ -33,7 +33,9 @@
+ rev="${vaadin.version}" conf="build->build">
+
+
+ conf="build->build">
+
+
-
+
+
+
+ rev="&jetty.version;" conf="ide, build-provided, jetty-run->default">
+
+
+ rev="&jetty.version;" conf="ide, build-provided, jetty-run->default" />
+ rev="&jetty.version;" conf="ide, jetty-run->default" />
+ rev="&jetty.version;" conf="ide, build-provided, jetty-run->default" />
+ rev="&jetty.version;" conf="ide, jetty-run->default">
+
+
@@ -71,6 +81,8 @@
+
diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
index 5ab2134cdb..a8d639cbc8 100644
--- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
+++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
@@ -24,10 +24,12 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -181,7 +183,8 @@ public class DevelopmentServerLauncher {
String[] paths = serverArgs.get("slowdown").split(",");
for (String p : paths) {
System.out.println("Slowing down: " + p);
- webappcontext.addFilter(SlowFilter.class, p, 1);
+ webappcontext.addFilter(SlowFilter.class, p,
+ EnumSet.of(DispatcherType.REQUEST));
}
}
// --cache=/run/APP/PUBLISHED/*,/other/path/asd.jpg
@@ -190,7 +193,8 @@ public class DevelopmentServerLauncher {
String[] paths = serverArgs.get("cache").split(",");
for (String p : paths) {
System.out.println("Enabling cache for: " + p);
- webappcontext.addFilter(CacheFilter.class, p, 1);
+ webappcontext.addFilter(CacheFilter.class, p,
+ EnumSet.of(DispatcherType.REQUEST));
}
}
--
cgit v1.2.3
From cdb9a49bd542fe28ed29c52b90ee9875e2556f67 Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Tue, 10 Sep 2013 15:36:51 +0300
Subject: Enable native scrolling in all iOS versions newer than 5, not just
iOS 6 (#12324)
Change-Id: I8f9ec7f34aefa5b48fd23f3f000f9455475edefa
---
WebContent/VAADIN/themes/base/common/common.scss | 8 +++++---
client/src/com/vaadin/client/BrowserInfo.java | 8 ++++----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/WebContent/VAADIN/themes/base/common/common.scss b/WebContent/VAADIN/themes/base/common/common.scss
index cb3645c9d8..07e244a76f 100644
--- a/WebContent/VAADIN/themes/base/common/common.scss
+++ b/WebContent/VAADIN/themes/base/common/common.scss
@@ -227,11 +227,13 @@ input::-ms-clear {
font-size: 0;
line-height: normal;
}
-
-/* Enable kinetic scrolling on iOS 6 */
-.v-ios6.v-webkit & .v-scrollable {
+.v-ios.v-webkit & .v-scrollable {
-webkit-overflow-scrolling: touch;
}
+/* Disable native scrolling on iOS 5 due to #8792 */
+.v-ios5.v-webkit & .v-scrollable {
+ -webkit-overflow-scrolling: none;
+}
&.v-overlay-container {
width: 0;
diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java
index 5d588f6f8b..84b6f14c34 100644
--- a/client/src/com/vaadin/client/BrowserInfo.java
+++ b/client/src/com/vaadin/client/BrowserInfo.java
@@ -207,8 +207,8 @@ public class BrowserInfo {
return prefix + OS_ANDROID;
} else if (browserDetails.isIOS()) {
String iosClass = prefix + OS_IOS;
- if (isIOS6()) {
- iosClass += " " + prefix + OS_IOS + "6";
+ if (getOperatingSystemMajorVersion() == 5) {
+ iosClass += " " + prefix + OS_IOS + "5";
}
return iosClass;
} else if (browserDetails.isWindows()) {
@@ -392,9 +392,9 @@ public class BrowserInfo {
if (isAndroid() && isWebkit() && getWebkitVersion() >= 534) {
return false;
}
- // iOS 6 Safari supports native scrolling; iOS 5 suffers from #8792
+ // iOS 6+ Safari supports native scrolling; iOS 5 suffers from #8792
// TODO Should test other iOS browsers
- if (isIOS6() && isWebkit()) {
+ if (isIOS() && isWebkit() && getOperatingSystemMajorVersion() >= 6) {
return false;
}
return true;
--
cgit v1.2.3
From 0e2780a0ad6212a7bee9d204464504c6ed0e41a1 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 14:33:54 +0300
Subject: Ensure string converter is always set
Change-Id: I8c9146975397356e92fded0d0207b56d057ac6c5
---
.../tests/server/component/abstractfield/AbsFieldValueConversions.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java
index 9854296538..a5e825bddb 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversions.java
@@ -249,6 +249,7 @@ public class AbsFieldValueConversions extends TestCase {
@Test
public void testNullConverter() {
TextField tf = new TextField("foo");
+ tf.setConverter(new StringToIntegerConverter());
tf.setPropertyDataSource(new ObjectProperty(12));
tf.setConverter((Converter) null);
try {
--
cgit v1.2.3
From cf796e281ec684c94117725ab27d4089859e0161 Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Thu, 19 Sep 2013 14:23:46 +0300
Subject: Add v-iosN classname for all iOS versions instead of just N=6
(#12324)
Change-Id: Id06cfab1404facd612aa470d82757ae6dfe71641
---
client/src/com/vaadin/client/BrowserInfo.java | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java
index 84b6f14c34..273964c889 100644
--- a/client/src/com/vaadin/client/BrowserInfo.java
+++ b/client/src/com/vaadin/client/BrowserInfo.java
@@ -207,10 +207,7 @@ public class BrowserInfo {
return prefix + OS_ANDROID;
} else if (browserDetails.isIOS()) {
String iosClass = prefix + OS_IOS;
- if (getOperatingSystemMajorVersion() == 5) {
- iosClass += " " + prefix + OS_IOS + "5";
- }
- return iosClass;
+ return iosClass + " " + iosClass + getOperatingSystemMajorVersion();
} else if (browserDetails.isWindows()) {
return prefix + OS_WINDOWS;
} else if (browserDetails.isLinux()) {
--
cgit v1.2.3
From 46ac1e6fb9d2ecf27b3946bffdc7d2f83f691924 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Thu, 19 Sep 2013 00:18:19 +0300
Subject: Update release notes to more closely be like 7.0.x (#12544)
* Fixed ticket link and removed duplicate link
* Reordered sections to changes in this version comes before changes in old versions
* Updated browser versions
Change-Id: Ib3afc6257c93fe6481103fbb80aa5ebf9d2a5dd5
---
WebContent/release-notes.html | 54 +++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html
index 387a5121cb..a11e526c3f 100644
--- a/WebContent/release-notes.html
+++ b/WebContent/release-notes.html
@@ -41,10 +41,10 @@
- ChangeLog
-
- This release includes the following closed issues:
-
- @release-notes-tickets@
-
-
-
- The full
- list of the closed issues can also be found at
- dev.vaadin.com
- .
-
-
Vaadin Installation
@@ -573,11 +577,11 @@
- Mozilla Firefox 18-23
+ Mozilla Firefox 18-24
Mozilla Firefox 17 ESR
Internet Explorer 8-10
Safari 6
- Opera 12
+ Opera 12,16
Google Chrome 23-29
@@ -587,7 +591,7 @@
- iOS 5-6
+ iOS 5-7
Android 2.3-4
--
cgit v1.2.3
From d9f204fda6b56429b6dfe2dda0b79203ff2ef99e Mon Sep 17 00:00:00 2001
From: Leif Åstrand
Date: Thu, 12 Sep 2013 10:13:12 +0300
Subject: PostLayoutListener javadocs (#12562)
Change-Id: Icdc39630a8d48f87ca4765f4513c9871d49f5d76
---
.../src/com/vaadin/client/ui/PostLayoutListener.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/client/src/com/vaadin/client/ui/PostLayoutListener.java b/client/src/com/vaadin/client/ui/PostLayoutListener.java
index d60360747c..3da2358b0c 100644
--- a/client/src/com/vaadin/client/ui/PostLayoutListener.java
+++ b/client/src/com/vaadin/client/ui/PostLayoutListener.java
@@ -15,6 +15,24 @@
*/
package com.vaadin.client.ui;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.LayoutManager;
+
+/**
+ * Interface implemented by {@link ComponentConnector} implementations that want
+ * to know whenever a layout phase has ended. At the end of each layout phase,
+ * {@link LayoutManager} invokes the {@link #postLayout()} method for all
+ * registered component connectors implementing this interface.
+ *
+ * @since 7.0
+ * @author Vaadin Ltd
+ */
public interface PostLayoutListener {
+ /**
+ * Method invoked by {@link LayoutManager} to notify the connector that a
+ * layout phase has ended. This method can be used to finalize internal
+ * layouting, but it is not allowed to change the its own external size or
+ * modify the conditions for any children.
+ */
public void postLayout();
}
--
cgit v1.2.3
From c7aaa0413f63d938791e760b23fb3f609f285aa0 Mon Sep 17 00:00:00 2001
From: Jonatan Kronqvist
Date: Fri, 20 Sep 2013 15:32:12 +0300
Subject: Don't try to cast a connector to Widget. Fixes #12619
Change-Id: I0fe98ca90ed3969f1af1be60668b4c1c561675eb
---
.../com/vaadin/client/ui/dd/VTargetInSubtree.java | 4 +-
uitest/src/com/vaadin/tests/dd/DnDOnSubtree.html | 51 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/dd/DnDOnSubtree.html
diff --git a/client/src/com/vaadin/client/ui/dd/VTargetInSubtree.java b/client/src/com/vaadin/client/ui/dd/VTargetInSubtree.java
index e9061114aa..c3f56b410d 100644
--- a/client/src/com/vaadin/client/ui/dd/VTargetInSubtree.java
+++ b/client/src/com/vaadin/client/ui/dd/VTargetInSubtree.java
@@ -32,7 +32,7 @@ final public class VTargetInSubtree extends VAcceptCriterion {
protected boolean accept(VDragEvent drag, UIDL configuration) {
VTree tree = (VTree) VDragAndDropManager.get().getCurrentDropHandler()
- .getConnector();
+ .getConnector().getWidget();
TreeNode treeNode = tree.getNodeByKey((String) drag.getDropDetails()
.get("itemIdOver"));
if (treeNode != null) {
@@ -53,4 +53,4 @@ final public class VTargetInSubtree extends VAcceptCriterion {
return false;
}
-}
\ No newline at end of file
+}
diff --git a/uitest/src/com/vaadin/tests/dd/DnDOnSubtree.html b/uitest/src/com/vaadin/tests/dd/DnDOnSubtree.html
new file mode 100644
index 0000000000..844636cb02
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/dd/DnDOnSubtree.html
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+ DnDOnSubtree
+
+
+
+
+
+ New Test
+
+
+
+
+ open
+ /run/com.vaadin.tests.dd.DDTest8?restartApplication
+
+
+
+ drag
+ vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[3]
+ 11,8
+
+
+
+ drop
+ vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[6]
+ 34,9
+
+
+ mouseClick
+
+ vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[5]/expand
+
+ 10,8
+
+
+
+ assertElementPresent
+
+ vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[5]/n[0]
+
+
+
+
+
+
+
--
cgit v1.2.3
From 7f7dc316e3593bc4823f2cbc8e6f4814f233ce03 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 08:50:16 +0300
Subject: Base files for TB3 tests (#12572)
* Converted LabelModes to TB3 for validation
Change-Id: Ic9e69d46623a16986961bdc8cc050b375622a91d
---
uitest/eclipse-run-selected-test.properties | 26 +-
.../vaadin/tests/components/label/LabelModes.html | 27 --
.../vaadin/tests/components/label/LabelModes.java | 9 +
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 516 +++++++++++++++++++++
.../src/com/vaadin/tests/tb3/MultiBrowserTest.java | 81 ++++
.../com/vaadin/tests/tb3/ParallelScheduler.java | 60 +++
.../vaadin/tests/tb3/PrivateTB3Configuration.java | 123 +++++
.../com/vaadin/tests/tb3/ScreenshotTB3Test.java | 392 ++++++++++++++++
.../vaadin/tests/tb3/SimpleMultiBrowserTest.java | 49 ++
uitest/src/com/vaadin/tests/tb3/TB3Runner.java | 167 +++++++
10 files changed, 1415 insertions(+), 35 deletions(-)
delete mode 100644 uitest/src/com/vaadin/tests/components/label/LabelModes.html
create mode 100644 uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/TB3Runner.java
diff --git a/uitest/eclipse-run-selected-test.properties b/uitest/eclipse-run-selected-test.properties
index f6cb2551e9..cbd1ab1cef 100644
--- a/uitest/eclipse-run-selected-test.properties
+++ b/uitest/eclipse-run-selected-test.properties
@@ -1,14 +1,23 @@
-; Location where vaadin-testbench jar can be found
-com.vaadin.testbench.lib.dir=
-
-; Deployment url to use for testing. Context path must be /
-com.vaadin.testbench.deployment.url=http://:8888/
+;
+; For both TestBench 2 and 3
+;
; Location of the screenshot directory.
; This is the directory that contains the "references" directory
com.vaadin.testbench.screenshot.directory=
-; Run the whole test even if
+
+;
+; For only TestBench 2
+;
+
+; Location where TestBench 2 jar can be found
+com.vaadin.testbench.lib.dir=
+
+; Deployment url to use for testing. Context path must be /
+com.vaadin.testbench.deployment.url=http://:8888/
+
+; Run the whole test even if a screenshot comparison fails
com.vaadin.testbench.screenshot.softfail=true
; Screen capture at the end if the test fails
@@ -23,7 +32,8 @@ com.vaadin.testbench.screenshot.cursor=true
; Uncomment to limit to certain browsers or override in launch configuration
; browsers=winxp-opera10
-; Claim that the server has started succesfully. Needed for the tests to run
+; Claim that the server has started succesfully. Needed for TB2 tests to be executed
server.start.succeeded=1
-test-output-dir=../build/test-output
\ No newline at end of file
+; Directory where temporary Java classes are created
+test-output-dir=../build/test-output
diff --git a/uitest/src/com/vaadin/tests/components/label/LabelModes.html b/uitest/src/com/vaadin/tests/components/label/LabelModes.html
deleted file mode 100644
index 356688b456..0000000000
--- a/uitest/src/com/vaadin/tests/components/label/LabelModes.html
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run/com.vaadin.tests.components.label.LabelModes?restartApplication
-
-
-
- screenCapture
-
- labelmodes
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/components/label/LabelModes.java b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
index e5bc539f36..1959447a4b 100644
--- a/uitest/src/com/vaadin/tests/components/label/LabelModes.java
+++ b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
@@ -2,10 +2,19 @@ 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 {
+ public static class LabelModesTest extends SimpleMultiBrowserTest {
+ @Override
+ public void test() throws Exception {
+ compareScreen("labelmodes");
+ }
+
+ }
+
@Override
protected Class getTestClass() {
return Label.class;
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
new file mode 100644
index 0000000000..f27fff5873
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -0,0 +1,516 @@
+/*
+ * 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.tb3;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.After;
+import org.junit.Before;
+import org.openqa.selenium.Platform;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.remote.BrowserType;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.remote.RemoteWebDriver;
+
+import com.vaadin.server.LegacyApplication;
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.TestBench;
+import com.vaadin.testbench.TestBenchTestCase;
+import com.vaadin.ui.UI;
+
+/**
+ * Base class for TestBench 3+ tests. All TB3+ tests in the project should
+ * extend this class.
+ *
+ * Provides:
+ *
+ * Helpers for browser selection
+ * Hub connection setup and teardown
+ * Automatic opening of a given test on the development server using
+ * {@link #getUIClass()} or by automatically finding an enclosing UI class
+ * Generic helpers for creating TB3+ tests
+ * Automatic URL generation based on needed features, e.g.
+ * {@link #isDebug()}, {@link #isPushEnabled()}
+ *
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class AbstractTB3Test extends TestBenchTestCase {
+ /**
+ * Height of the screenshots we want to capture
+ */
+ private static final int SCREENSHOT_HEIGHT = 850;
+
+ /**
+ * Width of the screenshots we want to capture
+ */
+ private static final int SCREENSHOT_WIDTH = 1500;
+
+ private DesiredCapabilities desiredCapabilities;
+ {
+ // Default browser to run on unless setDesiredCapabilities is called
+ desiredCapabilities = BrowserUtil.firefox(24);
+ }
+
+ /**
+ * Connect to the hub using a remote web driver, set the canvas size and
+ * opens the initial URL as specified by {@link #getTestUrl()}
+ *
+ * @throws MalformedURLException
+ */
+ @Before
+ public void setup() throws MalformedURLException {
+ DesiredCapabilities capabilities = getDesiredCapabilities();
+ driver = TestBench.createDriver(new RemoteWebDriver(
+ new URL(getHubURL()), capabilities));
+ int w = SCREENSHOT_WIDTH;
+ int h = SCREENSHOT_HEIGHT;
+
+ if (BrowserUtil.isIE8(capabilities)) {
+ // IE8 gets size wrong, who would have guessed...
+ w += 4;
+ h += 4;
+ }
+ try {
+ testBench().resizeViewPortTo(w, h);
+ } catch (UnsupportedOperationException e) {
+ // Opera does not support this...
+ }
+
+ String testUrl = getTestUrl();
+ if (testUrl != null) {
+ driver.get(testUrl);
+ }
+ }
+
+ /**
+ * Returns the full URL to be opened when the test starts.
+ *
+ * @return the full URL to open or null to not open any URL automatically
+ */
+ protected String getTestUrl() {
+ String baseUrl = getBaseURL();
+ if (baseUrl.endsWith("/")) {
+ baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
+ }
+
+ return baseUrl + getDeploymentPath();
+ }
+
+ /**
+ *
+ * @return the location (URL) of the TB hub
+ */
+ protected String getHubURL() {
+ return "http://" + getHubHostname() + ":4444/wd/hub";
+ }
+
+ /**
+ * Used for building the hub URL to use for the test
+ *
+ * @return the host name of the TestBench hub
+ */
+ protected abstract String getHubHostname();
+
+ /**
+ * Used to determine what URL to initially open for the test
+ *
+ * @return the host name of development server
+ */
+ protected abstract String getDeploymentHostname();
+
+ /**
+ * Used to determine which capabilities should be used when setting up a
+ * {@link WebDriver} for this test. Typically set by a test runner or left
+ * at its default (Firefox 24). If you want to run a test on a single
+ * browser other than Firefox 24 you can override this method.
+ *
+ * @return the requested browser capabilities
+ */
+ protected DesiredCapabilities getDesiredCapabilities() {
+ return desiredCapabilities;
+ }
+
+ /**
+ * Sets the requested browser capabilities (typically browser name and
+ * version)
+ *
+ * @param desiredCapabilities
+ */
+ public void setDesiredCapabilities(DesiredCapabilities desiredCapabilities) {
+ this.desiredCapabilities = desiredCapabilities;
+ }
+
+ /**
+ * Shuts down the driver after the test has been completed
+ *
+ * @throws Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ if (driver != null) {
+ driver.quit();
+ }
+ driver = null;
+ }
+
+ /**
+ * Finds a Vaadin element based on the part of a TB3 style locator following
+ * the :: (e.g.
+ * vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
+ * PID_Scheckboxaction-Enabled/domChild[0]).
+ *
+ * @param vaadinLocator
+ * The part following :: of the vaadin locator string
+ * @return
+ */
+ protected WebElement vaadinElement(String vaadinLocator) {
+ String base = getApplicationId(getDeploymentPath());
+
+ base += "::";
+
+ return driver.findElement(By.vaadin(base + vaadinLocator));
+ }
+
+ /**
+ * Find a Vaadin element based on its id given using Component.setId
+ *
+ * @param id
+ * The id to locate
+ * @return
+ */
+ public WebElement vaadinElementById(String id) {
+ return vaadinElement("PID_S" + id);
+ }
+
+ /**
+ * Returns the path that should be used for the test. The path contains the
+ * full path (appended to hostname+port) and must start with a slash.
+ *
+ * @return The path to open automatically when the test starts
+ */
+ protected String getDeploymentPath() {
+ Class> uiClass = getUIClass();
+ if (uiClass != null) {
+ return getDeploymentPath(uiClass);
+ }
+ throw new IllegalArgumentException("Unable to determine path for "
+ + getClass().getCanonicalName());
+
+ }
+
+ /**
+ * 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.
+ *
+ * Test which are not enclosed by a UI class must implement this method and
+ * return the UI class they want to test.
+ *
+ * Note that this method will update the test name to the enclosing class to
+ * be compatible with TB2 screenshot naming
+ *
+ * @return the UI class the current test is connected to
+ */
+ protected Class> getUIClass() {
+ Class> enclosingClass = getClass().getEnclosingClass();
+ if (enclosingClass != null) {
+ return enclosingClass;
+ }
+ return null;
+ }
+
+ /**
+ * Determines whether to run the test in debug mode (with the debug console
+ * open) or not
+ *
+ * @return true to run with the debug window open, false by default
+ */
+ protected boolean isDebug() {
+ return false;
+ }
+
+ /**
+ * Determines whether to run the test with push enabled (using /run-push) or
+ * not. Note that push tests can and should typically be created using @Push
+ * on the UI instead of overriding this method
+ *
+ * @return true to use push in the test, false to use whatever UI specifies
+ */
+ protected boolean isPushEnabled() {
+ return false;
+ }
+
+ /**
+ * Returns the path for the given UI class when deployed on the test server.
+ * The path contains the full path (appended to hostname+port) and must
+ * start with a slash.
+ *
+ * This method takes into account {@link #isPushEnabled()} and
+ * {@link #isDebug()} when the path is generated.
+ *
+ * @param uiClass
+ * @return The path to the given UI class
+ */
+ private String getDeploymentPath(Class> uiClass) {
+ String runPath = "/run";
+ if (isPushEnabled()) {
+ runPath = "/run-push";
+ }
+
+ if (UI.class.isAssignableFrom(uiClass)) {
+ return runPath + "/" + uiClass.getCanonicalName()
+ + (isDebug() ? "?debug" : "");
+ } else if (LegacyApplication.class.isAssignableFrom(uiClass)) {
+ return runPath + "/" + uiClass.getCanonicalName()
+ + "?restartApplication" + (isDebug() ? "&debug" : "");
+ } else {
+ throw new IllegalArgumentException(
+ "Unable to determine path for enclosing class "
+ + uiClass.getCanonicalName());
+ }
+ }
+
+ /**
+ * Used to determine what URL to initially open for the test
+ *
+ * @return The base URL for the test. Does not include a trailing slash.
+ */
+ protected String getBaseURL() {
+ return "http://" + getDeploymentHostname() + ":8888";
+ }
+
+ /**
+ * Generates the application id based on the URL in a way compatible with
+ * VaadinServletService.
+ *
+ * @param pathWithQueryParameters
+ * The path part of the URL, possibly still containing query
+ * parameters
+ * @return The application ID string used in Vaadin locators
+ */
+ private String getApplicationId(String pathWithQueryParameters) {
+ // Remove any possible URL parameters
+ String pathWithoutQueryParameters = pathWithQueryParameters.replaceAll(
+ "\\?.*", "");
+ if ("".equals(pathWithoutQueryParameters)) {
+ return "ROOT";
+ }
+
+ // Retain only a-z and numbers
+ return pathWithoutQueryParameters.replaceAll("[^a-zA-Z0-9]", "");
+ }
+
+ /**
+ * Helper method for sleeping X ms in a test. Catches and ignores
+ * InterruptedExceptions
+ *
+ * @param timeoutMillis
+ * Number of ms to wait
+ */
+ protected void sleep(int timeoutMillis) {
+ try {
+ Thread.sleep(timeoutMillis);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Provides helper method for selecting the browser to run on
+ *
+ * @author Vaadin Ltd
+ */
+ public static class BrowserUtil {
+ /**
+ * Gets the capabilities for Safari of the given version
+ *
+ * @param version
+ * the major version
+ * @return an object describing the capabilities required for running a
+ * test on the given Safari version
+ */
+ protected static DesiredCapabilities safari(int version) {
+ DesiredCapabilities c = DesiredCapabilities.safari();
+ c.setVersion("" + version);
+ return c;
+ }
+
+ /**
+ * Gets the capabilities for Chrome of the given version
+ *
+ * @param version
+ * the major version
+ * @return an object describing the capabilities required for running a
+ * test on the given Chrome version
+ */
+ protected static DesiredCapabilities chrome(int version) {
+ DesiredCapabilities c = DesiredCapabilities.chrome();
+ c.setVersion("" + version);
+ c.setPlatform(Platform.XP);
+ return c;
+ }
+
+ /**
+ * Gets the capabilities for Opera of the given version
+ *
+ * @param version
+ * the major version
+ * @return an object describing the capabilities required for running a
+ * test on the given Opera version
+ */
+ protected static DesiredCapabilities opera(int version) {
+ DesiredCapabilities c = DesiredCapabilities.opera();
+ c.setVersion("" + version);
+ c.setPlatform(Platform.XP);
+ return c;
+ }
+
+ /**
+ * Gets the capabilities for Firefox of the given version
+ *
+ * @param version
+ * the major version
+ * @return an object describing the capabilities required for running a
+ * test on the given Firefox version
+ */
+ protected static DesiredCapabilities firefox(int version) {
+ DesiredCapabilities c = DesiredCapabilities.firefox();
+ c.setVersion("" + version);
+ c.setPlatform(Platform.XP);
+ return c;
+ }
+
+ /**
+ * Gets the capabilities for Internet Explorer of the given version
+ *
+ * @param version
+ * the major version
+ * @return an object describing the capabilities required for running a
+ * test on the given Internet Explorer version
+ */
+ protected static DesiredCapabilities ie(int version) {
+ DesiredCapabilities c = DesiredCapabilities.internetExplorer();
+ c.setVersion("" + version);
+ return c;
+ }
+
+ /**
+ * Checks if the given capabilities refer to Internet Explorer 8
+ *
+ * @param capabilities
+ * @return true if the capabilities refer to IE8, false otherwise
+ */
+ public static boolean isIE8(DesiredCapabilities capabilities) {
+ return BrowserType.IE.equals(capabilities.getBrowserName())
+ && "8".equals(capabilities.getVersion());
+ }
+
+ /**
+ * Returns a human readable identifier of the given browser. Used for
+ * test naming and screenshots
+ *
+ * @param capabilities
+ * @return a human readable string describing the capabilities
+ */
+ public static String getBrowserIdentifier(
+ DesiredCapabilities capabilities) {
+ String browserName = capabilities.getBrowserName();
+
+ if (BrowserType.IE.equals(browserName)) {
+ return "InternetExplorer";
+ } else if (BrowserType.FIREFOX.equals(browserName)) {
+ return "Firefox";
+ } else if (BrowserType.CHROME.equals(browserName)) {
+ return "Chrome";
+ } else if (BrowserType.SAFARI.equals(browserName)) {
+ return "Safari";
+ } else if (BrowserType.OPERA.equals(browserName)) {
+ return "Opera";
+ }
+
+ return browserName;
+ }
+
+ /**
+ * Returns a human readable identifier of the platform described by the
+ * given capabilities. Used mainly for screenshots
+ *
+ * @param capabilities
+ * @return a human readable string describing the platform
+ */
+ public static String getPlatform(DesiredCapabilities capabilities) {
+ if (capabilities.getPlatform() == Platform.WIN8
+ || capabilities.getPlatform() == Platform.WINDOWS
+ || capabilities.getPlatform() == Platform.VISTA
+ || capabilities.getPlatform() == Platform.XP) {
+ return "Windows";
+ } else if (capabilities.getPlatform() == Platform.MAC) {
+ return "Mac";
+ }
+ return capabilities.getPlatform().toString();
+ }
+
+ /**
+ * Returns a string which uniquely (enough) identifies this browser.
+ * Used mainly in screenshot names.
+ *
+ * @param capabilities
+ *
+ * @return a unique string for each browser
+ */
+ public static String getUniqueIdentifier(
+ DesiredCapabilities capabilities) {
+ return getUniqueIdentifier(getPlatform(capabilities),
+ getBrowserIdentifier(capabilities),
+ capabilities.getVersion());
+ }
+
+ /**
+ * Returns a string which uniquely (enough) identifies this browser.
+ * Used mainly in screenshot names.
+ *
+ * @param capabilities
+ *
+ * @return a unique string for each browser
+ */
+ public static String getUniqueIdentifier(
+ DesiredCapabilities capabilities, String versionOverride) {
+ return getUniqueIdentifier(getPlatform(capabilities),
+ getBrowserIdentifier(capabilities), versionOverride);
+ }
+
+ private static String getUniqueIdentifier(String platform,
+ String browser, String version) {
+ return platform + "_" + browser + "_" + version;
+ }
+
+ }
+
+ /**
+ * Called by the test runner whenever there is an exception in the test that
+ * will cause termination of the test
+ *
+ * @param t
+ * the throwable which caused the termination
+ */
+ public void onUncaughtException(Throwable t) {
+ // Do nothing by default
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
new file mode 100644
index 0000000000..5a1d07c0c0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.tb3;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+/**
+ * Base class for tests which should be run on all supported browsers. The test
+ * is automatically launched for multiple browsers in parallel by the test
+ * runner.
+ *
+ * Sub classes can, but typically should not, restrict the browsers used by
+ * implementing a
+ *
+ *
+ * @Parameters
+ * public static Collection<DesiredCapabilities> getBrowsersForTest() {
+ * }
+ *
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(value = TB3Runner.class)
+public abstract class MultiBrowserTest extends PrivateTB3Configuration {
+
+ private static List allBrowsers = new ArrayList();
+ private static List websocketBrowsers = new ArrayList();
+ static {
+ allBrowsers.add(BrowserUtil.ie(8));
+ allBrowsers.add(BrowserUtil.ie(9));
+ allBrowsers.add(BrowserUtil.ie(10));
+ allBrowsers.add(BrowserUtil.firefox(17));
+ // Uncomment once we have the capability to run on Safari 6
+ // allBrowsers.add(safari(6));
+ allBrowsers.add(BrowserUtil.chrome(29));
+ allBrowsers.add(BrowserUtil.opera(12));
+
+ websocketBrowsers.addAll(allBrowsers);
+ websocketBrowsers.remove(BrowserUtil.ie(8));
+ websocketBrowsers.remove(BrowserUtil.ie(9));
+ }
+
+ @Parameters
+ public static Collection getBrowsersForTest() {
+ return getAllBrowsers();
+ }
+
+ public static Collection getAllBrowsers() {
+ return Collections.unmodifiableCollection(allBrowsers);
+ }
+
+ /**
+ * @return A subset of {@link #getAllBrowsers()} including only those which
+ * support websockets
+ */
+ public static Collection getWebsocketBrowsers() {
+ return Collections.unmodifiableCollection(websocketBrowsers);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
new file mode 100644
index 0000000000..f8013169fa
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
@@ -0,0 +1,60 @@
+/*
+ * 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.tb3;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.junit.runners.model.RunnerScheduler;
+
+/**
+ * JUnit scheduler capable of running multiple tets in parallel. Each test is
+ * run in its own thread. Uses an {@link ExecutorService} to manage the threads.
+ *
+ * @author Vaadin Ltd
+ */
+public class ParallelScheduler implements RunnerScheduler {
+ private final List> fResults = new ArrayList>();
+
+ private final ExecutorService fService = Executors.newCachedThreadPool();
+
+ @Override
+ public void schedule(final Runnable childStatement) {
+ fResults.add(fService.submit(new Callable() {
+ @Override
+ public Object call() throws Exception {
+ childStatement.run();
+ return null;
+ }
+ }));
+ }
+
+ @Override
+ public void finished() {
+ for (Future each : fResults) {
+ try {
+ each.get();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
new file mode 100644
index 0000000000..3d7dead928
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2013 Vaadind 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.tb3;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+import java.util.Properties;
+
+/**
+ * Provides values for parameters which depend on where the test is run.
+ * Parameters should be configured in work/eclipse-run-selected-test.properties.
+ * A template is available in uitest/.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
+ private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname";
+ private final Properties properties = new Properties();
+
+ public PrivateTB3Configuration() {
+ File file = new File("work", "eclipse-run-selected-test.properties");
+ if (file.exists()) {
+ try {
+ properties.load(new FileInputStream(file));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private String getProperty(String name) {
+ String property = properties.getProperty(name);
+ if (property == null) {
+ property = System.getProperty(name);
+ }
+
+ return property;
+ }
+
+ @Override
+ protected String getScreenshotDirectory() {
+ String screenshotDirectory = getProperty("com.vaadin.testbench.screenshot.directory");
+ if (screenshotDirectory == null) {
+ throw new RuntimeException(
+ "No screenshot directory defined. Use -Dcom.vaadin.testbench.screenshot.directory=");
+ }
+ return screenshotDirectory;
+ }
+
+ @Override
+ protected String getHubHostname() {
+ return "tb3-hub.intra.itmill.com";
+ }
+
+ @Override
+ protected String getDeploymentHostname() {
+ String hostName = getProperty(HOSTNAME_PROPERTY);
+
+ if (hostName == null || "".equals(hostName)) {
+ hostName = findAutoHostname();
+ }
+
+ return hostName;
+ }
+
+ /**
+ * Tries to automatically determine the IP address of the machine the test
+ * is running on.
+ *
+ * @return An IP address of one of the network interfaces in the machine.
+ * @throws RuntimeException
+ * if there was an error or no IP was found
+ */
+ private String findAutoHostname() {
+ try {
+ Enumeration interfaces = NetworkInterface
+ .getNetworkInterfaces();
+ while (interfaces.hasMoreElements()) {
+ NetworkInterface current = interfaces.nextElement();
+ if (!current.isUp() || current.isLoopback()
+ || current.isVirtual()) {
+ continue;
+ }
+ Enumeration addresses = current.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ InetAddress current_addr = addresses.nextElement();
+ if (current_addr.isLoopbackAddress()) {
+ continue;
+ }
+ String hostAddress = current_addr.getHostAddress();
+ if (hostAddress.startsWith("192.168.")) {
+ return hostAddress;
+ }
+ }
+ }
+ } catch (SocketException e) {
+ throw new RuntimeException("Could not enumerate ");
+ }
+
+ throw new RuntimeException(
+ "No compatible (192.168.*) ip address found.");
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
new file mode 100644
index 0000000000..645d9cd0cb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -0,0 +1,392 @@
+/*
+ * 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.tb3;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.openqa.selenium.OutputType;
+import org.openqa.selenium.TakesScreenshot;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.Parameters;
+import com.vaadin.testbench.commands.TestBenchCommands;
+
+/**
+ * Base class which provides functionality for tests which use the automatic
+ * screenshot comparison function.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class ScreenshotTB3Test extends AbstractTB3Test {
+
+ private String screenshotBaseName;
+
+ @Rule
+ public TestRule watcher = new TestWatcher() {
+
+ @Override
+ protected void starting(org.junit.runner.Description description) {
+ Class> testClass = description.getTestClass();
+ // Runner adds [BrowserName] which we do not want to use in the
+ // screenshot name
+ String testMethod = description.getMethodName();
+ testMethod = testMethod.replaceAll("\\[.*\\]", "");
+
+ String className = testClass.getSimpleName();
+ if (testClass.getEnclosingClass() != null) {
+ className = testClass.getEnclosingClass().getSimpleName();
+ }
+
+ screenshotBaseName = className + "-" + testMethod;
+ };
+ };
+
+ /**
+ * Contains a list of screenshot identifiers for which
+ * {@link #compareScreen(String)} has failed during the test
+ */
+ private List screenshotFailures = new ArrayList();
+
+ /**
+ * Defines TestBench screen comparison parameters before each test run
+ */
+ @Before
+ public void setupScreenComparisonParameters() {
+ Parameters.setScreenshotErrorDirectory(getScreenshotErrorDirectory());
+ Parameters
+ .setScreenshotReferenceDirectory(getScreenshotReferenceDirectory());
+ }
+
+ /**
+ * Grabs a screenshot and compares with the reference image with the given
+ * identifier. Supports alternative references and will succeed if the
+ * screenshot matches at least one of the references.
+ *
+ * In case of a failed comparison this method stores the grabbed screenshots
+ * in the error directory as defined by
+ * {@link #getScreenshotErrorDirectory()}. It will also generate a html file
+ * in the same directory, comparing the screenshot with the first found
+ * reference.
+ *
+ * @param identifier
+ * @throws IOException
+ */
+ protected void compareScreen(String identifier) throws IOException {
+ if (identifier == null || identifier.isEmpty()) {
+ throw new IllegalArgumentException("Empty identifier not supported");
+ }
+
+ File mainReference = getScreenshotReferenceFile(identifier);
+
+ List alternativeFiles = findReferenceAlternatives(mainReference);
+ List failedReferenceAlternatives = new ArrayList();
+
+ for (File file : alternativeFiles) {
+ if (testBench(driver).compareScreen(file)) {
+ break;
+ } else {
+ failedReferenceAlternatives.add(file);
+ }
+ }
+
+ File referenceToKeep = null;
+ if (failedReferenceAlternatives.size() != alternativeFiles.size()) {
+ // Matched one comparison but not all, remove all error images +
+ // HTML files
+ } else {
+ // All comparisons failed, keep the main error image + HTML
+ screenshotFailures.add(mainReference.getName());
+ referenceToKeep = mainReference;
+ }
+
+ // Remove all PNG/HTML files we no longer need (failed alternative
+ // references or all error files (PNG/HTML) if comparison succeeded)
+ for (File failedAlternative : failedReferenceAlternatives) {
+ File failurePng = getErrorFileFromReference(failedAlternative);
+ if (failedAlternative != referenceToKeep) {
+ // Delete png + HTML
+ String htmlFileName = failurePng.getName().replace(".png",
+ ".html");
+ File failureHtml = new File(failurePng.getParentFile(),
+ htmlFileName);
+
+ failurePng.delete();
+ failureHtml.delete();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param referenceFile
+ * The reference image file (in the directory defined by
+ * {@link #getScreenshotReferenceDirectory()})
+ * @return the file name of the file generated in the directory defined by
+ * {@link #getScreenshotErrorDirectory()} if comparison with the
+ * given reference image fails.
+ */
+ private File getErrorFileFromReference(File referenceFile) {
+ return new File(referenceFile.getAbsolutePath().replace(
+ getScreenshotReferenceDirectory(),
+ getScreenshotErrorDirectory()));
+ }
+
+ /**
+ * Finds alternative references for the given files
+ *
+ * @param reference
+ * @return all references which should be considered when comparing with the
+ * given files, including the given reference
+ */
+ private List findReferenceAlternatives(File reference) {
+ List files = new ArrayList();
+ files.add(reference);
+
+ File screenshotDir = reference.getParentFile();
+ String name = reference.getName();
+ // Remove ".png"
+ String nameBase = name.substring(0, name.length() - 4);
+ for (int i = 1;; i++) {
+ File file = new File(screenshotDir, nameBase + "_" + i + ".png");
+ if (file.exists()) {
+ files.add(file);
+ } else {
+ break;
+ }
+ }
+
+ return files;
+ }
+
+ /**
+ * @param testName
+ * @return the reference file name to use for the given browser, as
+ * described by {@literal capabilities}, and identifier
+ */
+ private File getScreenshotReferenceFile(String identifier) {
+ DesiredCapabilities capabilities = getDesiredCapabilities();
+
+ String originalName = getScreenshotReferenceName(identifier);
+ File exactVersionFile = new File(originalName);
+ if (exactVersionFile.exists()) {
+ return exactVersionFile;
+ }
+
+ String browserVersion = capabilities.getVersion();
+
+ if (browserVersion.matches("\\d+")) {
+ for (int version = Integer.parseInt(browserVersion); version > 0; version--) {
+ String fileName = getScreenshotReferenceName(identifier,
+ version);
+ File oldVersionFile = new File(fileName);
+ if (oldVersionFile.exists()) {
+ return oldVersionFile;
+ }
+ }
+ }
+
+ return exactVersionFile;
+ }
+
+ /**
+ * @return the base directory of 'reference' and 'errors' screenshots
+ */
+ protected abstract String getScreenshotDirectory();
+
+ /**
+ * @return the directory where reference images are stored (the 'reference'
+ * folder inside the screenshot directory)
+ */
+ private String getScreenshotReferenceDirectory() {
+ return getScreenshotDirectory() + "/reference";
+ }
+
+ /**
+ * @return the directory where comparison error images should be created
+ * (the 'errors' folder inside the screenshot directory)
+ */
+ private String getScreenshotErrorDirectory() {
+ return getScreenshotDirectory() + "/errors";
+ }
+
+ /**
+ * Checks if any screenshot comparisons failures occurred during the test
+ * and combines all comparison errors into one exception
+ *
+ * @throws IOException
+ * If there were failures during the test
+ */
+ @After
+ public void checkCompareFailures() throws IOException {
+ if (!screenshotFailures.isEmpty()) {
+ throw new IOException(
+ "The following screenshots did not match the reference: "
+ + screenshotFailures.toString());
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.tests.tb3.AbstractTB3Test#onUncaughtException(java.lang.Throwable
+ * )
+ */
+ @Override
+ public void onUncaughtException(Throwable cause) {
+ super.onUncaughtException(cause);
+ // Grab a "failure" screenshot and store in the errors folder for later
+ // analysis
+ try {
+ TestBenchCommands testBench = testBench();
+ if (testBench != null) {
+ testBench.disableWaitForVaadin();
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ try {
+ if (driver != null) {
+ BufferedImage screenshotImage = ImageIO
+ .read(new ByteArrayInputStream(
+ ((TakesScreenshot) driver)
+ .getScreenshotAs(OutputType.BYTES)));
+ ImageIO.write(screenshotImage, "png", new File(
+ getScreenshotFailureName()));
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
+ }
+
+ /**
+ * @return the name of a "failure" image which is stored in the folder
+ * defined by {@link #getScreenshotErrorDirectory()} when the test
+ * fails
+ */
+ private String getScreenshotFailureName() {
+ return getScreenshotErrorBaseName() + "-failure.png";
+ }
+
+ /**
+ * @return the base name used for screenshots. This is the first part of the
+ * screenshot file name, typically created as "testclass-testmethod"
+ */
+ public String getScreenshotBaseName() {
+ return screenshotBaseName;
+ }
+
+ /**
+ * Returns the name of the reference file based on the given parameters.
+ *
+ * @param testName
+ * @param capabilities
+ * @param identifier
+ * @return the full path of the reference
+ */
+ private String getScreenshotReferenceName(String identifier) {
+ return getScreenshotReferenceName(identifier, null);
+ }
+
+ /**
+ * Returns the name of the reference file based on the given parameters. The
+ * version given in {@literal capabilities} is used unless it is overridden
+ * by the {@literal versionOverride} parameter.
+ *
+ * @param testName
+ * @param capabilities
+ * @param identifier
+ * @return the full path of the reference
+ */
+ private String getScreenshotReferenceName(String identifier,
+ Integer versionOverride) {
+ String uniqueBrowserIdentifier;
+ if (versionOverride == null) {
+ uniqueBrowserIdentifier = BrowserUtil
+ .getUniqueIdentifier(getDesiredCapabilities());
+ } else {
+ uniqueBrowserIdentifier = BrowserUtil.getUniqueIdentifier(
+ getDesiredCapabilities(), "" + versionOverride);
+ }
+
+ // WindowMaximizeRestoreTest_Windows_InternetExplorer_8_window-1-moved-maximized-restored.png
+ return getScreenshotReferenceDirectory() + "/"
+ + getScreenshotBaseName() + "_" + uniqueBrowserIdentifier + "_"
+ + identifier + ".png";
+ }
+
+ /**
+ * Returns the base name of the screenshot in the error directory. This is a
+ * name so that all files matching {@link #getScreenshotErrorBaseName()}*
+ * are owned by this test instance (taking into account
+ * {@link #getDesiredCapabilities()}) and can safely be removed before
+ * running this test.
+ */
+ private String getScreenshotErrorBaseName() {
+ return getScreenshotReferenceName("dummy", null).replace(
+ getScreenshotReferenceDirectory(),
+ getScreenshotErrorDirectory()).replace("_dummy.png", "");
+ }
+
+ /**
+ * Removes any old screenshots related to this test from the errors
+ * directory before running the test
+ */
+ @Before
+ public void cleanErrorDirectory() {
+ // Remove any screenshots for this test from the error directory
+ // before running it. Leave unrelated files as-is
+ File errorDirectory = new File(getScreenshotErrorDirectory());
+
+ // Create errors directory if it does not exist
+ if (!errorDirectory.exists()) {
+ errorDirectory.mkdirs();
+ }
+
+ final String errorBase = getScreenshotErrorBaseName()
+ .replace("\\", "/");
+ File[] files = errorDirectory.listFiles(new FileFilter() {
+
+ @Override
+ public boolean accept(File pathname) {
+ String thisFile = pathname.getAbsolutePath().replace("\\", "/");
+ if (thisFile.startsWith(errorBase)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ for (File f : files) {
+ f.delete();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java
new file mode 100644
index 0000000000..a7ade3f9f7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.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.tb3;
+
+import org.junit.Test;
+
+/**
+ * A simple version of {@link MultiBrowserTest} which allows only one test
+ * method ({@link #test()}). Uses only the enclosing class name as test
+ * identifier (i.e. excludes "-test").
+ *
+ * This class is only provided as a helper for converting existing TB2 tests
+ * without renaming all screenshots. All new TB3+ tests should extend
+ * {@link MultiBrowserTest} directly instead of this.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class SimpleMultiBrowserTest extends MultiBrowserTest {
+
+ @Test
+ public abstract void test() throws Exception;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.ScreenshotTB3Test#getScreenshotBaseName()
+ */
+ @Override
+ public String getScreenshotBaseName() {
+ return super.getScreenshotBaseName().replaceFirst("-test$", "");
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
new file mode 100644
index 0000000000..510d200ffa
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -0,0 +1,167 @@
+/*
+ * 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.tb3;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+import org.junit.runners.model.Statement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil;
+
+/**
+ * This runner is loosely based on FactoryTestRunner by Ted Young
+ * (http://tedyoung.me/2011/01/23/junit-runtime-tests-custom-runners/). The
+ * generated test names give information about the parameters used (unlike
+ * {@link Parameterized}).
+ *
+ * @since 7.1
+ */
+public class TB3Runner extends BlockJUnit4ClassRunner {
+
+ public TB3Runner(Class> klass) throws InitializationError {
+ super(klass);
+ setScheduler(new ParallelScheduler());
+ }
+
+ @Override
+ protected List computeTestMethods() {
+ List tests = new LinkedList();
+
+ // Find all methods in our test class marked with @Parameters.
+ for (FrameworkMethod method : getTestClass().getAnnotatedMethods(
+ Parameters.class)) {
+ // Make sure the Parameters method is static
+ if (!Modifier.isStatic(method.getMethod().getModifiers())) {
+ throw new IllegalArgumentException("@Parameters " + method
+ + " must be static.");
+ }
+
+ // Execute the method (statically)
+ Object params;
+ try {
+ params = method.getMethod().invoke(
+ getTestClass().getJavaClass());
+ } catch (Throwable t) {
+ throw new RuntimeException("Could not run test factory method "
+ + method.getName(), t);
+ }
+
+ // Did the factory return an array? If so, make it a list.
+ if (params.getClass().isArray()) {
+ params = Arrays.asList((Object[]) params);
+ }
+
+ // Did the factory return a scalar object? If so, put it in a list.
+ if (!(params instanceof Iterable>)) {
+ params = Collections.singletonList(params);
+ }
+
+ // For each object returned by the factory.
+ for (Object param : (Iterable>) params) {
+ if (!(param instanceof DesiredCapabilities)) {
+ throw new RuntimeException("Unexpected parameter type "
+ + param.getClass().getName()
+ + " when expecting DesiredCapabilities");
+ }
+ DesiredCapabilities capabilities = (DesiredCapabilities) param;
+ // Find any methods marked with @Test.
+ for (FrameworkMethod m : getTestClass().getAnnotatedMethods(
+ Test.class)) {
+ tests.add(new TB3Method(m.getMethod(), capabilities));
+ }
+ }
+ }
+
+ return tests;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.junit.runners.BlockJUnit4ClassRunner#withBefores(org.junit.runners
+ * .model.FrameworkMethod, java.lang.Object,
+ * org.junit.runners.model.Statement)
+ */
+ @Override
+ protected Statement withBefores(final FrameworkMethod method,
+ final Object target, Statement statement) {
+ if (!(method instanceof TB3Method)) {
+ throw new RuntimeException("Unexpected method type "
+ + method.getClass().getName() + ", expected TB3Method");
+ }
+ final TB3Method tb3method = (TB3Method) method;
+
+ // setDesiredCapabilities before running the real @Befores (which use
+ // capabilities)
+
+ final Statement realBefores = super.withBefores(method, target,
+ statement);
+ return new Statement() {
+
+ @Override
+ public void evaluate() throws Throwable {
+ ((AbstractTB3Test) target)
+ .setDesiredCapabilities(tb3method.capabilities);
+ try {
+ realBefores.evaluate();
+ } catch (Throwable t) {
+ // Give the test a chance to e.g. produce an error
+ // screenshot before failing the test by re-throwing the
+ // exception
+ ((AbstractTB3Test) target).onUncaughtException(t);
+ throw t;
+ }
+ }
+ };
+ }
+
+ private static class TB3Method extends FrameworkMethod {
+ private DesiredCapabilities capabilities;
+
+ public TB3Method(Method method, DesiredCapabilities capabilities) {
+ super(method);
+ this.capabilities = capabilities;
+ }
+
+ @Override
+ public Object invokeExplosively(final Object target, Object... params)
+ throws Throwable {
+ // Executes the test method with the supplied parameters
+ return super.invokeExplosively(target);
+ }
+
+ @Override
+ public String getName() {
+ return String.format("%s[%s]", getMethod().getName(),
+ BrowserUtil.getUniqueIdentifier(capabilities));
+ }
+
+ }
+}
--
cgit v1.2.3
From 6b17abed4cbf3aff19efd58c5f3ca6195972f39e Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 23 Sep 2013 15:46:20 +0300
Subject: Make it possible to override web driver in tests (#12572)
Change-Id: If696c8a57fc370d2851592d745ab8a2698631ed5
---
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 35 +++++++++++++++++-----
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index f27fff5873..966be1a692 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -72,13 +72,36 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* Connect to the hub using a remote web driver, set the canvas size and
* opens the initial URL as specified by {@link #getTestUrl()}
*
- * @throws MalformedURLException
+ * @throws Exception
*/
@Before
- public void setup() throws MalformedURLException {
+ public void setup() throws Exception {
+ setupDriver();
+
+ String testUrl = getTestUrl();
+ if (testUrl != null) {
+ driver.get(testUrl);
+ }
+ }
+
+ /**
+ * Creates and configure the web driver to be used for the test. By default
+ * creates a remote web driver which connects to {@link #getHubURL()} and
+ * selects a browser based on {@link #getDesiredCapabilities()}.
+ *
+ * This method MUST call {@link #setDriver(WebDriver)} with the newly
+ * generated driver.
+ *
+ * @throws Exception
+ * If something goes wrong
+ */
+ protected void setupDriver() throws Exception {
DesiredCapabilities capabilities = getDesiredCapabilities();
- driver = TestBench.createDriver(new RemoteWebDriver(
- new URL(getHubURL()), capabilities));
+
+ WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL(
+ getHubURL()), capabilities));
+ setDriver(dr);
+
int w = SCREENSHOT_WIDTH;
int h = SCREENSHOT_HEIGHT;
@@ -93,10 +116,6 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
// Opera does not support this...
}
- String testUrl = getTestUrl();
- if (testUrl != null) {
- driver.get(testUrl);
- }
}
/**
--
cgit v1.2.3
From a682e3b5341e5cf21e84c1dbbb2bc98743674392 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 14:31:37 +0300
Subject: Refactored build scripts to support TB2, TB3 + integration tests
(#12572)
* Main build configuration triggers unit tests for all modules and uitest/build.xml testbench tests in parallel
* uitest/build.xml triggers Jetty startup and integration (server) tests in parallel. After the server has started, TB2 and TB3 tests are run in parallel.
* Server integration tests for servlet containers are run using TB3 and the com.vaadin.tests.tb3.ServletIntegrationTests test suite.
* Portlet integration tests are still run using TB2 test scripts
Change-Id: Ie6bffd4e68b4889074e9c470faa3c65f923e55c4
---
build.xml | 15 +-
uitest/build.xml | 55 ++++++
uitest/integration_tests.xml | 91 ++++-----
uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java | 42 ++++
uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java | 223 ++++++++++++++++++++++
uitest/tb3test.xml | 33 ++++
uitest/test.xml | 21 +-
7 files changed, 411 insertions(+), 69 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
create mode 100644 uitest/tb3test.xml
diff --git a/build.xml b/build.xml
index 5f748d8f40..bef7f7a2f3 100644
--- a/build.xml
+++ b/build.xml
@@ -43,19 +43,16 @@
+
+
-
-
-
-
-
-
-
+
-
+
+
+
diff --git a/uitest/build.xml b/uitest/build.xml
index bd0f49ae1e..76b75e9203 100644
--- a/uitest/build.xml
+++ b/uitest/build.xml
@@ -9,6 +9,7 @@
+
@@ -107,6 +108,11 @@
+
+
+
+
+
@@ -148,4 +154,53 @@
WHAT? No JUnit tests for ${module.name}!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uitest/integration_tests.xml b/uitest/integration_tests.xml
index 78e053991e..f1b2070bc8 100644
--- a/uitest/integration_tests.xml
+++ b/uitest/integration_tests.xml
@@ -1,6 +1,6 @@
-
+
@@ -32,33 +32,22 @@
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
@@ -73,7 +62,7 @@
-
+
@@ -90,7 +79,7 @@
-
+
@@ -107,6 +96,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -333,7 +343,7 @@
-
+
@@ -341,7 +351,8 @@
+ requires its own lock -->
+
@@ -387,7 +398,6 @@
-
@@ -446,31 +456,24 @@
-
-
-
-
-
-
-
-
+
-
+ Starting legacy (TB2) test for ${target-server}
+
+
+ Starting TB3 test for ${target-server}
+
+
+
+
+
-
-
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java b/uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java
new file mode 100644
index 0000000000..bd9027bec2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/AllTB3Tests.java
@@ -0,0 +1,42 @@
+/*
+ * 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.tb3;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.AllTB3Tests.AllTB3TestsSuite;
+
+/**
+ * Test consisting of all TB3 tests except integration tests (classes extending
+ * AbstractTB3Test, excludes package com.vaadin.test.integration).
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(AllTB3TestsSuite.class)
+public class AllTB3Tests {
+
+ public static class AllTB3TestsSuite extends TB3TestSuite {
+
+ public AllTB3TestsSuite(Class> klass) throws InitializationError {
+ super(klass, AbstractTB3Test.class, "com.vaadin.tests",
+ new String[] { "com.vaadin.tests.integration" });
+ }
+
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
new file mode 100644
index 0000000000..dc187000d2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
@@ -0,0 +1,223 @@
+/*
+ * 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.tb3;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.JarURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+import org.junit.runners.Suite;
+import org.junit.runners.model.InitializationError;
+
+/**
+ * Test suite which consists of all the TB3 tests passed in the constructor.
+ * Runs the tests in parallel using a {@link ParallelScheduler}
+ *
+ * @author Vaadin Ltd
+ */
+public class TB3TestSuite extends Suite {
+
+ public TB3TestSuite(Class> klass,
+ Class extends AbstractTB3Test> baseClass, String basePackage,
+ String[] ignorePackages) throws InitializationError {
+ super(klass, findTests(baseClass, basePackage, ignorePackages));
+ setScheduler(new ParallelScheduler());
+ }
+
+ /**
+ * Traverses the directory on the classpath (inside or outside a Jar file)
+ * specified by 'basePackage'. Collects all classes inside the location
+ * which can be assigned to 'baseClass' except for classes inside packages
+ * listed in 'ignoredPackages'.
+ *
+ * @param baseClass
+ * @param basePackage
+ * @param ignorePackages
+ * @return
+ */
+ private static Class>[] findTests(
+ Class extends AbstractTB3Test> baseClass, String basePackage,
+ String[] ignorePackages) {
+ try {
+ List> l = findClasses(baseClass, basePackage, ignorePackages);
+ return l.toArray(new Class[] {});
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Traverses the directory on the classpath (inside or outside a Jar file)
+ * specified by 'basePackage'. Collects all classes inside the location
+ * which can be assigned to 'baseClass' except for classes inside packages
+ * listed in 'ignoredPackages'.
+ *
+ * @param baseClass
+ * @param basePackage
+ * @param ignoredPackages
+ * @return
+ * @throws IOException
+ */
+ private static List> findClasses(Class baseClass,
+ String basePackage, String[] ignoredPackages) throws IOException {
+ List> classes = new ArrayList>();
+ String basePackageDirName = "/" + basePackage.replace('.', '/');
+ URL location = baseClass.getResource(basePackageDirName);
+ if (location.getProtocol().equals("file")) {
+ try {
+ File f = new File(location.toURI());
+ if (!f.exists()) {
+ throw new IOException("Directory " + f.toString()
+ + " does not exist");
+ }
+ findPackages(f, basePackage, baseClass, classes,
+ ignoredPackages);
+ } catch (URISyntaxException e) {
+ throw new IOException(e.getMessage());
+ }
+ } else if (location.getProtocol().equals("jar")) {
+ JarURLConnection juc = (JarURLConnection) location.openConnection();
+ findClassesInJar(juc, basePackage, baseClass, classes);
+ }
+
+ Collections.sort(classes, new Comparator>() {
+
+ @Override
+ public int compare(Class extends T> o1, Class extends T> o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ });
+ return classes;
+ }
+
+ /**
+ * Traverses the given directory and collects all classes which are inside
+ * the given 'javaPackage' and can be assigned to the given 'baseClass'. The
+ * found classes are added to 'result'.
+ *
+ * @param parent
+ * The directory to traverse
+ * @param javaPackage
+ * The java package which 'parent' contains
+ * @param baseClass
+ * The class which the target classes extend
+ * @param result
+ * The collection to which found classes are added
+ * @param ignoredPackages
+ * A collection of packages (including sub packages) to ignore
+ */
+ private static void findPackages(File parent, String javaPackage,
+ Class baseClass, Collection> result,
+ String[] ignoredPackages) {
+ for (String ignoredPackage : ignoredPackages) {
+ if (javaPackage.equals(ignoredPackage)) {
+ return;
+ }
+ }
+
+ for (File file : parent.listFiles()) {
+ if (file.isDirectory()) {
+ findPackages(file, javaPackage + "." + file.getName(),
+ baseClass, result, ignoredPackages);
+ } else if (file.getName().endsWith(".class")) {
+ String fullyQualifiedClassName = javaPackage + "."
+ + file.getName().replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+
+ }
+
+ /**
+ * Traverses a Jar file using the given connection and collects all classes
+ * which are inside the given 'javaPackage' and can be assigned to the given
+ * 'baseClass'. The found classes are added to 'result'.
+ *
+ * @param javaPackage
+ * The java package containing the classes (classes may be in a
+ * sub package)
+ * @param baseClass
+ * The class which the target classes extend
+ * @param result
+ * The collection to which found classes are added
+ * @throws IOException
+ */
+ private static void findClassesInJar(JarURLConnection juc,
+ String javaPackage, Class baseClass,
+ Collection> result) throws IOException {
+ String javaPackageDir = javaPackage.replace('.', '/');
+ Enumeration ent = juc.getJarFile().entries();
+ while (ent.hasMoreElements()) {
+ JarEntry e = ent.nextElement();
+ if (e.getName().endsWith(".class")
+ && e.getName().startsWith(javaPackageDir)) {
+ String fullyQualifiedClassName = e.getName().replace('/', '.')
+ .replace(".class", "");
+ addClassIfMatches(result, fullyQualifiedClassName, baseClass);
+ }
+ }
+ }
+
+ /**
+ * Verifies that the class represented by 'fullyQualifiedClassName' can be
+ * loaded, assigned to 'baseClass' and is not an abstract or anonymous
+ * class.
+ *
+ * @param result
+ * The collection to add to
+ * @param fullyQualifiedClassName
+ * The candidate class
+ * @param baseClass
+ * The class 'fullyQualifiedClassName' should be assignable to
+ */
+ @SuppressWarnings("unchecked")
+ private static void addClassIfMatches(
+ Collection> result,
+ String fullyQualifiedClassName, Class baseClass) {
+ try {
+ // Try to load the class
+
+ Class> c = Class.forName(fullyQualifiedClassName);
+ if (!baseClass.isAssignableFrom(c)) {
+ return;
+ }
+ if (!Modifier.isAbstract(c.getModifiers()) && !c.isAnonymousClass()) {
+ result.add((Class extends T>) c);
+ }
+ } catch (Exception e) {
+ // Could ignore that class cannot be loaded
+ e.printStackTrace();
+ } catch (LinkageError e) {
+ // Ignore. Client side classes will at least throw LinkageErrors
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml
new file mode 100644
index 0000000000..92008ff9f3
--- /dev/null
+++ b/uitest/tb3test.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uitest/test.xml b/uitest/test.xml
index 3baccb4117..dd6964e59c 100644
--- a/uitest/test.xml
+++ b/uitest/test.xml
@@ -83,7 +83,7 @@
-
+
@@ -161,12 +161,10 @@
-
+
-
-
-
-
+
+
@@ -177,15 +175,6 @@
-
-
-
-
-
-
-
-
-
-
+
--
cgit v1.2.3
From e5566429bf0dfb7e9a85148a152cee0445bd40f9 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 14:37:20 +0300
Subject: Converted servlet integration tests to TB3 (#12573)
Change-Id: I964be2ef805875f36a2f0f8139feaa353c9aaee0
---
.../integration/AbstractIntegrationTestTB3.java | 53 ++++++++++++++++++
.../tests/integration/IntegrationTestRunner.java | 54 +++++++++++++++++++
.../integration/IntegrationTestStreaming.java | 35 ++++++++++++
.../tests/integration/IntegrationTestUI.java | 5 ++
.../integration/IntegrationTestWebsocket.java | 49 +++++++++++++++++
.../integration/ServletIntegrationTestTB3.java | 62 ++++++++++++++++++++++
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 10 ++--
.../vaadin/tests/tb3/ServletIntegrationTests.java | 35 ++++++++++++
8 files changed, 298 insertions(+), 5 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
create mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
create mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
create mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
create mode 100644 uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
diff --git a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
new file mode 100644
index 0000000000..e170450619
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
@@ -0,0 +1,53 @@
+/*
+ * 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.integration;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.PrivateTB3Configuration;
+
+/**
+ * Base class for integration tests. Integration tests use the
+ * {@literal deployment.url} parameter to determine the base deployment url
+ * (http://hostname:123)
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(IntegrationTestRunner.class)
+public abstract class AbstractIntegrationTestTB3 extends
+ PrivateTB3Configuration {
+ @Override
+ protected String getBaseURL() {
+ String deploymentUrl = System.getProperty("deployment.url");
+ if (deploymentUrl == null || deploymentUrl.equals("")) {
+ throw new RuntimeException(
+ "Deployment url must be given as deployment.url");
+ }
+
+ return deploymentUrl;
+ }
+
+ @Parameters
+ public static Collection getBrowsersForTest() {
+ return Collections.singleton(BrowserUtil.firefox(17));
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
new file mode 100644
index 0000000000..29ee4e6023
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
@@ -0,0 +1,54 @@
+/*
+ * 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.integration;
+
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.tb3.TB3Runner;
+
+/**
+ * JUnit runner for integration tests. Replaces the actual method name with the
+ * server-name property when generating the test name.
+ *
+ * @author Vaadin Ltd
+ */
+public class IntegrationTestRunner extends TB3Runner {
+
+ private Class> testClass;
+
+ public IntegrationTestRunner(Class> klass) throws InitializationError {
+ super(klass);
+ testClass = klass;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.junit.runners.BlockJUnit4ClassRunner#testName(org.junit.runners.model
+ * .FrameworkMethod)
+ */
+ @Override
+ protected String testName(FrameworkMethod method) {
+ if (AbstractIntegrationTestTB3.class.isAssignableFrom(testClass)) {
+ return System.getProperty("server-name");
+ } else {
+ return super.testName(method);
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
new file mode 100644
index 0000000000..20ddac9dd1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
@@ -0,0 +1,35 @@
+/*
+ * 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.integration;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.shared.ui.ui.Transport;
+
+/**
+ * Server test which uses streaming
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+@Push(transport = Transport.STREAMING)
+public class IntegrationTestStreaming extends IntegrationTestUI {
+
+ public static class IntegrationTestStreamingTB3 extends
+ ServletIntegrationTestTB3 {
+ // Uses the test method declared in the super class
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
index 0e6cb19b30..3d0a338bba 100755
--- a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
+++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
@@ -12,6 +12,11 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
public class IntegrationTestUI extends UI {
+
+ public class IntegrationTestXhrTB3 extends ServletIntegrationTestTB3 {
+ // Uses the test method declared in the super class
+ }
+
@Override
protected void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java
new file mode 100644
index 0000000000..eaa23de3cf
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.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.integration;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
+
+/**
+ * Server test which uses websockets
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+@Push(transport = Transport.WEBSOCKET)
+public class IntegrationTestWebsocket extends IntegrationTestUI {
+
+ public class IntegrationTestWebsocketTB3 extends ServletIntegrationTestTB3 {
+ // Uses the test method declared in the super class
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.tests.integration.IntegrationTestUI#init(com.vaadin.server
+ * .VaadinRequest)
+ */
+ @Override
+ protected void init(VaadinRequest request) {
+ super.init(request);
+ // Ensure no fallback is used
+ getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
new file mode 100644
index 0000000000..ae83083d85
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
@@ -0,0 +1,62 @@
+/*
+ * 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.integration;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+/**
+ * Base class for servlet integration tests. Automatically prepends "/demo" to
+ * the deployment path
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class ServletIntegrationTestTB3 extends
+ AbstractIntegrationTestTB3 {
+
+ @Test
+ public void runTest() throws IOException, AssertionError {
+ compareScreen("initial");
+
+ WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1));
+ testBenchElement(cell).click(51, 13);
+
+ compareScreen("finland");
+ }
+
+ private String getTableCell(String tableLocator, int row, int col) {
+ return tableLocator
+ + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild["
+ + row + "]/domChild[" + col + "]/domChild[0]";
+ }
+
+ protected String getTable() {
+ return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#getDeploymentPath()
+ */
+ @Override
+ protected String getDeploymentPath() {
+ return "/demo" + super.getDeploymentPath();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 966be1a692..b3520e5326 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -364,7 +364,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return an object describing the capabilities required for running a
* test on the given Safari version
*/
- protected static DesiredCapabilities safari(int version) {
+ public static DesiredCapabilities safari(int version) {
DesiredCapabilities c = DesiredCapabilities.safari();
c.setVersion("" + version);
return c;
@@ -378,7 +378,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return an object describing the capabilities required for running a
* test on the given Chrome version
*/
- protected static DesiredCapabilities chrome(int version) {
+ public static DesiredCapabilities chrome(int version) {
DesiredCapabilities c = DesiredCapabilities.chrome();
c.setVersion("" + version);
c.setPlatform(Platform.XP);
@@ -393,7 +393,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return an object describing the capabilities required for running a
* test on the given Opera version
*/
- protected static DesiredCapabilities opera(int version) {
+ public static DesiredCapabilities opera(int version) {
DesiredCapabilities c = DesiredCapabilities.opera();
c.setVersion("" + version);
c.setPlatform(Platform.XP);
@@ -408,7 +408,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return an object describing the capabilities required for running a
* test on the given Firefox version
*/
- protected static DesiredCapabilities firefox(int version) {
+ public static DesiredCapabilities firefox(int version) {
DesiredCapabilities c = DesiredCapabilities.firefox();
c.setVersion("" + version);
c.setPlatform(Platform.XP);
@@ -423,7 +423,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return an object describing the capabilities required for running a
* test on the given Internet Explorer version
*/
- protected static DesiredCapabilities ie(int version) {
+ public static DesiredCapabilities ie(int version) {
DesiredCapabilities c = DesiredCapabilities.internetExplorer();
c.setVersion("" + version);
return c;
diff --git a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
new file mode 100644
index 0000000000..d2aa413749
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tb3;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.model.InitializationError;
+
+import com.vaadin.tests.integration.ServletIntegrationTestTB3;
+import com.vaadin.tests.tb3.ServletIntegrationTests.ServletIntegrationTestSuite;
+
+@RunWith(ServletIntegrationTestSuite.class)
+public class ServletIntegrationTests {
+
+ public static class ServletIntegrationTestSuite extends TB3TestSuite {
+ public ServletIntegrationTestSuite(Class> klass)
+ throws InitializationError {
+ super(klass, ServletIntegrationTestTB3.class,
+ "com.vaadin.tests.integration", new String[] {});
+ }
+ }
+}
--
cgit v1.2.3
From 21af0c343180acf008b3a04b8997ff67292e9d9f Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 23 Sep 2013 20:15:54 +0300
Subject: Updated TB3 tests to use Firefox 24 (#12604)
Change-Id: I738e5e3aca7b5332ced2179593f304c6d375b0f1
---
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
index 5a1d07c0c0..b278ef2c40 100644
--- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -50,7 +50,7 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
allBrowsers.add(BrowserUtil.ie(8));
allBrowsers.add(BrowserUtil.ie(9));
allBrowsers.add(BrowserUtil.ie(10));
- allBrowsers.add(BrowserUtil.firefox(17));
+ allBrowsers.add(BrowserUtil.firefox(24));
// Uncomment once we have the capability to run on Safari 6
// allBrowsers.add(safari(6));
allBrowsers.add(BrowserUtil.chrome(29));
--
cgit v1.2.3
From a7583c616e3365d698da99ef1cd66de34e2954b2 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 23 Sep 2013 19:57:08 +0300
Subject: TB3 test for browsers (#12572)
Change-Id: I1011aed7b3a7f4a339199be4e598b02b27500307
---
.../src/com/vaadin/tests/VerifyBrowserVersion.java | 54 ++++++++++++++++++++--
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 1 -
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
index 022a343196..59663a78d6 100644
--- a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
@@ -1,17 +1,65 @@
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 expectedUserAgent = new HashMap();
+
+ {
+ 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.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() {
+ Assert.assertEquals(
+ expectedUserAgent.get(getDesiredCapabilities()),
+ vaadinElementById("userAgent").getText());
+ Assert.assertEquals("Touch device? No",
+ vaadinElementById("touchDevice").getText());
+ }
+ }
+
@Override
protected void setup() {
WebBrowser browser = getBrowser();
- addComponent(new Label(browser.getBrowserApplication()));
- addComponent(new Label("Touch device? "
- + (browser.isTouchDevice() ? "YES" : "No")));
+ Label userAgent = new Label(browser.getBrowserApplication());
+ userAgent.setId("userAgent");
+ addComponent(userAgent);
+ Label touchDevice = new Label("Touch device? "
+ + (browser.isTouchDevice() ? "YES" : "No"));
+ touchDevice.setId("touchDevice");
+ addComponent(touchDevice);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index b3520e5326..63819e5f07 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -16,7 +16,6 @@
package com.vaadin.tests.tb3;
-import java.net.MalformedURLException;
import java.net.URL;
import org.junit.After;
--
cgit v1.2.3
From 37b85436cafede61f4b4f1e0b50e00c4c2295b4c Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 24 Sep 2013 13:36:03 +0300
Subject: Do not add empty package javadoc for new classes
Change-Id: I5b040806acaae3e94d2eb8c7ea78f9414d964564
---
.settings/org.eclipse.jdt.ui.prefs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index 31240a63bd..4f3b6f7ed3 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -3,7 +3,7 @@ editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Vaadin Java Conventions 20110923
formatter_settings_version=12
org.eclipse.jdt.ui.javadoc=true
-org.eclipse.jdt.ui.text.custom_code_templates=/**\n * @return the ${bare_field_name}\n */ /**\n * @param ${param} the ${bare_field_name} to set\n */ /**\n * ${tags}\n */ /**\n * \n */ /**\n * \n * @since \n * @author Vaadin Ltd\n * ${tags}\n */ /**\n * \n */ /**\n * @since\n * ${tags}\n */ /* (non-Javadoc)\n * ${see_to_overridden}\n */ /**\n * ${tags}\n * ${see_to_target}\n */ /*\n * Copyright 2000-2013 Vaadin Ltd.\n * \n * Licensed under the Apache License, Version 2.0 (the "License"); you may not\n * use this file except in compliance with the License. You may obtain a copy of\n * the License at\n * \n * http\://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration} \n \n \n \n // ${todo} Auto-generated catch block\n${exception_var}.printStackTrace(); // ${todo} Auto-generated method stub\n${body_statement} ${body_statement}\n// ${todo} Auto-generated constructor stub return ${field}; ${field} \= ${param};
+org.eclipse.jdt.ui.text.custom_code_templates=/**\n * @return the ${bare_field_name}\n */ /**\n * @param ${param} the ${bare_field_name} to set\n */ /**\n * ${tags}\n */ /**\n * \n */ /**\n * \n * @since \n * @author Vaadin Ltd\n * ${tags}\n */ /**\n * \n */ /**\n * @since\n * ${tags}\n */ /* (non-Javadoc)\n * ${see_to_overridden}\n */ /**\n * ${tags}\n * ${see_to_target}\n */ /*\n * Copyright 2000-2013 Vaadin Ltd.\n * \n * Licensed under the Apache License, Version 2.0 (the "License"); you may not\n * use this file except in compliance with the License. You may obtain a copy of\n * the License at\n * \n * http\://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations under\n * the License.\n */\n${package_declaration}\n\n${typecomment}\n${type_declaration} \n \n \n \n // ${todo} Auto-generated catch block\n${exception_var}.printStackTrace(); // ${todo} Auto-generated method stub\n${body_statement} ${body_statement}\n// ${todo} Auto-generated constructor stub return ${field}; ${field} \= ${param};
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
--
cgit v1.2.3
From 0248b8f7ba0817cc1dbf8bae431544803602cb08 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 24 Sep 2013 11:36:18 +0300
Subject: Fixes browser detection for IE11 (#12638)
Change-Id: I1f71477368ce42eac3679f7f2f9e87fe8e02e4de
---
.../client/TestVBrowserDetailsUserAgentParser.java | 28 ++++++++++++++++
shared/src/com/vaadin/shared/VBrowserDetails.java | 38 ++++++++++++++++++----
2 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
index 7d5911f5a0..5b428574e2 100644
--- a/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
+++ b/client/tests/src/com/vaadin/client/TestVBrowserDetailsUserAgentParser.java
@@ -27,6 +27,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
private static final String IE9_BETA_WINDOWS_7 = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
private static final String IE10_WINDOWS_8 = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
+ private static final String IE11_WINDOWS_7 = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; rv:11.0) like Gecko";
// "Version/" was added in 10.00
private static final String OPERA964_WINDOWS = "Opera/9.64(Windows NT 5.1; U; en) Presto/2.1.1";
@@ -314,6 +315,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE8() {
VBrowserDetails bd = new VBrowserDetails(IE8_WINDOWS);
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
@@ -325,6 +327,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
VBrowserDetails bd = new VBrowserDetails(IE8_IN_IE7_MODE_WINDOWS);
bd.setIEMode(7);
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
@@ -335,6 +338,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE9() {
VBrowserDetails bd = new VBrowserDetails(IE9_BETA_WINDOWS_7);
+ assertTrident(bd);
assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 9);
@@ -346,6 +350,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
VBrowserDetails bd = new VBrowserDetails(IE9_IN_IE7_MODE_WINDOWS_7);
// bd.setIE8InCompatibilityMode();
+ assertTrident(bd);
assertEngineVersion(bd, 5);
assertIE(bd);
assertBrowserMajorVersion(bd, 7);
@@ -362,6 +367,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
* Trident/4.0 in example user agent string based on beta even though it
* should be Trident/5.0 in real (non-beta) user agent strings
*/
+ assertTrident(bd);
assertEngineVersion(bd, 4);
assertIE(bd);
assertBrowserMajorVersion(bd, 8);
@@ -372,6 +378,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
public void testIE10() {
VBrowserDetails bd = new VBrowserDetails(IE10_WINDOWS_8);
+ assertTrident(bd);
assertEngineVersion(bd, 6);
assertIE(bd);
assertBrowserMajorVersion(bd, 10);
@@ -379,6 +386,16 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
assertWindows(bd);
}
+ public void testIE11() {
+ VBrowserDetails bd = new VBrowserDetails(IE11_WINDOWS_7);
+ assertTrident(bd);
+ assertEngineVersion(bd, 7);
+ assertIE(bd);
+ assertBrowserMajorVersion(bd, 11);
+ assertBrowserMinorVersion(bd, 0);
+ assertWindows(bd);
+ }
+
/*
* Helper methods below
*/
@@ -406,6 +423,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
assertTrue(browserDetails.isGecko());
assertFalse(browserDetails.isWebKit());
assertFalse(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
}
private void assertPresto(VBrowserDetails browserDetails) {
@@ -413,6 +431,15 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
assertFalse(browserDetails.isGecko());
assertFalse(browserDetails.isWebKit());
assertTrue(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
+ }
+
+ private void assertTrident(VBrowserDetails browserDetails) {
+ // Engine
+ assertFalse(browserDetails.isGecko());
+ assertFalse(browserDetails.isWebKit());
+ assertFalse(browserDetails.isPresto());
+ assertTrue(browserDetails.isTrident());
}
private void assertWebKit(VBrowserDetails browserDetails) {
@@ -420,6 +447,7 @@ public class TestVBrowserDetailsUserAgentParser extends TestCase {
assertFalse(browserDetails.isGecko());
assertTrue(browserDetails.isWebKit());
assertFalse(browserDetails.isPresto());
+ assertFalse(browserDetails.isTrident());
}
private void assertFirefox(VBrowserDetails browserDetails) {
diff --git a/shared/src/com/vaadin/shared/VBrowserDetails.java b/shared/src/com/vaadin/shared/VBrowserDetails.java
index f31f5f3c04..a745a212b0 100644
--- a/shared/src/com/vaadin/shared/VBrowserDetails.java
+++ b/shared/src/com/vaadin/shared/VBrowserDetails.java
@@ -31,6 +31,7 @@ public class VBrowserDetails implements Serializable {
private boolean isGecko = false;
private boolean isWebKit = false;
private boolean isPresto = false;
+ private boolean isTrident = false;
private boolean isChromeFrameCapable = false;
private boolean isChromeFrame = false;
@@ -65,9 +66,11 @@ public class VBrowserDetails implements Serializable {
// browser engine name
isGecko = userAgent.indexOf("gecko") != -1
- && userAgent.indexOf("webkit") == -1;
+ && userAgent.indexOf("webkit") == -1
+ && userAgent.indexOf("trident/") == -1;
isWebKit = userAgent.indexOf("applewebkit") != -1;
isPresto = userAgent.indexOf(" presto/") != -1;
+ isTrident = userAgent.indexOf("trident/") != -1;
// browser name
isChrome = userAgent.indexOf(" chrome/") != -1;
@@ -75,6 +78,9 @@ public class VBrowserDetails implements Serializable {
isOpera = userAgent.indexOf("opera") != -1;
isIE = userAgent.indexOf("msie") != -1 && !isOpera
&& (userAgent.indexOf("webtv") == -1);
+ // IE 11 no longer contains MSIE in the user agent
+ isIE = isIE || isTrident;
+
isFirefox = userAgent.indexOf(" firefox/") != -1;
// chromeframe
@@ -113,11 +119,21 @@ public class VBrowserDetails implements Serializable {
// Browser version
try {
if (isIE) {
- String ieVersionString = userAgent.substring(userAgent
- .indexOf("msie ") + 5);
- ieVersionString = safeSubstring(ieVersionString, 0,
- ieVersionString.indexOf(";"));
- parseVersionString(ieVersionString);
+ if (userAgent.indexOf("msie") == -1) {
+ // IE 11+
+ int rvPos = userAgent.indexOf("rv:");
+ if (rvPos >= 0) {
+ String tmp = userAgent.substring(rvPos + 3);
+ tmp = tmp.replaceFirst("(\\.[0-9]+).+", "$1");
+ parseVersionString(tmp);
+ }
+ } else {
+ String ieVersionString = userAgent.substring(userAgent
+ .indexOf("msie ") + 5);
+ ieVersionString = safeSubstring(ieVersionString, 0,
+ ieVersionString.indexOf(";"));
+ parseVersionString(ieVersionString);
+ }
} else if (isFirefox) {
int i = userAgent.indexOf(" firefox/") + 9;
parseVersionString(safeSubstring(userAgent, i, i + 5));
@@ -287,6 +303,16 @@ public class VBrowserDetails implements Serializable {
return isPresto;
}
+ /**
+ * Tests if the browser is using the Trident engine
+ *
+ * @since 7.1.7
+ * @return true if it is Trident, false otherwise
+ */
+ public boolean isTrident() {
+ return isTrident;
+ }
+
/**
* Tests if the browser is Safari.
*
--
cgit v1.2.3
From 1df28c314141d7531591ff9c5ee1ab3521f29e8c Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 25 Sep 2013 12:57:48 +0300
Subject: Run TB3 tests also on IE11 (#12631)
Change-Id: I1ae0f8618e69ba61bb946cde18c2936b751f3a5f
---
uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
index b278ef2c40..e24218eeb4 100644
--- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -50,6 +50,7 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
allBrowsers.add(BrowserUtil.ie(8));
allBrowsers.add(BrowserUtil.ie(9));
allBrowsers.add(BrowserUtil.ie(10));
+ allBrowsers.add(BrowserUtil.ie(11));
allBrowsers.add(BrowserUtil.firefox(24));
// Uncomment once we have the capability to run on Safari 6
// allBrowsers.add(safari(6));
--
cgit v1.2.3
From a2daf65958c602dd02099bf4415e7e432b706dc7 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 16 Sep 2013 14:44:43 +0300
Subject: Converted TB2 push tests to TB3 (#12580)
Change-Id: Ifd6286aee75946eb47c39886c08473a5a0c10545
---
.../com/vaadin/tests/components/ui/UIAccess.java | 392 +++++++++++++++++++++
.../com/vaadin/tests/components/ui/UiAccess.java | 361 -------------------
.../vaadin/tests/components/ui/UiAccessPush.html | 41 ---
uitest/src/com/vaadin/tests/push/BarInUIDL.html | 42 ---
uitest/src/com/vaadin/tests/push/BarInUIDL.java | 30 ++
uitest/src/com/vaadin/tests/push/BasicPush.html | 88 -----
uitest/src/com/vaadin/tests/push/BasicPush.java | 136 ++++++-
.../com/vaadin/tests/push/BasicPushStreaming.java | 34 +-
.../com/vaadin/tests/push/BasicPushWebsocket.java | 36 ++
.../com/vaadin/tests/push/PushConfiguration.html | 130 -------
.../vaadin/tests/push/PushConfigurationTest.java | 113 ++++++
uitest/src/com/vaadin/tests/push/PushFromInit.html | 32 --
uitest/src/com/vaadin/tests/push/PushFromInit.java | 46 +++
.../vaadin/tests/push/PushReattachedComponent.html | 47 ---
.../vaadin/tests/push/PushReattachedComponent.java | 65 ++++
.../vaadin/tests/push/PushTransportAnnotation.html | 46 ---
.../src/com/vaadin/tests/push/StreamingPush.html | 88 -----
uitest/src/com/vaadin/tests/push/TogglePush.html | 91 -----
uitest/src/com/vaadin/tests/push/TogglePush.java | 154 ++++++++
.../com/vaadin/tests/push/TogglePushInInit.html | 69 ----
.../tests/push/TrackMessageSizeUnitTests.html | 26 --
.../tests/push/TrackMessageSizeUnitTests.java | 11 +
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 91 ++++-
.../src/com/vaadin/tests/tb3/MultiBrowserTest.java | 31 +-
uitest/src/com/vaadin/tests/tb3/TB3Runner.java | 51 +--
uitest/src/com/vaadin/tests/tb3/WebsocketTest.java | 60 ++++
26 files changed, 1159 insertions(+), 1152 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/ui/UIAccess.java
delete mode 100644 uitest/src/com/vaadin/tests/components/ui/UiAccess.java
delete mode 100644 uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html
delete mode 100644 uitest/src/com/vaadin/tests/push/BarInUIDL.html
delete mode 100644 uitest/src/com/vaadin/tests/push/BasicPush.html
delete mode 100644 uitest/src/com/vaadin/tests/push/PushConfiguration.html
delete mode 100644 uitest/src/com/vaadin/tests/push/PushFromInit.html
delete mode 100644 uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
create mode 100644 uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
delete mode 100644 uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
delete mode 100644 uitest/src/com/vaadin/tests/push/StreamingPush.html
delete mode 100644 uitest/src/com/vaadin/tests/push/TogglePush.html
delete mode 100644 uitest/src/com/vaadin/tests/push/TogglePushInInit.html
delete mode 100644 uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
create mode 100644 uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
new file mode 100644
index 0000000000..057dcaa917
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
@@ -0,0 +1,392 @@
+/*
+ * 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 java.util.concurrent.CountDownLatch;
+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;
+import com.vaadin.util.CurrentInstance;
+
+public class UIAccess extends AbstractTestUIWithLog {
+
+ public static class UIAccessTest extends MultiBrowserTest {
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ @Test
+ public void testThreadLocals() {
+ 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 checkFromBeforeClientResponse;
+
+ private class CurrentInstanceTestType {
+ private String value;
+
+ public CurrentInstanceTestType(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponent(new Button("Access from UI thread",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ // Ensure beforeClientResponse is invoked
+ markAsDirty();
+ checkFromBeforeClientResponse = access(new Runnable() {
+ @Override
+ public void run() {
+ log("Access from UI thread is run");
+ }
+ });
+ log("Access from UI thread future is done? "
+ + checkFromBeforeClientResponse.isDone());
+ }
+ }));
+ addComponent(new Button("Access from background thread",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ new Thread() {
+ @Override
+ public void run() {
+ final boolean threadHasCurrentResponse = VaadinService
+ .getCurrentResponse() != null;
+ // session is locked by request thread at this
+ // point
+ final Future initialFuture = access(new Runnable() {
+ @Override
+ public void run() {
+ log("Initial background message");
+ log("Thread has current response? "
+ + threadHasCurrentResponse);
+ }
+ });
+
+ // Let request thread continue
+ latch.countDown();
+
+ // Wait until thread can be locked
+ while (!getSession().getLockInstance()
+ .tryLock()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ try {
+ log("Thread got lock, inital future done? "
+ + initialFuture.isDone());
+ setPollInterval(-1);
+ } finally {
+ getSession().unlock();
+ }
+ }
+ }.start();
+
+ // Wait for thread to do initialize before continuing
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+
+ setPollInterval(3000);
+ }
+ }));
+ addComponent(new Button("Access throwing exception",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ final Future firstFuture = access(new Runnable() {
+ @Override
+ public void run() {
+ log("Throwing exception in access");
+ throw new RuntimeException(
+ "Catch me if you can");
+ }
+ });
+ access(new Runnable() {
+ @Override
+ public void run() {
+ log("firstFuture is done? "
+ + firstFuture.isDone());
+ try {
+ firstFuture.get();
+ log("Should not get here");
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } catch (ExecutionException e) {
+ log("Got exception from firstFuture: "
+ + e.getMessage());
+ }
+ }
+ });
+ }
+ }));
+ addComponent(new Button("Cancel future before started",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ Future future = access(new Runnable() {
+ @Override
+ public void run() {
+ log("Should not get here");
+ }
+ });
+ future.cancel(false);
+ log("future was cancled, should not start");
+ }
+ }));
+ addComponent(new Button("Cancel running future",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ final ReentrantLock interruptLock = new ReentrantLock();
+
+ final Future future = access(new Runnable() {
+ @Override
+ public void run() {
+ log("Waiting for thread to start");
+ while (!interruptLock.isLocked()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ log("Premature interruption");
+ throw new RuntimeException(e);
+ }
+ }
+
+ log("Thread started, waiting for interruption");
+ try {
+ interruptLock.lockInterruptibly();
+ } catch (InterruptedException e) {
+ log("I was interrupted");
+ }
+ }
+ });
+
+ new Thread() {
+ @Override
+ public void run() {
+ interruptLock.lock();
+ // Wait until UI thread has started waiting for
+ // the lock
+ while (!interruptLock.hasQueuedThreads()) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ future.cancel(true);
+ }
+ }.start();
+ }
+ }));
+ addComponent(new Button("CurrentInstance accessSynchronously values",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ // accessSynchronously should maintain values
+ CurrentInstance.set(CurrentInstanceTestType.class,
+ new CurrentInstanceTestType(
+ "Set before accessSynchronosly"));
+ accessSynchronously(new Runnable() {
+ @Override
+ public void run() {
+ log.log("accessSynchronously has request? "
+ + (VaadinService.getCurrentRequest() != null));
+ log.log("Test value in accessSynchronously: "
+ + CurrentInstance
+ .get(CurrentInstanceTestType.class));
+ CurrentInstance.set(
+ CurrentInstanceTestType.class,
+ new CurrentInstanceTestType(
+ "Set in accessSynchronosly"));
+ }
+ });
+ log.log("has request after accessSynchronously? "
+ + (VaadinService.getCurrentRequest() != null));
+ log("Test value after accessSynchornously: "
+ + CurrentInstance
+ .get(CurrentInstanceTestType.class));
+ }
+ }));
+ addComponent(new Button("CurrentInstance access values",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ // accessSynchronously should maintain values
+ CurrentInstance
+ .setInheritable(CurrentInstanceTestType.class,
+ new CurrentInstanceTestType(
+ "Set before access"));
+ access(new Runnable() {
+ @Override
+ public void run() {
+ log.log("access has request? "
+ + (VaadinService.getCurrentRequest() != null));
+ log.log("Test value in access: "
+ + CurrentInstance
+ .get(CurrentInstanceTestType.class));
+ CurrentInstance.setInheritable(
+ CurrentInstanceTestType.class,
+ new CurrentInstanceTestType(
+ "Set in access"));
+ }
+ });
+ CurrentInstance.setInheritable(
+ CurrentInstanceTestType.class,
+ new CurrentInstanceTestType(
+ "Set before run pending"));
+
+ getSession().getService().runPendingAccessTasks(
+ getSession());
+
+ log.log("has request after access? "
+ + (VaadinService.getCurrentRequest() != null));
+ log("Test value after access: "
+ + CurrentInstance
+ .get(CurrentInstanceTestType.class));
+ }
+ }));
+
+ addComponent(new Button("CurrentInstance when pushing",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.clear();
+ if (getPushConfiguration().getPushMode() != PushMode.AUTOMATIC) {
+ log("Can only test with automatic push enabled");
+ return;
+ }
+
+ final VaadinSession session = getSession();
+ new Thread() {
+ @Override
+ public void run() {
+ // Pretend this isn't a Vaadin thread
+ CurrentInstance.clearAll();
+
+ /*
+ * Get explicit lock to ensure the (implicit)
+ * push does not happen during normal request
+ * handling.
+ */
+ session.lock();
+ try {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ checkCurrentInstancesBeforeResponse = true;
+ // Trigger beforeClientResponse
+ markAsDirty();
+ }
+ });
+ } finally {
+ session.unlock();
+ }
+ }
+ }.start();
+ }
+ }));
+ }
+
+ @Override
+ public void beforeClientResponse(boolean initial) {
+ if (checkFromBeforeClientResponse != null) {
+ log("beforeClientResponse future is done? "
+ + checkFromBeforeClientResponse.isDone());
+ checkFromBeforeClientResponse = null;
+ }
+ if (checkCurrentInstancesBeforeResponse) {
+ UI currentUI = UI.getCurrent();
+ VaadinSession currentSession = VaadinSession.getCurrent();
+
+ log("Current UI matches in beforeResponse? " + (currentUI == this));
+ log("Current session matches in beforeResponse? "
+ + (currentSession == getSession()));
+ checkCurrentInstancesBeforeResponse = false;
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test for various ways of using UI.access";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(11897);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java b/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
deleted file mode 100644
index 09f2fd8816..0000000000
--- a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * 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 java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.locks.ReentrantLock;
-
-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.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.UI;
-import com.vaadin.util.CurrentInstance;
-
-public class UiAccess extends AbstractTestUIWithLog {
-
- private volatile boolean checkCurrentInstancesBeforeResponse = false;
-
- private Future checkFromBeforeClientResponse;
-
- private class CurrentInstanceTestType {
- private String value;
-
- public CurrentInstanceTestType(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return value;
- }
- }
-
- @Override
- protected void setup(VaadinRequest request) {
- addComponent(new Button("Access from UI thread",
- new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- // Ensure beforeClientResponse is invoked
- markAsDirty();
- checkFromBeforeClientResponse = access(new Runnable() {
- @Override
- public void run() {
- log("Access from UI thread is run");
- }
- });
- log("Access from UI thread future is done? "
- + checkFromBeforeClientResponse.isDone());
- }
- }));
- addComponent(new Button("Access from background thread",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- final CountDownLatch latch = new CountDownLatch(1);
-
- new Thread() {
- @Override
- public void run() {
- final boolean threadHasCurrentResponse = VaadinService
- .getCurrentResponse() != null;
- // session is locked by request thread at this
- // point
- final Future initialFuture = access(new Runnable() {
- @Override
- public void run() {
- log("Initial background message");
- log("Thread has current response? "
- + threadHasCurrentResponse);
- }
- });
-
- // Let request thread continue
- latch.countDown();
-
- // Wait until thread can be locked
- while (!getSession().getLockInstance()
- .tryLock()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- try {
- log("Thread got lock, inital future done? "
- + initialFuture.isDone());
- setPollInterval(-1);
- } finally {
- getSession().unlock();
- }
- }
- }.start();
-
- // Wait for thread to do initialize before continuing
- try {
- latch.await();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
-
- setPollInterval(3000);
- }
- }));
- addComponent(new Button("Access throwing exception",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- final Future firstFuture = access(new Runnable() {
- @Override
- public void run() {
- log("Throwing exception in access");
- throw new RuntimeException(
- "Catch me if you can");
- }
- });
- access(new Runnable() {
- @Override
- public void run() {
- log("firstFuture is done? "
- + firstFuture.isDone());
- try {
- firstFuture.get();
- log("Should not get here");
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- } catch (ExecutionException e) {
- log("Got exception from firstFuture: "
- + e.getMessage());
- }
- }
- });
- }
- }));
- addComponent(new Button("Cancel future before started",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- Future future = access(new Runnable() {
- @Override
- public void run() {
- log("Should not get here");
- }
- });
- future.cancel(false);
- log("future was cancled, should not start");
- }
- }));
- addComponent(new Button("Cancel running future",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- final ReentrantLock interruptLock = new ReentrantLock();
-
- final Future future = access(new Runnable() {
- @Override
- public void run() {
- log("Waiting for thread to start");
- while (!interruptLock.isLocked()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- log("Premature interruption");
- throw new RuntimeException(e);
- }
- }
-
- log("Thread started, waiting for interruption");
- try {
- interruptLock.lockInterruptibly();
- } catch (InterruptedException e) {
- log("I was interrupted");
- }
- }
- });
-
- new Thread() {
- @Override
- public void run() {
- interruptLock.lock();
- // Wait until UI thread has started waiting for
- // the lock
- while (!interruptLock.hasQueuedThreads()) {
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- future.cancel(true);
- }
- }.start();
- }
- }));
- addComponent(new Button("CurrentInstance accessSynchronously values",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- // accessSynchronously should maintain values
- CurrentInstance.set(CurrentInstanceTestType.class,
- new CurrentInstanceTestType(
- "Set before accessSynchronosly"));
- accessSynchronously(new Runnable() {
- @Override
- public void run() {
- log.log("accessSynchronously has request? "
- + (VaadinService.getCurrentRequest() != null));
- log.log("Test value in accessSynchronously: "
- + CurrentInstance
- .get(CurrentInstanceTestType.class));
- CurrentInstance.set(
- CurrentInstanceTestType.class,
- new CurrentInstanceTestType(
- "Set in accessSynchronosly"));
- }
- });
- log.log("has request after accessSynchronously? "
- + (VaadinService.getCurrentRequest() != null));
- log("Test value after accessSynchornously: "
- + CurrentInstance
- .get(CurrentInstanceTestType.class));
- }
- }));
- addComponent(new Button("CurrentInstance access values",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- // accessSynchronously should maintain values
- CurrentInstance
- .setInheritable(CurrentInstanceTestType.class,
- new CurrentInstanceTestType(
- "Set before access"));
- access(new Runnable() {
- @Override
- public void run() {
- log.log("access has request? "
- + (VaadinService.getCurrentRequest() != null));
- log.log("Test value in access: "
- + CurrentInstance
- .get(CurrentInstanceTestType.class));
- CurrentInstance.setInheritable(
- CurrentInstanceTestType.class,
- new CurrentInstanceTestType(
- "Set in access"));
- }
- });
- CurrentInstance.setInheritable(
- CurrentInstanceTestType.class,
- new CurrentInstanceTestType(
- "Set before run pending"));
-
- getSession().getService().runPendingAccessTasks(
- getSession());
-
- log.log("has request after access? "
- + (VaadinService.getCurrentRequest() != null));
- log("Test value after access: "
- + CurrentInstance
- .get(CurrentInstanceTestType.class));
- }
- }));
-
- addComponent(new Button("CurrentInstance when pushing",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- log.clear();
- if (getPushConfiguration().getPushMode() != PushMode.AUTOMATIC) {
- log("Can only test with automatic push enabled");
- return;
- }
-
- final VaadinSession session = getSession();
- new Thread() {
- @Override
- public void run() {
- // Pretend this isn't a Vaadin thread
- CurrentInstance.clearAll();
-
- /*
- * Get explicit lock to ensure the (implicit)
- * push does not happen during normal request
- * handling.
- */
- session.lock();
- try {
- access(new Runnable() {
- @Override
- public void run() {
- checkCurrentInstancesBeforeResponse = true;
- // Trigger beforeClientResponse
- markAsDirty();
- }
- });
- } finally {
- session.unlock();
- }
- }
- }.start();
- }
- }));
- }
-
- @Override
- public void beforeClientResponse(boolean initial) {
- if (checkFromBeforeClientResponse != null) {
- log("beforeClientResponse future is done? "
- + checkFromBeforeClientResponse.isDone());
- checkFromBeforeClientResponse = null;
- }
- if (checkCurrentInstancesBeforeResponse) {
- UI currentUI = UI.getCurrent();
- VaadinSession currentSession = VaadinSession.getCurrent();
-
- log("Current UI matches in beforeResponse? " + (currentUI == this));
- log("Current session matches in beforeResponse? "
- + (currentSession == getSession()));
- checkCurrentInstancesBeforeResponse = false;
- }
- }
-
- @Override
- protected String getTestDescription() {
- return "Test for various ways of using UI.access";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return Integer.valueOf(11897);
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html b/uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html
deleted file mode 100644
index bc29534ee4..0000000000
--- a/uitest/src/com/vaadin/tests/components/ui/UiAccessPush.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run/com.vaadin.tests.components.ui.UiAccess?restartApplication&transport=websocket
-
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- waitForNotText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- exact:1. Current session matches in beforeResponse? true
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- exact:0. Current UI matches in beforeResponse? true
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.html b/uitest/src/com/vaadin/tests/push/BarInUIDL.html
deleted file mode 100644
index 66f03158b6..0000000000
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.html
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.push.BarInUIDL?restartApplication
-
-
-
- click
- vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- Thank you for clicking | bar
-
-
- click
- vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]
- Thank you for clicking | bar
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index 7e414cc89d..ef2568bebe 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -16,14 +16,44 @@
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;
+@Push(transport = Transport.STREAMING)
public class BarInUIDL extends AbstractTestUI {
+ public static class BarInUIDLTest extends MultiBrowserTest {
+ @Test
+ public void sendBarInUIDL() {
+ 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/BasicPush.html b/uitest/src/com/vaadin/tests/push/BasicPush.html
deleted file mode 100644
index 173ec90674..0000000000
--- a/uitest/src/com/vaadin/tests/push/BasicPush.html
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 0
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 1
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 4
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 0
-
-
- pause
- 3000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 1
-
-
- pause
- 3000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 2
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java
index b80d287a1d..1f184863f7 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPush.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPush.java
@@ -1,40 +1,115 @@
+/*
+ * 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.annotations.Widgetset;
+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.widgetset.TestingWidgetSet;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
-@Widgetset(TestingWidgetSet.NAME)
+@Push
public class BasicPush extends AbstractTestUI {
+ public static abstract class BasicPushTest extends MultiBrowserTest {
+
+ @Test
+ public void testPush() {
+ // 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 counter = new ObjectProperty(0);
private ObjectProperty counter2 = new ObjectProperty(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);
- }
- });
- }
- };
+ private TimerTask task;
@Override
protected void setup(VaadinRequest request) {
@@ -65,11 +140,37 @@ public class BasicPush extends AbstractTestUI {
lbl.setCaption("Server counter (updates each 3s by server thread) :");
addComponent(lbl);
- addComponent(new Button("Reset", new Button.ClickListener() {
+ addComponent(new Button("Start timer", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
counter2.setValue(0);
+ if (task != null) {
+ task.cancel();
+ }
+ task = new TimerTask() {
+
+ @Override
+ public void run() {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ counter2.setValue(counter2.getValue() + 1);
+ }
+ });
+ }
+ };
+ timer.scheduleAtFixedRate(task, 3000, 3000);
+ }
+ }));
+
+ addComponent(new Button("Stop timer", new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (task != null) {
+ task.cancel();
+ task = null;
+ }
}
}));
}
@@ -94,7 +195,6 @@ public class BasicPush extends AbstractTestUI {
@Override
public void attach() {
super.attach();
- timer.scheduleAtFixedRate(task, new Date(), 3000);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
index 37a8afd819..29534e1f5c 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
@@ -1,12 +1,42 @@
+/*
+ * 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.Test;
+
import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
@Push(transport = Transport.STREAMING)
public class BasicPushStreaming extends BasicPush {
@Override
- protected void setup(com.vaadin.server.VaadinRequest request) {
- addComponent(new PushConfigurator(this));
+ public void init(VaadinRequest request) {
+ super.init(request);
+ // Don't use fallback so we can easier detect if streaming fails
+ getPushConfiguration().setFallbackTransport(Transport.STREAMING);
+
}
+
+ public static class BasicPushStreamingTest extends BasicPushTest {
+ @Override
+ @Test
+ public void testPush() {
+ super.testPush();
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
index 6fc27e8974..4765183fca 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java
@@ -1,8 +1,44 @@
+/*
+ * 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.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 {
+
+ @Override
+ public void init(VaadinRequest request) {
+ super.init(request);
+ // Don't use fallback so we can easier detect if websocket fails
+ getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+ }
+
+ public static class BasicPushWebsocketTest extends BasicPushTest {
+ @Override
+ public Collection getBrowsersToTest() {
+ return WebsocketTest.getWebsocketBrowsers();
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.html b/uitest/src/com/vaadin/tests/push/PushConfiguration.html
deleted file mode 100644
index c3786b1cc1..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushConfiguration.html
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
-
- open
- /run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication
-
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]
- label=WEBSOCKET
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]
- label=AUTOMATIC
-
-
- assertText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]
- *fallbackTransport: streaming*transport: websocket*
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- waitForText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
-
- assertTextPresent
- Push connection established using websocket
-
-
-
- assertTextNotPresent
- Push connection established using streaming
- Push connection established using streaming
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]
- label=DISABLED
-
-
-
- open
- /run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication
-
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]
- label=STREAMING
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]
- label=AUTOMATIC
-
-
- assertNotText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
- assertText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]
- *fallbackTransport: streaming*transport: streaming*
-
-
- waitForText
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]
- 4
-
-
-
- assertTextNotPresent
- Push connection established using websocket
-
-
-
- assertTextPresent
- Push connection established using streaming
-
-
-
- select
- vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]
- label=DISABLED
-
-
-
-
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 counter = new ObjectProperty(0);
private ObjectProperty counter2 = new ObjectProperty(0);
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.html b/uitest/src/com/vaadin/tests/push/PushFromInit.html
deleted file mode 100644
index d009eb3baf..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.push.PushFromInit?debug&restartApplication
-
-
-
- waitForText
- vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_1
- 1. Logged in init
-
-
- assertText
- vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_0
- 2. Logged from background thread started in init
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java
index 4b442de499..000d5c0bce 100644
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.java
+++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java
@@ -1,11 +1,57 @@
+/*
+ * 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.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() {
+ 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/PushReattachedComponent.html b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
deleted file mode 100644
index e1f6a5f048..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.html
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.components.panel.PanelChangeContents?restartApplication
-
-
-
- assertText
- vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- stats
-
-
- click
- vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- companies
-
-
- click
- vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- stats
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
new file mode 100644
index 0000000000..35934273a4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
@@ -0,0 +1,65 @@
+/*
+ * 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.components.panel.PanelChangeContents;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PushReattachedComponent extends MultiBrowserTest {
+
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ @Override
+ protected Class> getUIClass() {
+ return PanelChangeContents.class;
+ }
+
+ @Test
+ public void testReattachComponentUsingPush() {
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "companies",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html b/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
deleted file mode 100644
index 854dd458bb..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushTransportAnnotation.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run/com.vaadin.tests.push.BasicPushStreaming?debug&restartApplication
-
-
-
- waitForTextPresent
- Push connection established using streaming
-
-
-
- assertTextNotPresent
- Push connection established using websocket
-
-
-
- open
- /run/com.vaadin.tests.push.BasicPushWebsocket?debug&restartApplication
-
-
-
- assertTextNotPresent
- Push connection established using streaming
-
-
-
- waitForTextPresent
- Push connection established using websocket
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/StreamingPush.html b/uitest/src/com/vaadin/tests/push/StreamingPush.html
deleted file mode 100644
index cf94a09c63..0000000000
--- a/uitest/src/com/vaadin/tests/push/StreamingPush.html
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug&transport=streaming
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 0
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 1
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]
- 4
-
-
-
- click
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 0
-
-
- pause
- 3000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 1
-
-
- pause
- 3000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]
- 2
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.html b/uitest/src/com/vaadin/tests/push/TogglePush.html
deleted file mode 100644
index b752d2120c..0000000000
--- a/uitest/src/com/vaadin/tests/push/TogglePush.html
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run-push/com.vaadin.tests.push.TogglePush?restartApplication
-
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- pause
- 2000
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 1 times
-
-
- mouseClick
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]
- 61,6
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- pause
- 2000
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 1 times
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 3 times
-
-
- mouseClick
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]
- 61,3
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- pause
- 2000
-
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 4 times
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java
index c0bdc54ee0..f59ef83fe7 100644
--- a/uitest/src/com/vaadin/tests/push/TogglePush.java
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.java
@@ -1,19 +1,173 @@
+/*
+ * 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.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 TogglePushInInitTB3 extends MultiBrowserTest {
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#getTestUrl()
+ */
+ @Override
+ protected String getTestUrl() {
+ return null;
+ }
+
+ @Test
+ public void togglePushInInit() {
+ String baseUrl = getBaseURL();
+ if (baseUrl.endsWith("/")) {
+ baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
+ }
+
+ String url = baseUrl + getDeploymentPath();
+
+ // 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());
+
+ }
+
+ /**
+ * @since
+ * @param url
+ * @param string
+ * @return
+ */
+ private String addParameter(String url, String queryParameter) {
+ if (url.contains("?")) {
+ return url + "&" + queryParameter;
+ } else {
+ return url + "?" + queryParameter;
+ }
+ }
+
+ private String getCounterText() {
+ return vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText();
+ }
+
+ 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]");
+ }
+
+ }
+
+ public static class TogglePushTB3 extends MultiBrowserTest {
+
+ @Override
+ protected boolean isPushEnabled() {
+ return true;
+ }
+
+ @Test
+ public void togglePush() {
+ 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 String getCounterText() {
+ return vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText();
+ }
+
+ private WebElement getDelayedCounterUpdateButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
+ }
+ }
+
private final Label counterLabel = new Label();
private int counter = 0;
diff --git a/uitest/src/com/vaadin/tests/push/TogglePushInInit.html b/uitest/src/com/vaadin/tests/push/TogglePushInInit.html
deleted file mode 100644
index c735f225e1..0000000000
--- a/uitest/src/com/vaadin/tests/push/TogglePushInInit.html
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-TogglePushInInit
-
-
-
-
-TogglePushInInit
-
-
-
- open
- /run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=disabled
-
-
-
- assertValue
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]
- off
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- pause
- 2000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 0 times
-
-
-
- open
- /run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=enabled
-
-
-
- assertValue
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]
- on
-
-
- click
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- pause
- 2000
-
-
-
- assertText
- vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]
- Counter has been updated 1 times
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
deleted file mode 100644
index 89dd7d4e78..0000000000
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run/com.vaadin.tests.push.TrackMessageSizeUnitTests?restartApplication
-
-
-
- assertText
- vaadin=runcomvaadintestspushTrackMessageSizeUnitTests::PID_SLog_row_0
- 1. All tests run
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
index 062698edf5..d7459f83ab 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
@@ -25,18 +25,29 @@ 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() {
+ Assert.assertEquals("1. All tests run",
+ vaadinElementById("Log_row_0").getText());
+ }
+ }
+
private String testMethod = "function testSequence(expected, data) {\n"
+ " var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
+ " var response = {partialMessage: ''};\n"
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 63819e5f07..1897728366 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -17,18 +17,24 @@
package com.vaadin.tests.tb3;
import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
import org.junit.After;
import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
import com.vaadin.server.LegacyApplication;
-import com.vaadin.testbench.By;
import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchTestCase;
import com.vaadin.ui.UI;
@@ -50,6 +56,7 @@ import com.vaadin.ui.UI;
*
* @author Vaadin Ltd
*/
+@RunWith(value = TB3Runner.class)
public abstract class AbstractTB3Test extends TestBenchTestCase {
/**
* Height of the screenshots we want to capture
@@ -153,6 +160,24 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
*/
protected abstract String getDeploymentHostname();
+ /**
+ * Produces a collection of browsers to run the test on. This method is
+ * executed by the test runner when determining how many test methods to
+ * invoke and with what parameters. For each returned value a test method is
+ * ran and before running that,
+ * {@link #setDesiredCapabilities(DesiredCapabilities)} is invoked with the
+ * value returned by this method.
+ *
+ * This method is not static to allow overriding it in sub classes. By
+ * default runs the test only on Firefox
+ *
+ * @return The browsers to run the test on
+ */
+ public Collection getBrowsersToTest() {
+ return Collections.singleton(BrowserUtil.firefox(17));
+
+ }
+
/**
* Used to determine which capabilities should be used when setting up a
* {@link WebDriver} for this test. Typically set by a test runner or left
@@ -189,9 +214,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
/**
- * Finds a Vaadin element based on the part of a TB3 style locator following
- * the :: (e.g.
- * vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
+ * Finds an element based on the part of a TB2 style locator following the
+ * :: (e.g. vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
* PID_Scheckboxaction-Enabled/domChild[0]).
*
* @param vaadinLocator
@@ -199,11 +223,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return
*/
protected WebElement vaadinElement(String vaadinLocator) {
- String base = getApplicationId(getDeploymentPath());
-
- base += "::";
-
- return driver.findElement(By.vaadin(base + vaadinLocator));
+ return driver.findElement(vaadinLocator(vaadinLocator));
}
/**
@@ -214,7 +234,58 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return
*/
public WebElement vaadinElementById(String id) {
- return vaadinElement("PID_S" + id);
+ return driver.findElement(vaadinLocatorById(id));
+ }
+
+ /**
+ * Finds a {@link By} locator based on the part of a TB2 style locator
+ * following the :: (e.g.
+ * vaadin=runLabelModes::PID_Scheckboxaction-Enabled/domChild[0] ->
+ * PID_Scheckboxaction-Enabled/domChild[0]).
+ *
+ * @param vaadinLocator
+ * The part following :: of the vaadin locator string
+ * @return
+ */
+ public org.openqa.selenium.By vaadinLocator(String vaadinLocator) {
+ String base = getApplicationId(getDeploymentPath());
+
+ base += "::";
+ return com.vaadin.testbench.By.vaadin(base + vaadinLocator);
+ }
+
+ /**
+ * Constructs a {@link By} locator for the id given using Component.setId
+ *
+ * @param id
+ * The id to locate
+ * @return a locator for the given id
+ */
+ public By vaadinLocatorById(String id) {
+ return vaadinLocator("PID_S" + id);
+ }
+
+ /**
+ * Waits a short while for the given condition to become true. Use e.g. as
+ * {@link #waitUntil(ExpectedConditions.textToBePresentInElement(by, text))}
+ *
+ * @param condition
+ * the condition to wait for to become true
+ */
+ protected void waitUntil(ExpectedCondition condition) {
+ new WebDriverWait(driver, 10).until(condition);
+ }
+
+ /**
+ * Waits a short while for the given condition to become false. Use e.g. as
+ * {@link #waitUntilNot(ExpectedConditions.textToBePresentInElement(by,
+ * text))}
+ *
+ * @param condition
+ * the condition to wait for to become false
+ */
+ protected void waitUntilNot(ExpectedCondition condition) {
+ new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
}
/**
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
index e24218eeb4..3553954ec0 100644
--- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -18,11 +18,8 @@ package com.vaadin.tests.tb3;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameters;
import org.openqa.selenium.remote.DesiredCapabilities;
/**
@@ -41,11 +38,9 @@ import org.openqa.selenium.remote.DesiredCapabilities;
*
* @author Vaadin Ltd
*/
-@RunWith(value = TB3Runner.class)
public abstract class MultiBrowserTest extends PrivateTB3Configuration {
- private static List allBrowsers = new ArrayList();
- private static List websocketBrowsers = new ArrayList();
+ static List allBrowsers = new ArrayList();
static {
allBrowsers.add(BrowserUtil.ie(8));
allBrowsers.add(BrowserUtil.ie(9));
@@ -57,26 +52,18 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
allBrowsers.add(BrowserUtil.chrome(29));
allBrowsers.add(BrowserUtil.opera(12));
- websocketBrowsers.addAll(allBrowsers);
- websocketBrowsers.remove(BrowserUtil.ie(8));
- websocketBrowsers.remove(BrowserUtil.ie(9));
- }
-
- @Parameters
- public static Collection getBrowsersForTest() {
- return getAllBrowsers();
- }
-
- public static Collection getAllBrowsers() {
- return Collections.unmodifiableCollection(allBrowsers);
}
/**
- * @return A subset of {@link #getAllBrowsers()} including only those which
- * support websockets
+ * @return all supported browsers which are actively tested
*/
- public static Collection getWebsocketBrowsers() {
- return Collections.unmodifiableCollection(websocketBrowsers);
+ public static List getAllBrowsers() {
+ return allBrowsers;
+ }
+
+ @Override
+ public Collection getBrowsersToTest() {
+ return allBrowsers;
}
}
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
index 510d200ffa..5860ac42c0 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -17,16 +17,12 @@
package com.vaadin.tests.tb3;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
@@ -53,49 +49,26 @@ public class TB3Runner extends BlockJUnit4ClassRunner {
protected List computeTestMethods() {
List tests = new LinkedList();
- // Find all methods in our test class marked with @Parameters.
- for (FrameworkMethod method : getTestClass().getAnnotatedMethods(
- Parameters.class)) {
- // Make sure the Parameters method is static
- if (!Modifier.isStatic(method.getMethod().getModifiers())) {
- throw new IllegalArgumentException("@Parameters " + method
- + " must be static.");
- }
-
- // Execute the method (statically)
- Object params;
- try {
- params = method.getMethod().invoke(
- getTestClass().getJavaClass());
- } catch (Throwable t) {
- throw new RuntimeException("Could not run test factory method "
- + method.getName(), t);
- }
-
- // Did the factory return an array? If so, make it a list.
- if (params.getClass().isArray()) {
- params = Arrays.asList((Object[]) params);
- }
+ if (!AbstractTB3Test.class.isAssignableFrom(getTestClass()
+ .getJavaClass())) {
+ throw new RuntimeException(getClass().getName() + " only supports "
+ + AbstractTB3Test.class.getName());
+ }
- // Did the factory return a scalar object? If so, put it in a list.
- if (!(params instanceof Iterable>)) {
- params = Collections.singletonList(params);
- }
+ try {
+ AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass()
+ .getOnlyConstructor().newInstance();
+ for (DesiredCapabilities capabilities : testClassInstance
+ .getBrowsersToTest()) {
- // For each object returned by the factory.
- for (Object param : (Iterable>) params) {
- if (!(param instanceof DesiredCapabilities)) {
- throw new RuntimeException("Unexpected parameter type "
- + param.getClass().getName()
- + " when expecting DesiredCapabilities");
- }
- DesiredCapabilities capabilities = (DesiredCapabilities) param;
// Find any methods marked with @Test.
for (FrameworkMethod m : getTestClass().getAnnotatedMethods(
Test.class)) {
tests.add(new TB3Method(m.getMethod(), capabilities));
}
}
+ } catch (Exception e) {
+ throw new RuntimeException("Error retrieving browsers to run on", e);
}
return tests;
diff --git a/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
new file mode 100644
index 0000000000..5c6ea329f5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.tb3;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+/**
+ * A {@link MultiBrowserTest} which restricts the tests to the browsers which
+ * support websocket
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class WebsocketTest extends PrivateTB3Configuration {
+ private static List websocketBrowsers = new ArrayList();
+ static {
+ websocketBrowsers.addAll(MultiBrowserTest.getAllBrowsers());
+ websocketBrowsers.remove(BrowserUtil.ie(8));
+ websocketBrowsers.remove(BrowserUtil.ie(9));
+ }
+
+ /**
+ * @return All supported browsers which are actively tested and support
+ * websockets
+ */
+ public static Collection getWebsocketBrowsers() {
+ return Collections.unmodifiableCollection(websocketBrowsers);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#getBrowserToRunOn()
+ */
+ @Override
+ public Collection getBrowsersToTest() {
+ return getWebsocketBrowsers();
+ }
+}
--
cgit v1.2.3
From d3261d77a45a24edcb4e77370e12c8e88c119d35 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Thu, 19 Sep 2013 16:42:50 +0300
Subject: Fixes issue with Table not scrolling completely to the end #12651
Made the Table notice if the user is trying to scroll to an item on the
last "page" and in those cases actually scroll to that item, not just to
the page's first item as it did before.
Change-Id: I47df33c75aa9b7e4f9a5f4bd5daeb301028517e8
---
client/src/com/vaadin/client/ui/VScrollTable.java | 27 +++++----
server/src/com/vaadin/ui/Table.java | 32 +++++++++--
.../tests/components/table/ShowLastItem.html | 36 ++++++++++++
.../tests/components/table/ShowLastItem.java | 66 ++++++++++++++++++++++
4 files changed, 143 insertions(+), 18 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/table/ShowLastItem.html
create mode 100644 uitest/src/com/vaadin/tests/components/table/ShowLastItem.java
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 3733ee204a..492730259a 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -176,6 +176,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private int firstRowInViewPort = 0;
private int pageLength = 15;
private int lastRequestedFirstvisible = 0; // to detect "serverside scroll"
+ private int firstvisibleOnLastPage = -1; // To detect if the first visible
+ // is on the last page
/** For internal use only. May be removed or replaced in the future. */
public boolean showRowHeaders = false;
@@ -1111,8 +1113,14 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private ScheduledCommand lazyScroller = new ScheduledCommand() {
@Override
public void execute() {
- int offsetTop = measureRowHeightOffset(firstvisible);
- scrollBodyPanel.setScrollPosition(offsetTop);
+ if (firstvisibleOnLastPage > -1) {
+ scrollBodyPanel
+ .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage));
+ } else {
+ scrollBodyPanel
+ .setScrollPosition(measureRowHeightOffset(firstvisible));
+ }
+ firstRowInViewPort = firstvisible;
}
};
@@ -1120,6 +1128,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
public void updateFirstVisibleAndScrollIfNeeded(UIDL uidl) {
firstvisible = uidl.hasVariable("firstvisible") ? uidl
.getIntVariable("firstvisible") : 0;
+ firstvisibleOnLastPage = uidl.hasVariable("firstvisibleonlastpage") ? uidl
+ .getIntVariable("firstvisibleonlastpage") : -1;
if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
// received 'surprising' firstvisible from server: scroll there
firstRowInViewPort = firstvisible;
@@ -2150,18 +2160,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
isNewBody = false;
- if (firstvisible > 0) {
- // Deferred due to some Firefox oddities
- Scheduler.get().scheduleDeferred(new Command() {
-
- @Override
- public void execute() {
- scrollBodyPanel
- .setScrollPosition(measureRowHeightOffset(firstvisible));
- firstRowInViewPort = firstvisible;
- }
- });
- }
+ Scheduler.get().scheduleFinally(lazyScroller);
if (enabled) {
// Do we need cache rows
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index bd2b7828de..32ed738697 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -426,6 +426,12 @@ public class Table extends AbstractSelect implements Action.Container,
*/
private int currentPageFirstItemIndex = 0;
+ /**
+ * Index of the "first" item on the last page if a user has used
+ * setCurrentPageFirstItemIndex to scroll down. -1 if not set.
+ */
+ private int currentPageFirstItemIndexOnLastPage = -1;
+
/**
* Holds value of property selectable.
*/
@@ -1477,12 +1483,14 @@ public class Table extends AbstractSelect implements Action.Container,
}
/*
- * FIXME #7607 Take somehow into account the case where we want to
- * scroll to the bottom so that the last row is completely visible even
- * if (table height) / (row height) is not an integer. Reverted the
- * original fix because of #8662 regression.
+ * If the new index is on the last page we set the index to be the first
+ * item on that last page and make a note of the real index for the
+ * client side to be able to move the scroll position to the correct
+ * position.
*/
+ int indexOnLastPage = -1;
if (newIndex > maxIndex) {
+ indexOnLastPage = newIndex;
newIndex = maxIndex;
}
@@ -1494,6 +1502,20 @@ public class Table extends AbstractSelect implements Action.Container,
currentPageFirstItemId = null;
}
currentPageFirstItemIndex = newIndex;
+
+ if (needsPageBufferReset) {
+ /*
+ * The flag currentPageFirstItemIndexOnLastPage denotes a user
+ * set scrolling position on the last page via
+ * setCurrentPageFirstItemIndex() and shouldn't be changed by
+ * the table component internally changing the firstvisible item
+ * on lazy row fetching. Doing so would make the scrolling
+ * position not be updated correctly when the lazy rows are
+ * finally rendered.
+ */
+ currentPageFirstItemIndexOnLastPage = indexOnLastPage;
+ }
+
} else {
// For containers not supporting indexes, we must iterate the
@@ -3447,6 +3469,8 @@ public class Table extends AbstractSelect implements Action.Container,
if (getCurrentPageFirstItemIndex() != 0 || getPageLength() > 0) {
target.addVariable(this, "firstvisible",
getCurrentPageFirstItemIndex());
+ target.addVariable(this, "firstvisibleonlastpage",
+ currentPageFirstItemIndexOnLastPage);
}
}
diff --git a/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html
new file mode 100644
index 0000000000..c9c93198fa
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+New Test
+
+
+
+
+New Test
+
+
+ open
+ /run/com.vaadin.tests.components.table.ShowLastItem?restartApplication
+
+
+
+ click
+ vaadin=runcomvaadintestscomponentstableShowLastItem::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
+
+
+
+ pause
+ 1000
+
+
+
+ screenCapture
+
+ row-20-fully-visible
+
+
+
+
+
diff --git a/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java
new file mode 100644
index 0000000000..6d6f744918
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.java
@@ -0,0 +1,66 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Table;
+
+public class ShowLastItem extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Table table = new Table();
+ table.setHeight("210px");
+
+ table.addContainerProperty("Col", String.class, "");
+
+ for (int i = 0; i < 20; i++) {
+ table.addItem(i).getItemProperty("Col")
+ .setValue("row " + String.valueOf(i));
+ }
+
+ Button addItemBtn = new Button("Add item", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object itemId = "row " + table.getItemIds().size();
+
+ table.addItem(itemId).getItemProperty("Col")
+ .setValue(String.valueOf(itemId));
+
+ table.setCurrentPageFirstItemIndex(table.getItemIds().size() - 1);
+ }
+ });
+
+ addComponent(table);
+ addComponent(addItemBtn);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Show last item in Table by using setCurrentPageFirstItemId";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 12407;
+ }
+
+}
--
cgit v1.2.3
From bd0ae0581f265be57374b236cfe1b71043ab69aa Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Tue, 24 Sep 2013 18:19:45 +0300
Subject: Limit the number of tests run concurrently (#12572)
Change-Id: I015e92ccc9be963543032c14dd9d051bcba58e53
---
uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java | 13 +++++++++++--
uitest/src/com/vaadin/tests/tb3/TB3Runner.java | 16 +++++++++++++++-
uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java | 17 ++++++++++++++++-
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
index f8013169fa..912d7d010e 100644
--- a/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
+++ b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.junit.runners.model.RunnerScheduler;
@@ -33,8 +32,18 @@ import org.junit.runners.model.RunnerScheduler;
*/
public class ParallelScheduler implements RunnerScheduler {
private final List> fResults = new ArrayList>();
+ private ExecutorService fService;
- private final ExecutorService fService = Executors.newCachedThreadPool();
+ /**
+ * Creates a parallel scheduler which will use the given executor service
+ * when submitting test jobs.
+ *
+ * @param service
+ * The service to use for tests
+ */
+ public ParallelScheduler(ExecutorService service) {
+ fService = service;
+ }
@Override
public void schedule(final Runnable childStatement) {
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
index 5860ac42c0..b612b17caa 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java
@@ -19,6 +19,8 @@ package com.vaadin.tests.tb3;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import org.junit.Test;
import org.junit.runners.BlockJUnit4ClassRunner;
@@ -40,9 +42,21 @@ import com.vaadin.tests.tb3.AbstractTB3Test.BrowserUtil;
*/
public class TB3Runner extends BlockJUnit4ClassRunner {
+ /**
+ * This is the total limit of actual JUnit test instances run in parallel
+ */
+ private static final int MAX_CONCURRENT_TESTS = 50;
+
+ /**
+ * This is static so it is shared by all tests running concurrently on the
+ * same machine and thus can limit the number of threads in use.
+ */
+ private static final ExecutorService service = Executors
+ .newFixedThreadPool(MAX_CONCURRENT_TESTS);
+
public TB3Runner(Class> klass) throws InitializationError {
super(klass);
- setScheduler(new ParallelScheduler());
+ setScheduler(new ParallelScheduler(service));
}
@Override
diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
index dc187000d2..e1c8edfd60 100644
--- a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
+++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java
@@ -28,6 +28,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.jar.JarEntry;
import org.junit.runners.Suite;
@@ -41,11 +43,24 @@ import org.junit.runners.model.InitializationError;
*/
public class TB3TestSuite extends Suite {
+ /**
+ * This only restricts the number of test suites running concurrently. The
+ * number of tests to run concurrently are configured in {@link TB3Runner}.
+ */
+ private static final int MAX_CONCURRENT_TEST_SUITES = 20;
+
+ /**
+ * This is static so it is shared by all test suites running concurrently on
+ * the same machine and thus can limit the number of threads in use.
+ */
+ private final ExecutorService service = Executors
+ .newFixedThreadPool(MAX_CONCURRENT_TEST_SUITES);
+
public TB3TestSuite(Class> klass,
Class extends AbstractTB3Test> baseClass, String basePackage,
String[] ignorePackages) throws InitializationError {
super(klass, findTests(baseClass, basePackage, ignorePackages));
- setScheduler(new ParallelScheduler());
+ setScheduler(new ParallelScheduler(service));
}
/**
--
cgit v1.2.3
From 8ce6565b3ee456db4f95b41568a8b31721a48cd6 Mon Sep 17 00:00:00 2001
From: Matti Tahvonen
Date: Thu, 26 Sep 2013 15:59:55 +0300
Subject: Fixes normal drag and drop events (regression since 7.1) and html5
style D&D in IE10 (#12339)
Change-Id: Ied4504406ebbeab6ff464fb239f7b3f5987fbbd9
---
client/src/com/vaadin/client/ui/VDragAndDropWrapper.java | 15 ++++++++++-----
.../src/com/vaadin/client/ui/dd/VDragAndDropManager.java | 11 +++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
index 1c1173c295..ccd7e2758e 100644
--- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
+++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
@@ -332,11 +332,16 @@ public class VDragAndDropWrapper extends VCustomComponent implements
vaadinDragEvent.setCurrentGwtEvent(event);
getDropHandler().dragOver(vaadinDragEvent);
- String s = event.getEffectAllowed();
- if ("all".equals(s) || s.contains("opy")) {
- event.setDropEffect("copy");
- } else {
- event.setDropEffect(s);
+ try {
+ String s = event.getEffectAllowed();
+ if ("all".equals(s) || s.contains("opy")) {
+ event.setDropEffect("copy");
+ } else {
+ event.setDropEffect(s);
+ }
+ } catch (Exception e) {
+ // IE10 throws exception here in getEffectAllowed, ignore it, let
+ // drop effect be whatever it is
}
try {
diff --git a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
index b4cf008a38..b911c28a07 100644
--- a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
+++ b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java
@@ -374,6 +374,17 @@ public class VDragAndDropManager {
public void onPreviewNativeEvent(
NativePreviewEvent event) {
int typeInt = event.getTypeInt();
+ if (typeInt == -1
+ && event.getNativeEvent().getType()
+ .contains("MSPointer")) {
+ /*
+ * Ignore MSPointer events, until they are
+ * properly used (might improve usability on
+ * touch devices).
+ */
+ return;
+ }
+
switch (typeInt) {
case Event.ONMOUSEOVER:
if (dragElement == null) {
--
cgit v1.2.3
From 5fb1da2da04ccca2305af31a9105b848e42b1ed6 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Wed, 25 Sep 2013 13:51:23 +0300
Subject: Publish error artifacts immediatly in TeamCity
Change-Id: I69cb2208b7f6b3263ddb25fa26eebebcc6f9a7c3
---
uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java | 12 +++++++++++-
uitest/test.xml | 4 ++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index 645d9cd0cb..565d04fdb9 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -31,6 +31,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.remote.DesiredCapabilities;
@@ -65,7 +66,16 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
}
screenshotBaseName = className + "-" + testMethod;
- };
+ }
+
+ @Override
+ protected void failed(Throwable e, Description description) {
+
+ // Notify Teamcity of failed test
+ System.out.print("##teamcity[publishArtifacts '");
+ System.out.println(getScreenshotErrorDirectory() + "/"
+ + getScreenshotBaseName() + "* => screenshot-errors']");
+ }
};
/**
diff --git a/uitest/test.xml b/uitest/test.xml
index dd6964e59c..88b5238c09 100644
--- a/uitest/test.xml
+++ b/uitest/test.xml
@@ -134,6 +134,10 @@
+
+
+ ##teamcity[publishArtifacts '${com.vaadin.testbench.screenshot.directory}/errors/${basename}* => screenshot-errors']
+
--
cgit v1.2.3
From 649735f755c51e5c11d5ebe984e7a308fe97552a Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Fri, 27 Sep 2013 13:12:35 +0300
Subject: Added user agent for IE 11 (#12631)
Change-Id: I1ba1791c04a3d1685e1bc482d2b04a748e19f012
---
uitest/src/com/vaadin/tests/VerifyBrowserVersion.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
index 59663a78d6..ae6f0afa4d 100644
--- a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
@@ -31,6 +31,9 @@ public class VerifyBrowserVersion extends TestBase {
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");
--
cgit v1.2.3
From a5795f346e077268eb77edef09d902fba57d5804 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Mon, 23 Sep 2013 16:51:42 +0300
Subject: Prefixes GET parameters in Liferay with portlet namespace #12602
Change-Id: I9939a7af83482e136ed0d146accdeec0cd9f10ea
---
.../vaadin/client/ApplicationConfiguration.java | 17 +++++++++++++
.../com/vaadin/client/ApplicationConnection.java | 2 +-
server/src/com/vaadin/server/VaadinPortlet.java | 29 +++++++++++++++++++---
.../communication/PortletBootstrapHandler.java | 11 ++++++++
.../com/vaadin/shared/ApplicationConstants.java | 4 +++
5 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index da8f521799..7a70080c7e 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -246,6 +246,23 @@ public class ApplicationConfiguration implements EntryPoint {
ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER) == Boolean.TRUE;
}
+ /**
+ * Return the name of the parameter used to to send data to the service url.
+ * This method should only be called if {@link #useServiceUrlPathParam()} is
+ * true.
+ *
+ * @since 7.1.6
+ * @return The parameter name, by default v-resourcePath
+ */
+ public String getServiceUrlParameterName() {
+ String prefix = getJsoConfiguration(id).getConfigString(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE);
+ if (prefix == null) {
+ prefix = "";
+ }
+ return prefix + ApplicationConstants.V_RESOURCE_PATH;
+ }
+
public String getRootPanelId() {
return id;
}
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 0d9c859ee8..4314602bc2 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -2994,7 +2994,7 @@ public class ApplicationConnection {
if (!path.startsWith("/")) {
path = '/' + path;
}
- String pathParam = ApplicationConstants.V_RESOURCE_PATH + "="
+ String pathParam = conf.getServiceUrlParameterName() + "="
+ URL.encodeQueryString(path);
serviceUrl = addGetParameters(serviceUrl, pathParam);
uidlUri = serviceUrl;
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index d86e5e6507..093a1c9152 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -422,16 +422,37 @@ public class VaadinPortlet extends GenericPortlet implements Constants,
* @return A wrapped version of the PorletRequest
*/
protected VaadinPortletRequest createVaadinRequest(PortletRequest request) {
- String portalInfo = request.getPortalContext().getPortalInfo()
- .toLowerCase();
- if (portalInfo.contains("liferay")) {
+ if (isLiferay(request)) {
return new VaadinLiferayRequest(request, getService());
- } else if (portalInfo.contains("gatein")) {
+ } else if (isGateIn(request)) {
return new VaadinGateinRequest(request, getService());
} else {
return new VaadinPortletRequest(request, getService());
}
+ }
+ /**
+ * Returns true if the portlet request is from Liferay.
+ *
+ * @param request
+ * @return True if Liferay, false otherwise
+ */
+ private static boolean isLiferay(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("liferay");
+ }
+
+ /**
+ * Returns true if the portlet request if from GateIn
+ *
+ * @param request
+ * @return True if GateIn, false otherwise
+ */
+ private static boolean isGateIn(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("gatein");
}
private VaadinPortletResponse createVaadinResponse(PortletResponse response) {
diff --git a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
index 2458951ada..dd6d3c9283 100644
--- a/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
+++ b/server/src/com/vaadin/server/communication/PortletBootstrapHandler.java
@@ -31,6 +31,7 @@ import org.json.JSONObject;
import com.vaadin.server.BootstrapHandler;
import com.vaadin.server.PaintException;
import com.vaadin.server.VaadinPortlet;
+import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
import com.vaadin.server.VaadinPortletRequest;
import com.vaadin.server.VaadinPortletResponse;
import com.vaadin.server.VaadinRequest;
@@ -98,6 +99,8 @@ public class PortletBootstrapHandler extends BootstrapHandler {
JSONObject parameters = super.getApplicationParameters(context);
VaadinPortletResponse response = (VaadinPortletResponse) context
.getResponse();
+ VaadinPortletRequest request = (VaadinPortletRequest) context
+ .getRequest();
MimeResponse portletResponse = (MimeResponse) response
.getPortletResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
@@ -108,6 +111,14 @@ public class PortletBootstrapHandler extends BootstrapHandler {
parameters
.put(ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER, true);
+ // If we are running in Liferay then we need to prefix all parameters
+ // with the portlet namespace
+ if (request instanceof VaadinLiferayRequest) {
+ parameters.put(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE,
+ response.getPortletResponse().getNamespace());
+ }
+
return parameters;
}
}
\ No newline at end of file
diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java
index 104f3047a8..4b5dc9140b 100644
--- a/shared/src/com/vaadin/shared/ApplicationConstants.java
+++ b/shared/src/com/vaadin/shared/ApplicationConstants.java
@@ -49,6 +49,10 @@ public class ApplicationConstants implements Serializable {
public static final String SERVICE_URL_PATH_AS_PARAMETER = "usePathParameter";
+ // Denotes the namespace which parameters should be prefixed with when
+ // passed as GET parameters. Currently only used by Liferay.
+ public static final String SERVICE_URL_PARAMETER_NAMESPACE = "pathParameterNS";
+
// Javadocs in ApplicationConfiguration should be updated if this is changed
public static final String V_RESOURCE_PATH = "v-resourcePath";
--
cgit v1.2.3
From b235d9c4e166197f3369694feec8d8f12a93c49d Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Fri, 27 Sep 2013 13:14:36 +0300
Subject: Refactor how TB3 tests are written (#12572)
* openTestUrl() must be called in the beginning of each test. Before that setPush and setDebug can be used to determine whether /run-push or ?debug should be used in the URL
Change-Id: Ie70996fcbdb2769fcd4ec56cb878e20198e02bf6
---
.../src/com/vaadin/tests/VerifyBrowserVersion.java | 1 +
.../vaadin/tests/components/label/LabelModes.java | 1 +
.../com/vaadin/tests/components/ui/UIAccess.java | 7 +-
uitest/src/com/vaadin/tests/push/BarInUIDL.java | 1 +
uitest/src/com/vaadin/tests/push/BasicPush.java | 2 +
.../com/vaadin/tests/push/BasicPushStreaming.java | 8 --
.../vaadin/tests/push/PushConfigurationTest.java | 7 +-
uitest/src/com/vaadin/tests/push/PushFromInit.java | 2 +
.../vaadin/tests/push/PushReattachedComponent.java | 8 +-
uitest/src/com/vaadin/tests/push/TogglePush.java | 62 +++-------------
.../tests/push/TrackMessageSizeUnitTests.java | 1 +
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 85 ++++++++++++++++------
12 files changed, 87 insertions(+), 98 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
index ae6f0afa4d..47c09bdfd7 100644
--- a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
+++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java
@@ -45,6 +45,7 @@ public class VerifyBrowserVersion extends TestBase {
@Test
public void verifyUserAgent() {
+ openTestURL();
Assert.assertEquals(
expectedUserAgent.get(getDesiredCapabilities()),
vaadinElementById("userAgent").getText());
diff --git a/uitest/src/com/vaadin/tests/components/label/LabelModes.java b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
index 1959447a4b..9e51978743 100644
--- a/uitest/src/com/vaadin/tests/components/label/LabelModes.java
+++ b/uitest/src/com/vaadin/tests/components/label/LabelModes.java
@@ -10,6 +10,7 @@ public class LabelModes extends ComponentTestCase {
public static class LabelModesTest extends SimpleMultiBrowserTest {
@Override
public void test() throws Exception {
+ openTestURL();
compareScreen("labelmodes");
}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
index 057dcaa917..7515b3ede8 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java
@@ -40,13 +40,10 @@ import com.vaadin.util.CurrentInstance;
public class UIAccess extends AbstractTestUIWithLog {
public static class UIAccessTest extends MultiBrowserTest {
- @Override
- protected boolean isPushEnabled() {
- return true;
- }
-
@Test
public void testThreadLocals() {
+ setPush(true);
+ openTestURL();
getCurrentInstanceWhenPushingButton().click();
waitUntil(ExpectedConditions.textToBePresentInElement(
vaadinLocatorById("Log_row_0"), "1."));
diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
index ef2568bebe..ebf349683d 100644
--- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java
+++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java
@@ -35,6 +35,7 @@ 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",
diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java
index 1f184863f7..d1a9fb575f 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPush.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPush.java
@@ -39,6 +39,8 @@ public class BasicPush extends AbstractTestUI {
@Test
public void testPush() {
+ openTestURL();
+
// Test client initiated push
Assert.assertEquals(0, getClientCounter());
getIncrementButton().click();
diff --git a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
index 29534e1f5c..b63f782cc9 100644
--- a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
+++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java
@@ -15,8 +15,6 @@
*/
package com.vaadin.tests.push;
-import org.junit.Test;
-
import com.vaadin.annotations.Push;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ui.Transport;
@@ -32,11 +30,5 @@ public class BasicPushStreaming extends BasicPush {
}
public static class BasicPushStreamingTest extends BasicPushTest {
- @Override
- @Test
- public void testPush() {
- super.testPush();
- }
}
-
}
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
index f4a537392d..5100e8a4ea 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
@@ -37,13 +37,10 @@ public class PushConfigurationTest extends AbstractTestUI {
public static class PushConfigurationWebsocket extends WebsocketTest {
- @Override
- protected boolean isDebug() {
- return true;
- }
-
@Test
public void testWebsocketAndStreaming() {
+ setDebug(true);
+ openTestURL();
// Websocket
Assert.assertEquals(1, getServerCounter());
new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java
index 000d5c0bce..de3334f707 100644
--- a/uitest/src/com/vaadin/tests/push/PushFromInit.java
+++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java
@@ -28,6 +28,8 @@ 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");
diff --git a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
index 35934273a4..0bc796e0ee 100644
--- a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
+++ b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
@@ -27,11 +27,6 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class PushReattachedComponent extends MultiBrowserTest {
- @Override
- protected boolean isPushEnabled() {
- return true;
- }
-
@Override
protected Class> getUIClass() {
return PanelChangeContents.class;
@@ -39,6 +34,9 @@ public class PushReattachedComponent extends MultiBrowserTest {
@Test
public void testReattachComponentUsingPush() {
+ setPush(true);
+ openTestURL();
+
Assert.assertEquals(
"stats",
vaadinElement(
diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java
index f59ef83fe7..3ef369b408 100644
--- a/uitest/src/com/vaadin/tests/push/TogglePush.java
+++ b/uitest/src/com/vaadin/tests/push/TogglePush.java
@@ -34,30 +34,12 @@ import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Label;
public class TogglePush extends AbstractTestUI {
- public static class TogglePushInInitTB3 extends MultiBrowserTest {
- @Override
- protected boolean isPushEnabled() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getTestUrl()
- */
- @Override
- protected String getTestUrl() {
- return null;
- }
+ public static class TogglePushTB3 extends MultiBrowserTest {
@Test
public void togglePushInInit() {
- String baseUrl = getBaseURL();
- if (baseUrl.endsWith("/")) {
- baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
- }
-
- String url = baseUrl + getDeploymentPath();
+ setPush(true);
+ String url = getTestUrl();
// Open with push disabled
driver.get(addParameter(url, "push=disabled"));
@@ -80,12 +62,6 @@ public class TogglePush extends AbstractTestUI {
}
- /**
- * @since
- * @param url
- * @param string
- * @return
- */
private String addParameter(String url, String queryParameter) {
if (url.contains("?")) {
return url + "&" + queryParameter;
@@ -94,31 +70,10 @@ public class TogglePush extends AbstractTestUI {
}
}
- private String getCounterText() {
- return vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
- .getText();
- }
-
- 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]");
- }
-
- }
-
- public static class TogglePushTB3 extends MultiBrowserTest {
-
- @Override
- protected boolean isPushEnabled() {
- return true;
- }
-
@Test
public void togglePush() {
+ setPush(true);
+ openTestURL();
getDelayedCounterUpdateButton().click();
sleep(2000);
@@ -157,15 +112,16 @@ public class TogglePush extends AbstractTestUI {
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 WebElement getDelayedCounterUpdateButton() {
- return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]");
- }
}
private final Label counterLabel = new Label();
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
index d7459f83ab..cb3033aa58 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
@@ -43,6 +43,7 @@ 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());
}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 1897728366..054492444d 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -47,11 +47,10 @@ import com.vaadin.ui.UI;
*
* Helpers for browser selection
* Hub connection setup and teardown
- * Automatic opening of a given test on the development server using
- * {@link #getUIClass()} or by automatically finding an enclosing UI class
+ * Automatic generation of URL for a given test on the development server
+ * using {@link #getUIClass()} or by automatically finding an enclosing UI class
+ * and based on requested features, e.g. {@link #isDebug()}, {@link #isPush()}
* Generic helpers for creating TB3+ tests
- * Automatic URL generation based on needed features, e.g.
- * {@link #isDebug()}, {@link #isPushEnabled()}
*
*
* @author Vaadin Ltd
@@ -69,6 +68,10 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
private static final int SCREENSHOT_WIDTH = 1500;
private DesiredCapabilities desiredCapabilities;
+
+ private boolean debug = false;
+
+ private boolean push = false;
{
// Default browser to run on unless setDesiredCapabilities is called
desiredCapabilities = BrowserUtil.firefox(24);
@@ -83,11 +86,6 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
@Before
public void setup() throws Exception {
setupDriver();
-
- String testUrl = getTestUrl();
- if (testUrl != null) {
- driver.get(testUrl);
- }
}
/**
@@ -125,9 +123,20 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
/**
- * Returns the full URL to be opened when the test starts.
+ * Opens the given test (defined by {@link #getTestUrl(boolean, boolean)},
+ * optionally with debug window and/or push
+ *
+ * @param debug
+ * @param push
+ */
+ protected void openTestURL() {
+ driver.get(getTestUrl());
+ }
+
+ /**
+ * Returns the full URL to be used for the test
*
- * @return the full URL to open or null to not open any URL automatically
+ * @return the full URL for the test
*/
protected String getTestUrl() {
String baseUrl = getBaseURL();
@@ -292,7 +301,12 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* Returns the path that should be used for the test. The path contains the
* full path (appended to hostname+port) and must start with a slash.
*
- * @return The path to open automatically when the test starts
+ * @param push
+ * true if "?debug" should be added
+ * @param debug
+ * true if /run-push should be used instead of /run
+ *
+ * @return The URL path to the UI class to test
*/
protected String getDeploymentPath() {
Class> uiClass = getUIClass();
@@ -325,24 +339,47 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
/**
- * Determines whether to run the test in debug mode (with the debug console
+ * Returns whether to run the test in debug mode (with the debug console
* open) or not
*
* @return true to run with the debug window open, false by default
*/
- protected boolean isDebug() {
- return false;
+ protected final boolean isDebug() {
+ return debug;
}
/**
- * Determines whether to run the test with push enabled (using /run-push) or
+ * Sets whether to run the test in debug mode (with the debug console open)
+ * or not.
+ *
+ * @param debug
+ * true to open debug window, false otherwise
+ */
+ protected final void setDebug(boolean debug) {
+ this.debug = debug;
+ }
+
+ /**
+ * Returns whether to run the test with push enabled (using /run-push) or
* not. Note that push tests can and should typically be created using @Push
* on the UI instead of overriding this method
*
- * @return true to use push in the test, false to use whatever UI specifies
+ * @return true if /run-push is used, false otherwise
+ */
+ protected final boolean isPush() {
+ return push;
+ }
+
+ /**
+ * Sets whether to run the test with push enabled (using /run-push) or not.
+ * Note that push tests can and should typically be created using @Push on
+ * the UI instead of overriding this method
+ *
+ * @param push
+ * true to use /run-push in the test, false otherwise
*/
- protected boolean isPushEnabled() {
- return false;
+ protected final void setPush(boolean push) {
+ this.push = push;
}
/**
@@ -350,15 +387,19 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* The path contains the full path (appended to hostname+port) and must
* start with a slash.
*
- * This method takes into account {@link #isPushEnabled()} and
- * {@link #isDebug()} when the path is generated.
+ * This method takes into account {@link #isPush()} and {@link #isDebug()}
+ * when the path is generated.
*
* @param uiClass
+ * @param push
+ * true if "?debug" should be added
+ * @param debug
+ * true if /run-push should be used instead of /run
* @return The path to the given UI class
*/
private String getDeploymentPath(Class> uiClass) {
String runPath = "/run";
- if (isPushEnabled()) {
+ if (isPush()) {
runPath = "/run-push";
}
--
cgit v1.2.3
From 478acb8e9aa7505cc6eacf219e87202191810a39 Mon Sep 17 00:00:00 2001
From: Juho Nurminen
Date: Mon, 23 Sep 2013 13:17:41 +0300
Subject: Check modifiers when handling TabSheet hot keys. Fixes #12178
Change-Id: I685dbf2c22e3b160632b811652bf3ab52d3ef6dc
---
client/src/com/vaadin/client/ui/VTabsheet.java | 18 ++++----
.../tabsheet/TabSheetHotKeysWithModifiers.java | 50 ++++++++++++++++++++++
2 files changed, 60 insertions(+), 8 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSheetHotKeysWithModifiers.java
diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java
index fe29e2ebc0..7dec62bde0 100644
--- a/client/src/com/vaadin/client/ui/VTabsheet.java
+++ b/client/src/com/vaadin/client/ui/VTabsheet.java
@@ -1115,14 +1115,16 @@ public class VTabsheet extends VTabsheetBase implements Focusable,
if (event.getSource() instanceof Tab) {
int keycode = event.getNativeEvent().getKeyCode();
- if (keycode == getPreviousTabKey()) {
- selectPreviousTab();
- } else if (keycode == getNextTabKey()) {
- selectNextTab();
- } else if (keycode == getCloseTabKey()) {
- Tab tab = tb.getTab(activeTabIndex);
- if (tab.isClosable()) {
- tab.onClose();
+ if (!event.isAnyModifierKeyDown()) {
+ if (keycode == getPreviousTabKey()) {
+ selectPreviousTab();
+ } else if (keycode == getNextTabKey()) {
+ selectNextTab();
+ } else if (keycode == getCloseTabKey()) {
+ Tab tab = tb.getTab(activeTabIndex);
+ if (tab.isClosable()) {
+ tab.onClose();
+ }
}
}
}
diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetHotKeysWithModifiers.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetHotKeysWithModifiers.java
new file mode 100644
index 0000000000..c0b30ff68d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetHotKeysWithModifiers.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.components.tabsheet;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+
+public class TabSheetHotKeysWithModifiers extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TabSheet tabSheet = new TabSheet();
+ tabSheet.setWidth("500px");
+ tabSheet.setHeight("500px");
+ tabSheet.addTab(new Label("Tab 1"), "Tab 1").setClosable(true);
+ tabSheet.addTab(new Label("Tab 2"), "Tab 2").setClosable(true);
+ tabSheet.addTab(new Label("Tab 3"), "Tab 3").setClosable(true);
+ setContent(tabSheet);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Hot keys (left and right arrow keys and the delete key) should be ignored when they are pressed simultaneously with modifier keys";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12178;
+ }
+
+}
--
cgit v1.2.3
From ffb33be8a15f3e82ca095901ca4fd2713eb229e6 Mon Sep 17 00:00:00 2001
From: Juho Nurminen
Date: Tue, 1 Oct 2013 15:14:28 +0300
Subject: Update slider client-side state object on value change (#12676)
Change-Id: Ief93d845e5498388072e05a0faff7ef2d29f1c77
---
.../vaadin/client/ui/slider/SliderConnector.java | 1 +
.../tests/components/slider/SliderDisable.java | 81 ++++++++++++++++++++++
2 files changed, 82 insertions(+)
create mode 100644 uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
diff --git a/client/src/com/vaadin/client/ui/slider/SliderConnector.java b/client/src/com/vaadin/client/ui/slider/SliderConnector.java
index e6e3e0467d..71462d69f0 100644
--- a/client/src/com/vaadin/client/ui/slider/SliderConnector.java
+++ b/client/src/com/vaadin/client/ui/slider/SliderConnector.java
@@ -52,6 +52,7 @@ public class SliderConnector extends AbstractFieldConnector implements
@Override
public void onValueChange(ValueChangeEvent event) {
+ getState().value = event.getValue();
rpc.valueChanged(event.getValue());
}
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java b/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
new file mode 100644
index 0000000000..ea29a1657c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisable.java
@@ -0,0 +1,81 @@
+/*
+ * 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.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;
+import com.vaadin.ui.Slider;
+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();
+ content.setMargin(true);
+ content.setSpacing(true);
+
+ final Slider slider = new Slider(0, 5);
+ slider.setWidth(200, Unit.PIXELS);
+ slider.setValue(1.0D);
+
+ Button disableButton = new Button("Disable slider");
+ disableButton.setId("disableButton");
+ disableButton.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ slider.setEnabled(false);
+ }
+ });
+
+ content.addComponent(slider);
+ content.addComponent(disableButton);
+ setContent(content);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "The apparent value of the slider should not change when the slider is disabled";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12676;
+ }
+
+}
--
cgit v1.2.3
From b8828e7270122930d21d9b561cde73a652d62f7a Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 2 Oct 2013 09:39:34 +0300
Subject: Only publish files actually produced by this test/browser
Change-Id: If4f66157791d642801c0100bb4bc0f293efe76cc
---
uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index 565d04fdb9..7f19a76ed6 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -73,8 +73,8 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
// Notify Teamcity of failed test
System.out.print("##teamcity[publishArtifacts '");
- System.out.println(getScreenshotErrorDirectory() + "/"
- + getScreenshotBaseName() + "* => screenshot-errors']");
+ System.out.println(getScreenshotErrorBaseName()
+ + "* => screenshot-errors']");
}
};
--
cgit v1.2.3
From 5966f01b9f804621ac123792850b43e86399ec60 Mon Sep 17 00:00:00 2001
From: Fabian Lange
Date: Thu, 12 Sep 2013 16:20:17 +0200
Subject: reduce reflow and calculation in VOverlay (#12566)
the actual position of VOverlay is only required when a shim or shadow is used.
Otherwise the calculation of its position causes unnecessary reflows.
Change-Id: Id3915fe55c6b477f5d3ff01ee3a505014303d6d6
---
client/src/com/vaadin/client/ui/VOverlay.java | 71 ++++++++++++++-------------
1 file changed, 38 insertions(+), 33 deletions(-)
diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java
index ced476f9dd..0e031e3d0d 100644
--- a/client/src/com/vaadin/client/ui/VOverlay.java
+++ b/client/src/com/vaadin/client/ui/VOverlay.java
@@ -248,10 +248,6 @@ public class VOverlay extends PopupPanel implements CloseHandler {
return isShadowEnabled() && shadow.getParentElement() != null;
}
- private boolean isShimElementAttached() {
- return shimElement != null && shimElement.hasParentElement();
- }
-
private void adjustZIndex() {
setZIndex(Z_INDEX);
}
@@ -469,36 +465,51 @@ public class VOverlay extends PopupPanel implements CloseHandler {
getOffsetWidth();
}
- PositionAndSize positionAndSize = new PositionAndSize(getActualLeft(),
- getActualTop(), getOffsetWidth(), getOffsetHeight());
+ if (isShadowEnabled() || needsShimElement()) {
+
+ PositionAndSize positionAndSize = new PositionAndSize(
+ getActualLeft(), getActualTop(), getOffsetWidth(),
+ getOffsetHeight());
+
+ // Animate the size
+ positionAndSize.setAnimationFromCenterProgress(progress);
+
+ Element container = getElement().getParentElement().cast();
- // Animate the size
- positionAndSize.setAnimationFromCenterProgress(progress);
+ if (isShadowEnabled()) {
+ updateShadowPosition(progress, zIndex, positionAndSize);
+ if (shadow.getParentElement() == null) {
+ container.insertBefore(shadow, getElement());
+ sinkShadowEvents();
+ }
+ }
+
+ if (needsShimElement()) {
+ updateShimPosition(positionAndSize);
+ if (shimElement.getParentElement() == null) {
+ container.insertBefore(shimElement, getElement());
+ }
+ }
+ }
+ }
+ private void updateShadowPosition(final double progress, String zIndex,
+ PositionAndSize positionAndSize) {
// Opera needs some shaking to get parts of the shadow showing
- // properly
- // (ticket #2704)
- if (BrowserInfo.get().isOpera() && isShadowEnabled()) {
+ // properly (ticket #2704)
+ if (BrowserInfo.get().isOpera()) {
// Clear the height of all middle elements
DOM.getChild(shadow, 3).getStyle().setProperty("height", "auto");
DOM.getChild(shadow, 4).getStyle().setProperty("height", "auto");
DOM.getChild(shadow, 5).getStyle().setProperty("height", "auto");
}
- // Update correct values
- if (isShadowEnabled()) {
- updatePositionAndSize(shadow, positionAndSize);
- DOM.setStyleAttribute(shadow, "zIndex", zIndex);
- DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none"
- : "");
- }
- if (needsShimElement()) {
- updatePositionAndSize((Element) Element.as(getShimElement()),
- positionAndSize);
- }
+ updatePositionAndSize(shadow, positionAndSize);
+ DOM.setStyleAttribute(shadow, "zIndex", zIndex);
+ DOM.setStyleAttribute(shadow, "display", progress < 0.9 ? "none" : "");
// Opera fix, part 2 (ticket #2704)
- if (BrowserInfo.get().isOpera() && isShadowEnabled()) {
+ if (BrowserInfo.get().isOpera()) {
// We'll fix the height of all the middle elements
DOM.getChild(shadow, 3)
.getStyle()
@@ -513,17 +524,11 @@ public class VOverlay extends PopupPanel implements CloseHandler {
.setPropertyPx("height",
DOM.getChild(shadow, 5).getOffsetHeight());
}
+ }
- Element container = getElement().getParentElement().cast();
- // Attach to dom if not there already
- if (isShadowEnabled() && !isShadowAttached()) {
- container.insertBefore(shadow, getElement());
- sinkShadowEvents();
- }
- if (needsShimElement() && !isShimElementAttached()) {
- container.insertBefore(getShimElement(), getElement());
- }
-
+ private void updateShimPosition(PositionAndSize positionAndSize) {
+ updatePositionAndSize((Element) Element.as(getShimElement()),
+ positionAndSize);
}
/**
--
cgit v1.2.3
From 600f5f3238ecca22a8e7890d0656b0a23bd7dbba Mon Sep 17 00:00:00 2001
From: Yuriy Artamonov
Date: Thu, 26 Sep 2013 11:37:42 +0400
Subject: Do not try to focus invisible components which not present in UIDL
#12654
Change-Id: I365940e72d97426eceb408878bc8b24d7655de7c
---
client/src/com/vaadin/client/ui/ui/UIConnector.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java
index c6d2e1436b..46b5f63180 100644
--- a/client/src/com/vaadin/client/ui/ui/UIConnector.java
+++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java
@@ -319,6 +319,11 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
ComponentConnector paintable = (ComponentConnector) uidl
.getPaintableAttribute("focused", getConnection());
+ if (paintable == null) {
+ // Do not try to focus invisible components which not present in UIDL
+ return;
+ }
+
final Widget toBeFocused = paintable.getWidget();
/*
* Two types of Widgets can be focused, either implementing
--
cgit v1.2.3
From d0e604f6b509767c46ffe0fd6765cf23535f593e Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Mon, 30 Sep 2013 14:45:43 +0300
Subject: Only print testbench failure TeamCity messages when running in TC
Change-Id: Ifa04ce512743bc8ccddea0bdca7b82cceaff150e
---
uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java | 8 +++++---
uitest/tb3test.xml | 9 +++++++++
uitest/test.xml | 12 +++++++++---
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index 7f19a76ed6..94bcebde84 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -72,9 +72,11 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
protected void failed(Throwable e, Description description) {
// Notify Teamcity of failed test
- System.out.print("##teamcity[publishArtifacts '");
- System.out.println(getScreenshotErrorBaseName()
- + "* => screenshot-errors']");
+ if (!System.getProperty("teamcity.version", "").equals("")) {
+ System.out.print("##teamcity[publishArtifacts '");
+ System.out.println(getScreenshotErrorBaseName()
+ + "* => screenshot-errors']");
+ }
}
};
diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml
index 92008ff9f3..de69e0ebe6 100644
--- a/uitest/tb3test.xml
+++ b/uitest/tb3test.xml
@@ -19,12 +19,21 @@
+
+
+
+
+
+
+
+
+
diff --git a/uitest/test.xml b/uitest/test.xml
index 88b5238c09..c534d676b9 100644
--- a/uitest/test.xml
+++ b/uitest/test.xml
@@ -134,12 +134,18 @@
-
-
- ##teamcity[publishArtifacts '${com.vaadin.testbench.screenshot.directory}/errors/${basename}* => screenshot-errors']
+
+
+
+
+
+
+ ##teamcity[publishArtifacts '${com.vaadin.testbench.screenshot.directory}/errors/${basename}* => screenshot-errors']
+
+
--
cgit v1.2.3
From 0e9ff32598ed86d5f24a8bce5c5c898d81dc2c84 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Wed, 2 Oct 2013 16:33:41 +0300
Subject: Ported regression fixes in 6.8 for #12407 to 7.1 branch
Change-Id: Ie46ab97fc1ff89dd241eec9182ed0f92164b754d
---
client/src/com/vaadin/client/ui/VScrollTable.java | 32 ++++++++++++-----------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 492730259a..6e9e28ff25 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -1113,14 +1113,16 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private ScheduledCommand lazyScroller = new ScheduledCommand() {
@Override
public void execute() {
- if (firstvisibleOnLastPage > -1) {
- scrollBodyPanel
- .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage));
- } else {
- scrollBodyPanel
- .setScrollPosition(measureRowHeightOffset(firstvisible));
+ if (firstvisible > 0) {
+ firstRowInViewPort = firstvisible;
+ if (firstvisibleOnLastPage > -1) {
+ scrollBodyPanel
+ .setScrollPosition(measureRowHeightOffset(firstvisibleOnLastPage));
+ } else {
+ scrollBodyPanel
+ .setScrollPosition(measureRowHeightOffset(firstvisible));
+ }
}
- firstRowInViewPort = firstvisible;
}
};
@@ -1131,17 +1133,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
firstvisibleOnLastPage = uidl.hasVariable("firstvisibleonlastpage") ? uidl
.getIntVariable("firstvisibleonlastpage") : -1;
if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
- // received 'surprising' firstvisible from server: scroll there
- firstRowInViewPort = firstvisible;
+
// Update lastRequestedFirstvisible right away here
// (don't rely on update in the timer which could be cancelled).
lastRequestedFirstvisible = firstRowInViewPort;
- /*
- * Schedule the scrolling to be executed last so no updates to the
- * rows affect scrolling measurements.
- */
- Scheduler.get().scheduleFinally(lazyScroller);
+ // Only scroll if the first visible changes from the server side.
+ // Else we might unintentionally scroll even when the scroll
+ // position has not changed.
+ Scheduler.get().scheduleDeferred(lazyScroller);
}
}
@@ -2160,7 +2160,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
isNewBody = false;
- Scheduler.get().scheduleFinally(lazyScroller);
+ if (firstvisible > 0) {
+ Scheduler.get().scheduleDeferred(lazyScroller);
+ }
if (enabled) {
// Do we need cache rows
--
cgit v1.2.3
From 267a4cae6de31d143c3d8d1d8dd79d4616896603 Mon Sep 17 00:00:00 2001
From: Artem Godin
Date: Wed, 2 Oct 2013 17:07:14 +0300
Subject: Fix OptionGroup elements losing focus on value change (#10451)
The misbehavior was caused by VOptionGroup.buildOptions recreating
associated panel on every change by removing and adding new elements.
With this fix applied it tries to update existing elements,
distinguishing them by assigned keys. It will recreate panel though if
elements are reordered or new elements were added/removed.
Change-Id: I1245b2ff30ce1932614c1eac37bd0131cbd29dd7
---
client/src/com/vaadin/client/ui/VOptionGroup.java | 67 +++++++++++++++------
.../OptionGroupRetainFocusKeyboardValueChange.html | 54 +++++++++++++++++
.../OptionGroupRetainFocusKeyboardValueChange.java | 70 ++++++++++++++++++++++
3 files changed, 174 insertions(+), 17 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.html
create mode 100644 uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java
diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java
index a4c8b6733c..455c7669f5 100644
--- a/client/src/com/vaadin/client/ui/VOptionGroup.java
+++ b/client/src/com/vaadin/client/ui/VOptionGroup.java
@@ -95,11 +95,29 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
}
/*
- * Return true if no elements were changed, false otherwise.
+ * Try to update content of existing elements, rebuild panel entirely
+ * otherwise
*/
@Override
public void buildOptions(UIDL uidl) {
- panel.clear();
+ /*
+ * In order to retain focus, we need to update values rather than
+ * recreate panel from scratch (#10451). However, the panel will be
+ * rebuilt (losing focus) if number of elements or their order is
+ * changed.
+ */
+ HashMap keysToOptions = new HashMap();
+ for (Map.Entry entry : optionsToKeys.entrySet()) {
+ keysToOptions.put(entry.getValue(), entry.getKey());
+ }
+ ArrayList existingwidgets = new ArrayList();
+ ArrayList newwidgets = new ArrayList();
+
+ // Get current order of elements
+ for (Widget wid : panel) {
+ existingwidgets.add(wid);
+ }
+
optionsEnabled.clear();
if (isMultiselect()) {
@@ -110,7 +128,6 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
for (final Iterator> it = uidl.getChildIterator(); it.hasNext();) {
final UIDL opUidl = (UIDL) it.next();
- CheckBox op;
String itemHtml = opUidl.getStringAttribute("caption");
if (!htmlContentAllowed) {
@@ -124,32 +141,48 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
+ Icon.CLASSNAME + "\" alt=\"\" />" + itemHtml;
}
- if (isMultiselect()) {
- op = new VCheckBox();
- op.setHTML(itemHtml);
- } else {
- op = new RadioButton(paintableId, itemHtml, true);
- op.setStyleName("v-radiobutton");
- }
+ String key = opUidl.getStringAttribute("key");
+ CheckBox op = keysToOptions.get(key);
+ if (op == null) {
+ // Create a new element
+ if (isMultiselect()) {
+ op = new VCheckBox();
+ } else {
+ op = new RadioButton(paintableId);
+ op.setStyleName("v-radiobutton");
+ }
+ if (icon != null && icon.length() != 0) {
+ Util.sinkOnloadForImages(op.getElement());
+ op.addHandler(iconLoadHandler, LoadEvent.getType());
+ }
- if (icon != null && icon.length() != 0) {
- Util.sinkOnloadForImages(op.getElement());
- op.addHandler(iconLoadHandler, LoadEvent.getType());
+ op.addStyleName(CLASSNAME_OPTION);
+ op.addClickHandler(this);
+
+ optionsToKeys.put(op, key);
}
- op.addStyleName(CLASSNAME_OPTION);
+ op.setHTML(itemHtml);
op.setValue(opUidl.getBooleanAttribute("selected"));
boolean optionEnabled = !opUidl
.getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED);
boolean enabled = optionEnabled && !isReadonly() && isEnabled();
op.setEnabled(enabled);
optionsEnabled.add(optionEnabled);
+
setStyleName(op.getElement(),
ApplicationConnection.DISABLED_CLASSNAME,
!(optionEnabled && isEnabled()));
- op.addClickHandler(this);
- optionsToKeys.put(op, opUidl.getStringAttribute("key"));
- panel.add(op);
+
+ newwidgets.add(op);
+ }
+
+ if (!newwidgets.equals(existingwidgets)) {
+ // Rebuild the panel, losing focus
+ panel.clear();
+ for (Widget wid : newwidgets) {
+ panel.add(wid);
+ }
}
}
diff --git a/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.html b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.html
new file mode 100644
index 0000000000..046cac0e30
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+OptionGroupRetainFocusKeyboardValueChange
+
+
+
+
+OptionGroupRetainFocusKeyboardValueChange
+
+
+ open
+ /run/OptionGroupRetainFocusKeyboardValueChange?restartApplication
+
+
+
+ pressSpecialKey
+ vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[0]/domChild[0]
+ space
+
+
+
+ screenCapture
+
+
+
+
+ pressSpecialKey
+ vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[0]/domChild[0]
+ down
+
+
+
+ screenCapture
+
+
+
+
+ pressSpecialKey
+ vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[1]/domChild[0]
+ down
+
+
+
+ screenCapture
+
+
+
+
+
+
diff --git a/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java
new file mode 100644
index 0000000000..570a300cb3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/optiongroup/OptionGroupRetainFocusKeyboardValueChange.java
@@ -0,0 +1,70 @@
+/*
+ * 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.optiongroup;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.OptionGroup;
+
+/**
+ * Testcase for #10451
+ *
+ * @author Vaadin Ltd
+ */
+public class OptionGroupRetainFocusKeyboardValueChange extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final OptionGroup optiongroup = new OptionGroup();
+ optiongroup.addItem(1);
+ optiongroup.addItem(2);
+ optiongroup.addItem(3);
+ optiongroup.setItemCaption(1, "A");
+ optiongroup.setItemCaption(2, "B");
+ optiongroup.setItemCaption(3, "C");
+ optiongroup.setImmediate(true);
+
+ optiongroup.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (optiongroup.isSelected(2)) {
+ optiongroup.setItemCaption(1, "A+");
+ } else if (optiongroup.isSelected(3)) {
+ optiongroup.removeItem(2);
+ optiongroup.addItem(2);
+ optiongroup.setItemCaption(2, "B");
+ }
+ }
+ });
+
+ addComponent(optiongroup);
+
+ optiongroup.focus();
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "OptionGroup should retain focus after it's value being changed with keyboard";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10451;
+ }
+}
--
cgit v1.2.3
From 07ca622a6b2edcf7a253762cf222155bdf460a88 Mon Sep 17 00:00:00 2001
From: Matti Tahvonen
Date: Fri, 27 Sep 2013 19:00:53 +0300
Subject: Fixes #12564 (HorizontalLayout breaks w/ alignment & error indicator)
Removed some obsolete (hopefully!?) code doing some odd things with caption height calculation and some refactoring to make that part of code slightly more readable.
Change-Id: I960e4a9eba0388281868f18a182c8788cedf08f9
---
.../AbstractOrderedLayoutConnector.java | 32 ++++----
...orizontalLayoutFullsizeContentWithErrorMsg.java | 96 ++++++++++++++++++++++
2 files changed, 111 insertions(+), 17 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
index e0dc0d51df..ec4307e50b 100644
--- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
+++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
@@ -19,6 +19,7 @@ import java.util.List;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
@@ -611,13 +612,14 @@ public abstract class AbstractOrderedLayoutConnector extends
LayoutManager layoutManager = getLayoutManager();
for (ComponentConnector child : getChildComponents()) {
- Slot slot = getWidget().getSlot(child.getWidget());
+ Widget childWidget = child.getWidget();
+ Slot slot = getWidget().getSlot(childWidget);
Element captionElement = slot.getCaptionElement();
- CaptionPosition pos = slot.getCaptionPosition();
+ CaptionPosition captionPosition = slot.getCaptionPosition();
- Element childElement = child.getWidget().getElement();
- int h = layoutManager.getOuterHeight(childElement);
- if (h == -1) {
+ int pixelHeight = layoutManager.getOuterHeight(childWidget
+ .getElement());
+ if (pixelHeight == -1) {
// Height has not yet been measured -> postpone actions that
// depend on the max height
return -1;
@@ -625,14 +627,10 @@ public abstract class AbstractOrderedLayoutConnector extends
boolean hasRelativeHeight = slot.hasRelativeHeight();
+ boolean captionSizeShouldBeAddedtoComponentHeight = captionPosition == CaptionPosition.TOP
+ || captionPosition == CaptionPosition.BOTTOM;
boolean includeCaptionHeight = captionElement != null
- && (pos == CaptionPosition.TOP || pos == CaptionPosition.BOTTOM);
- if (!hasRelativeHeight && !includeCaptionHeight
- && captionElement != null) {
- String sHeight = childElement.getStyle().getHeight();
- includeCaptionHeight = (sHeight == null || !sHeight
- .endsWith("%"));
- }
+ && captionSizeShouldBeAddedtoComponentHeight;
if (includeCaptionHeight) {
int captionHeight = layoutManager
@@ -643,16 +641,16 @@ public abstract class AbstractOrderedLayoutConnector extends
// depend on the max height
return -1;
}
- h += captionHeight;
+ pixelHeight += captionHeight;
}
if (!hasRelativeHeight) {
- if (h > highestNonRelative) {
- highestNonRelative = h;
+ if (pixelHeight > highestNonRelative) {
+ highestNonRelative = pixelHeight;
}
} else {
- if (h > highestRelative) {
- highestRelative = h;
+ if (pixelHeight > highestRelative) {
+ highestRelative = pixelHeight;
}
}
}
diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
new file mode 100644
index 0000000000..25675e07c5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java
@@ -0,0 +1,96 @@
+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;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TextField;
+
+public class HorizontalLayoutFullsizeContentWithErrorMsg extends AbstractTestUI {
+
+ private static final String FIELD_ID = "f";
+ private static final String BUTTON_ID = "b";
+ private TextField tf;
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 12564;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("500px");
+
+ tf = new TextField();
+ tf.setId(FIELD_ID);
+ tf.setWidth("100%");
+ hl.addComponent(tf);
+ hl.setExpandRatio(tf, 1);
+ hl.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
+
+ Button toggleError = new Button("Toggle error");
+ toggleError.setId(BUTTON_ID);
+ toggleError.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ tf.setComponentError(tf.getComponentError() == null ? new UserError(
+ "foo") : null);
+ }
+ });
+ hl.addComponent(toggleError);
+
+ addComponent(hl);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ 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());
+
+ }
+
+ }
+
+}
--
cgit v1.2.3
From 633b4e858c31769f4b8848c934651da1d54b2721 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Thu, 12 Sep 2013 20:57:01 +0300
Subject: Prepare for Atmosphere Javascript 2.0 (#12241)
* Atmosphere 2.0 has changed enableProtocol to default to true.
* Reopening a connection in Atmosphere 2.0 is signalled through an onReopen event (not present at all in Atmosphere 1.0.x)
Fix was backported from master
Change-Id: I6ed258087a0b3a06440ab9d19b621560fa4f998f
Merge: no
---
.../communication/AtmospherePushConnection.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index 3cecb09dc1..8bddd78688 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -228,10 +228,26 @@ public class AtmospherePushConnection implements PushConnection {
return config;
}
- protected void onOpen(AtmosphereResponse response) {
- transport = response.getTransport();
+ protected void onReopen(AtmosphereResponse response) {
+ VConsole.log("Push connection re-established using " + transport);
+ onConnect(response);
+ }
+ protected void onOpen(AtmosphereResponse response) {
VConsole.log("Push connection established using " + transport);
+ onConnect(response);
+ }
+
+ /**
+ * Called whenever a server push connection is established (or
+ * re-established).
+ *
+ * @param response
+ *
+ * @since 7.2
+ */
+ protected void onConnect(AtmosphereResponse response) {
+ transport = response.getTransport();
switch (state) {
case CONNECT_PENDING:
@@ -422,6 +438,7 @@ public class AtmospherePushConnection implements PushConnection {
reconnectInterval: 5000,
maxReconnectOnClose: 10000000,
trackMessageLength: true,
+ enableProtocol: false,
messageDelimiter: String.fromCharCode(@com.vaadin.shared.communication.PushConstants::MESSAGE_DELIMITER)
};
}-*/;
@@ -435,6 +452,9 @@ public class AtmospherePushConnection implements PushConnection {
config.onOpen = $entry(function(response) {
self.@com.vaadin.client.communication.AtmospherePushConnection::onOpen(*)(response);
});
+ config.onReopen = $entry(function(response) {
+ self.@com.vaadin.client.communication.AtmospherePushConnection::onReopen(*)(response);
+ });
config.onMessage = $entry(function(response) {
self.@com.vaadin.client.communication.AtmospherePushConnection::onMessage(*)(response);
});
--
cgit v1.2.3
From 503e5757bbac1a28c8987ecae9f75d271a61899b Mon Sep 17 00:00:00 2001
From: Artem Godin
Date: Thu, 3 Oct 2013 15:47:08 +0300
Subject: Fix NullPointerException in logger when message is null (#12588)
LogSection.publish and VConsole.log/VConsole.error methods now replace
null message with an empty string ("")
Change-Id: I735b51bce971ababe2557f1b6c317c01066bc03c
---
client/src/com/vaadin/client/VConsole.java | 18 ++++++++++++++----
.../com/vaadin/client/debug/internal/LogSection.java | 6 ++++++
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/client/src/com/vaadin/client/VConsole.java b/client/src/com/vaadin/client/VConsole.java
index 37ed8e6370..32eb206a70 100644
--- a/client/src/com/vaadin/client/VConsole.java
+++ b/client/src/com/vaadin/client/VConsole.java
@@ -41,25 +41,35 @@ public class VConsole {
public static void log(String msg) {
if (LogConfiguration.loggingIsEnabled(Level.INFO)) {
- getLogger().log(Level.INFO, msg);
+ // Check for null, so no NullPointerException is generated when
+ // formatting (#12588)
+ getLogger().log(Level.INFO, msg == null ? "null" : msg);
}
}
public static void log(Throwable e) {
if (LogConfiguration.loggingIsEnabled(Level.INFO)) {
- getLogger().log(Level.INFO, e.getMessage(), e);
+ // Check for null, so no NullPointerException is generated when
+ // formatting (#12588)
+ getLogger().log(Level.INFO,
+ e.getMessage() == null ? "" : e.getMessage(), e);
}
}
public static void error(Throwable e) {
if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) {
- getLogger().log(Level.SEVERE, e.getMessage(), e);
+ // Check for null, so no NullPointerException is generated when
+ // formatting (#12588)
+ getLogger().log(Level.SEVERE,
+ e.getMessage() == null ? "" : e.getMessage(), e);
}
}
public static void error(String msg) {
if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) {
- getLogger().log(Level.SEVERE, msg);
+ // Check for null, so no NullPointerException is generated when
+ // formatting (#12588)
+ getLogger().log(Level.SEVERE, msg == null ? "null" : msg);
}
}
diff --git a/client/src/com/vaadin/client/debug/internal/LogSection.java b/client/src/com/vaadin/client/debug/internal/LogSection.java
index 1e7524b56d..f792ec95be 100644
--- a/client/src/com/vaadin/client/debug/internal/LogSection.java
+++ b/client/src/com/vaadin/client/debug/internal/LogSection.java
@@ -73,6 +73,12 @@ public class LogSection implements Section {
return;
}
+ // If no message is provided, record.getMessage will be null and so
+ // the formatter.format will fail with NullPointerException (#12588)
+ if (record.getMessage() == null) {
+ record.setMessage("");
+ }
+
Formatter formatter = getFormatter();
String msg = formatter.format(record);
--
cgit v1.2.3
From d9f6dadfb41c2b618390edf8a05bbe78a8794e06 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Mon, 7 Oct 2013 12:37:50 +0300
Subject: Fixed Table range selection IE regression #12407
After fixes for #12407 the range selection did not work in the case
where the selection start had previously been removed. This caused
MultiSelectWithRemovedRow test to fail on IE.
Change-Id: Iaa91cc6a3a310aedc80c4c2475fa8e94a30a5563
---
client/src/com/vaadin/client/ui/VScrollTable.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 6e9e28ff25..9cec59a5a2 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -6110,7 +6110,13 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
.next();
setRowFocus(endRow);
}
+ } else if (!startRow.isSelected()) {
+ // The start row is no longer selected (probably removed)
+ // and so we select from above
+ startRow = (VScrollTableRow) scrollBody.iterator().next();
+ setRowFocus(endRow);
}
+
// Deselect previous items if so desired
if (deselectPrevious) {
deselectAll();
--
cgit v1.2.3
From 64530550abb89aa59d05f824e949f58ba05f1202 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 20:49:18 +0300
Subject: Run tests on Tomcat 8 (#12326)
Change-Id: I99d91f16c5ad2dce6fb93f2862913b23518410d7
---
uitest/integration_tests.xml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/uitest/integration_tests.xml b/uitest/integration_tests.xml
index f1b2070bc8..1c9c2b1f8f 100644
--- a/uitest/integration_tests.xml
+++ b/uitest/integration_tests.xml
@@ -124,6 +124,12 @@
+
+
+
+
+
+
@@ -397,6 +403,7 @@
+
--
cgit v1.2.3
From 10bcbdc652c6a61a0adbb8a8b357402ab1b65e2f Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 20:16:15 +0300
Subject: Actually open integration test.
Regression since the change in test behavior (no longer automatically
opens test URL)
Change-Id: I1c4efc9b5b5c8a28818afa6f91af1a8b159354b4
---
uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
index ae83083d85..2a2f8ab3d1 100644
--- a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
@@ -31,6 +31,7 @@ public abstract class ServletIntegrationTestTB3 extends
@Test
public void runTest() throws IOException, AssertionError {
+ openTestURL();
compareScreen("initial");
WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1));
--
cgit v1.2.3
From 3cba6bf847df3fab77cec04dcd2586c76316fd74 Mon Sep 17 00:00:00 2001
From: Artem Godin
Date: Mon, 7 Oct 2013 17:19:57 +0300
Subject: Rebuild OptionGroup on HtmlContentAllowed/Multiselect changes
(#10451)
Fixes regression with HtmlContent in Safari 5 and changing of
Multiselect properties on the fly.
Change-Id: I4a3820eba8d1c06460777340ea36b1df31b38983
---
client/src/com/vaadin/client/ui/VOptionGroup.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/client/src/com/vaadin/client/ui/VOptionGroup.java b/client/src/com/vaadin/client/ui/VOptionGroup.java
index 455c7669f5..fee1c313f5 100644
--- a/client/src/com/vaadin/client/ui/VOptionGroup.java
+++ b/client/src/com/vaadin/client/ui/VOptionGroup.java
@@ -87,11 +87,16 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
/** For internal use only. May be removed or replaced in the future. */
public boolean htmlContentAllowed = false;
+ private boolean wasHtmlContentAllowed = false;
+ private boolean wasMultiselect = false;
+
public VOptionGroup() {
super(CLASSNAME);
panel = (Panel) optionsContainer;
optionsToKeys = new HashMap();
optionsEnabled = new ArrayList();
+
+ wasMultiselect = isMultiselect();
}
/*
@@ -143,7 +148,11 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
String key = opUidl.getStringAttribute("key");
CheckBox op = keysToOptions.get(key);
- if (op == null) {
+
+ // Need to recreate object if isMultiselect is changed (#10451)
+ // OR if htmlContentAllowed changed due to Safari 5 issue
+ if ((op == null) || (htmlContentAllowed != wasHtmlContentAllowed)
+ || (isMultiselect() != wasMultiselect)) {
// Create a new element
if (isMultiselect()) {
op = new VCheckBox();
@@ -184,6 +193,9 @@ public class VOptionGroup extends VOptionGroupBase implements FocusHandler,
panel.add(wid);
}
}
+
+ wasHtmlContentAllowed = htmlContentAllowed;
+ wasMultiselect = isMultiselect();
}
@Override
--
cgit v1.2.3
From 4f3cc4cef8c75a6f3a6af26e95509247a84c08b8 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Fri, 27 Sep 2013 13:44:00 +0300
Subject: Converted push test to TB3 (#12226, #12522)
Change-Id: Ia12b35ef6beed0bf2f534f2c9505b22ce7b3c7c3
---
.../com/vaadin/tests/push/EnableDisablePush.html | 97 ----------------------
.../com/vaadin/tests/push/EnableDisablePush.java | 60 ++++++++++++-
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 25 ++++++
3 files changed, 84 insertions(+), 98 deletions(-)
delete mode 100644 uitest/src/com/vaadin/tests/push/EnableDisablePush.html
diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.html b/uitest/src/com/vaadin/tests/push/EnableDisablePush.html
deleted file mode 100644
index 87dfa8428f..0000000000
--- a/uitest/src/com/vaadin/tests/push/EnableDisablePush.html
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-EnableDisablePush
-
-
-
-
-EnableDisablePush
-
-
- open
- /run/EnableDisablePush?restartApplication
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 1. Push enabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 3. Push disabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 5. Poll enabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 7. Push enabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 9. Poll disabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 11. Push disabled, polling enabled
-
-
- pause
- 3500
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 16. Polling disabled, push enabled
-
-
- click
- vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runEnableDisablePush::PID_SLog_row_0
- 18. Push disabled
-
-
-
-
-
diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java
index 1911c66c2d..50dab43667 100644
--- a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java
+++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java
@@ -1,19 +1,74 @@
package com.vaadin.tests.push;
+import static org.junit.Assert.assertEquals;
+
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
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.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.UIDetachedException;
public class EnableDisablePush extends AbstractTestUI {
+ public static class EnableDisablePushTest extends MultiBrowserTest {
+ @Test
+ public void testEnablePushWhenUsingPolling() throws Exception {
+ openTestURL();
+
+ assertEquals("1. Push enabled", getLogRow(0));
+
+ getDisablePushButton().click();
+ assertEquals("3. Push disabled", getLogRow(0));
+
+ getEnablePollButton().click();
+ assertEquals("5. Poll enabled", getLogRow(0));
+
+ getEnablePushButton().click();
+ assertEquals("7. Push enabled", getLogRow(0));
+
+ getDisablePollButton().click();
+ assertEquals("9. Poll disabled", getLogRow(0));
+
+ getDisablePushButtonAndReenableFromBackground().click();
+ Thread.sleep(2500);
+ assertEquals("16. Polling disabled, push enabled", getLogRow(0));
+
+ getDisablePushButton().click();
+ assertEquals("18. Push disabled", getLogRow(0));
+ }
+
+ private WebElement getDisablePushButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]");
+ }
+
+ private WebElement getEnablePushButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]");
+ }
+
+ private WebElement getDisablePollButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]");
+ }
+
+ private WebElement getEnablePollButton() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]");
+ }
+
+ private WebElement getDisablePushButtonAndReenableFromBackground() {
+ return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]");
+ }
+
+ }
+
private int c = 0;
private Log log = new Log(15);
@@ -27,7 +82,7 @@ public class EnableDisablePush extends AbstractTestUI {
try {
while (true) {
- TimeUnit.MILLISECONDS.sleep(1000);
+ TimeUnit.MILLISECONDS.sleep(500);
access(new Runnable() {
@Override
@@ -42,6 +97,9 @@ public class EnableDisablePush extends AbstractTestUI {
}
}
});
+ if (c == 3) {
+ return;
+ }
}
} catch (InterruptedException e) {
} catch (UIDetachedException e) {
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 054492444d..5d5f5fae31 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -37,6 +37,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import com.vaadin.server.LegacyApplication;
import com.vaadin.testbench.TestBench;
import com.vaadin.testbench.TestBenchTestCase;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.UI;
/**
@@ -297,6 +298,30 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
new WebDriverWait(driver, 10).until(ExpectedConditions.not(condition));
}
+ /**
+ * For tests extending {@link AbstractTestUIWithLog}, returns the element
+ * for the Nth log row
+ *
+ * @param rowNr
+ * The log row to retrieve
+ * @return the Nth log row
+ */
+ protected WebElement getLogRowElement(int rowNr) {
+ return vaadinElementById("Log_row_" + rowNr);
+ }
+
+ /**
+ * For tests extending {@link AbstractTestUIWithLog}, returns the text in
+ * the Nth log row
+ *
+ * @param rowNr
+ * The log row to retrieve text for
+ * @return the text in the log row
+ */
+ protected String getLogRow(int rowNr) {
+ return getLogRowElement(rowNr).getText();
+ }
+
/**
* Returns the path that should be used for the test. The path contains the
* full path (appended to hostname+port) and must start with a slash.
--
cgit v1.2.3
From 281fc4334881080a89c487b2d867d4643b667809 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 18:53:53 +0300
Subject: Fixed incorrect logging (#12241)
Change-Id: Icfe32a26f9069b7c5ed8160dba93b806754acf58
---
.../com/vaadin/client/communication/AtmospherePushConnection.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
index 8bddd78688..4bf12ca1f3 100644
--- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
+++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java
@@ -229,12 +229,14 @@ public class AtmospherePushConnection implements PushConnection {
}
protected void onReopen(AtmosphereResponse response) {
- VConsole.log("Push connection re-established using " + transport);
+ VConsole.log("Push connection re-established using "
+ + response.getTransport());
onConnect(response);
}
protected void onOpen(AtmosphereResponse response) {
- VConsole.log("Push connection established using " + transport);
+ VConsole.log("Push connection established using "
+ + response.getTransport());
onConnect(response);
}
--
cgit v1.2.3
From 63e16e6547b4a7c067a9a1fa53dcecb9d704016b Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 17:56:31 +0300
Subject: Mark as deprecated to discourage usage for new tests
Change-Id: I87d417da5b6b8cf9753604944dff74f8f39c321a
---
uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java
index a7ade3f9f7..aeeed4198c 100644
--- a/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/SimpleMultiBrowserTest.java
@@ -32,6 +32,7 @@ import org.junit.Test;
*
* @author Vaadin Ltd
*/
+@Deprecated
public abstract class SimpleMultiBrowserTest extends MultiBrowserTest {
@Test
--
cgit v1.2.3
From f488825d46c984cea841534178b094be3a562eea Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 18:12:06 +0300
Subject: 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
---
.../src/com/vaadin/tests/VerifyBrowserVersion.java | 48 ----
.../com/vaadin/tests/VerifyBrowserVersionTest.java | 66 ++++++
.../vaadin/tests/components/label/LabelModes.java | 10 -
.../tests/components/label/LabelModesTest.java | 30 +++
...orizontalLayoutFullsizeContentWithErrorMsg.java | 34 +--
...ontalLayoutFullsizeContentWithErrorMsgTest.java | 49 ++++
.../components/panel/PanelChangeContentsTest.java | 53 +++++
.../tests/components/slider/SliderDisable.java | 19 --
.../tests/components/slider/SliderDisableTest.java | 36 +++
.../com/vaadin/tests/components/ui/UIAccess.java | 28 ---
.../vaadin/tests/components/ui/UIAccessTest.java | 45 ++++
uitest/src/com/vaadin/tests/push/BarInUIDL.java | 28 ---
.../src/com/vaadin/tests/push/BarInUIDLTest.java | 45 ++++
uitest/src/com/vaadin/tests/push/BasicPush.java | 75 -------
.../com/vaadin/tests/push/BasicPushStreaming.java | 3 -
.../vaadin/tests/push/BasicPushStreamingTest.java | 19 ++
.../src/com/vaadin/tests/push/BasicPushTest.java | 92 ++++++++
.../com/vaadin/tests/push/BasicPushWebsocket.java | 12 -
.../vaadin/tests/push/BasicPushWebsocketTest.java | 29 +++
.../com/vaadin/tests/push/PushConfiguration.java | 117 ++++++++++
.../vaadin/tests/push/PushConfigurationTest.java | 246 ++++++---------------
uitest/src/com/vaadin/tests/push/PushFromInit.java | 33 ---
.../com/vaadin/tests/push/PushFromInitTest.java | 50 +++++
.../vaadin/tests/push/PushReattachedComponent.java | 63 ------
uitest/src/com/vaadin/tests/push/TogglePush.java | 95 --------
.../src/com/vaadin/tests/push/TogglePushTest.java | 112 ++++++++++
.../com/vaadin/tests/push/TrackMessageSizeUI.java | 152 +++++++++++++
.../vaadin/tests/push/TrackMessageSizeUITest.java | 30 +++
.../tests/push/TrackMessageSizeUnitTests.java | 164 --------------
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 43 +++-
30 files changed, 1039 insertions(+), 787 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/label/LabelModesTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsgTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/slider/SliderDisableTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/BarInUIDLTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/BasicPushStreamingTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/BasicPushTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/BasicPushWebsocketTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/PushConfiguration.java
create mode 100644 uitest/src/com/vaadin/tests/push/PushFromInitTest.java
delete mode 100644 uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
create mode 100644 uitest/src/com/vaadin/tests/push/TogglePushTest.java
create mode 100644 uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
create mode 100644 uitest/src/com/vaadin/tests/push/TrackMessageSizeUITest.java
delete mode 100644 uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
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 expectedUserAgent = new HashMap();
-
- {
- 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 expectedUserAgent = new HashMap();
+
+ {
+ 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 {
- public static class LabelModesTest extends SimpleMultiBrowserTest {
- @Override
- public void test() throws Exception {
- openTestURL();
- compareScreen("labelmodes");
- }
-
- }
-
@Override
protected Class 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/components/panel/PanelChangeContentsTest.java b/uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java
new file mode 100644
index 0000000000..5bc505dbc8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/panel/PanelChangeContentsTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.panel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class PanelChangeContentsTest extends MultiBrowserTest {
+
+ @Test
+ public void testReattachComponentUsingPush() {
+ setPush(true);
+ openTestURL();
+
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "companies",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ Assert.assertEquals(
+ "stats",
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
+ .getText());
+
+ }
+}
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 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 counter = new ObjectProperty(0);
private ObjectProperty counter2 = new ObjectProperty(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 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 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 counter = new ObjectProperty(0);
+
+ private ObjectProperty counter2 = new ObjectProperty(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(" ", 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 counter = new ObjectProperty(0);
-
- private ObjectProperty counter2 = new ObjectProperty(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(" ", 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/PushReattachedComponent.java b/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
deleted file mode 100644
index 0bc796e0ee..0000000000
--- a/uitest/src/com/vaadin/tests/push/PushReattachedComponent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.components.panel.PanelChangeContents;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class PushReattachedComponent extends MultiBrowserTest {
-
- @Override
- protected Class> getUIClass() {
- return PanelChangeContents.class;
- }
-
- @Test
- public void testReattachComponentUsingPush() {
- setPush(true);
- openTestURL();
-
- Assert.assertEquals(
- "stats",
- vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
- .getText());
- vaadinElement(
- "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]")
- .click();
- Assert.assertEquals(
- "companies",
- vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
- .getText());
- vaadinElement(
- "/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
- .click();
- Assert.assertEquals(
- "stats",
- vaadinElement(
- "/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]")
- .getText());
-
- }
-}
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/TrackMessageSizeUI.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
new file mode 100644
index 0000000000..67715339da
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
@@ -0,0 +1,152 @@
+/*
+ * 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.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.servlet.ServletContext;
+
+import org.apache.commons.io.IOUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+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.ui.JavaScriptFunction;
+
+// Load vaadinPush.js so that jQueryVaadin is defined
+@JavaScript("vaadin://vaadinPush.js")
+public class TrackMessageSizeUI extends AbstractTestUIWithLog {
+
+ private String testMethod = "function testSequence(expected, data) {\n"
+ + " var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
+ + " var response = {partialMessage: ''};\n"
+ + " var messages = [];\n"
+ + " for(var i = 0; i < data.length; i++) {\n"
+ + " if (!_trackMessageSize(data[i], request, response))\n"
+ + " messages = messages.concat(response.messages);\n"
+ + " }\n"
+ + " if (JSON.stringify(expected) != JSON.stringify(messages)) {\n"
+ + " if (console && typeof console.error == 'function') console.error('Expected', expected, 'but got', messages, 'for', data);\n"
+ + " logToServer('Test failed, see javascript console for details.');\n"
+ + " }" + "}\n";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ String methodImplementation = findMethodImplementation();
+ getPage().getJavaScript().addFunction("logToServer",
+ new JavaScriptFunction() {
+ @Override
+ public void call(JSONArray arguments) throws JSONException {
+ String message = arguments.getString(0);
+ log(message);
+ }
+ });
+
+ getPage().getJavaScript().execute(
+ methodImplementation + testMethod + buildTestCase());
+ }
+
+ private String buildTestCase() {
+ // Could maybe express the cases in java and generate JS?
+ return "testSequence(['a', 'b'], ['1|a1|b', '']);\n"
+ + "testSequence(['a', 'b'], ['1|a1|', 'b']);\n"
+ + "testSequence(['a', 'b'], ['1|a1', '|b']);\n"
+ + "testSequence(['a', 'b'], ['1|a', '1|b']);\n"
+ + "testSequence(['a', 'b'], ['1|a', '', '1|b']);\n"
+ + "testSequence(['a|', '|b'], ['2|a|2||b']);\n"
+ + "testSequence(['a|', 'b'], ['2|a|', '', '1|b']);\n"
+ + "testSequence(['a|', 'b'], ['2|a|', '1|b']);\n"
+ + "testSequence(['a|', 'b'], ['2|a|1', '|b']);\n"
+ + "testSequence(['a|', 'b'], ['2|a|1|', 'b']);\n"
+ + "testSequence([' ', 'b'], ['1| 1|b']);\n"
+ + "testSequence([' ', 'b'], ['1| ','1|b']);\n"
+ + "testSequence([' ', 'b'], ['1|',' 1|b']);\n"
+ + "logToServer('All tests run')\n";
+ }
+
+ private String findMethodImplementation() {
+ String filename = "/VAADIN/jquery.atmosphere.js";
+ URL resourceURL = findResourceURL(filename,
+ (VaadinServletService) VaadinService.getCurrent());
+ if (resourceURL == null) {
+ log("Can't find " + filename);
+ return null;
+ }
+
+ try {
+ String string = IOUtils.toString(resourceURL);
+
+ // Find the function inside the script content
+ int startIndex = string.indexOf("function _trackMessageSize");
+ if (startIndex == -1) {
+ log("function not found");
+ return null;
+ }
+
+ // Assumes there's a /** comment before the next function
+ int endIndex = string.indexOf("/**", startIndex);
+ if (endIndex == -1) {
+ log("End of function not found");
+ return null;
+ }
+
+ string = string.substring(startIndex, endIndex);
+ string = string.replaceAll("jQuery", "jQueryVaadin");
+ return string;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private URL findResourceURL(String filename, VaadinServletService service) {
+ ServletContext sc = service.getServlet().getServletContext();
+ URL resourceUrl;
+ try {
+ resourceUrl = sc.getResource(filename);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ if (resourceUrl == null) {
+ // try if requested file is found from classloader
+
+ // strip leading "/" otherwise stream from JAR wont work
+ if (filename.startsWith("/")) {
+ filename = filename.substring(1);
+ }
+
+ resourceUrl = service.getClassLoader().getResource(filename);
+ }
+ return resourceUrl;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Unit tests for _trackMessageSize in jquery.atmosphere.js. Implemented with testbench and a full Vaadin server side since the testing requires some file mangling.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(12468);
+ }
+
+}
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/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
deleted file mode 100644
index cb3033aa58..0000000000
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-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());
- }
- }
-
- private String testMethod = "function testSequence(expected, data) {\n"
- + " var request = {trackMessageLength: true, messageDelimiter: '|'};\n"
- + " var response = {partialMessage: ''};\n"
- + " var messages = [];\n"
- + " for(var i = 0; i < data.length; i++) {\n"
- + " if (!_trackMessageSize(data[i], request, response))\n"
- + " messages = messages.concat(response.messages);\n"
- + " }\n"
- + " if (JSON.stringify(expected) != JSON.stringify(messages)) {\n"
- + " if (console && typeof console.error == 'function') console.error('Expected', expected, 'but got', messages, 'for', data);\n"
- + " logToServer('Test failed, see javascript console for details.');\n"
- + " }" + "}\n";
-
- @Override
- protected void setup(VaadinRequest request) {
- String methodImplementation = findMethodImplementation();
- getPage().getJavaScript().addFunction("logToServer",
- new JavaScriptFunction() {
- @Override
- public void call(JSONArray arguments) throws JSONException {
- String message = arguments.getString(0);
- log(message);
- }
- });
-
- getPage().getJavaScript().execute(
- methodImplementation + testMethod + buildTestCase());
- }
-
- private String buildTestCase() {
- // Could maybe express the cases in java and generate JS?
- return "testSequence(['a', 'b'], ['1|a1|b', '']);\n"
- + "testSequence(['a', 'b'], ['1|a1|', 'b']);\n"
- + "testSequence(['a', 'b'], ['1|a1', '|b']);\n"
- + "testSequence(['a', 'b'], ['1|a', '1|b']);\n"
- + "testSequence(['a', 'b'], ['1|a', '', '1|b']);\n"
- + "testSequence(['a|', '|b'], ['2|a|2||b']);\n"
- + "testSequence(['a|', 'b'], ['2|a|', '', '1|b']);\n"
- + "testSequence(['a|', 'b'], ['2|a|', '1|b']);\n"
- + "testSequence(['a|', 'b'], ['2|a|1', '|b']);\n"
- + "testSequence(['a|', 'b'], ['2|a|1|', 'b']);\n"
- + "testSequence([' ', 'b'], ['1| 1|b']);\n"
- + "testSequence([' ', 'b'], ['1| ','1|b']);\n"
- + "testSequence([' ', 'b'], ['1|',' 1|b']);\n"
- + "logToServer('All tests run')\n";
- }
-
- private String findMethodImplementation() {
- String filename = "/VAADIN/jquery.atmosphere.js";
- URL resourceURL = findResourceURL(filename,
- (VaadinServletService) VaadinService.getCurrent());
- if (resourceURL == null) {
- log("Can't find " + filename);
- return null;
- }
-
- try {
- String string = IOUtils.toString(resourceURL);
-
- // Find the function inside the script content
- int startIndex = string.indexOf("function _trackMessageSize");
- if (startIndex == -1) {
- log("function not found");
- return null;
- }
-
- // Assumes there's a /** comment before the next function
- int endIndex = string.indexOf("/**", startIndex);
- if (endIndex == -1) {
- log("End of function not found");
- return null;
- }
-
- string = string.substring(startIndex, endIndex);
- string = string.replaceAll("jQuery", "jQueryVaadin");
- return string;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private URL findResourceURL(String filename, VaadinServletService service) {
- ServletContext sc = service.getServlet().getServletContext();
- URL resourceUrl;
- try {
- resourceUrl = sc.getResource(filename);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- if (resourceUrl == null) {
- // try if requested file is found from classloader
-
- // strip leading "/" otherwise stream from JAR wont work
- if (filename.startsWith("/")) {
- filename = filename.substring(1);
- }
-
- resourceUrl = service.getClassLoader().getResource(filename);
- }
- return resourceUrl;
- }
-
- @Override
- protected String getTestDescription() {
- return "Unit tests for _trackMessageSize in jquery.atmosphere.js. Implemented with testbench and a full Vaadin server side since the testing requires some file mangling.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return Integer.valueOf(12468);
- }
-
-}
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;
}
/**
--
cgit v1.2.3
From 5fb877b093e4b2a9ddc98d558fe92f66d26af149 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 19:56:43 +0300
Subject: Makes test stable and adds helper comparison methods
* Takes into account that the timer can be triggered multiple times before the initial request is done (especially if the server is slow)
* Adds assertLessThan, assertLessThanOrEqual, assertGreaterThan, assertGreaterThanOrEqual to ease test creation
Change-Id: I5ce1681e35d9c1de02a83b38528f17ee705331d7
---
.../vaadin/tests/push/PushConfigurationTest.java | 25 ++++---
.../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 80 ++++++++++++++++++++++
2 files changed, 92 insertions(+), 13 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
index d23c48e14a..1f8c4c0e38 100644
--- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
+++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java
@@ -17,7 +17,9 @@ package com.vaadin.tests.push;
import org.junit.Assert;
import org.junit.Test;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.Select;
import com.vaadin.tests.tb3.WebsocketTest;
@@ -29,7 +31,9 @@ public class PushConfigurationTest extends WebsocketTest {
setDebug(true);
openTestURL();
// Websocket
- Assert.assertEquals(1, getServerCounter());
+ int counter = getServerCounter();
+ assertGreaterOrEqual("Counter should be >= 1. Was: " + counter,
+ counter, 1);
new Select(getTransportSelect()).selectByVisibleText("WEBSOCKET");
new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC");
Assert.assertTrue(vaadinElement(
@@ -37,20 +41,15 @@ public class PushConfigurationTest extends WebsocketTest {
.getText()
.matches(
"^[\\s\\S]*fallbackTransport: streaming[\\s\\S]*transport: websocket[\\s\\S]*$"));
- int counter = getServerCounter();
+ counter = getServerCounter();
+ final int waitCounter = counter + 2;
+ waitUntil(new ExpectedCondition() {
- for (int second = 0;; second++) {
- if (second >= 5) {
- Assert.fail("timeout");
+ @Override
+ public Boolean apply(WebDriver input) {
+ return (getServerCounter() >= waitCounter);
}
- 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(
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 5c4ee01d5f..38c5b29bf9 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -324,6 +324,86 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return getLogRowElement(rowNr).getText();
}
+ /**
+ * Asserts that {@literal a} is >= {@literal b}
+ *
+ * @param message
+ * The message to include in the {@link AssertionError}
+ * @param a
+ * @param b
+ * @throws AssertionError
+ * If comparison fails
+ */
+ public static final void assertGreaterOrEqual(String message,
+ Comparable a, T b) throws AssertionError {
+ if (a.compareTo(b) >= 0) {
+ return;
+ }
+
+ throw new AssertionError(decorate(message, a, b));
+ }
+
+ /**
+ * Asserts that {@literal a} is > {@literal b}
+ *
+ * @param message
+ * The message to include in the {@link AssertionError}
+ * @param a
+ * @param b
+ * @throws AssertionError
+ * If comparison fails
+ */
+ public static final void assertGreater(String message, Comparable a,
+ T b) throws AssertionError {
+ if (a.compareTo(b) > 0) {
+ return;
+ }
+ throw new AssertionError(decorate(message, a, b));
+ }
+
+ /**
+ * Asserts that {@literal a} is <= {@literal b}
+ *
+ * @param message
+ * The message to include in the {@link AssertionError}
+ * @param a
+ * @param b
+ * @throws AssertionError
+ * If comparison fails
+ */
+ public static final void assertLessThanOrEqual(String message,
+ Comparable a, T b) throws AssertionError {
+ if (a.compareTo(b) <= 0) {
+ return;
+ }
+
+ throw new AssertionError(decorate(message, a, b));
+ }
+
+ /**
+ * Asserts that {@literal a} is < {@literal b}
+ *
+ * @param message
+ * The message to include in the {@link AssertionError}
+ * @param a
+ * @param b
+ * @throws AssertionError
+ * If comparison fails
+ */
+ public static final void assertLessThan(String message,
+ Comparable a, T b) throws AssertionError {
+ if (a.compareTo(b) < 0) {
+ return;
+ }
+ throw new AssertionError(decorate(message, a, b));
+ }
+
+ private static String decorate(String message, Comparable a, T b) {
+ message = message.replace("{0}", a.toString());
+ message = message.replace("{1}", b.toString());
+ return message;
+ }
+
/**
* Returns the path that should be used for the test. The path contains the
* full path (appended to hostname+port) and must start with a slash.
--
cgit v1.2.3
From daf06e935ab932e2b9194d35ad81cb36a4911338 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 20:17:40 +0300
Subject: Use class name and not enclosing class for screenshot name
Change-Id: I8e9e0487f4354ee0523b5d3c0c016a002c395107
---
uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java | 4 ----
1 file changed, 4 deletions(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
index 94bcebde84..cbdae1a6c1 100644
--- a/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java
@@ -61,10 +61,6 @@ public abstract class ScreenshotTB3Test extends AbstractTB3Test {
testMethod = testMethod.replaceAll("\\[.*\\]", "");
String className = testClass.getSimpleName();
- if (testClass.getEnclosingClass() != null) {
- className = testClass.getEnclosingClass().getSimpleName();
- }
-
screenshotBaseName = className + "-" + testMethod;
}
--
cgit v1.2.3
From ebdc3652764e8ec2ce292879d459a8d0c6c2d2e3 Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Tue, 24 Sep 2013 16:08:08 +0300
Subject: Recreate transient pendingAccessQueue in readObject() (#12456)
This prevents a race condition in getPendingAccessQueue().
Change-Id: I1b8d013119e5963ed6083b7dd17afccd3a915e42
---
server/src/com/vaadin/server/VaadinSession.java | 26 ++++++++++++++--------
.../com/vaadin/tests/server/TestSerialization.java | 19 +++++++++++++---
2 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 1f7a577a42..c73ac8b686 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -16,6 +16,8 @@
package com.vaadin.server;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -203,10 +205,10 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* session is serialized as long as it doesn't happen while some other
* thread has the lock.
*/
- private transient ConcurrentLinkedQueue pendingAccessQueue;
+ private transient ConcurrentLinkedQueue pendingAccessQueue = new ConcurrentLinkedQueue();
/**
- * Create a new service session tied to a Vaadin service
+ * Creates a new VaadinSession tied to a VaadinService.
*
* @param service
* the Vaadin service for the new session
@@ -1272,18 +1274,15 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
}
/**
- * Gets the queue of tasks submitted using {@link #access(Runnable)}.
+ * Gets the queue of tasks submitted using {@link #access(Runnable)}. It is
+ * safe to call this method and access the returned queue without holding
+ * the {@link #lock() session lock}.
*
* @since 7.1
*
- * @return the pending access queue
+ * @return the queue of pending access tasks
*/
public Queue getPendingAccessQueue() {
- if (pendingAccessQueue == null) {
- // pendingAccessQueue is transient, so will be null after
- // deserialization
- pendingAccessQueue = new ConcurrentLinkedQueue();
- }
return pendingAccessQueue;
}
@@ -1299,4 +1298,13 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
return csrfToken;
}
+ /**
+ * Override default deserialization logic to account for transient
+ * {@link #pendingAccessQueue}.
+ */
+ private void readObject(ObjectInputStream stream) throws IOException,
+ ClassNotFoundException {
+ stream.defaultReadObject();
+ pendingAccessQueue = new ConcurrentLinkedQueue();
+ }
}
diff --git a/server/tests/src/com/vaadin/tests/server/TestSerialization.java b/server/tests/src/com/vaadin/tests/server/TestSerialization.java
index 84ff5ad6fa..a52821a919 100644
--- a/server/tests/src/com/vaadin/tests/server/TestSerialization.java
+++ b/server/tests/src/com/vaadin/tests/server/TestSerialization.java
@@ -14,6 +14,7 @@ import com.vaadin.data.Property;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.server.VaadinSession;
import com.vaadin.ui.Form;
public class TestSerialization extends TestCase {
@@ -21,7 +22,7 @@ public class TestSerialization extends TestCase {
public void testValidators() throws Exception {
RegexpValidator validator = new RegexpValidator(".*", "Error");
validator.validate("aaa");
- RegexpValidator validator2 = (RegexpValidator) serializeAndDeserialize(validator);
+ RegexpValidator validator2 = serializeAndDeserialize(validator);
validator2.validate("aaa");
}
@@ -67,7 +68,17 @@ public class TestSerialization extends TestCase {
serializeAndDeserialize(mp);
}
- private static Serializable serializeAndDeserialize(Serializable s)
+ public void testVaadinSession() throws Exception {
+ VaadinSession session = new VaadinSession(null);
+
+ session = serializeAndDeserialize(session);
+
+ assertNotNull(
+ "Pending access queue was not recreated after deserialization",
+ session.getPendingAccessQueue());
+ }
+
+ private static S serializeAndDeserialize(S s)
throws IOException, ClassNotFoundException {
// Serialize and deserialize
@@ -77,10 +88,12 @@ public class TestSerialization extends TestCase {
byte[] data = bs.toByteArray();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
data));
- Serializable s2 = (Serializable) in.readObject();
+ @SuppressWarnings("unchecked")
+ S s2 = (S) in.readObject();
// using special toString(Object) method to avoid calling
// Property.toString(), which will be temporarily disabled
+ // TODO This is hilariously broken (#12723)
if (s.equals(s2)) {
System.out.println(toString(s) + " equals " + toString(s2));
} else {
--
cgit v1.2.3
From 377d49ee174a6e2fb47152e5dbf0aac2db1276f5 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Tue, 8 Oct 2013 15:54:55 +0300
Subject: Allow configuring deployment port for TB3 tests
Change-Id: Iee0827d1e65dcbc1fc6c71701b80f355285b6902
---
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 9 ++++++++-
uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java | 12 ++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index 38c5b29bf9..1967891a7a 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -172,6 +172,13 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
*/
protected abstract String getDeploymentHostname();
+ /**
+ * Used to determine what port the test is running on
+ *
+ * @return The port teh test is running on, by default 8888
+ */
+ protected abstract String getDeploymentPort();
+
/**
* Produces a collection of browsers to run the test on. This method is
* executed by the test runner when determining how many test methods to
@@ -562,7 +569,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
* @return The base URL for the test. Does not include a trailing slash.
*/
protected String getBaseURL() {
- return "http://" + getDeploymentHostname() + ":8888";
+ return "http://" + getDeploymentHostname() + ":" + getDeploymentPort();
}
/**
diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
index 3d7dead928..09615f0b2e 100644
--- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
+++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java
@@ -34,6 +34,7 @@ import java.util.Properties;
*/
public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname";
+ private static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port";
private final Properties properties = new Properties();
public PrivateTB3Configuration() {
@@ -82,6 +83,17 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test {
return hostName;
}
+ @Override
+ protected String getDeploymentPort() {
+ String port = getProperty(PORT_PROPERTY);
+
+ if (port == null || "".equals(port)) {
+ port = "8888";
+ }
+
+ return port;
+ }
+
/**
* Tries to automatically determine the IP address of the machine the test
* is running on.
--
cgit v1.2.3
From 6779857911a4eeb2bbfe0720629b058facc40f4d Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Mon, 7 Oct 2013 20:34:23 +0300
Subject: Updatet servlet tests to follow the same *Test naming convention
Change-Id: I3c718232364f5ca7cce7131fa7685e4a2b833120
---
WebContent/WEB-INF/web.xml | 2 +-
WebContent/WEB-INF/web.xml.2.4 | 2 +-
.../tests/integration/AbstractIntegrationTest.java | 53 ++++++++++++++++++
.../integration/AbstractIntegrationTestTB3.java | 53 ------------------
.../AbstractServletIntegrationTest.java | 63 ++++++++++++++++++++++
.../tests/integration/IntegrationTestRunner.java | 2 +-
.../integration/IntegrationTestStreaming.java | 35 ------------
.../tests/integration/IntegrationTestUI.java | 52 ------------------
.../integration/IntegrationTestWebsocket.java | 49 -----------------
.../integration/ServletIntegrationStreamingUI.java | 30 +++++++++++
.../ServletIntegrationStreamingUITest.java | 21 ++++++++
.../integration/ServletIntegrationTestTB3.java | 63 ----------------------
.../tests/integration/ServletIntegrationUI.java | 48 +++++++++++++++++
.../integration/ServletIntegrationUITest.java | 20 +++++++
.../integration/ServletIntegrationWebsocketUI.java | 45 ++++++++++++++++
.../ServletIntegrationWebsocketUITest.java | 21 ++++++++
.../vaadin/tests/tb3/ServletIntegrationTests.java | 4 +-
17 files changed, 306 insertions(+), 257 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java
delete mode 100644 uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
create mode 100644 uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java
delete mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
delete mode 100755 uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
delete mode 100644 uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java
delete mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
create mode 100755 uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationUITest.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java
create mode 100644 uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java
diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml
index b93e0670fc..8a917966a1 100644
--- a/WebContent/WEB-INF/web.xml
+++ b/WebContent/WEB-INF/web.xml
@@ -92,7 +92,7 @@
com.vaadin.server.VaadinServlet
UI
- com.vaadin.tests.integration.IntegrationTestUI
+ com.vaadin.tests.integration.ServletIntegrationUI
true
diff --git a/WebContent/WEB-INF/web.xml.2.4 b/WebContent/WEB-INF/web.xml.2.4
index bcc5f3a651..96144b8036 100644
--- a/WebContent/WEB-INF/web.xml.2.4
+++ b/WebContent/WEB-INF/web.xml.2.4
@@ -86,7 +86,7 @@
com.vaadin.server.VaadinServlet
UI
- com.vaadin.tests.integration.IntegrationTestUI
+ com.vaadin.tests.integration.ServletIntegrationUI
diff --git a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java
new file mode 100644
index 0000000000..5f4ae41361
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.integration;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized.Parameters;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.PrivateTB3Configuration;
+
+/**
+ * Base class for integration tests. Integration tests use the
+ * {@literal deployment.url} parameter to determine the base deployment url
+ * (http://hostname:123)
+ *
+ * @author Vaadin Ltd
+ */
+@RunWith(IntegrationTestRunner.class)
+public abstract class AbstractIntegrationTest extends
+ PrivateTB3Configuration {
+ @Override
+ protected String getBaseURL() {
+ String deploymentUrl = System.getProperty("deployment.url");
+ if (deploymentUrl == null || deploymentUrl.equals("")) {
+ throw new RuntimeException(
+ "Deployment url must be given as deployment.url");
+ }
+
+ return deploymentUrl;
+ }
+
+ @Parameters
+ public static Collection getBrowsersForTest() {
+ return Collections.singleton(BrowserUtil.firefox(17));
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
deleted file mode 100644
index e170450619..0000000000
--- a/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTestTB3.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.integration;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized.Parameters;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import com.vaadin.tests.tb3.PrivateTB3Configuration;
-
-/**
- * Base class for integration tests. Integration tests use the
- * {@literal deployment.url} parameter to determine the base deployment url
- * (http://hostname:123)
- *
- * @author Vaadin Ltd
- */
-@RunWith(IntegrationTestRunner.class)
-public abstract class AbstractIntegrationTestTB3 extends
- PrivateTB3Configuration {
- @Override
- protected String getBaseURL() {
- String deploymentUrl = System.getProperty("deployment.url");
- if (deploymentUrl == null || deploymentUrl.equals("")) {
- throw new RuntimeException(
- "Deployment url must be given as deployment.url");
- }
-
- return deploymentUrl;
- }
-
- @Parameters
- public static Collection getBrowsersForTest() {
- return Collections.singleton(BrowserUtil.firefox(17));
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java
new file mode 100644
index 0000000000..f736a126a5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/AbstractServletIntegrationTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.integration;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+/**
+ * Base class for servlet integration tests. Automatically prepends "/demo" to
+ * the deployment path
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class AbstractServletIntegrationTest extends
+ AbstractIntegrationTest {
+
+ @Test
+ public void runTest() throws IOException, AssertionError {
+ openTestURL();
+ compareScreen("initial");
+
+ WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1));
+ testBenchElement(cell).click(51, 13);
+
+ compareScreen("finland");
+ }
+
+ private String getTableCell(String tableLocator, int row, int col) {
+ return tableLocator
+ + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild["
+ + row + "]/domChild[" + col + "]/domChild[0]";
+ }
+
+ protected String getTable() {
+ return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.tb3.AbstractTB3Test#getDeploymentPath()
+ */
+ @Override
+ protected String getDeploymentPath() {
+ return "/demo" + super.getDeploymentPath();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
index 29ee4e6023..f5042b54b6 100644
--- a/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
+++ b/uitest/src/com/vaadin/tests/integration/IntegrationTestRunner.java
@@ -45,7 +45,7 @@ public class IntegrationTestRunner extends TB3Runner {
*/
@Override
protected String testName(FrameworkMethod method) {
- if (AbstractIntegrationTestTB3.class.isAssignableFrom(testClass)) {
+ if (AbstractIntegrationTest.class.isAssignableFrom(testClass)) {
return System.getProperty("server-name");
} else {
return super.testName(method);
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
deleted file mode 100644
index 20ddac9dd1..0000000000
--- a/uitest/src/com/vaadin/tests/integration/IntegrationTestStreaming.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.integration;
-
-import com.vaadin.annotations.Push;
-import com.vaadin.shared.ui.ui.Transport;
-
-/**
- * Server test which uses streaming
- *
- * @since 7.1
- * @author Vaadin Ltd
- */
-@Push(transport = Transport.STREAMING)
-public class IntegrationTestStreaming extends IntegrationTestUI {
-
- public static class IntegrationTestStreamingTB3 extends
- ServletIntegrationTestTB3 {
- // Uses the test method declared in the super class
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
deleted file mode 100755
index 3d0a338bba..0000000000
--- a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.vaadin.tests.integration;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.server.ClassResource;
-import com.vaadin.server.Resource;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-
-public class IntegrationTestUI extends UI {
-
- public class IntegrationTestXhrTB3 extends ServletIntegrationTestTB3 {
- // Uses the test method declared in the super class
- }
-
- @Override
- protected void init(VaadinRequest request) {
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- setContent(layout);
-
- final Table table = new Table();
- table.addContainerProperty("icon", Resource.class, null);
- table.setItemIconPropertyId("icon");
- table.addContainerProperty("country", String.class, null);
- table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY);
- table.setImmediate(true);
- table.setSelectable(true);
- table.setVisibleColumns(new Object[] { "country" });
- layout.addComponent(table);
-
- Item item = table.addItem("FI");
- item.getItemProperty("icon").setValue(new ClassResource("fi.gif"));
- item.getItemProperty("country").setValue("Finland");
- item = table.addItem("SE");
- item.getItemProperty("icon").setValue(new FlagSeResource());
- item.getItemProperty("country").setValue("Sweden");
-
- final Label selectedLabel = new Label();
- table.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(ValueChangeEvent event) {
- selectedLabel.setValue(String.valueOf(table.getValue()));
- }
- });
- layout.addComponent(selectedLabel);
- }
-}
diff --git a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java b/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java
deleted file mode 100644
index eaa23de3cf..0000000000
--- a/uitest/src/com/vaadin/tests/integration/IntegrationTestWebsocket.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.integration;
-
-import com.vaadin.annotations.Push;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.ui.ui.Transport;
-
-/**
- * Server test which uses websockets
- *
- * @since 7.1
- * @author Vaadin Ltd
- */
-@Push(transport = Transport.WEBSOCKET)
-public class IntegrationTestWebsocket extends IntegrationTestUI {
-
- public class IntegrationTestWebsocketTB3 extends ServletIntegrationTestTB3 {
- // Uses the test method declared in the super class
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.tests.integration.IntegrationTestUI#init(com.vaadin.server
- * .VaadinRequest)
- */
- @Override
- protected void init(VaadinRequest request) {
- super.init(request);
- // Ensure no fallback is used
- getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUI.java
new file mode 100644
index 0000000000..0d92fb1bb8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUI.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.integration;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.shared.ui.ui.Transport;
+
+/**
+ * Server test which uses streaming
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+@Push(transport = Transport.STREAMING)
+public class ServletIntegrationStreamingUI extends ServletIntegrationUI {
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java
new file mode 100644
index 0000000000..36a946bfa3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationStreamingUITest.java
@@ -0,0 +1,21 @@
+/*
+ * 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.integration;
+
+public class ServletIntegrationStreamingUITest extends
+ AbstractServletIntegrationTest {
+ // Uses the test method declared in the super class
+}
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
deleted file mode 100644
index 2a2f8ab3d1..0000000000
--- a/uitest/src/com/vaadin/tests/integration/ServletIntegrationTestTB3.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.integration;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-/**
- * Base class for servlet integration tests. Automatically prepends "/demo" to
- * the deployment path
- *
- * @author Vaadin Ltd
- */
-public abstract class ServletIntegrationTestTB3 extends
- AbstractIntegrationTestTB3 {
-
- @Test
- public void runTest() throws IOException, AssertionError {
- openTestURL();
- compareScreen("initial");
-
- WebElement cell = vaadinElement(getTableCell(getTable(), 0, 1));
- testBenchElement(cell).click(51, 13);
-
- compareScreen("finland");
- }
-
- private String getTableCell(String tableLocator, int row, int col) {
- return tableLocator
- + "/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild["
- + row + "]/domChild[" + col + "]/domChild[0]";
- }
-
- protected String getTable() {
- return "/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.tb3.AbstractTB3Test#getDeploymentPath()
- */
- @Override
- protected String getDeploymentPath() {
- return "/demo" + super.getDeploymentPath();
- }
-
-}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java
new file mode 100755
index 0000000000..6aec2c8e2a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java
@@ -0,0 +1,48 @@
+package com.vaadin.tests.integration;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.ClassResource;
+import com.vaadin.server.Resource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class ServletIntegrationUI extends UI {
+
+ @Override
+ protected void init(VaadinRequest request) {
+ VerticalLayout layout = new VerticalLayout();
+ layout.setMargin(true);
+ setContent(layout);
+
+ final Table table = new Table();
+ table.addContainerProperty("icon", Resource.class, null);
+ table.setItemIconPropertyId("icon");
+ table.addContainerProperty("country", String.class, null);
+ table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY);
+ table.setImmediate(true);
+ table.setSelectable(true);
+ table.setVisibleColumns(new Object[] { "country" });
+ layout.addComponent(table);
+
+ Item item = table.addItem("FI");
+ item.getItemProperty("icon").setValue(new ClassResource("fi.gif"));
+ item.getItemProperty("country").setValue("Finland");
+ item = table.addItem("SE");
+ item.getItemProperty("icon").setValue(new FlagSeResource());
+ item.getItemProperty("country").setValue("Sweden");
+
+ final Label selectedLabel = new Label();
+ table.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ selectedLabel.setValue(String.valueOf(table.getValue()));
+ }
+ });
+ layout.addComponent(selectedLabel);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationUITest.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUITest.java
new file mode 100644
index 0000000000..25ffdac4a2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUITest.java
@@ -0,0 +1,20 @@
+/*
+ * 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.integration;
+
+public class ServletIntegrationUITest extends AbstractServletIntegrationTest {
+ // Uses the test method declared in the super class
+}
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java
new file mode 100644
index 0000000000..905b80fd85
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.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.integration;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
+
+/**
+ * Server test which uses websockets
+ *
+ * @since 7.1
+ * @author Vaadin Ltd
+ */
+@Push(transport = Transport.WEBSOCKET)
+public class ServletIntegrationWebsocketUI extends ServletIntegrationUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.vaadin.tests.integration.IntegrationTestUI#init(com.vaadin.server
+ * .VaadinRequest)
+ */
+ @Override
+ protected void init(VaadinRequest request) {
+ super.init(request);
+ // Ensure no fallback is used
+ getPushConfiguration().setFallbackTransport(Transport.WEBSOCKET);
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java
new file mode 100644
index 0000000000..f2e7a6f2d0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUITest.java
@@ -0,0 +1,21 @@
+/*
+ * 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.integration;
+
+public class ServletIntegrationWebsocketUITest extends
+ AbstractServletIntegrationTest {
+ // Uses the test method declared in the super class
+}
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
index d2aa413749..c511b99e6e 100644
--- a/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
+++ b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java
@@ -19,7 +19,7 @@ package com.vaadin.tests.tb3;
import org.junit.runner.RunWith;
import org.junit.runners.model.InitializationError;
-import com.vaadin.tests.integration.ServletIntegrationTestTB3;
+import com.vaadin.tests.integration.AbstractServletIntegrationTest;
import com.vaadin.tests.tb3.ServletIntegrationTests.ServletIntegrationTestSuite;
@RunWith(ServletIntegrationTestSuite.class)
@@ -28,7 +28,7 @@ public class ServletIntegrationTests {
public static class ServletIntegrationTestSuite extends TB3TestSuite {
public ServletIntegrationTestSuite(Class> klass)
throws InitializationError {
- super(klass, ServletIntegrationTestTB3.class,
+ super(klass, AbstractServletIntegrationTest.class,
"com.vaadin.tests.integration", new String[] {});
}
}
--
cgit v1.2.3
From e1c38bf70c9bb563dbe7771c8713a94fd9e99836 Mon Sep 17 00:00:00 2001
From: Matti Tahvonen
Date: Fri, 27 Sep 2013 15:07:48 +0300
Subject: Avoid obsolete calendar panel renderings to avoid various NPEs.
(#12504,#12667)
Change-Id: Ie0a9a8d9913116520b766062ebabdb771a76d1b6
---
.../src/com/vaadin/client/ui/VCalendarPanel.java | 24 +++--
.../ui/datefield/PopupDateFieldConnector.java | 9 +-
.../tests/components/datefield/DateFieldTest.java | 103 +++++++++++++++++++++
3 files changed, 121 insertions(+), 15 deletions(-)
diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java
index 1f40298760..58e0448b5f 100644
--- a/client/src/com/vaadin/client/ui/VCalendarPanel.java
+++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java
@@ -2215,11 +2215,13 @@ public class VCalendarPanel extends FocusableFlexTable implements
* - the allowed range's start date
*/
public void setRangeStart(Date rangeStart) {
- this.rangeStart = rangeStart;
- if (initialRenderDone) {
- // Dynamic updates to the range needs to render the calendar to
- // update the element stylenames
- renderCalendar();
+ if (this.rangeStart != rangeStart) {
+ this.rangeStart = rangeStart;
+ if (initialRenderDone) {
+ // Dynamic updates to the range needs to render the calendar to
+ // update the element stylenames
+ renderCalendar();
+ }
}
}
@@ -2232,11 +2234,13 @@ public class VCalendarPanel extends FocusableFlexTable implements
* - the allowed range's end date
*/
public void setRangeEnd(Date rangeEnd) {
- this.rangeEnd = rangeEnd;
- if (initialRenderDone) {
- // Dynamic updates to the range needs to render the calendar to
- // update the element stylenames
- renderCalendar();
+ if (this.rangeEnd != rangeEnd) {
+ this.rangeEnd = rangeEnd;
+ if (initialRenderDone) {
+ // Dynamic updates to the range needs to render the calendar to
+ // update the element stylenames
+ renderCalendar();
+ }
}
}
}
diff --git a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
index 627478ebe5..f018caefa5 100644
--- a/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
+++ b/client/src/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
@@ -77,9 +77,6 @@ public class PopupDateFieldConnector extends TextualDateConnector {
String oldLocale = getWidget().getCurrentLocale();
- boolean lastReadOnlyState = getWidget().isReadonly();
- boolean lastEnabledState = getWidget().isEnabled();
-
getWidget().parsable = uidl.getBooleanAttribute("parsable");
super.updateFromUIDL(uidl, client);
@@ -92,7 +89,8 @@ public class PopupDateFieldConnector extends TextualDateConnector {
.getCurrentResolution()) {
getWidget().calendar.setResolution(getWidget()
.getCurrentResolution());
- if (getWidget().calendar.getDate() != null) {
+ if (getWidget().calendar.getDate() != null
+ && getWidget().getCurrentDate() != null) {
getWidget().calendar.setDate((Date) getWidget()
.getCurrentDate().clone());
// force re-render when changing resolution only
@@ -101,7 +99,7 @@ public class PopupDateFieldConnector extends TextualDateConnector {
}
// Force re-render of calendar if locale has changed (#12153)
- if (getWidget().getCurrentLocale() != oldLocale) {
+ if (!getWidget().getCurrentLocale().equals(oldLocale)) {
getWidget().calendar.renderCalendar();
}
@@ -113,6 +111,7 @@ public class PopupDateFieldConnector extends TextualDateConnector {
.setFocusChangeListener(new FocusChangeListener() {
@Override
public void focusChanged(Date date) {
+
getWidget().updateValue(date);
getWidget().buildDate();
Date date2 = getWidget().calendar.getDate();
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
index d92199a214..2a61e79f32 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
@@ -7,8 +7,17 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
+import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.DateField;
public class DateFieldTest extends AbstractFieldTest {
@@ -140,4 +149,98 @@ public class DateFieldTest extends AbstractFieldTest {
}
};
+ public static class Tb3DateFieldTests extends MultiBrowserTest {
+
+ @Override
+ protected boolean isDebug() {
+ // run in debug to see js errors
+ return true;
+ }
+
+ @Test
+ public void testMakingRequired() throws InterruptedException {
+ Thread.sleep(1000);
+ menu("Component");
+ menuSub("State");
+ menu("Required");
+ assertNoErrorNotification();
+ }
+
+ private void assertNoErrorNotification() {
+ try {
+ getDriver().findElement(
+ By.xpath("//div[contains(@class, 'v-Notification') ]"));
+ Assert.fail("Error notification shown!");
+ } catch (NoSuchElementException e) {
+ // As expected
+ }
+ }
+
+ @Test
+ public void testValueAfterOpeningPopupInRequiredField()
+ throws InterruptedException {
+ Thread.sleep(1000);
+ menu("Component");
+ menuSub("State");
+ menu("Required");
+
+ menu("Component");
+ menuSub("Features");
+ menuSub("Resolution");
+ menu("Month");
+
+ menu("Component");
+ menuSub("Listeners");
+ menu("Value change listener");
+
+ String inputtedValue = "2/12";
+ getInput().sendKeys(inputtedValue);
+
+ openPopup();
+ closePopup();
+ String actual = getInput().getAttribute("value");
+ Assert.assertEquals(inputtedValue, actual);
+ assertNoErrorNotification();
+
+ }
+
+ private void openPopup() throws InterruptedException {
+ Dimension size = getInput().getSize();
+ new Actions(getDriver()).moveToElement(getInput(), 0, 0)
+ .moveByOffset(size.getWidth() + 5, size.getHeight() / 2)
+ .click();
+ // This fails in Opera for some weird reason
+ // getDriver().findElement(By.className("v-datefield-button")).click();
+ }
+
+ private WebElement getInput() {
+ return getDriver().findElement(By.xpath("//input"));
+ }
+
+ private void closePopup() {
+ getDriver().findElement(By.tagName("body")).click();
+ }
+
+ /**
+ * @since
+ * @param string
+ */
+ private void menuSub(String string) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + string + "']")).click();
+ new Actions(getDriver()).moveByOffset(100, 0).build().perform();
+ }
+
+ /**
+ * @since
+ * @param string
+ */
+ private void menu(String string) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + string + "']")).click();
+
+ }
+
+ }
+
}
--
cgit v1.2.3
From 63f10ec8bbeb6faa5ff685bfe375b1d0decd39cd Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Wed, 9 Oct 2013 09:59:03 +0300
Subject: Fixed compilation error in TB3 test
Change-Id: I62e246995879733393af3275778e9201cd970adb
---
.../tests/components/datefield/DateFieldTest.java | 103 ------------------
.../components/datefield/DateFieldTestTest.java | 118 +++++++++++++++++++++
2 files changed, 118 insertions(+), 103 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
index 2a61e79f32..d92199a214 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTest.java
@@ -7,17 +7,8 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Dimension;
-import org.openqa.selenium.NoSuchElementException;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
-import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.DateField;
public class DateFieldTest extends AbstractFieldTest {
@@ -149,98 +140,4 @@ public class DateFieldTest extends AbstractFieldTest {
}
};
- public static class Tb3DateFieldTests extends MultiBrowserTest {
-
- @Override
- protected boolean isDebug() {
- // run in debug to see js errors
- return true;
- }
-
- @Test
- public void testMakingRequired() throws InterruptedException {
- Thread.sleep(1000);
- menu("Component");
- menuSub("State");
- menu("Required");
- assertNoErrorNotification();
- }
-
- private void assertNoErrorNotification() {
- try {
- getDriver().findElement(
- By.xpath("//div[contains(@class, 'v-Notification') ]"));
- Assert.fail("Error notification shown!");
- } catch (NoSuchElementException e) {
- // As expected
- }
- }
-
- @Test
- public void testValueAfterOpeningPopupInRequiredField()
- throws InterruptedException {
- Thread.sleep(1000);
- menu("Component");
- menuSub("State");
- menu("Required");
-
- menu("Component");
- menuSub("Features");
- menuSub("Resolution");
- menu("Month");
-
- menu("Component");
- menuSub("Listeners");
- menu("Value change listener");
-
- String inputtedValue = "2/12";
- getInput().sendKeys(inputtedValue);
-
- openPopup();
- closePopup();
- String actual = getInput().getAttribute("value");
- Assert.assertEquals(inputtedValue, actual);
- assertNoErrorNotification();
-
- }
-
- private void openPopup() throws InterruptedException {
- Dimension size = getInput().getSize();
- new Actions(getDriver()).moveToElement(getInput(), 0, 0)
- .moveByOffset(size.getWidth() + 5, size.getHeight() / 2)
- .click();
- // This fails in Opera for some weird reason
- // getDriver().findElement(By.className("v-datefield-button")).click();
- }
-
- private WebElement getInput() {
- return getDriver().findElement(By.xpath("//input"));
- }
-
- private void closePopup() {
- getDriver().findElement(By.tagName("body")).click();
- }
-
- /**
- * @since
- * @param string
- */
- private void menuSub(String string) {
- getDriver().findElement(
- By.xpath("//span[text() = '" + string + "']")).click();
- new Actions(getDriver()).moveByOffset(100, 0).build().perform();
- }
-
- /**
- * @since
- * @param string
- */
- private void menu(String string) {
- getDriver().findElement(
- By.xpath("//span[text() = '" + string + "']")).click();
-
- }
-
- }
-
}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java
new file mode 100644
index 0000000000..557201e803
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldTestTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.datefield;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DateFieldTestTest extends MultiBrowserTest {
+
+ @Test
+ public void testMakingRequired() throws InterruptedException {
+ setDebug(true);
+ openTestURL();
+ Thread.sleep(1000);
+ menu("Component");
+ menuSub("State");
+ menu("Required");
+ assertNoErrorNotification();
+ }
+
+ private void assertNoErrorNotification() {
+ try {
+ getDriver().findElement(
+ By.xpath("//div[contains(@class, 'v-Notification') ]"));
+ Assert.fail("Error notification shown!");
+ } catch (NoSuchElementException e) {
+ // As expected
+ }
+ }
+
+ @Test
+ public void testValueAfterOpeningPopupInRequiredField()
+ throws InterruptedException {
+ setDebug(true);
+ openTestURL();
+ Thread.sleep(1000);
+ menu("Component");
+ menuSub("State");
+ menu("Required");
+
+ menu("Component");
+ menuSub("Features");
+ menuSub("Resolution");
+ menu("Month");
+
+ menu("Component");
+ menuSub("Listeners");
+ menu("Value change listener");
+
+ String inputtedValue = "2/12";
+ getInput().sendKeys(inputtedValue);
+
+ openPopup();
+ closePopup();
+ String actual = getInput().getAttribute("value");
+ Assert.assertEquals(inputtedValue, actual);
+ assertNoErrorNotification();
+
+ }
+
+ private void openPopup() throws InterruptedException {
+ Dimension size = getInput().getSize();
+ new Actions(getDriver()).moveToElement(getInput(), 0, 0)
+ .moveByOffset(size.getWidth() + 5, size.getHeight() / 2)
+ .click();
+ // This fails in Opera for some weird reason
+ // getDriver().findElement(By.className("v-datefield-button")).click();
+ }
+
+ private WebElement getInput() {
+ return getDriver().findElement(By.xpath("//input"));
+ }
+
+ private void closePopup() {
+ getDriver().findElement(By.tagName("body")).click();
+ }
+
+ /**
+ * @since
+ * @param string
+ */
+ private void menuSub(String string) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + string + "']")).click();
+ new Actions(getDriver()).moveByOffset(100, 0).build().perform();
+ }
+
+ /**
+ * @since
+ * @param string
+ */
+ private void menu(String string) {
+ getDriver().findElement(
+ By.xpath("//span[text() = '" + string + "']")).click();
+
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3
From 3e593b0949b2b26fdc89b2aa5e8e93b006a513d0 Mon Sep 17 00:00:00 2001
From: John Ahlroos
Date: Tue, 1 Oct 2013 16:55:39 +0300
Subject: Focus selected row in Table #12540
Change-Id: Ic920f9cb11840a456a7c49746317eaccde1e1406
---
client/src/com/vaadin/client/ui/VScrollTable.java | 11 ++
.../table/TableMoveFocusWithSelection.java | 125 +++++++++++++++++++++
.../table/TableMoveFocusWithSelectionTest.java | 75 +++++++++++++
3 files changed, 211 insertions(+)
create mode 100644 uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java
create mode 100644 uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelectionTest.java
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 9cec59a5a2..104cbbd5b9 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -1072,6 +1072,17 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
if (selected != row.isSelected()) {
row.toggleSelection();
+
+ if (selected) {
+ if (focusedRow == null
+ || !selectedRowKeys.contains(focusedRow
+ .getKey())) {
+ // The focus is no longer on a selected row,
+ // move focus to first selected row
+ setRowFocus(row);
+ }
+ }
+
if (!isSingleSelectMode() && !selected) {
// Update selection range in case a row is
// unselected from the middle of a range - #8076
diff --git a/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java b/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java
new file mode 100644
index 0000000000..20170efa13
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelection.java
@@ -0,0 +1,125 @@
+/*
+ * 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.table;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.vaadin.event.LayoutEvents.LayoutClickEvent;
+import com.vaadin.event.LayoutEvents.LayoutClickListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class TableMoveFocusWithSelection extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Table t = new Table();
+ t.setImmediate(true);
+ t.setId("test-table");
+ t.setSizeFull();
+ t.setSelectable(true);
+ t.addContainerProperty("layout", VerticalLayout.class, null);
+ t.addContainerProperty("string", String.class, null);
+
+ for (int i = 0; i < 100; i++) {
+ t.addItem(i);
+ final VerticalLayout l = new VerticalLayout();
+ l.setId("row-" + i);
+ l.setHeight(20, Unit.PIXELS);
+ l.setData(i);
+ l.addLayoutClickListener(new LayoutClickListener() {
+ @Override
+ public void layoutClick(LayoutClickEvent event) {
+ if (t.isMultiSelect()) {
+ Set values = new HashSet(
+ (Set) t.getValue());
+ values.add(l.getData());
+ t.setValue(values);
+ } else {
+ t.setValue(l.getData());
+ }
+ }
+ });
+ t.getContainerProperty(i, "layout").setValue(l);
+ t.getContainerProperty(i, "string").setValue("Item #" + i);
+ }
+ addComponent(t);
+
+ // Select mode
+ Button toggleSelectMode = new Button(
+ t.isMultiSelect() ? "Press to use single select"
+ : "Press to use multi select");
+ toggleSelectMode.setId("toggle-mode");
+ toggleSelectMode.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ t.setMultiSelect(!t.isMultiSelect());
+
+ event.getButton().setCaption(
+ t.isMultiSelect() ? "Press to use single select"
+ : "Press to use multi select");
+ }
+ });
+
+ addComponent(toggleSelectMode);
+
+ Button select5210 = new Button("Select row 5-10",
+ new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ t.setValue(Arrays.asList(5, 6, 7, 8, 9, 10));
+ }
+ });
+ select5210.setId("select-510");
+ addComponent(select5210);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Changing selection in single select mode should move focus";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 12540;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelectionTest.java b/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelectionTest.java
new file mode 100644
index 0000000000..b38705eeb6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelectionTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.table;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests if table focus is moved correctly to the selected item
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class TableMoveFocusWithSelectionTest extends MultiBrowserTest {
+
+ @Test
+ public void selectUnfocusedTableAndAssumeSelectionGetsFocus() {
+
+ openTestURL();
+
+ // Click on row 5
+ getDriver().findElement(By.id("row-5")).click();
+
+ // Ensure row 5 gets focused
+ WebElement row5TableRow = getDriver().findElement(
+ By.xpath("//div[@id='row-5']/../../.."));
+ String row5StyleName = row5TableRow.getAttribute("class");
+ assertTrue(row5StyleName.contains("v-table-focus"));
+ }
+
+ @Test
+ public void focusShouldStayOnUserSelectedRowIfSelectionChangesServerSide() {
+
+ openTestURL();
+
+ // Select multiselect
+ getDriver().findElement(By.id("toggle-mode")).click();
+
+ // Click on row 7
+ getDriver().findElement(By.id("row-7")).click();
+
+ // Select row 5-10 server side
+ getDriver().findElement(By.id("select-510")).click();
+
+ // Ensure row 7 is still focused
+ WebElement row7TableRow = getDriver().findElement(
+ By.xpath("//div[@id='row-7']/../../.."));
+ String row7StyleName = row7TableRow.getAttribute("class");
+ assertTrue(row7StyleName.contains("v-table-focus"));
+ }
+
+ @Override
+ protected Class> getUIClass() {
+ // FIXME Remove when this is done automatically
+ return TableMoveFocusWithSelection.class;
+ }
+}
--
cgit v1.2.3
From 3c842b76ed6ecbf3cf92cb9a7cca3b72e326a2ed Mon Sep 17 00:00:00 2001
From: Matti Tahvonen
Date: Wed, 9 Oct 2013 14:37:57 +0300
Subject: added small pause to make test pass
Change-Id: I2e58a7444e5a2740f81409e6f248e0acedcead54
---
.../tests/components/datefield/DynamicallyChangeDateRange.html | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html
index 77c610f211..75c19945b0 100644
--- a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html
+++ b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html
@@ -51,6 +51,11 @@
vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
+
+ pause
+ 300
+
+
mouseClick
vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton
@@ -86,6 +91,11 @@
vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
+
+ pause
+ 300
+
+
mouseClick
vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton
--
cgit v1.2.3
From 1b7e40de9435f2584fe6c7f1b7f69cc448c16cc8 Mon Sep 17 00:00:00 2001
From: Matti Tahvonen
Date: Fri, 4 Oct 2013 15:41:06 +0300
Subject: Only fetch rows if there are some (#11189)
IE hacks cause calls to onScroll in situations where the cache row fetch
logic is not working correctly (causes JS exception). This change has an
optimization to pass this logic if there are no rows available and this
way fixes the JS exception as well.
Change-Id: I3425f3d75cad8b65e605638343b167abf7b48067
---
client/src/com/vaadin/client/ui/VScrollTable.java | 5 ++
.../vaadin/tests/components/table/EmptyTable.java | 58 ++++++++++++++++++++++
.../tests/components/table/EmptyTableTest.java | 44 ++++++++++++++++
3 files changed, 107 insertions(+)
create mode 100644 uitest/src/com/vaadin/tests/components/table/EmptyTable.java
create mode 100644 uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 104cbbd5b9..0304acd590 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -6913,6 +6913,11 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
// fix footers horizontal scrolling
tFoot.setHorizontalScrollPosition(scrollLeft);
+ if (totalRows == 0) {
+ // No rows, no need to fetch new rows
+ return;
+ }
+
firstRowInViewPort = calcFirstRowInViewPort();
if (firstRowInViewPort > totalRows - pageLength) {
firstRowInViewPort = totalRows - pageLength;
diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyTable.java b/uitest/src/com/vaadin/tests/components/table/EmptyTable.java
new file mode 100644
index 0000000000..d6c30efa5a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/EmptyTable.java
@@ -0,0 +1,58 @@
+/*
+ * 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.table;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Table;
+
+public class EmptyTable extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ Table table = new Table("Table");
+ table.addContainerProperty("testColumn", String.class, null);
+ table.setPageLength(0); // disable paging
+ addComponent(table);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Empty Table should not cause JS exception";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 11189;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java
new file mode 100644
index 0000000000..229dc23b9a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/EmptyTableTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.table;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class EmptyTableTest extends MultiBrowserTest {
+
+ @Test
+ public void test() {
+ setDebug(true);
+ openTestURL();
+
+ ensureNoErrors();
+ }
+
+ private void ensureNoErrors() {
+ try {
+ getDriver().findElement(By.className("v-Notification"));
+ } catch (NoSuchElementException e) {
+ return;
+ }
+ Assert.fail("Error notification was shown!");
+ }
+
+}
\ No newline at end of file
--
cgit v1.2.3
From f595d057951523baf35a797692376dfa5de0bc8d Mon Sep 17 00:00:00 2001
From: Johannes Dahlström
Date: Thu, 12 Sep 2013 16:07:59 +0300
Subject: Make the various Writers member fields instead of local variables
(#12446)
Change-Id: I9ca101edf6df41702b27635da9f749bdac5bf5f4
---
.../server/communication/UidlRequestHandler.java | 5 +-
.../vaadin/server/communication/UidlWriter.java | 32 ++++--
.../server/communication/UidlWriterTest.java | 125 +++++++++++++++++++++
3 files changed, 148 insertions(+), 14 deletions(-)
create mode 100644 server/tests/src/com/vaadin/server/communication/UidlWriterTest.java
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index d52c5e9fe0..f13199e9ae 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -56,8 +56,7 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
private ServerRpcHandler rpcHandler = new ServerRpcHandler();
- public UidlRequestHandler() {
- }
+ private UidlWriter uidlWriter = new UidlWriter();
@Override
public boolean synchronizedHandleRequest(VaadinSession session,
@@ -146,7 +145,7 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
JSONException {
openJsonMessage(writer, response);
- new UidlWriter().write(ui, writer, repaintAll, false);
+ uidlWriter.write(ui, writer, repaintAll, false);
closeJsonMessage(writer);
}
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 60933a75c2..fe7a7d42bf 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -51,6 +51,14 @@ import com.vaadin.ui.UI;
*/
public class UidlWriter implements Serializable {
+ private LegacyUidlWriter legacyUidlWriter = new LegacyUidlWriter();
+ private SharedStateWriter sharedStateWriter = new SharedStateWriter();
+ private ConnectorTypeWriter connectorTypeWriter = new ConnectorTypeWriter();
+ private ConnectorHierarchyWriter connectorHierarchyWriter = new ConnectorHierarchyWriter();
+ private ClientRpcWriter clientRpcWriter = new ClientRpcWriter();
+ private MetadataWriter metadataWriter = new MetadataWriter();
+ private ResourceWriter resourceWriter = new ResourceWriter();
+
/**
* Writes a JSON object containing all pending changes to the given UI.
*
@@ -79,13 +87,12 @@ public class UidlWriter implements Serializable {
// to write out
session.getService().runPendingAccessTasks(session);
- ArrayList dirtyVisibleConnectors = ui
- .getConnectorTracker().getDirtyVisibleConnectors();
- LegacyCommunicationManager manager = session.getCommunicationManager();
// Paints components
- ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
getLogger().log(Level.FINE, "* Creating response to client");
+ ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
+ ArrayList dirtyVisibleConnectors = uiConnectorTracker
+ .getDirtyVisibleConnectors();
getLogger().log(
Level.FINE,
"Found " + dirtyVisibleConnectors.size()
@@ -100,10 +107,13 @@ public class UidlWriter implements Serializable {
try {
writer.write("\"changes\" : ");
+ LegacyCommunicationManager manager = session
+ .getCommunicationManager();
+
JsonPaintTarget paintTarget = new JsonPaintTarget(manager, writer,
!repaintAll);
- new LegacyUidlWriter().write(ui, writer, paintTarget);
+ legacyUidlWriter.write(ui, writer, paintTarget);
paintTarget.close();
writer.write(", "); // close changes
@@ -120,7 +130,7 @@ public class UidlWriter implements Serializable {
// processing.
writer.write("\"state\":");
- new SharedStateWriter().write(ui, writer);
+ sharedStateWriter.write(ui, writer);
writer.write(", "); // close states
// TODO This should be optimized. The type only needs to be
@@ -129,7 +139,7 @@ public class UidlWriter implements Serializable {
// widget mapping
writer.write("\"types\":");
- new ConnectorTypeWriter().write(ui, writer, paintTarget);
+ connectorTypeWriter.write(ui, writer, paintTarget);
writer.write(", "); // close states
// Send update hierarchy information to the client.
@@ -140,7 +150,7 @@ public class UidlWriter implements Serializable {
// child to 0 children)
writer.write("\"hierarchy\":");
- new ConnectorHierarchyWriter().write(ui, writer);
+ connectorHierarchyWriter.write(ui, writer);
writer.write(", "); // close hierarchy
// send server to client RPC calls for components in the UI, in call
@@ -150,7 +160,7 @@ public class UidlWriter implements Serializable {
// which they were performed, remove the calls from components
writer.write("\"rpc\" : ");
- new ClientRpcWriter().write(ui, writer);
+ clientRpcWriter.write(ui, writer);
writer.write(", "); // close rpc
uiConnectorTracker.markAllConnectorsClean();
@@ -160,11 +170,11 @@ public class UidlWriter implements Serializable {
SystemMessages messages = ui.getSession().getService()
.getSystemMessages(ui.getLocale(), null);
// TODO hilightedConnector
- new MetadataWriter().write(ui, writer, repaintAll, async, messages);
+ metadataWriter.write(ui, writer, repaintAll, async, messages);
writer.write(", ");
writer.write("\"resources\" : ");
- new ResourceWriter().write(ui, writer, paintTarget);
+ resourceWriter.write(ui, writer, paintTarget);
Collection> usedClientConnectors = paintTarget
.getUsedClientConnectors();
diff --git a/server/tests/src/com/vaadin/server/communication/UidlWriterTest.java b/server/tests/src/com/vaadin/server/communication/UidlWriterTest.java
new file mode 100644
index 0000000000..8dcd6cbdf4
--- /dev/null
+++ b/server/tests/src/com/vaadin/server/communication/UidlWriterTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.server.communication;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Locale;
+
+import org.easymock.EasyMock;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.server.ClientConnector;
+import com.vaadin.server.LegacyCommunicationManager;
+import com.vaadin.server.SystemMessages;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinService;
+import com.vaadin.server.VaadinSession;
+import com.vaadin.server.WrappedSession;
+import com.vaadin.ui.ConnectorTracker;
+import com.vaadin.ui.UI;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class UidlWriterTest {
+
+ private UI ui;
+ private UidlWriter uidlWriter;
+
+ @Before
+ public void setUp() {
+ SystemMessages messages = EasyMock.createNiceMock(SystemMessages.class);
+ EasyMock.expect(messages.isSessionExpiredNotificationEnabled())
+ .andReturn(true).anyTimes();
+ EasyMock.replay(messages);
+
+ VaadinService service = EasyMock.createNiceMock(VaadinService.class);
+ EasyMock.expect(
+ service.getSystemMessages(EasyMock.anyObject(Locale.class),
+ EasyMock.anyObject(VaadinRequest.class)))
+ .andReturn(messages).anyTimes();
+ EasyMock.replay(service);
+
+ LegacyCommunicationManager manager = EasyMock
+ .createNiceMock(LegacyCommunicationManager.class);
+ EasyMock.replay(manager);
+
+ WrappedSession wrappedSession = EasyMock
+ .createNiceMock(WrappedSession.class);
+ EasyMock.expect(wrappedSession.getMaxInactiveInterval()).andReturn(100)
+ .times(3).andReturn(200);
+
+ EasyMock.replay(wrappedSession);
+
+ VaadinSession session = EasyMock.createNiceMock(VaadinSession.class);
+ EasyMock.expect(session.getService()).andReturn(service).anyTimes();
+ EasyMock.expect(session.getCommunicationManager()).andReturn(manager)
+ .anyTimes();
+ EasyMock.expect(session.getSession()).andReturn(wrappedSession)
+ .anyTimes();
+ EasyMock.replay(session);
+
+ ConnectorTracker tracker = EasyMock
+ .createNiceMock(ConnectorTracker.class);
+ EasyMock.expect(tracker.getDirtyVisibleConnectors())
+ .andReturn(new ArrayList()).anyTimes();
+ EasyMock.replay(tracker);
+
+ ui = EasyMock.createNiceMock(UI.class);
+ EasyMock.expect(ui.getSession()).andReturn(session).anyTimes();
+ EasyMock.expect(ui.getConnectorTracker()).andReturn(tracker).anyTimes();
+ EasyMock.replay(ui);
+
+ uidlWriter = new UidlWriter();
+ }
+
+ @Test
+ public void testMetadataWriterState() throws IOException, JSONException {
+
+ Assert.assertEquals(
+ "Metadata should contain redirect interval on first write",
+ 115, getRedirect(uidl(false, false)).optInt("interval"));
+ Assert.assertNull(
+ "Metadata should not contain redirect interval on second write",
+ getRedirect(uidl(false, false)));
+ Assert.assertEquals(
+ "Metadata should contain redirect interval on repaintAll", 115,
+ getRedirect(uidl(true, false)).optInt("interval"));
+ Assert.assertEquals(
+ "Metadata should contain redirect interval when changed in session",
+ 215, getRedirect(uidl(false, false)).optInt("interval"));
+ }
+
+ private JSONObject uidl(boolean repaintAll, boolean async)
+ throws IOException, JSONException {
+ StringWriter writer = new StringWriter();
+ uidlWriter.write(ui, writer, repaintAll, async);
+ return new JSONObject("{" + writer.toString() + "}");
+ }
+
+ private JSONObject getRedirect(JSONObject json) throws JSONException {
+ return json.getJSONObject("meta").optJSONObject("timedRedirect");
+
+ }
+}
--
cgit v1.2.3
From 4cb304d8eb63ce0045a2742bd9c945af4f12aa66 Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Fri, 27 Sep 2013 13:16:45 +0300
Subject: Converted broken test to TB3
Change-Id: Ic30db7584a65c944eb45c576e12b7671399d1965
---
.../vaadin/tests/components/ui/UIAccessTest.java | 163 +++++++++++++++++++-
.../com/vaadin/tests/components/ui/UiAccess.html | 166 ---------------------
2 files changed, 161 insertions(+), 168 deletions(-)
delete mode 100644 uitest/src/com/vaadin/tests/components/ui/UiAccess.html
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java b/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
index 8d04ceae71..9db2c2f0d3 100644
--- a/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java
@@ -15,11 +15,16 @@
*/
package com.vaadin.tests.components.ui;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
+import com.vaadin.testbench.By;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class UIAccessTest extends MultiBrowserTest {
@@ -30,8 +35,7 @@ public class UIAccessTest extends MultiBrowserTest {
getCurrentInstanceWhenPushingButton().click();
waitUntil(ExpectedConditions.textToBePresentInElement(
vaadinLocatorById("Log_row_0"), "1."));
- Assert.assertEquals(
- "0. Current UI matches in beforeResponse? true",
+ Assert.assertEquals("0. Current UI matches in beforeResponse? true",
vaadinElementById("Log_row_1").getText());
Assert.assertEquals(
"1. Current session matches in beforeResponse? true",
@@ -39,6 +43,161 @@ public class UIAccessTest extends MultiBrowserTest {
}
+ @Test
+ public void testAccessMethod() throws Exception {
+ openTestURL();
+
+ vaadinElement(
+ "/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]")
+ .click();
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText()
+ .matches(
+ "^0\\. Access from UI thread future is done[\\s\\S] false$"));
+ assertEquals(
+ "1. Access from UI thread is run",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText());
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText()
+ .matches(
+ "^2\\. beforeClientResponse future is done[\\s\\S] true$"));
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertEquals(
+ "0. Initial background message",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText());
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText()
+ .matches("^1\\. Thread has current response[\\s\\S] false$"));
+ for (int second = 0;; second++) {
+ if (second >= 30) {
+ fail("timeout");
+ }
+ try {
+ if ("0. Initial background message"
+ .equals(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText())) {
+ break;
+ }
+ } catch (Exception e) {
+ }
+ Thread.sleep(1000);
+ }
+
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText()
+ .matches(
+ "^2\\. Thread got lock, inital future done[\\s\\S] true$"));
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertEquals(
+ "0. Throwing exception in access",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText());
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText().matches("^1\\. firstFuture is done[\\s\\S] true$"));
+ assertEquals(
+ "2. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText());
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertEquals(
+ "0. future was cancled, should not start",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText());
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertEquals(
+ "0. Waiting for thread to start",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText());
+ assertEquals(
+ "1. Thread started, waiting for interruption",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText());
+ assertEquals(
+ "2. I was interrupted",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText());
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_3"))
+ .getText()
+ .matches("^0\\. accessSynchronously has request[\\s\\S] true$"));
+ assertEquals(
+ "1. Test value in accessSynchronously: Set before accessSynchronosly",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText());
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText()
+ .matches(
+ "^2\\. has request after accessSynchronously[\\s\\S] true$"));
+ assertEquals(
+ "3. Test value after accessSynchornously: Set in accessSynchronosly",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText());
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]"))
+ .click();
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_3"))
+ .getText().matches("^0\\. access has request[\\s\\S] false$"));
+ assertEquals(
+ "1. Test value in access: Set before access",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_2"))
+ .getText());
+ assertTrue(driver
+ .findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_1"))
+ .getText()
+ .matches("^2\\. has request after access[\\s\\S] true$"));
+ assertEquals(
+ "3. Test value after access: Set before run pending",
+ driver.findElement(
+ By.vaadin("runcomvaadintestscomponentsuiUIAccess::PID_SLog_row_0"))
+ .getText());
+
+ }
+
private WebElement getCurrentInstanceWhenPushingButton() {
return vaadinElement("/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]");
}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.html b/uitest/src/com/vaadin/tests/components/ui/UiAccess.html
deleted file mode 100644
index 613691623c..0000000000
--- a/uitest/src/com/vaadin/tests/components/ui/UiAccess.html
+++ /dev/null
@@ -1,166 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-New Test
-
-
- open
- /run/com.vaadin.tests.components.ui.UiAccess?restartApplication
-
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- exact:0. Access from UI thread future is done? false
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- 1. Access from UI thread is run
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- exact:2. beforeClientResponse future is done? true
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- 0. Initial background message
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- exact:1. Thread has current response? false
-
-
- waitForText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- 0. Initial background message
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- exact:2. Thread got lock, inital future done? true
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- 0. Throwing exception in access
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- exact:1. firstFuture is done? true
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- 2. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- 0. future was cancled, should not start
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- 0. Waiting for thread to start
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- 1. Thread started, waiting for interruption
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- 2. I was interrupted
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3
- 0. accessSynchronously has request? true
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- 1. Test value in accessSynchronously: Set before accessSynchronosly
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- 2. has request after accessSynchronously? true
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- 3. Test value after accessSynchornously: Set in accessSynchronosly
-
-
- click
- vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]
-
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3
- 0. access has request? false
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2
- 1. Test value in access: Set before access
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1
- 2. has request after access? true
-
-
- assertText
- vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0
- 3. Test value after access: Set before run pending
-
-
-
-
--
cgit v1.2.3