diff options
author | John Ahlroos <john@vaadin.com> | 2013-11-20 14:26:40 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-11-20 14:27:09 +0200 |
commit | e3b1e6be389cbe48d1782723adf1595edbd10ea2 (patch) | |
tree | 61dbd2fac407f0b6657863d100d6b1f09e67e356 /uitest | |
parent | 96de019ea4ee5536dab87d1f04d4cb94ae71371d (diff) | |
parent | dd7e6fee8c4717df59699f04f7e72a6f2e92008f (diff) | |
download | vaadin-framework-e3b1e6be389cbe48d1782723adf1595edbd10ea2.tar.gz vaadin-framework-e3b1e6be389cbe48d1782723adf1595edbd10ea2.zip |
Merge branch 'master' into grid
Change-Id: I9f669ec38c39a42d1ef2a25121b77aab31551863
Diffstat (limited to 'uitest')
127 files changed, 7694 insertions, 2047 deletions
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 @@ <!-- global properties --> <property name="module.name" value="vaadin-uitest" /> + <property name="uitest.dir" location="${vaadin.basedir}/uitest" /> <property name="result.dir" value="result" /> <property name="result.war" location="${result.dir}/lib/${module.name}-${vaadin.version}.war" /> @@ -107,6 +108,11 @@ <path refid="classpath.runtime.dependencies" /> </copy> + <delete> + <!-- Avoid including some potentially conflicting jars in the war --> + <fileset dir="${deps.dir}" includes="jetty-*.jar" /> + <fileset dir="${deps.dir}" includes="servlet-api-*.jar" /> + </delete> <!-- Ensure filtered webcontent files are available --> <antcall target="common.filter.webcontent" /> @@ -148,4 +154,53 @@ <echo>WHAT? No JUnit tests for ${module.name}!</echo> </target> + <target name="test-testbench" depends="clean-testbench-errors" description="Run all TestBench based tests, including server tests"> + <parallel> + <daemons> + <!-- Start server --> + <ant antfile="${uitest.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" /> + </daemons> + <sequential> + <!-- Server tests --> + + <!-- Sleep before running integration tests so testbench 2 + tests have time to compile and start --> + <sleep minutes="4" /> + <ant antfile="${uitest.dir}/integration_tests.xml" target="integration-test-all" inheritall="false" inheritrefs="false"> + <property name="demo.war" value="${war.file}" /> + </ant> + </sequential> + <sequential> + <!-- Wait for server to start --> + <ant antfile="${uitest.dir}/vaadin-server.xml" target="wait-for-startup" /> + + <!-- Run all different kinds of TestBench tests in parallel --> + <parallel> + + <!-- Legacy TestBench 2 tests --> + <sequential> + <ant antfile="${uitest.dir}/test.xml" target="tb2-tests" /> + <echo message="TestBench 2 tests complete" /> + </sequential> + + <!-- TestBench 3 tests --> + <sequential> + <ant antfile="${uitest.dir}/tb3test.xml" target="run-all-tb3-tests" inheritall="true" /> + <echo message="TestBench 3 tests complete" /> + </sequential> + </parallel> + </sequential> + </parallel> + </target> + + <target name="clean-testbench-errors"> + <fail unless="com.vaadin.testbench.screenshot.directory" message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" /> + <mkdir dir="${com.vaadin.testbench.screenshot.directory}/errors" /> + <delete> + <fileset dir="${com.vaadin.testbench.screenshot.directory}/errors"> + <include name="*" /> + </fileset> + </delete> + </target> + </project> 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=<enter location of testbench here> - -; Deployment url to use for testing. Context path must be / -com.vaadin.testbench.deployment.url=http://<enter your ip here>: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=<enter the full path to the screenshots directory, parent of "references" directory> -; Run the whole test even if + +; +; For only TestBench 2 +; + +; Location where TestBench 2 jar can be found +com.vaadin.testbench.lib.dir=<enter location of testbench here> + +; Deployment url to use for testing. Context path must be / +com.vaadin.testbench.deployment.url=http://<enter your ip here>: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/integration_tests.xml b/uitest/integration_tests.xml index 78e053991e..73aac2405c 100644 --- a/uitest/integration_tests.xml +++ b/uitest/integration_tests.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<project xmlns:antcontrib="antlib:net.sf.antcontrib" name="Vaadin Integration Tests" basedir="." default="integration-test-all"> +<project xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" name="Vaadin Integration Tests" basedir="." default="integration-test-all"> <!-- Import common targets --> <import file="../common.xml" /> @@ -32,33 +32,22 @@ <property name="user" value="${test.integration.user}" /> <property name="passphrase" value="" /> + <ivy:resolve file="ivy.xml" conf="build, build-provided" /> + <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" /> + <path id="classpath.tb3"> + <path refid="classpath.tb3.lib" /> + <path location="result/classes" /> + </path> + <!-- Upload war to deploy to ssh host --> <target name="integration-test-upload-demo"> <scp file="${demo.war}" todir="${user}@${test.integration.server}:integration-tests/servers/demo.war" keyfile="${sshkey.file}" passphrase="${passphrase}" /> </target> <!-- Run basic integration test test --> - <target name="integration-test-servlet"> - <fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-${server-name}-servlet.html" /> - <pathconvert pathsep=" " property="testfiles" refid="html-test-files" /> - <subant target="run-tests" failonerror="false" antfile="test.xml"> - <property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" /> - <property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" /> - <property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" /> - <property name="server.start.succeeded" value="1" /> - <property name="browsers" value="${test_browsers}" /> - <property name="testfiles" value="${testfiles}" /> - <property name="test-output-dir" value="${integration_test.dir}/result/integration-test-output/${server-name}" /> - <property name="retries" value="0" /> - - <fileset dir="." includes="test.xml" /> - </subant> - </target> - - <target name="integration-test-push-servlet"> - <fileset dir="integration-testscripts" id="html-test-files" includes="integration-test-${server-name}-push-servlet.html" /> - <pathconvert pathsep=" " property="testfiles" refid="html-test-files" /> - <subant target="run-tests" failonerror="false" antfile="test.xml"> + <target name="legacy-integration-test"> + <fail unless="testfiles" message="You need to specify the files to run using the 'testfiles' property" /> + <subant target="run-tb2-tests" failonerror="false" antfile="test.xml"> <property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" /> <property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" /> <property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" /> @@ -73,7 +62,7 @@ </target> <target name="integration-test-theme"> - <subant target="run-tests" failonerror="false" antfile="test.xml"> + <subant target="run-tb2-tests" failonerror="false" antfile="test.xml"> <property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" /> <property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" /> <property name="com.vaadin.testbench.deployment.url" value="${deployment.url}" /> @@ -90,7 +79,7 @@ <fileset dir="integration-testscripts" id="html-test-files" includes="GoogleAppEngine/integration-test-GAE.html" /> <pathconvert pathsep=" " property="test-GAE" refid="html-test-files" /> - <subant target="run-tests" failonerror="false" antfile="test.xml"> + <subant target="run-tb2-tests" failonerror="false" antfile="test.xml"> <property name="com.vaadin.testbench.lib.dir" value="${com.vaadin.testbench.lib.dir}" /> <property name="com.vaadin.testbench.tester.host" value="${com.vaadin.testbench.tester.host}" /> <property name="com.vaadin.testbench.deployment.url" value="http://vaadin-integration-test.appspot.com/" /> @@ -107,6 +96,27 @@ <sshexec host="${test.integration.server}" username="${user}" keyfile="${sshkey.file}" command="ant -f ${ant.hub} deploy-to-GAE" /> </target> + <target name="run-tb3-servlet-test"> + <antcall target="run-tb3-test" inheritall="true"> + <param name="junit.test.suite" value="com.vaadin.tests.tb3.ServletIntegrationTests" /> + </antcall> + </target> + <target name="run-tb3-test"> + <fail unless="server-name" message="Server name must be defined in server-name" /> + <fail unless="deployment.url" message="Deplyoment url must be defined in deployment.url" /> + <fail unless="com.vaadin.testbench.screenshot.directory" message="Screenshot directory must be defined in com.vaadin.testbench.screenshot.directory" /> + + <junit printsummary="withOutAndErr" fork="yes"> + <formatter usefile="false" type="plain" /> + <classpath refid="classpath.tb3" /> + + <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" /> + <jvmarg value="-Ddeployment.url=${deployment.url}" /> + <jvmarg value="-Dserver-name=${server-name}" /> + <jvmarg value="-Djava.awt.headless=true" /> + <test name="${junit.test.suite}" /> + </junit> + </target> <target name="integration-test-tomcat7"> <antcall target="run-generic-integration-test"> @@ -114,6 +124,12 @@ <param name="target-server" value="tomcat7" /> </antcall> </target> + <target name="integration-test-tomcat8"> + <antcall target="run-generic-integration-test"> + <param name="startDelay" value="10" /> + <param name="target-server" value="tomcat8" /> + </antcall> + </target> <target name="integration-test-tomcat5"> <antcall target="run-generic-integration-test"> <param name="startDelay" value="10" /> @@ -188,6 +204,13 @@ </antcall> </target> + <target name="integration-test-jboss-eap6"> + <antcall target="run-generic-integration-test"> + <param name="startDelay" value="10" /> + <param name="target-server" value="jbosseap6" /> + </antcall> + </target> + <target name="integration-test-glassfish2"> <antcall target="run-generic-integration-test"> <param name="startDelay" value="10" /> @@ -333,7 +356,7 @@ <!-- Upload demo, clean error screenshots and test deployment on all servers --> - <target name="integration-test-all"> + <target name="integration-test-all" unless="tests.integration.skip"> <property name="passphrase" value="${passphrase}" /> <fail unless="sshkey.file" message="You must define an ssh.keyfile parameter" /> <fail unless="com.vaadin.testbench.screenshot.directory" message="You must define a com.vaadin.testbench.screenshot.directory parameter" /> @@ -341,7 +364,8 @@ <antcontrib:trycatch property="tried"> <try> <!-- Still running GAE test from the old server which - requires its own lock --> + requires its own lock --> + <echo message="Getting lock" /> <antcall target="integration-test-get-lock" /> <echo message="Got lock" /> @@ -378,6 +402,7 @@ <antcall target="integration-test-jboss5" /> <antcall target="integration-test-jboss6" /> <antcall target="integration-test-jboss7" /> + <antcall target="integration-test-jboss-eap6" /> <antcall target="integration-test-jetty5" /> <antcall target="integration-test-jetty6" /> <antcall target="integration-test-jetty7" /> @@ -386,8 +411,8 @@ <antcall target="integration-test-tomcat5" /> <antcall target="integration-test-tomcat6" /> <antcall target="integration-test-tomcat7" /> + <antcall target="integration-test-tomcat8" /> <antcall target="integration-test-websphere8" /> - </parallel> </target> @@ -446,31 +471,24 @@ </condition> </fail> - <copy file="integration-testscripts/common/integration_test.tpl" tofile="integration-testscripts/integration-test-${target-server}-servlet.html" overwrite="true" /> - <antcall target="integration-test-servlet"> - <param name="server-name" value="${target-server}" /> - <param name="deployment.url" value="http://${target-host}:${target-port}" /> - </antcall> - - <!-- Run theme tests in all browsers if there's a property - with the test files --> <antcontrib:if> - <isset property="testfiles-theme" /> + <isset property="testfiles" /> <antcontrib:then> - <antcall target="integration-test-theme"> + <echo>Starting legacy (TB2) test for ${target-server}</echo> + <antcall target="legacy-integration-test"> <param name="server-name" value="${target-server}" /> <param name="deployment.url" value="http://${target-host}:${target-port}" /> </antcall> </antcontrib:then> + <antcontrib:else> + <echo>Starting TB3 test for ${target-server}</echo> + <antcall target="run-tb3-servlet-test"> + <param name="server-name" value="${target-server}" /> + <param name="deployment.url" value="http://${target-host}:${target-port}" /> + </antcall> + </antcontrib:else> </antcontrib:if> - <!-- Run integration tests with push --> - <copy file="integration-testscripts/common/integration_push_test.tpl" tofile="integration-testscripts/integration-test-${target-server}-push-servlet.html" overwrite="true" /> - <antcall target="integration-test-push-servlet"> - <param name="server-name" value="${target-server}" /> - <param name="deployment.url" value="http://${target-host}:${target-port}" /> - </antcall> - <!-- Run theme tests in all browsers if there's a property with the test files --> <antcontrib:if> diff --git a/uitest/ivy.xml b/uitest/ivy.xml index 7ff83324ae..9c86b2b68c 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -1,4 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE ivy-module [ + <!ENTITY jetty.version "8.1.9.v20130131"> +]> <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" @@ -11,7 +14,7 @@ <conf name="build" /> <conf name="build-provided" visibility="private" /> <conf name="ide" visibility="private" /> - <conf name="jetty-run" extends="build" visibility="private" /> + <conf name="jetty-run" visibility="private" /> </configurations> <publications> <artifact type="war" ext="war" /> @@ -23,9 +26,6 @@ <dependency org="javax.validation" name="validation-api" rev="1.0.0.GA" conf="build,ide -> default,sources" /> - <!-- Servlet API --> - <dependency org="javax.servlet" name="servlet-api" - rev="2.4" conf="build-provided,ide -> default" /> <!-- Google App Engine --> <dependency org="com.google.appengine" name="appengine-api-1.0-sdk" rev="1.2.1" conf="build-provided,ide -> default" /> @@ -33,7 +33,9 @@ <!-- LIBRARY DEPENDENCIES (compile time) --> <!-- Project modules --> <dependency org="com.vaadin" name="vaadin-server" - rev="${vaadin.version}" conf="build->build"></dependency> + rev="${vaadin.version}" conf="build->build"> + <exclude org="javax.servlet"></exclude> + </dependency> <dependency org="com.vaadin" name="vaadin-client" rev="${vaadin.version}" conf="build->build"></dependency> <dependency org="com.vaadin" name="vaadin-client-compiled" @@ -41,29 +43,38 @@ <dependency org="com.vaadin" name="vaadin-themes" rev="${vaadin.version}" conf="build->build"></dependency> <dependency org="com.vaadin" name="vaadin-push" rev="${vaadin.version}" - conf="build->build"></dependency> + conf="build->build"> + <exclude org="javax.servlet"></exclude> + </dependency> <!-- For compiling TestingWidgetSet --> <dependency org="com.vaadin" name="vaadin-client-compiler" rev="${vaadin.version}" conf="build-provided-> build"></dependency> - <!-- Newest Jetty does not work with Ivy currently (orbit -> jar - mapping problem) --> + <!-- Servlet 3.0 API --> + <dependency org="javax.servlet" name="javax.servlet-api" + rev="3.0.1" conf="build-provided,ide -> default" /> + <dependency org="org.eclipse.jetty" name="jetty-server" - rev="7.5.0.v20110901" conf="ide, build-provided, jetty-run->default" /> + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default"> + <exclude org="org.eclipse.jetty.orbit"></exclude> + </dependency> <!-- jetty-servlets needed by ProxyTest, but not by jetty-runner --> <dependency org="org.eclipse.jetty" name="jetty-servlets" - rev="7.5.0.v20110901" conf="ide, build-provided, jetty-run->default" /> + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default" /> <dependency org="org.eclipse.jetty" name="jetty-websocket" - rev="7.5.0.v20110901" conf="ide, jetty-run->default" /> + rev="&jetty.version;" conf="ide, jetty-run->default" /> <dependency org="org.eclipse.jetty" name="jetty-webapp" - rev="7.5.0.v20110901" conf="ide, build-provided, jetty-run->default" /> + rev="&jetty.version;" conf="ide, build-provided, jetty-run->default" /> <dependency org="org.mortbay.jetty" name="jetty-runner" - rev="7.5.0.v20110901" conf="jetty-run->default" /> + rev="&jetty.version;" conf="ide, jetty-run->default"> + <exclude org="org.eclipse.jetty.orbit"></exclude> + </dependency> - <dependency org="junit" name="junit" rev="4.5" + <dependency org="junit" name="junit" rev="4.11" conf="build,ide -> default" /> - + <dependency org="com.jcraft" name="jsch" rev="0.1.50" + conf="ide, build->default" /> <dependency org="commons-codec" name="commons-codec" rev="1.5" conf="build,ide->default" /> <dependency org="commons-io" name="commons-io" rev="2.2" @@ -71,6 +82,8 @@ <!-- Mainly for SQLContainer tests --> <dependency org="org.hsqldb" name="hsqldb" rev="2.2.6" conf="build,ide -> default" /> + <dependency org="com.vaadin" name="vaadin-testbench" + rev="3.1.1" conf="build-provided,ide -> default" /> </dependencies> </ivy-module> 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)); } } diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java index 022a343196..1b21f08aa7 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersion.java @@ -9,9 +9,13 @@ public class VerifyBrowserVersion extends TestBase { @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/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java new file mode 100644 index 0000000000..ae5806af56 --- /dev/null +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.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; + +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; + +public class VerifyBrowserVersionTest extends MultiBrowserTest { + + private Map<DesiredCapabilities, String> expectedUserAgent = new HashMap<DesiredCapabilities, String>(); + + { + expectedUserAgent + .put(BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION), + "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(MultiBrowserTest.TESTED_CHROME_VERSION), + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"); + + } + + @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/actions/ActionsOnInvisibleComponents.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java new file mode 100644 index 0000000000..0f4c179cee --- /dev/null +++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java @@ -0,0 +1,76 @@ +package com.vaadin.tests.actions; + +import com.vaadin.event.ShortcutAction.KeyCode; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class ActionsOnInvisibleComponents extends AbstractTestUIWithLog { + + private static final long serialVersionUID = -5993467736906948993L; + + @Override + protected void setup(VaadinRequest request) { + getContent().setId("test-root"); + log("'A' triggers a click on an invisible button"); + log("'B' triggers a click on a disabled button"); + log("'C' triggers a click on a visible and enabled button"); + + Button invisibleButton = new Button("Invisible button with shortcut"); + invisibleButton.setClickShortcut(KeyCode.A); + invisibleButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log("Click event for invisible button"); + } + }); + + invisibleButton.setVisible(false); + addComponent(invisibleButton); + + Button disabledButton = new Button("Disabled button with shortcut"); + disabledButton.setClickShortcut(KeyCode.B); + disabledButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log("Click event for disabled button"); + } + }); + + disabledButton.setEnabled(false); + addComponent(disabledButton); + + Button enabledButton = new Button("Enabled button with shortcut"); + enabledButton.setClickShortcut(KeyCode.C); + enabledButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + log("Click event for enabled button"); + } + }); + + addComponent(enabledButton); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Test to ensure actions are not performed on disabled/invisible components"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12743; + } + +} diff --git a/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java new file mode 100644 index 0000000000..ca00c998a6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponentsTest.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.actions; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ActionsOnInvisibleComponentsTest extends MultiBrowserTest { + + private static final String LAST_INIT_LOG = "3. 'C' triggers a click on a visible and enabled button"; + + // This method should be removed once #12785 is fixed + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = super.getBrowsersToTest(); + // sendKeys does nothing on these browsers + browsers.remove(BrowserUtil.firefox(24)); + browsers.remove(BrowserUtil.ie(8)); + browsers.remove(BrowserUtil.opera(12)); + + // Causes 'cannot focus element' + browsers.remove(BrowserUtil.chrome(29)); + return browsers; + } + + @Test + public void testShortcutsOnInvisibleDisabledButtons() { + openTestURL(); + Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + invokeShortcut("A"); + Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + invokeShortcut("B"); + Assert.assertEquals(LAST_INIT_LOG, getLogRow(0)); + invokeShortcut("C"); + Assert.assertEquals("4. Click event for enabled button", getLogRow(0)); + } + + private void invokeShortcut(CharSequence key) { + WebElement shortcutTarget = vaadinElementById("test-root"); + shortcutTarget.sendKeys(key); + } +} diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html index 038283324d..33fc46f060 100644 --- a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html +++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.html @@ -27,6 +27,11 @@ <td></td> </tr> <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> <td>assertText</td> <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> <td>1. UI 0 has been detached</td> @@ -42,6 +47,11 @@ <td></td> </tr> <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> <td>assertText</td> <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> <td>2. UI 1 has been detached</td> @@ -62,6 +72,11 @@ <td></td> </tr> <tr> + <td>click</td> + <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> <td>assertText</td> <td>vaadin=runcomvaadintestsapplicationDetachOldUIOnReload::PID_SLog_row_0</td> <td>3. UI 2 has been detached</td> diff --git a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java index 7104146203..154c84b4f5 100644 --- a/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java +++ b/uitest/src/com/vaadin/tests/application/DetachOldUIOnReload.java @@ -31,10 +31,6 @@ public class DetachOldUIOnReload extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - for (String message : getSessionMessages(false)) { - log(message); - } - addComponent(new Label("This is UI " + getUIId())); addComponent(new Button("Reload page", new Button.ClickListener() { @Override @@ -42,6 +38,15 @@ public class DetachOldUIOnReload extends AbstractTestUIWithLog { getPage().reload(); } })); + addComponent(new Button("Read log messages from session", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + for (String message : getSessionMessages(false)) { + log(message); + } + } + })); } private List<String> getSessionMessages(boolean storeIfNeeded) { diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index f567106d60..8f92ff3118 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -9,6 +9,7 @@ import com.vaadin.server.WebBrowser; import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; @@ -100,6 +101,15 @@ public abstract class AbstractTestUI extends UI { } } + /** + * Sets the push transport according to the transport= URL parameter if such + * is given. Supports transport=xhr (disables push), transport=websocket + * (forces websocket into use), transport=streaming (forces streaming into + * use). Using ?transport=xyz disables the fallback transport. + * + * @param request + * The UI init request + */ protected void setTransport(VaadinRequest request) { String transport = request.getParameter("transport"); PushConfiguration config = getPushConfiguration(); @@ -112,11 +122,17 @@ public abstract class AbstractTestUI extends UI { config.setPushMode(PushMode.AUTOMATIC); } config.setTransport(Transport.WEBSOCKET); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } else if ("streaming".equals(transport)) { if (!mode.isEnabled()) { config.setPushMode(PushMode.AUTOMATIC); } config.setTransport(Transport.STREAMING); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } } diff --git a/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbars.java b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbars.java new file mode 100644 index 0000000000..5151ad5dd3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbars.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.components.browserframe; + +import com.vaadin.server.ExternalResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.BrowserFrame; +import com.vaadin.ui.TabSheet; + +public class BrowserFrameDoubleScrollbars extends AbstractTestUI { + + @Override + protected Integer getTicketNumber() { + return 11780; + } + + @Override + protected void setup(VaadinRequest request) { + + getLayout().setHeight("100%"); + getLayout().setSizeFull(); + getLayout().getParent().setSizeFull(); + + TabSheet tabs = new TabSheet(); + tabs.setSizeFull(); + getLayout().addComponent(tabs); + + BrowserFrame help = new BrowserFrame(); + help.setSizeFull(); + help.setSource(new ExternalResource("/statictestfiles/long-html.htm")); + + tabs.addComponent(help); + + } + + @Override + protected String getTestDescription() { + return "Embedded browser causes second scrollbar"; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbarsTest.java b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbarsTest.java new file mode 100644 index 0000000000..ade43735a7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameDoubleScrollbarsTest.java @@ -0,0 +1,15 @@ +package com.vaadin.tests.components.browserframe; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class BrowserFrameDoubleScrollbarsTest extends MultiBrowserTest { + + @Test + public void testWindowRepositioning() throws Exception { + openTestURL(); + + compareScreen("BrowserFrameDoubleScrollbars"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java index cc75f87a71..24dc942171 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java +++ b/uitest/src/com/vaadin/tests/components/button/ButtonsWaiAria.java @@ -32,6 +32,10 @@ public class ButtonsWaiAria extends ComponentTestCase<Button> { l = createButton("Tooltip Button", nat); l.setDescription("Tooltip"); addTestComponent(l); + + l = createButton("Another tooltip", nat); + l.setDescription("Another"); + addTestComponent(l); } private Button createButton(String text, boolean nativeButton) { diff --git a/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.java b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.java new file mode 100644 index 0000000000..a3e19513b0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSize.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.components.customfield; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.CustomField; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class CustomFieldSize extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + setContent(layout); + layout.setWidth("50px"); + + layout.addComponent(new TextField()); + + layout.addComponent(new CustomField<String>() { + + @Override + protected Component initContent() { + return new TextField(); + } + + @Override + public Class<? extends String> getType() { + return String.class; + } + + }); + } + + @Override + protected String getTestDescription() { + return "Any part of a TextField wrapped in a CustomField should not be cut off even when the dimensions of the TextField exceed those of the CustomField"; + } + + @Override + protected Integer getTicketNumber() { + return 12482; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.java b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.java new file mode 100644 index 0000000000..c47ec0b792 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/customfield/CustomFieldSizeTest.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.customfield; + +import java.io.IOException; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class CustomFieldSizeTest extends MultiBrowserTest { + + @Test + public void checkScreenshot() throws IOException { + openTestURL(); + compareScreen("size"); + } +} 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 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 @@ -52,6 +52,11 @@ <td></td> </tr> <tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> <td>mouseClick</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td> <td>14,16</td> @@ -87,6 +92,11 @@ <td></td> </tr> <tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> <td>mouseClick</td> <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td> <td>14,15</td> 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/nativebutton/NativeButtonIconAndText.java b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndText.java new file mode 100644 index 0000000000..fdeed316ba --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndText.java @@ -0,0 +1,124 @@ +/* + * 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.nativebutton; + +import com.vaadin.server.ThemeResource; +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.NativeButton; + +public class NativeButtonIconAndText extends AbstractTestUI implements + ClickListener { + + static final String UPDATED_ALTERNATE_TEXT = "Now has alternate text"; + static final String INITIAL_ALTERNATE_TEXT = "Initial alternate text"; + static final String BUTTON_TEXT = "buttonText"; + static final String BUTTON_TEXT_ICON = "buttonTextIcon"; + static final String BUTTON_TEXT_ICON_ALT = "buttonTextIconAlt"; + static final String NATIVE_BUTTON_TEXT = "nativeButtonText"; + static final String NATIVE_BUTTON_TEXT_ICON = "nativeButtonTextIcon"; + static final String NATIVE_BUTTON_TEXT_ICON_ALT = "nativeButtonTextIconAlt"; + + @Override + protected void setup(VaadinRequest request) { + Button buttonText = new Button("Only text"); + + Button buttonTextIcon = new Button("Text icon"); + buttonTextIcon.setIcon(new ThemeResource("../runo/icons/64/ok.png")); + + Button buttonTextIconAlt = new Button("Text icon alt"); + buttonTextIconAlt.setIcon(new ThemeResource( + "../runo/icons/64/cancel.png")); + buttonTextIconAlt.setIconAlternateText(INITIAL_ALTERNATE_TEXT); + + buttonText.addClickListener(this); + buttonTextIcon.addClickListener(this); + buttonTextIconAlt.addClickListener(this); + + buttonText.setId(BUTTON_TEXT); + buttonTextIcon.setId(BUTTON_TEXT_ICON); + buttonTextIconAlt.setId(BUTTON_TEXT_ICON_ALT); + + addComponent(buttonText); + addComponent(buttonTextIcon); + addComponent(buttonTextIconAlt); + + NativeButton nativeButtonText = new NativeButton("Only text"); + + NativeButton nativeButtonTextIcon = new NativeButton("Text icon"); + nativeButtonTextIcon.setIcon(new ThemeResource( + "../runo/icons/64/ok.png")); + + NativeButton nativeButtonTextIconAlt = new NativeButton("Text icon alt"); + nativeButtonTextIconAlt.setIcon(new ThemeResource( + "../runo/icons/64/cancel.png")); + nativeButtonTextIconAlt.setIconAlternateText(INITIAL_ALTERNATE_TEXT); + + nativeButtonText.addClickListener(this); + nativeButtonTextIcon.addClickListener(this); + nativeButtonTextIconAlt.addClickListener(this); + + nativeButtonText.setId(NATIVE_BUTTON_TEXT); + nativeButtonTextIcon.setId(NATIVE_BUTTON_TEXT_ICON); + nativeButtonTextIconAlt.setId(NATIVE_BUTTON_TEXT_ICON_ALT); + + addComponent(nativeButtonText); + addComponent(nativeButtonTextIcon); + addComponent(nativeButtonTextIconAlt); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Click the buttons to toggle icon alternate text"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12780; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui.Button. + * ClickEvent) + */ + @Override + public void buttonClick(ClickEvent event) { + Button b = event.getButton(); + String was = b.getIconAlternateText(); + if (was == null || was.isEmpty()) { + b.setIconAlternateText(UPDATED_ALTERNATE_TEXT); + } else { + b.setIconAlternateText(null); + } + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java new file mode 100644 index 0000000000..2cb294de77 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/nativebutton/NativeButtonIconAndTextTest.java @@ -0,0 +1,94 @@ +/* + * 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.nativebutton; + +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT_ICON; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.BUTTON_TEXT_ICON_ALT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.INITIAL_ALTERNATE_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.NATIVE_BUTTON_TEXT_ICON_ALT; +import static com.vaadin.tests.components.nativebutton.NativeButtonIconAndText.UPDATED_ALTERNATE_TEXT; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class NativeButtonIconAndTextTest extends MultiBrowserTest { + + @Test + public void testNativeButtonIconAltText() { + openTestURL(); + assertAltText(BUTTON_TEXT, ""); + assertAltText(BUTTON_TEXT_ICON, ""); + assertAltText(BUTTON_TEXT_ICON_ALT, INITIAL_ALTERNATE_TEXT); + assertAltText(NATIVE_BUTTON_TEXT, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON_ALT, INITIAL_ALTERNATE_TEXT); + + clickElements(BUTTON_TEXT, BUTTON_TEXT_ICON, BUTTON_TEXT_ICON_ALT, + NATIVE_BUTTON_TEXT, NATIVE_BUTTON_TEXT_ICON, + NATIVE_BUTTON_TEXT_ICON_ALT); + + // Button without icon - should not get alt text + assertAltText(BUTTON_TEXT, ""); + assertAltText(BUTTON_TEXT_ICON, UPDATED_ALTERNATE_TEXT); + assertAltText(BUTTON_TEXT_ICON_ALT, ""); + // Button without icon - should not get alt text + assertAltText(NATIVE_BUTTON_TEXT, ""); + assertAltText(NATIVE_BUTTON_TEXT_ICON, UPDATED_ALTERNATE_TEXT); + assertAltText(NATIVE_BUTTON_TEXT_ICON_ALT, ""); + + } + + private void clickElements(String... ids) { + for (String id : ids) { + vaadinElementById(id).click(); + } + } + + /** + * If the button identified by 'buttonId' has an icon, asserts that the + * alternate text of the icon matches 'expected'. "" and null are considered + * equivalent. + * + * @param buttonId + * the id of the button who possibly contains an icon + * @param expected + * the expected alternate text, cannot be null + */ + private void assertAltText(String buttonId, String expected) { + WebElement button = vaadinElementById(buttonId); + List<WebElement> imgList = button.findElements(By.xpath(".//img")); + if (imgList.isEmpty()) { + return; + } + WebElement img = imgList.get(0); + String alt = img.getAttribute("alt"); + if (alt == null) { + alt = ""; + } + + Assert.assertEquals(expected, alt); + + } +} 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>OptionGroupRetainFocusKeyboardValueChange</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">OptionGroupRetainFocusKeyboardValueChange</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/OptionGroupRetainFocusKeyboardValueChange?restartApplication</td> + <td></td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[0]/domChild[0]</td> + <td>space</td> +</tr> +<!-- The element 'A' should be selected and focused --> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[0]/domChild[0]</td> + <td>down</td> +</tr> +<!-- The element 'B' should be selected and focused, the caption of first element is changed from 'A' to 'A+' --> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runOptionGroupRetainFocusKeyboardValueChange::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VOptionGroup[0]/domChild[1]/domChild[0]</td> + <td>down</td> +</tr> +<!-- Elements 'B' and 'C' should be swapped; 'C' selected but not focused --> +<tr> + <td>screenCapture</td> + <td></td> + <td></td> +</tr> +</tbody></table> +</body> +</html> 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; + } +} 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..030bfa693e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/HorizontalLayoutFullsizeContentWithErrorMsg.java @@ -0,0 +1,66 @@ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +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 { + + static final String FIELD_ID = "f"; + 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."; + } + +} 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/label/LabelModes.html b/uitest/src/com/vaadin/tests/components/panel/WebkitScrollbarTest.html index 356688b456..ee33ee2bf0 100644 --- a/uitest/src/com/vaadin/tests/components/label/LabelModes.html +++ b/uitest/src/com/vaadin/tests/components/panel/WebkitScrollbarTest.html @@ -12,14 +12,14 @@ <tr><td rowspan="1" colspan="3">New Test</td></tr> </thead><tbody> <tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.label.LabelModes?restartApplication</td> - <td></td> + <td>open</td> + <td>/run/com.vaadin.tests.components.panel.WebkitScrollbarTest?restartApplication</td> + <td></td> </tr> <tr> - <td>screenCapture</td> - <td></td> - <td>labelmodes</td> + <td>screenCapture</td> + <td></td> + <td>panelShouldNotHaveScrollbars</td> </tr> </tbody></table> diff --git a/uitest/src/com/vaadin/tests/components/panel/WebkitScrollbarTest.java b/uitest/src/com/vaadin/tests/components/panel/WebkitScrollbarTest.java new file mode 100644 index 0000000000..8981f52f12 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/panel/WebkitScrollbarTest.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.components.panel; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.Panel; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class WebkitScrollbarTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Panel panel = new Panel(); + + VerticalLayout content = new VerticalLayout(); + panel.setContent(content); + + GridLayout gridLayout = new GridLayout(); + gridLayout.setHeight(null); + gridLayout.setWidth(100, Unit.PERCENTAGE); + content.addComponent(gridLayout); + + ListSelect listSelect = new ListSelect(); + + listSelect.setWidth(100, Unit.PERCENTAGE); + listSelect.setHeight(300, Unit.PIXELS); + + gridLayout.addComponent(listSelect); + + gridLayout.setMargin(true); + + setContent(panel); + } + + @Override + protected String getTestDescription() { + return "When opening the window, it should NOT contain a horizontal"; + } + + @Override + protected Integer getTicketNumber() { + return 12727; + } + +} 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..bd1d175119 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/slider/SliderDisable.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.components.slider; + +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.Slider; +import com.vaadin.ui.VerticalLayout; + +public class SliderDisable extends AbstractTestUI { + + @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; + } + +} 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/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 diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.html b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html index d009eb3baf..c9c93198fa 100644 --- a/uitest/src/com/vaadin/tests/push/PushFromInit.html +++ b/uitest/src/com/vaadin/tests/components/table/ShowLastItem.html @@ -3,7 +3,6 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> <title>New Test</title> </head> <body> @@ -12,19 +11,24 @@ <tr><td rowspan="1" colspan="3">New Test</td></tr> </thead><tbody> <tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.PushFromInit?debug&restartApplication</td> - <td></td> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.ShowLastItem?restartApplication</td> + <td></td> </tr> <tr> - <td>waitForText</td> - <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_1</td> - <td>1. Logged in init</td> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableShowLastItem::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> </tr> <tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushPushFromInit::PID_SLog_row_0</td> - <td>2. Logged from background thread started in init</td> + <td>pause</td> + <td>1000</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>row-20-fully-visible</td> </tr> </tbody></table> 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; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html b/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html new file mode 100644 index 0000000000..e225091b5f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableDragColumnFloatingElementStyles.html @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TableDragColumn</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TableDragColumn</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td> + <td></td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>1 basic ghost element</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +<!--Add style name "red-border-1px" to table--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td> + <td>24,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>18,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td> + <td>19,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item2</td> + <td>75,7</td> +</tr> +<!-- Drag and drop column 1 to the left of column 4 --> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>2 themed ghost element should have red borders</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +<!--Add style name "red-border-1px" to table--> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td> + <td>24,7</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td> + <td>18,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item4</td> + <td>19,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item3</td> + <td>164,10</td> +</tr> +<tr> + <td>drag</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>51,6</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]</td> + <td>70,10</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>3 themed ghost element should have 2px blue borders</td> +</tr> +<tr> + <td>drop</td> + <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td> + <td>10,10</td> +</tr> +</tbody></table> +</body> +</html>
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html new file mode 100644 index 0000000000..6fd54ba0ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.html @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>TableHorizontalScrollPositionOnItemSetChange</title> +</head> +<body> + <table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">TableHorizontalScrollPositionOnItemSetChange</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.table.TableHorizontalScrollPositionOnItemSetChange?restartApplication</td> + <td></td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>326</td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-in-middle-with-fewer-items</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-in-middle-with-more-items</td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>653</td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Slessitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-max-with-fewer-items</td> + </tr> + <tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Smoreitems/domChild[0]/domChild[0]</td> + <td></td> + </tr> + <tr> + <td>pause</td> + <td>500</td> + <td></td> + </tr> + <tr> + <td>screenCapture</td> + <td></td> + <td>left-scroll-position-stays-max-with-more-items</td> + </tr> + <tr> + <td>scrollLeft</td> + <td>vaadin=runcomvaadintestscomponentstableTableHorizontalScrollPositionOnItemSetChange::PID_Shorscrolltable/domChild[1]</td> + <td>0</td> + </tr> + </tbody> + </table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java new file mode 100644 index 0000000000..1f59a84428 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableHorizontalScrollPositionOnItemSetChange.java @@ -0,0 +1,101 @@ +/* + * 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.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +public class TableHorizontalScrollPositionOnItemSetChange extends + AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + final Table table = new Table(); + table.setWidth("640px"); + table.setHeight("243px"); + table.setId("horscrolltable"); + layout.addComponent(table); + + for (int i = 0; i < 15; i++) { + table.addContainerProperty("Column " + i, String.class, null); + } + + for (int i = 0; i < 60; i++) { + table.addItem(); + } + + Button lessItems = new Button("Less items", new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + table.removeAllItems(); + for (int i = 0; i < 5; i++) { + table.addItem(); + } + } + }); + lessItems.setId("lessitems"); + + Button moreItems = new Button("More items", new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + table.removeAllItems(); + for (int i = 0; i < 50; i++) { + table.addItem(); + } + } + }); + moreItems.setId("moreitems"); + + Button clearItems = new Button("Clear all", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + table.removeAllItems(); + } + }); + + HorizontalLayout buttonLayout = new HorizontalLayout(); + buttonLayout.setSpacing(true); + layout.addComponent(buttonLayout); + + buttonLayout.addComponent(lessItems); + buttonLayout.addComponent(moreItems); + buttonLayout.addComponent(clearItems); + clearItems.setId("clearitems"); + } + + @Override + protected String getTestDescription() { + return "Horizontal scrolling position should not be lost if amount of items changes in Table."; + } + + @Override + protected Integer getTicketNumber() { + return 12652; + } + +} 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<Object> values = new HashSet<Object>( + (Set<Object>) 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..5075e22f1b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableMoveFocusWithSelectionTest.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.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(); + + // Clicking a row should get the row focus + WebElement row7TableRow = getDriver().findElement( + By.xpath("//div[@id='row-7']/../../..")); + String row7StyleName = row7TableRow.getAttribute("class"); + assertTrue(row7StyleName.contains("v-table-focus")); + + // Select row 5-10 server side + getDriver().findElement(By.id("select-510")).click(); + + /* + * Focus the table again (some browsers steal focus when performing + * button click, other don't) + */ + getDriver().findElement(By.id("test-table")).click(); + + // Ensure row 7 is still focused + row7TableRow = getDriver().findElement( + By.xpath("//div[@id='row-7']/../../..")); + row7StyleName = row7TableRow.getAttribute("class"); + assertTrue(row7StyleName.contains("v-table-focus")); + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java new file mode 100644 index 0000000000..6e4b62e4f7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java @@ -0,0 +1,107 @@ +/* + * 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.annotations.Push; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.event.ItemClickEvent.ItemClickListener; +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; + +@Push +public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + addComponent(new Button("Blink a table", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + blinkTable(); + } + })); + } + + private void blinkTable() { + final Table table = new Table(); + table.setPageLength(5); + table.addContainerProperty(new Object(), String.class, null); + + for (int i = 0; i < 50; i++) { + table.addItem(new Object[] { "Row" }, new Object()); + } + + table.addItemClickListener(new ItemClickListener() { + private int i; + + @Override + public void itemClick(ItemClickEvent event) { + /* + * Ignore implementation. This is only an easy way to make the + * client-side update table's variables (by furiously clicking + * on the table row. + * + * This way, we get variable changes queued. The push call will + * then remove the Table, while the variable changes being still + * in the queue, leading to the issue as described in the + * ticket. + */ + System.out.println("clicky " + (++i)); + } + }); + + System.out.println("adding component"); + addComponent(table); + + new Thread() { + @Override + public void run() { + getSession().lock(); + try { + Thread.sleep(500); + access(new Runnable() { + @Override + public void run() { + System.out.println("removing component"); + removeComponent(table); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + getSession().unlock(); + } + }; + }.start(); + } + + @Override + protected String getTestDescription() { + return "Adding and subsequently quickly removing a table " + + "should not leave any pending RPC calls waiting " + + "in a Timer. Issue can be reproduced by " + + "1) pressing the button 2) clicking furiously " + + "on a row in the table."; + } + + @Override + protected Integer getTicketNumber() { + return 12337; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java new file mode 100644 index 0000000000..f84f83718d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheet.java @@ -0,0 +1,69 @@ +/* + * 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.Component; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.Layout; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class TableSizeInTabsheet extends AbstractTestUI { + + static final String TABLE = "table"; + static final String TABSHEET = "tabsheet"; + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + setContent(layout); + + TabSheet tabSheet = new TabSheet(); + tabSheet.setId(TABSHEET); + layout.addComponent(tabSheet); + tabSheet.addTab(new TabComposite(), "Tab"); + } + + public class TabComposite extends CustomComponent { + + public TabComposite() { + Layout mainLayout = new VerticalLayout(); + addComponent(mainLayout); + setCompositionRoot(mainLayout); + + Component table = new Table(); + table.setWidth("100%"); + table.setId(TABLE); + mainLayout.addComponent(table); + } + } + + @Override + protected String getTestDescription() { + return "The size calculations fails in IE8 when undefined size table is inside a tabsheet"; + } + + @Override + protected Integer getTicketNumber() { + return 12687; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.java new file mode 100644 index 0000000000..29fc5a2e52 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableSizeInTabsheetTest.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.table; + +import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABLE; +import static com.vaadin.tests.components.table.TableSizeInTabsheet.TABSHEET; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableSizeInTabsheetTest extends MultiBrowserTest { + + private static final String TABSHEET_CONTENT_STYLENAME = "v-tabsheet-content"; + + @Test + public void testTabsheetContentHasTheSameHeightAsTable() { + openTestURL(); + int tableHeight = getTableHeigth(); + int tabSheetContentHeight = getTableSheetContentHeight(); + + Assert.assertEquals(tableHeight, tabSheetContentHeight); + } + + private int getTableHeigth() { + return vaadinElementById(TABLE).getSize().getHeight(); + } + + private int getTableSheetContentHeight() { + WebElement tabsheetContent = vaadinElementById(TABSHEET).findElement( + By.className(TABSHEET_CONTENT_STYLENAME)); + return tabsheetContent.getSize().getHeight(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.java new file mode 100644 index 0000000000..02482b7049 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltip.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.components.tabsheet; + +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet; +import com.vaadin.ui.TabSheet.Tab; + +public class TabSheetErrorTooltip extends AbstractTestUI { + + private TabSheet tabSheet = new TabSheet(); + private int tabCount = 0; + + @Override + protected void setup(VaadinRequest request) { + + addTab(); + addTab().setComponentError(new UserError("Error!")); + addTab().setDescription("This is a tab"); + + Tab t = addTab(); + t.setComponentError(new UserError("Error!")); + t.setDescription("This tab has both an error and a description"); + + setContent(tabSheet); + } + + private Tab addTab() { + tabCount++; + Label contents = new Label("Contents for tab " + tabCount); + return tabSheet.addTab(contents, "Tab " + tabCount); + } + + @Override + protected String getTestDescription() { + return "TabSheet Tabs should display component error tooltips when expected"; + } + + @Override + protected Integer getTicketNumber() { + return 12802; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.java new file mode 100644 index 0000000000..88bc23d12b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetErrorTooltipTest.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.tabsheet; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabSheetErrorTooltipTest extends MultiBrowserTest { + + @Test + public void checkTooltips() throws IOException { + openTestURL(); + + testBenchElement(getTab(0)).showTooltip(); + assertNoTooltip(); + + testBenchElement(getTab(1)).showTooltip(); + assertErrorMessage("Error!"); + assertTooltip(""); + + testBenchElement(getTab(2)).showTooltip(); + assertErrorMessage(""); + assertTooltip("This is a tab"); + + testBenchElement(getTab(3)).showTooltip(); + assertErrorMessage("Error!"); + assertTooltip("This tab has both an error and a description"); + } + + private WebElement getTab(int index) { + return vaadinElement("/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[" + + index + "]/domChild[0]"); + } + + private WebElement getTooltip() { + return getDriver().findElement( + By.xpath("//div[@class='v-tooltip-text']")); + } + + private WebElement getErrorMessage() { + return getDriver().findElement( + By.xpath("//div[@class='v-errormessage']")); + } + + private void assertTooltip(String tooltip) { + Assert.assertEquals(tooltip, getTooltip().getText()); + } + + private void assertErrorMessage(String message) { + Assert.assertEquals(message, getErrorMessage().getText()); + } + + private void assertNoTooltip() { + try { + getTooltip(); + } catch (NoSuchElementException e) { + return; + } + Assert.fail("Tooltip exists"); + } +} 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; + } + +} diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.html index 89dd7d4e78..ac39d1f03c 100644 --- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.html +++ b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.html @@ -3,24 +3,30 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://192.168.2.162:8888/" /> -<title>New Test</title> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>PollListenerTest</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> +<tr><td rowspan="1" colspan="3">PollListenerTest</td></tr> </thead><tbody> <tr> <td>open</td> - <td>/run/com.vaadin.tests.push.TrackMessageSizeUnitTests?restartApplication</td> + <td>/run/com.vaadin.tests.components.ui.PollListenerTest?restartApplication</td> <td></td> </tr> <tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestspushTrackMessageSizeUnitTests::PID_SLog_row_0</td> - <td>1. All tests run</td> + <td>pause</td> + <td>5000</td> + <td></td> +</tr> +<tr> + <td>verifyTextPresent</td> + <td>PollEvent received</td> + <td></td> </tr> + </tbody></table> </body> </html> diff --git a/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.java b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.java new file mode 100644 index 0000000000..0e5ddaab87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/PollListenerTest.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.components.ui; + +import com.vaadin.event.UIEvents.PollEvent; +import com.vaadin.event.UIEvents.PollListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +public class PollListenerTest extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Label statusLabel = new Label("Default Label"); + addComponent(statusLabel); + + setPollInterval(2000); + addPollListener(new PollListener() { + @Override + public void poll(PollEvent event) { + setPollInterval(-1); + statusLabel.setValue(event.getClass().getSimpleName() + + " received"); + removePollListener(this); + } + }); + } + + @Override + protected String getTestDescription() { + return "Polling should fire a PollEvent on the server-side"; + } + + @Override + protected Integer getTicketNumber() { + return 12466; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java index 09f2fd8816..d036827159 100644 --- a/uitest/src/com/vaadin/tests/components/ui/UiAccess.java +++ b/uitest/src/com/vaadin/tests/components/ui/UIAccess.java @@ -31,7 +31,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.UI; import com.vaadin.util.CurrentInstance; -public class UiAccess extends AbstractTestUIWithLog { +public class UIAccess extends AbstractTestUIWithLog { private volatile boolean checkCurrentInstancesBeforeResponse = false; diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.html b/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.html new file mode 100644 index 0000000000..94d8aa2777 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.html @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.ui.UIAccessExceptionHandling?restartApplication</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_0</td> + <td>1. Exception catched on get: java.util.concurrent.ExecutionException</td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_1</td> + <td>0. Exception catched on execution with ConnectorErrorEvent : java.util.concurrent.ExecutionException</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_0</td> + <td>1. Exception catched on get: java.util.concurrent.ExecutionException</td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_1</td> + <td>0. Exception catched on execution with ErrorEvent : java.util.concurrent.ExecutionException</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_0</td> + <td>1. Exception catched on get: java.util.concurrent.ExecutionException</td> +</tr> +<tr> + <td>verifyText</td> + <td>vaadin=runcomvaadintestscomponentsuiUIAccessExceptionHandling::PID_SLog_row_1</td> + <td>0. Exception catched on execution with ConnectorErrorEvent : java.util.concurrent.ExecutionException</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java b/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java new file mode 100644 index 0000000000..1cd4be576b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIAccessExceptionHandling.java @@ -0,0 +1,157 @@ +/* + * 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.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import com.vaadin.server.DefaultErrorHandler; +import com.vaadin.server.ErrorHandler; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinService; +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 UIAccessExceptionHandling extends AbstractTestUIWithLog implements + ErrorHandler { + + private Future<Void> future; + + @Override + protected void setup(VaadinRequest request) { + getSession().setErrorHandler(this); + + addComponent(new Button("Throw RuntimeException on UI.access", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + + // Ensure beforeClientResponse is invoked + markAsDirty(); + + future = access(new Runnable() { + @Override + public void run() { + throw new RuntimeException(); + } + }); + } + })); + + addComponent(new Button("Throw RuntimeException on Session.access", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + + // Ensure beforeClientResponse is invoked + markAsDirty(); + + VaadinService service = VaadinService.getCurrent(); + + future = service.accessSession(getSession(), + new Runnable() { + + @Override + public void run() { + throw new RuntimeException(); + } + }); + } + })); + + addComponent(new Button( + "Throw RuntimeException after removing instances", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + + // Ensure beforeClientResponse is invoked + markAsDirty(); + + assert UI.getCurrent() == UIAccessExceptionHandling.this; + + Map<Class<?>, CurrentInstance> instances = CurrentInstance + .getInstances(false); + CurrentInstance.clearAll(); + + assert UI.getCurrent() == null; + + future = access(new Runnable() { + @Override + public void run() { + throw new RuntimeException(); + } + }); + + CurrentInstance.restoreInstances(instances); + } + })); + + addComponent(new Button("Clear", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.clear(); + } + })); + } + + @Override + public void beforeClientResponse(boolean initial) { + if (future != null) { + try { + future.get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + log("Exception catched on get: " + e.getClass().getName()); + } finally { + future = null; + } + } + } + + @Override + protected String getTestDescription() { + return "Test for handling exceptions in UI.access and Session.access"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(12703); + } + + @Override + public void error(com.vaadin.server.ErrorEvent event) { + log("Exception catched on execution with " + + event.getClass().getSimpleName() + " : " + + event.getThrowable().getClass().getName()); + + DefaultErrorHandler.doDefault(event); + } + +} 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..9db2c2f0d3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UIAccessTest.java @@ -0,0 +1,204 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import static org.junit.Assert.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 { + @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()); + + } + + @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]"); + } +}
\ No newline at end of file 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.ui.UiAccess?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>exact:0. Access from UI thread future is done? false</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>1. Access from UI thread is run</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>exact:2. beforeClientResponse future is done? true</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>0. Initial background message</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>exact:1. Thread has current response? false</td> -</tr> -<tr> - <td>waitForText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>0. Initial background message</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>exact:2. Thread got lock, inital future done? true</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>0. Throwing exception in access</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>exact:1. firstFuture is done? true</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>2. Got exception from firstFuture: java.lang.RuntimeException: Catch me if you can</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>0. future was cancled, should not start</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>0. Waiting for thread to start</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>1. Thread started, waiting for interruption</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>2. I was interrupted</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3</td> - <td>0. accessSynchronously has request? true</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>1. Test value in accessSynchronously: Set before accessSynchronosly</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>2. has request after accessSynchronously? true</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>3. Test value after accessSynchornously: Set in accessSynchronosly</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[6]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_3</td> - <td>0. access has request? false</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_2</td> - <td>1. Test value in access: Set before access</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>2. has request after access? true</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>3. Test value after access: Set before run pending</td> -</tr> -</tbody></table> -</body> -</html> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.ui.UiAccess?restartApplication&transport=websocket</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::/VVerticalLayout[0]/Slot[2]/VVerticalLayout[0]/Slot[7]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForNotText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_0</td> - <td>exact:1. Current session matches in beforeResponse? true</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentsuiUiAccess::PID_SLog_row_1</td> - <td>exact:0. Current UI matches in beforeResponse? true</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.java b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.java new file mode 100644 index 0000000000..6347ff9a76 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindow.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.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class ComboboxScrollableWindow extends AbstractTestUI { + + static final String WINDOW_ID = "window"; + static final String COMBOBOX_ID = "combobox"; + + @Override + protected void setup(VaadinRequest request) { + + Window w = new Window(); + w.setId(WINDOW_ID); + w.setWidth("300px"); + w.setHeight("300px"); + w.center(); + + VerticalLayout content = new VerticalLayout(); + w.setContent(content); + content.setHeight("1000px"); + ComboBox cb = new ComboBox(); + cb.setId(COMBOBOX_ID); + content.addComponent(cb); + content.setComponentAlignment(cb, Alignment.BOTTOM_CENTER); + + addWindow(w); + + } + + @Override + protected String getTestDescription() { + return "The combo box in the bottom of the scrollable window should remain visible when it is clicked."; + } + + @Override + protected Integer getTicketNumber() { + return 12736; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java new file mode 100644 index 0000000000..665e175f2c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ComboboxScrollableWindowTest.java @@ -0,0 +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.components.window; + +import static com.vaadin.tests.components.window.ComboboxScrollableWindow.COMBOBOX_ID; +import static com.vaadin.tests.components.window.ComboboxScrollableWindow.WINDOW_ID; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class ComboboxScrollableWindowTest extends MultiBrowserTest { + + @Test + public void testWindowScrollbars() throws Exception { + openTestURL(); + com.vaadin.testbench.Parameters + .setScreenshotComparisonCursorDetection(true); + + WebElement window = driver.findElement(By.id(WINDOW_ID)); + WebElement scrollableElement = window.findElement(By + .className("v-scrollable")); + TestBenchElementCommands scrollable = testBenchElement(scrollableElement); + scrollable.scroll(1000); + WebElement comboBox = driver.findElement(By.id(COMBOBOX_ID)); + WebElement selectButton = driver.findElement(By + .className("v-filterselect-button")); + selectButton.click(); + + // Wait for the browser before taking a screenshot + Thread.sleep(1000); + compareScreen(getScreenshotBaseName()); + + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java new file mode 100644 index 0000000000..e0bc0d9471 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.components.window; + +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.Window; + +@SuppressWarnings("serial") +public class WindowMoveListener extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + Window w = new Window("Caption"); + w.setId("testwindow"); + w.setHeight("100px"); + w.setWidth("100px"); + w.setPositionX(100); + w.setPositionY(100); + addWindow(w); + + Button b = new Button(); + b.setId("testbutton"); + addComponent(b); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + for (Window window : getWindows()) { + window.setPositionX(100); + window.setPositionY(100); + } + } + }); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Tests that windows send their updated position " + + "to server-side after being moved by user"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 12885; + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java new file mode 100644 index 0000000000..3ea3b719c0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java @@ -0,0 +1,50 @@ +package com.vaadin.tests.components.window; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class WindowMoveListenerTest extends MultiBrowserTest { + + @Test + public void testWindowRepositioning() throws Exception { + openTestURL(); + + WebElement window = getDriver().findElement(By.id("testwindow")); + WebElement button = getDriver().findElement(By.id("testbutton")); + + // I'd loved to use the header, but that doesn't work. Footer works + // fine, though :) + WebElement windowHeader = getDriver().findElement( + By.className("v-window-footer")); + + Point winPos = window.getLocation(); + + // move window + Action a = new Actions(driver).clickAndHold(windowHeader) + .moveByOffset(100, 100).release().build(); + a.perform(); + + assertNotEquals("Window was not dragged correctly.", winPos.x, + window.getLocation().x); + assertNotEquals("Window was not dragged correctly.", winPos.y, + window.getLocation().y); + + // re-set window + button.click(); + + assertEquals("Window was not re-positioned correctly.", winPos.x, + window.getLocation().x); + assertEquals("Window was not re-positioned correctly.", winPos.y, + window.getLocation().y); + + } +}
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <link rel="selenium.base" href="http://localhost:8888/"/> + <title>DnDOnSubtree</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> + <thead> + <tr> + <td rowspan="1" colspan="3">New Test</td> + </tr> + </thead> + <tbody> + <tr> + <td>open</td> + <td>/run/com.vaadin.tests.dd.DDTest8?restartApplication</td> + <td></td> + </tr> + <tr> + <td>drag</td> + <td>vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[3]</td> + <td>11,8</td> + </tr> + <!-- Drop on Bar5, which is a subtree target --> + <tr> + <td>drop</td> + <td>vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[6]</td> + <td>34,9</td> + </tr> + <tr> + <td>mouseClick</td> + <td> + vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[5]/expand + </td> + <td>10,8</td> + </tr> + <!-- Assert that the dragged & dropped node is now a child of Bar5 --> + <tr> + <td>assertElementPresent</td> + <td> + vaadin=runcomvaadintestsddDDTest8::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTree[0]#n[5]/n[0] + </td> + <td></td> + </tr> + </tbody> +</table> +</body> +</html> 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..ddaf84b3e1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/AbstractIntegrationTest.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 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.MultiBrowserTest; +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<DesiredCapabilities> getBrowsersForTest() { + return Collections.singleton(BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + } + +} 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 new file mode 100644 index 0000000000..f5042b54b6 --- /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 (AbstractIntegrationTest.class.isAssignableFrom(testClass)) { + return System.getProperty("server-name"); + } else { + return super.testName(method); + } + } +} 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/IntegrationTestUI.java b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java index 0e6cb19b30..6aec2c8e2a 100755 --- a/uitest/src/com/vaadin/tests/integration/IntegrationTestUI.java +++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationUI.java @@ -11,7 +11,8 @@ import com.vaadin.ui.Table; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; -public class IntegrationTestUI extends UI { +public class ServletIntegrationUI extends UI { + @Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); 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..d7c525f202 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/ServletIntegrationWebsocketUI.java @@ -0,0 +1,48 @@ +/* + * 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; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +/** + * 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().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + + } + +} 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/layouts/layouttester/GridLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java index 221680be11..f55867c464 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/GridLayoutTests.java @@ -124,6 +124,13 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button5 = new Button("Test remove row 0"); final Button button6 = new Button("Test remove comp row3"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + button5.setId("testButton5"); + button6.setId("testButton6"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); @@ -223,6 +230,10 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button4 = new Button("undefined size+add, table"); glo.replaceComponent(x22, x22 = getTestTable()); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); @@ -287,6 +298,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("set all cols expand 0.25"); final Button button3 = new Button("set row 0 expand 0.5"); final Button button4 = new Button("set row 3 expand 0.2"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + glo.setHeight("400px"); glo.replaceComponent(x22, x22 = getTestTable()); @@ -396,6 +412,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + glo.replaceComponent(x22, x22 = getTestTable()); baseLayout.addComponent(button1); @@ -467,6 +488,11 @@ public class GridLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java index 7a53a6583e..971205ccbb 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/HorizontalLayoutTests.java @@ -123,7 +123,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button replaceButton = new Button("Test replace"); final Button moveButton = new Button("Test move"); final Button removeButton = new Button("Test remove"); - + addButton.setId("testButton1"); + replaceButton.setId("testButton2"); + moveButton.setId("testButton3"); + removeButton.setId("testButton4"); replaceButton.setEnabled(false); moveButton.setEnabled(false); removeButton.setEnabled(false); @@ -193,6 +196,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button smallerButton = new Button("200 px width"); final Button originalButton = new Button("undefined size+add"); + biggerButton.setId("testButton1"); + smallerButton.setId("testButton2"); + originalButton.setId("testButton3"); + baseLayout.addComponent(biggerButton); baseLayout.addComponent(smallerButton); baseLayout.addComponent(originalButton); @@ -257,6 +264,11 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + baseLayout.addComponent(button1); baseLayout.addComponent(button2); baseLayout.addComponent(button3); @@ -332,6 +344,9 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button1 = new Button("Expand to 1/undefined"); final Button button2 = new Button("Expand to 0.5/0.5"); final Button button3 = new Button("Expand to 0.75/0.25"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); @@ -438,6 +453,10 @@ public class HorizontalLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("Set spacing on"); final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); baseLayout.addComponent(button1); baseLayout.addComponent(button2); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html deleted file mode 100644 index 8408aba9fd..0000000000 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.html +++ /dev/null @@ -1,896 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>LayoutTesterApplication</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">LayoutTesterApplication</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.layouts.layouttester.LayoutTesterApplication?restartApplication</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>1</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>2</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>3</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>4</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>5</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>6</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>7</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>8</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>9</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>10</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>11</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>12</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>13</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>14</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>15</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>16</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>17</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>18</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>19</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>20</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>21</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>22</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>23</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>24</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>25</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>26</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VHorizontalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>27</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>28</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=class com.vaadin.ui.HorizontalLayout</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>29</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>30</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>31</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>32</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>33</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>34</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>35</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>36</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>37</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>38</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>39</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>40</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>41</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>42</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>43</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>44</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>45</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>46</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>47</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>48</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>49</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>50</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>51</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>52</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>53</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>54</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>55</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>56</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=class com.vaadin.ui.GridLayout</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>57</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>58</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>59</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>60</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>61</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>62</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>63</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>64</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>65</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>66</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>67</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>68</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>69</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>70</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>71</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>72</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>73</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>74</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>75</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>76</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>77</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>78</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>79</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>80</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>81</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>82</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>83</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>84</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>85</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>86</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>87</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestslayoutslayouttesterLayoutTesterApplication::/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>88</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java index 72863895a1..5b68e04144 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplication.java @@ -20,18 +20,20 @@ public class LayoutTesterApplication extends AbstractTestCase { Button nextButton = new Button("Next"); private int layoutIndex = -1; - private static final String[] layoutGetters = new String[] { - "getCaptionsTests", "getIconsTests", - "getRequiredErrorIndicatorsTests", "getAlignmentTests", - "getExpandRatiosTests", "getMarginSpacingTests", - "getComponentAddReplaceMoveTests", "getComponentSizingTests", - "getLayoutSizingTests" }; + static final String[] layoutGetters = new String[] { "getCaptionsTests", + "getIconsTests", "getRequiredErrorIndicatorsTests", + "getAlignmentTests", "getExpandRatiosTests", + "getMarginSpacingTests", "getComponentAddReplaceMoveTests", + "getComponentSizingTests", "getLayoutSizingTests" }; + public static final String NEXT_BUTTON_ID = "nextButton"; + private static final String LAYOUT_SELECT_ID = "layoutSelect"; private LegacyWindow mainWindow; private NativeSelect layoutSelector; @Override public void init() { + nextButton.setId(NEXT_BUTTON_ID); mainWindow = new LegacyWindow("LayoutTesterApplication"); setMainWindow(mainWindow); nextLayout(); @@ -112,6 +114,7 @@ public class LayoutTesterApplication extends AbstractTestCase { private NativeSelect getLayoutTypeSelect() { if (layoutSelector == null) { layoutSelector = new NativeSelect(); + layoutSelector.setId(LAYOUT_SELECT_ID); layoutSelector.addItem(VerticalLayout.class); layoutSelector.addItem(HorizontalLayout.class); layoutSelector.addItem(GridLayout.class); diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java new file mode 100644 index 0000000000..33197613dc --- /dev/null +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/LayoutTesterApplicationTest.java @@ -0,0 +1,137 @@ +/* + * 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.layouts.layouttester; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.VerticalLayout; + +public class LayoutTesterApplicationTest extends MultiBrowserTest { + Map<String, Integer> numberOfSubTests = new HashMap<String, Integer>(); + private Set<String> tableOrIconsTests = new HashSet<String>(); + + { + numberOfSubTests.put("getExpandRatiosTests", 3); + numberOfSubTests.put("getLayoutSizingTests", 4); + numberOfSubTests.put("getComponentAddReplaceMoveTests", 4); + numberOfSubTests.put("getMarginSpacingTests", 4); + numberOfSubTests.put("getComponentSizingTests", 3); + + tableOrIconsTests.add("getComponentSizingTests"); + tableOrIconsTests.add("getExpandRatiosTests"); + tableOrIconsTests.add("getLayoutSizingTests"); + tableOrIconsTests.add("getMarginSpacingTests"); + tableOrIconsTests.add("getIconsTests"); + + } + + @Test + public void verticalLayout() throws Exception { + openTestURL(); + runTest(VerticalLayout.class); + } + + @Test + public void horizontalLayout() throws Exception { + openTestURL(); + runTest(HorizontalLayout.class); + } + + @Test + public void gridLayout() throws Exception { + numberOfSubTests.put("getComponentAddReplaceMoveTests", 6); + numberOfSubTests.put("getComponentSizingTests", 4); + numberOfSubTests.put("getExpandRatiosTests", 4); + + openTestURL(); + runTest(GridLayout.class); + } + + private void runTest(Class<?> layoutClass) throws Exception { + new Select(vaadinElementById("layoutSelect").findElement( + By.xpath("select"))) + .selectByVisibleText(layoutClass.toString()); + focusElementWithId("nextButton"); + + for (String subTest : LayoutTesterApplication.layoutGetters) { + compareScreen(subTest); + Integer subTests = numberOfSubTests.get(subTest); + if (subTests != null) { + for (int i = 1; i <= subTests; i++) { + clickAndCompareScreen(subTest, "testButton" + i); + } + } + getNextButton().click(); + } + + } + + /** + * @param elementId + * the id of the element to focus + */ + private void focusElementWithId(String elementId) { + // This should really be in TestBench + ((JavascriptExecutor) getDriver()) + .executeScript("document.getElementById('" + elementId + + "').focus()"); + } + + /** + * Clicks the button with the given id and compares the result to a + * screenshot named 'screenshotPrefix'-buttonCaption. + * + * @param screenshotPrefix + * @param buttonId + * @throws Exception + */ + private void clickAndCompareScreen(String screenshotPrefix, String buttonId) + throws Exception { + WebElement button = vaadinElementById(buttonId); + button.click(); + if (needsDelayToStabilize(screenshotPrefix)) { + // Table does some extra layout phase and TestBench does not always + // take this into account, grabbing screenshots before the layout + // phase is done (see #12866). + sleep(200); + } + compareScreen(screenshotPrefix + "-" + sanitize(button.getText())); + } + + private boolean needsDelayToStabilize(String screenshotPrefix) { + return tableOrIconsTests.contains(screenshotPrefix); + } + + private String sanitize(String text) { + return text.replace("%", "pct").replaceAll("[^a-zA-Z0-9]", "-"); + } + + private WebElement getNextButton() { + return vaadinElementById(LayoutTesterApplication.NEXT_BUTTON_ID); + } +} diff --git a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java index 7764589ff7..04cee2d68d 100644 --- a/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java +++ b/uitest/src/com/vaadin/tests/layouts/layouttester/VerticalLayoutTests.java @@ -127,6 +127,10 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button replaceButton = new Button("Test replace"); final Button moveButton = new Button("Test move"); final Button removeButton = new Button("Test remove"); + addButton.setId("testButton1"); + replaceButton.setId("testButton2"); + moveButton.setId("testButton3"); + removeButton.setId("testButton4"); replaceButton.setEnabled(false); moveButton.setEnabled(false); @@ -196,7 +200,9 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button biggerButton = new Button("full size"); final Button smallerButton = new Button("200 px width"); final Button originalButton = new Button("undefined size and add"); - + biggerButton.setId("testButton1"); + smallerButton.setId("testButton2"); + originalButton.setId("testButton3"); vlo.addComponent(biggerButton); vlo.addComponent(smallerButton); vlo.addComponent(originalButton); @@ -265,6 +271,11 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button button3 = new Button("Set fixed width and height 75%"); final Button button4 = new Button("Set size full"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); + vlo.addComponent(button1); vlo.addComponent(button2); vlo.addComponent(button3); @@ -344,8 +355,11 @@ public class VerticalLayoutTests extends AbstractLayoutTests { c2.setSizeFull(); final Button button1 = new Button("Expand to 1/undefined"); + button1.setId("testButton1"); final Button button2 = new Button("Expand to 0.5/0.5"); + button2.setId("testButton2"); final Button button3 = new Button("Expand to 0.75/0.25"); + button3.setId("testButton3"); vlo.addComponent(button1); vlo.addComponent(button2); @@ -460,6 +474,10 @@ public class VerticalLayoutTests extends AbstractLayoutTests { final Button button2 = new Button("Set spacing on"); final Button button3 = new Button("Set margin off"); final Button button4 = new Button("Set spacing off"); + button1.setId("testButton1"); + button2.setId("testButton2"); + button3.setId("testButton3"); + button4.setId("testButton4"); vlo.addComponent(button1); vlo.addComponent(button2); 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.BarInUIDL?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>Thank you for clicking | bar</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBarInUIDL::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]</td> - <td>Thank you for clicking | bar</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/BarInUIDL.java b/uitest/src/com/vaadin/tests/push/BarInUIDL.java index 7e414cc89d..bc05f7c306 100644 --- a/uitest/src/com/vaadin/tests/push/BarInUIDL.java +++ b/uitest/src/com/vaadin/tests/push/BarInUIDL.java @@ -16,12 +16,15 @@ package com.vaadin.tests.push; +import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; import com.vaadin.tests.components.AbstractTestUI; 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 { /* 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.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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug</td> - <td></td> -</tr> -<!--Test client initiated push --> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>0</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>1</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>4</td> -</tr> -<!--Test server initiated push--> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>0</td> -</tr> -<tr> - <td>pause</td> - <td>3000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>1</td> -</tr> -<tr> - <td>pause</td> - <td>3000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>2</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/BasicPush.java b/uitest/src/com/vaadin/tests/push/BasicPush.java index b80d287a1d..8e8f418c5f 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPush.java +++ b/uitest/src/com/vaadin/tests/push/BasicPush.java @@ -1,40 +1,52 @@ +/* + * 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 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.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; -@Widgetset(TestingWidgetSet.NAME) +@Push public class BasicPush extends AbstractTestUI { + public static final String CLIENT_COUNTER_ID = "clientCounter"; + + public static final String STOP_TIMER_ID = "stopTimer"; + + public static final String START_TIMER_ID = "startTimer"; + + public static final String SERVER_COUNTER_ID = "serverCounter"; + + public static final String INCREMENT_BUTTON_ID = "incrementCounter"; + private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); private final Timer timer = new Timer(true); - private final TimerTask task = new TimerTask() { - - @Override - public void run() { - access(new Runnable() { - @Override - public void run() { - counter2.setValue(counter2.getValue() + 1); - } - }); - } - }; + private TimerTask task; @Override protected void setup(VaadinRequest request) { @@ -46,15 +58,19 @@ public class BasicPush extends AbstractTestUI { */ Label lbl = new Label(counter); lbl.setCaption("Client counter (click 'increment' to update):"); + lbl.setId(CLIENT_COUNTER_ID); addComponent(lbl); - addComponent(new Button("Increment", new Button.ClickListener() { + Button incrementButton = new Button("Increment", + new Button.ClickListener() { - @Override - public void buttonClick(ClickEvent event) { - counter.setValue(counter.getValue() + 1); - } - })); + @Override + public void buttonClick(ClickEvent event) { + counter.setValue(counter.getValue() + 1); + } + }); + incrementButton.setId(INCREMENT_BUTTON_ID); + addComponent(incrementButton); spacer(); @@ -63,15 +79,47 @@ public class BasicPush extends AbstractTestUI { */ lbl = new Label(counter2); lbl.setCaption("Server counter (updates each 3s by server thread) :"); + lbl.setId(SERVER_COUNTER_ID); addComponent(lbl); - addComponent(new Button("Reset", new Button.ClickListener() { - + Button startTimer = 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); + } + }); + startTimer.setId(START_TIMER_ID); + addComponent(startTimer); + + Button stopTimer = new Button("Stop timer", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { - counter2.setValue(0); + if (task != null) { + task.cancel(); + task = null; + } } - })); + }); + stopTimer.setId(STOP_TIMER_ID); + addComponent(stopTimer); } @Override @@ -94,7 +142,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..f9dc78dd43 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushStreaming.java @@ -1,12 +1,31 @@ +/* + * 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 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); + } } 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..ef40ae09dc --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java @@ -0,0 +1,108 @@ +/* + * 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.AbstractTB3Test; +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 getServerCounter(this); + } + + private int getClientCounter() { + return getClientCounter(this); + } + + public static int getClientCounter(AbstractTB3Test t) { + WebElement clientCounterElem = t + .vaadinElementById(BasicPush.CLIENT_COUNTER_ID); + return Integer.parseInt(clientCounterElem.getText()); + } + + private WebElement getIncrementButton() { + return getIncrementButton(this); + } + + private WebElement getServerCounterStopButton() { + return getServerCounterStopButton(this); + } + + private WebElement getServerCounterStartButton() { + return getServerCounterStartButton(this); + } + + public static int getServerCounter(AbstractTB3Test t) { + WebElement serverCounterElem = t + .vaadinElementById(BasicPush.SERVER_COUNTER_ID); + return Integer.parseInt(serverCounterElem.getText()); + } + + public static WebElement getServerCounterStartButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.START_TIMER_ID); + } + + public static WebElement getServerCounterStopButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.STOP_TIMER_ID); + } + + public static WebElement getIncrementButton(AbstractTB3Test t) { + return t.vaadinElementById(BasicPush.INCREMENT_BUTTON_ID); + } + +}
\ 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 6fc27e8974..465caf0165 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushWebsocket.java @@ -1,8 +1,34 @@ +/* + * 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 com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; @Push(transport = Transport.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().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + } 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..dd0a147d99 --- /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.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class BasicPushWebsocketTest extends BasicPushTest { + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return WebsocketTest.getWebsocketBrowsers(); + } +}
\ No newline at end of file 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>EnableDisablePush</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">EnableDisablePush</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/EnableDisablePush?restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>1. Push enabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>3. Push disabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>5. Poll enabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>7. Push enabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>9. Poll disabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>11. Push disabled, polling enabled</td> -</tr> -<tr> - <td>pause</td> - <td>3500</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>16. Polling disabled, push enabled</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runEnableDisablePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runEnableDisablePush::PID_SLog_row_0</td> - <td>18. Push disabled</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java index 1911c66c2d..ac37e75fea 100644 --- a/uitest/src/com/vaadin/tests/push/EnableDisablePush.java +++ b/uitest/src/com/vaadin/tests/push/EnableDisablePush.java @@ -27,7 +27,7 @@ public class EnableDisablePush extends AbstractTestUI { try { while (true) { - TimeUnit.MILLISECONDS.sleep(1000); + TimeUnit.MILLISECONDS.sleep(500); access(new Runnable() { @Override @@ -42,6 +42,9 @@ public class EnableDisablePush extends AbstractTestUI { } } }); + if (c == 3) { + return; + } } } catch (InterruptedException e) { } catch (UIDetachedException e) { diff --git a/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java b/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java new file mode 100644 index 0000000000..275b6d5b53 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/EnableDisablePushTest.java @@ -0,0 +1,72 @@ +/* + * 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 static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public 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]"); + } + +}
\ No newline at end of file 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<!--Websocket--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=WEBSOCKET</td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> - <td>label=AUTOMATIC</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td> - <td>*fallbackTransport: streaming*transport: websocket*</td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>waitForText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<!--Use debug console to verify we used the correct transport type--> -<tr> - <td>assertTextPresent</td> - <td>Push connection established using websocket</td> - <td></td> -</tr> -<tr> - <td>assertTextNotPresent</td> - <td>Push connection established using streaming</td> - <td>Push connection established using streaming</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> - <td>label=DISABLED</td> -</tr> -<!--Streaming--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.push.PushConfigurationTest?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td> - <td>label=STREAMING</td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> - <td>label=AUTOMATIC</td> -</tr> -<tr> - <td>assertNotText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[5]/VLabel[0]/domChild[0]</td> - <td>*fallbackTransport: streaming*transport: streaming*</td> -</tr> -<tr> - <td>waitForText</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]</td> - <td>4</td> -</tr> -<!--Use debug console to verify we used the correct transport type--> -<tr> - <td>assertTextNotPresent</td> - <td>Push connection established using websocket</td> - <td></td> -</tr> -<tr> - <td>assertTextPresent</td> - <td>Push connection established using streaming</td> - <td></td> -</tr> -<tr> - <td>select</td> - <td>vaadin=runcomvaadintestspushPushConfigurationTest::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]</td> - <td>label=DISABLED</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/PushConfiguration.java b/uitest/src/com/vaadin/tests/push/PushConfiguration.java new file mode 100644 index 0000000000..a7ba4e43ba --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushConfiguration.java @@ -0,0 +1,117 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import java.util.Date; +import java.util.Timer; +import java.util.TimerTask; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; + +public class PushConfiguration extends AbstractTestUI { + + private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); + + private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); + + private final Timer timer = new Timer(true); + + private final TimerTask task = new TimerTask() { + + @Override + public void run() { + access(new Runnable() { + @Override + public void run() { + counter2.setValue(counter2.getValue() + 1); + } + }); + } + }; + + @Override + protected void setup(VaadinRequest request) { + addComponent(new PushConfigurator(this)); + spacer(); + + /* + * Client initiated push. + */ + Label lbl = new Label(counter); + lbl.setCaption("Client counter (click 'increment' to update):"); + addComponent(lbl); + + addComponent(new Button("Increment", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter.setValue(counter.getValue() + 1); + } + })); + + spacer(); + + /* + * Server initiated push. + */ + lbl = new Label(counter2); + lbl.setCaption("Server counter (updates each 1s by server thread) :"); + addComponent(lbl); + + addComponent(new Button("Reset", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + counter2.setValue(0); + } + })); + } + + @Override + protected String getTestDescription() { + return "This test tests the very basic operations of push. " + + "It tests that client initiated changes are " + + "recieved back to the client as well as server " + + "initiated changes are correctly updated to the client."; + } + + @Override + protected Integer getTicketNumber() { + return 11494; + } + + private void spacer() { + addComponent(new Label("<hr/>", ContentMode.HTML)); + } + + @Override + public void attach() { + super.attach(); + timer.scheduleAtFixedRate(task, new Date(), 1000); + } + + @Override + public void detach() { + super.detach(); + timer.cancel(); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java index b57e9732cc..1f8c4c0e38 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationTest.java @@ -1,102 +1,111 @@ +/* + * 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 PushConfigurationTest extends AbstractTestUI { - - private ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0); - - private ObjectProperty<Integer> counter2 = new ObjectProperty<Integer>(0); - - private final Timer timer = new Timer(true); - - private final TimerTask task = new TimerTask() { - - @Override - public void run() { - access(new Runnable() { - @Override - public void run() { - counter2.setValue(counter2.getValue() + 1); - } - }); - } - }; - - @Override - protected void setup(VaadinRequest request) { - addComponent(new PushConfigurator(this)); - spacer(); - - /* - * Client initiated push. - */ - Label lbl = new Label(counter); - lbl.setCaption("Client counter (click 'increment' to update):"); - addComponent(lbl); - - addComponent(new Button("Increment", new Button.ClickListener() { +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; + +public class PushConfigurationTest extends WebsocketTest { + + @Test + public void testWebsocketAndStreaming() { + setDebug(true); + openTestURL(); + // Websocket + 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( + "/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]*$")); + counter = getServerCounter(); + final int waitCounter = counter + 2; + waitUntil(new ExpectedCondition<Boolean>() { @Override - public void buttonClick(ClickEvent event) { - counter.setValue(counter.getValue() + 1); + public Boolean apply(WebDriver input) { + return (getServerCounter() >= waitCounter); } - })); - - 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); + }); + + // 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")); - @Override - protected String getTestDescription() { - return "This test tests the very basic operations of push. " - + "It tests that client initiated changes are " - + "recieved back to the client as well as server " - + "initiated changes are correctly updated to the client."; } - @Override - protected Integer getTicketNumber() { - return 11494; + private WebElement getPushModeSelect() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VNativeSelect[0]/domChild[0]"); } - private void spacer() { - addComponent(new Label("<hr/>", ContentMode.HTML)); + private WebElement getTransportSelect() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[0]/VVerticalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]"); } - @Override - public void attach() { - super.attach(); - timer.scheduleAtFixedRate(task, new Date(), 1000); + private int getServerCounter() { + return Integer.parseInt(getServerCounterElement().getText()); } - @Override - public void detach() { - super.detach(); - timer.cancel(); + private WebElement getServerCounterElement() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VLabel[0]"); } -} +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandling.java b/uitest/src/com/vaadin/tests/push/PushErrorHandling.java new file mode 100644 index 0000000000..a1182c0daf --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushErrorHandling.java @@ -0,0 +1,95 @@ +package com.vaadin.tests.push; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.vaadin.data.util.AbstractInMemoryContainer; +import com.vaadin.data.util.BeanContainer; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.server.ErrorHandler; +import com.vaadin.server.VaadinRequest; +import com.vaadin.server.VaadinSession; +import com.vaadin.shared.communication.PushMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +public class PushErrorHandling extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + getPushConfiguration().setPushMode(PushMode.AUTOMATIC); + + VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() { + + @Override + public void error(com.vaadin.server.ErrorEvent event) { + addComponent(new Label("An error! " + + event.getThrowable().getMessage())); + System.err.println("An error! " + + event.getThrowable().getMessage()); + } + }); + + final Button button = new Button("Click for NPE!", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + ((String) null).length(); // Null-pointer exception + } + }); + button.setId("npeButton"); + addComponent(button); + + final Table view = new Table("testtable"); + view.setId("testtable"); + view.setSelectable(true); + view.setMultiSelect(false); + view.setImmediate(true); + view.setSizeFull(); + + view.addItemClickListener(new ItemClickListener() { + + @Override + public void itemClick(ItemClickEvent event) { + BeanContainer<String, AbstractInMemoryContainer> metaContainer = new BeanContainer<String, AbstractInMemoryContainer>( + AbstractInMemoryContainer.class) { + @Override + public Collection<String> getContainerPropertyIds() { + List<String> cpropIds = new ArrayList<String>(super + .getContainerPropertyIds()); + cpropIds.add("testid"); + return cpropIds; + } + + @Override + public Class<?> getType(Object propertyId) { + ((Object) null).hashCode(); + return super.getType(propertyId); + } + }; + view.setContainerDataSource(metaContainer); + + } + }); + view.addContainerProperty("Column", String.class, "Click for NPE"); + view.addItem(new Object()); + + addComponent(view); + + } + + @Override + protected String getTestDescription() { + return "Error handling should still work w/ push enabled. (Button can be handled properly, table causes internal error)"; + } + + @Override + protected Integer getTicketNumber() { + return 11882; + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java new file mode 100644 index 0000000000..a4b94b0573 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushErrorHandlingTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PushErrorHandlingTest extends MultiBrowserTest { + + @Test + public void testErrorHandling() { + setPush(true); + openTestURL(); + vaadinElementById("npeButton").click(); + Assert.assertEquals( + "An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", + vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VLabel[0]") + .getText()); + + WebElement table = vaadinElementById("testtable"); + WebElement row = table.findElement(By + .xpath("//div[text()='Click for NPE']")); + row.click(); + + Assert.assertEquals("Internal error", + vaadinElement("Root/VNotification[0]/HTML[0]/domChild[0]") + .getText()); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java index 4b442de499..cb084f1232 100644 --- a/uitest/src/com/vaadin/tests/push/PushFromInit.java +++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java @@ -1,3 +1,18 @@ +/* + * 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 com.vaadin.server.VaadinRequest; 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/PushLargeData.java b/uitest/src/com/vaadin/tests/push/PushLargeData.java new file mode 100644 index 0000000000..3b72424b32 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeData.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.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.tests.util.LoremIpsum; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; + +public abstract class PushLargeData extends AbstractTestUIWithLog { + + // 1MB + static final int DEFAULT_SIZE_BYTES = 1000 * 1000; + + // Every other second + static final int DEFAULT_DELAY_MS = 2000; + + // 20 MB is enough for streaming to reconnect + static final int DEFAULT_DATA_TO_PUSH = 20 * 1000 * 1000; + + static final int DEFAULT_DURATION_MS = DEFAULT_DATA_TO_PUSH + / DEFAULT_SIZE_BYTES * DEFAULT_DELAY_MS; + + private Label dataLabel = new Label(); + + private final ExecutorService executor = Executors + .newSingleThreadExecutor(); + + @Override + protected void setup(VaadinRequest request) { + dataLabel.setSizeUndefined(); + final TextField dataSize = new TextField("Data size"); + dataSize.setConverter(Integer.class); + final TextField interval = new TextField("Interval (ms)"); + interval.setConverter(Integer.class); + final TextField duration = new TextField("Duration (ms)"); + duration.setConverter(Integer.class); + + dataSize.setValue(DEFAULT_SIZE_BYTES + ""); + interval.setValue(DEFAULT_DELAY_MS + ""); + duration.setValue(DEFAULT_DURATION_MS + ""); + + addComponent(dataSize); + addComponent(interval); + addComponent(duration); + + Button b = new Button("Start pushing"); + b.setId("startButton"); + b.addClickListener(new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Integer pushSize = (Integer) dataSize.getConvertedValue(); + Integer pushInterval = (Integer) interval.getConvertedValue(); + Integer pushDuration = (Integer) duration.getConvertedValue(); + PushRunnable r = new PushRunnable(pushSize, pushInterval, + pushDuration); + executor.execute(r); + log.log("Starting push, size: " + pushSize + ", interval: " + + pushInterval + "ms, duration: " + pushDuration + "ms"); + } + }); + addComponent(b); + addComponent(dataLabel); + } + + public Label getDataLabel() { + return dataLabel; + } + + @Override + protected String getTestDescription() { + return "Tests that pushing large amounts of data do not cause problems"; + } + + @Override + protected Integer getTicketNumber() { + return 12567; + } + + public static class PushRunnable implements Runnable { + + private Integer size; + private Integer interval; + private Integer duration; + + public PushRunnable(Integer size, Integer interval, Integer duration) { + this.size = size; + this.interval = interval; + this.duration = duration; + } + + @Override + public void run() { + final long endTime = System.currentTimeMillis() + duration; + final String data = LoremIpsum.get(size); + int packageIndex = 1; + while (System.currentTimeMillis() < endTime) { + final int idx = packageIndex++; + UI.getCurrent().access(new Runnable() { + @Override + public void run() { + PushLargeData ui = (PushLargeData) UI.getCurrent(); + // Using description as it is not rendered to the DOM + // immediately + ui.getDataLabel().setDescription( + System.currentTimeMillis() + ": " + data); + ui.log("Package " + idx + " pushed"); + } + }); + try { + Thread.sleep(interval); + } catch (InterruptedException e) { + return; + } + } + UI.getCurrent().access(new Runnable() { + @Override + public void run() { + PushLargeData ui = (PushLargeData) UI.getCurrent(); + ui.log("Push complete"); + } + }); + + } + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java new file mode 100644 index 0000000000..7706aa90c6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreaming.java @@ -0,0 +1,33 @@ +/* + * 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 com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.STREAMING) +public class PushLargeDataStreaming extends PushLargeData { + + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + getPushConfiguration().setTransport(Transport.STREAMING); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java new file mode 100644 index 0000000000..8f10f0fbba --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java @@ -0,0 +1,61 @@ +/* + * 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 org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PushLargeDataStreamingTest extends MultiBrowserTest { + + @Test + public void testStreamingLargeData() { + openTestURL(); + + // Without this there is a large chance that we will wait for all pushes + // to complete before moving on + testBench(driver).disableWaitForVaadin(); + + push(); + // Push complete. Browser will reconnect now as > 10MB has been sent + // Push again to ensure push still works + push(); + + } + + private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + + String logRow0Id = "Log_row_0"; + By logRow0 = vaadinLocatorById(logRow0Id); + + vaadinElementById("startButton").click(); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package ")); + + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + + // Wait until push is actually done + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Push complete")); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java new file mode 100644 index 0000000000..4115a825d1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocket.java @@ -0,0 +1,33 @@ +/* + * 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 com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.WEBSOCKET) +public class PushLargeDataWebsocket extends PushLargeData { + + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java new file mode 100644 index 0000000000..70a94f743e --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.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.push; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class PushLargeDataWebsocketTest extends WebsocketTest { + + @Test + public void testWebsocketLargeData() { + openTestURL(); + + // Without this timing will be completly off as pushing "start" can + // remain waiting for all pushes to complete + testBench(driver).disableWaitForVaadin(); + + push(); + // Push complete. Browser will reconnect now as > 10MB has been sent + // Push again to ensure push still works + push(); + + } + + private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + + String logRow0Id = "Log_row_0"; + By logRow0 = vaadinLocatorById(logRow0Id); + + vaadinElementById("startButton").click(); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package")); + + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + + // Wait until push is actually done + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Push complete")); + } +} diff --git a/uitest/src/com/vaadin/tests/push/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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://192.168.2.162:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.components.panel.PanelChangeContents?restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>stats</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>companies</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestscomponentspanelPanelChangeContents::/VVerticalLayout[0]/Slot[1]/VPanel[0]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>stats</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/PushReconnectTest.java b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java new file mode 100644 index 0000000000..76a0b547da --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushReconnectTest.java @@ -0,0 +1,164 @@ +/* + * 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.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.tests.tb3.MultiBrowserTestWithProxy; + +public abstract class PushReconnectTest extends MultiBrowserTestWithProxy { + + @Test + public void testShortDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testUserActionWhileDisconnectedWithDelay() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Assert.assertEquals(0, getClientCounter()); + getIncrementClientCounterButton().click(); + // No change while disconnected + Assert.assertEquals(0, getClientCounter()); + // Firefox sends extra onopen calls after a while, which breaks + // everything + Thread.sleep(10000); + connectProxy(); + waitUntilServerCounterChanges(); + // The change should have appeared when reconnected + Assert.assertEquals(1, getClientCounter()); + } + + @Test + public void testUserActionWhileDisconnected() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Assert.assertEquals(0, getClientCounter()); + getIncrementClientCounterButton().click(); + // No change while disconnected + Assert.assertEquals(0, getClientCounter()); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + // The change should have appeared when reconnected + Assert.assertEquals(1, getClientCounter()); + + // IE has problems with another reconnect + disconnectProxy(); + getIncrementClientCounterButton().click(); + Assert.assertEquals(1, getClientCounter()); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + Assert.assertEquals(2, getClientCounter()); + } + + @Test + public void testLongDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(12000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testReallyLongDisconnect() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + disconnectProxy(); + Thread.sleep(120000); + connectProxy(); + waitUntilServerCounterChanges(); + } + + @Test + public void testMultipleDisconnects() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + for (int i = 0; i < 5; i++) { + disconnectProxy(); + Thread.sleep(1000); + connectProxy(); + waitUntilServerCounterChanges(); + } + } + + @Test + public void testMultipleQuickReconnects() throws Exception { + setDebug(true); + openTestURL(); + startTimer(); + waitUntilServerCounterChanges(); + for (int i = 0; i < 50; i++) { + disconnectProxy(); + Thread.sleep(100); + connectProxy(); + Thread.sleep(100); + } + waitUntilServerCounterChanges(); + waitUntilServerCounterChanges(); + } + + private int getClientCounter() { + return BasicPushTest.getClientCounter(this); + } + + private WebElement getIncrementClientCounterButton() { + return BasicPushTest.getIncrementButton(this); + } + + private void waitUntilServerCounterChanges() { + final int counter = BasicPushTest.getServerCounter(this); + waitUntil(new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return BasicPushTest.getServerCounter(PushReconnectTest.this) > counter; + } + }, 30); + } + + private void startTimer() { + BasicPushTest.getServerCounterStartButton(this).click(); + } + +} 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.push.BasicPushStreaming?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>waitForTextPresent</td> - <td>Push connection established using streaming</td> - <td></td> -</tr> -<tr> - <td>assertTextNotPresent</td> - <td>Push connection established using websocket</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.push.BasicPushWebsocket?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>assertTextNotPresent</td> - <td>Push connection established using streaming</td> - <td></td> -</tr> -<tr> - <td>waitForTextPresent</td> - <td>Push connection established using websocket</td> - <td></td> -</tr> -</tbody></table> -</body> -</html> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.BasicPush?restartApplication&debug&transport=streaming</td> - <td></td> -</tr> -<!--Test client initiated push --> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>0</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>1</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]</td> - <td>4</td> -</tr> -<!--Test server initiated push--> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[5]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>0</td> -</tr> -<tr> - <td>pause</td> - <td>3000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>1</td> -</tr> -<tr> - <td>pause</td> - <td>3000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushBasicPush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[4]/VLabel[0]</td> - <td>2</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java b/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java new file mode 100755 index 0000000000..24dfdd8ba1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/StreamingReconnectTest.java @@ -0,0 +1,25 @@ +/* + * 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 StreamingReconnectTest extends PushReconnectTest { + + @Override + protected Class<?> getUIClass() { + return BasicPushStreaming.class; + } + +} 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>2000</td> - <td></td> -</tr> -<!--Push is enabled, so text gets updated--> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 1 times</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> - <td>61,6</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>2000</td> - <td></td> -</tr> -<!--Push is disabled, so text is not updated--> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 1 times</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<!--Direct update is visible, and includes previous update--> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 3 times</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> - <td>61,3</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>2000</td> - <td></td> -</tr> -<!--Push is enabled again, so text gets updated--> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 4 times</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/TogglePush.java b/uitest/src/com/vaadin/tests/push/TogglePush.java index c0bdc54ee0..6ec8903d65 100644 --- a/uitest/src/com/vaadin/tests/push/TogglePush.java +++ b/uitest/src/com/vaadin/tests/push/TogglePush.java @@ -1,3 +1,18 @@ +/* + * 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; 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8071/" /> -<title>TogglePushInInit</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">TogglePushInInit</td></tr> -</thead><tbody> -<!--Open with push disabled--> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=disabled</td> - <td></td> -</tr> -<tr> - <td>assertValue</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> - <td>off</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>2000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 0 times</td> -</tr> -<!--Open with push enabled--> -<tr> - <td>open</td> - <td>/run-push/com.vaadin.tests.push.TogglePush?restartApplication&push=enabled</td> - <td></td> -</tr> -<tr> - <td>assertValue</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]</td> - <td>on</td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>pause</td> - <td>2000</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runpushcomvaadintestspushTogglePush::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]</td> - <td>Counter has been updated 1 times</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/push/TogglePushTest.java b/uitest/src/com/vaadin/tests/push/TogglePushTest.java new file mode 100644 index 0000000000..68d6f52b9f --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/TogglePushTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TogglePushTest extends MultiBrowserTest { + + @Test + public void togglePushInInit() { + setPush(true); + String url = getTestUrl(); + + // Open with push disabled + driver.get(addParameter(url, "push=disabled")); + + Assert.assertFalse(getPushToggle().isSelected()); + + getDelayedCounterUpdateButton().click(); + sleep(2000); + Assert.assertEquals("Counter has been updated 0 times", + getCounterText()); + + // Open with push enabled + driver.get(addParameter(url, "push=enabled")); + Assert.assertTrue(getPushToggle().isSelected()); + + getDelayedCounterUpdateButton().click(); + sleep(2000); + Assert.assertEquals("Counter has been updated 1 times", + getCounterText()); + + } + + private String addParameter(String url, String queryParameter) { + if (url.contains("?")) { + return url + "&" + queryParameter; + } else { + return url + "?" + queryParameter; + } + } + + @Test + public void togglePush() { + setPush(true); + openTestURL(); + getDelayedCounterUpdateButton().click(); + sleep(2000); + + // Push is enabled, so text gets updated + Assert.assertEquals("Counter has been updated 1 times", + getCounterText()); + + // Disable push + getPushToggle().click(); + getDelayedCounterUpdateButton().click(); + sleep(2000); + // Push is disabled, so text is not updated + Assert.assertEquals("Counter has been updated 1 times", + getCounterText()); + + getDirectCounterUpdateButton().click(); + // Direct update is visible, and includes previous update + Assert.assertEquals("Counter has been updated 3 times", + getCounterText()); + + // Re-enable push + getPushToggle().click(); + getDelayedCounterUpdateButton().click(); + sleep(2000); + + // Push is enabled again, so text gets updated + Assert.assertEquals("Counter has been updated 4 times", + getCounterText()); + } + + private WebElement getDirectCounterUpdateButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]"); + } + + private WebElement getPushToggle() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VCheckBox[0]/domChild[0]"); + } + + private WebElement getDelayedCounterUpdateButton() { + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VButton[0]/domChild[0]/domChild[0]"); + } + + private String getCounterText() { + return vaadinElement( + "/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VLabel[0]") + .getText(); + } + +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java index 062698edf5..23702564f9 100644 --- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUnitTests.java +++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java @@ -34,11 +34,13 @@ 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 TrackMessageSizeUnitTests extends AbstractTestUIWithLog { +@JavaScript("vaadin://vaadinPush.debug.js") +public class TrackMessageSizeUI extends AbstractTestUIWithLog { private String testMethod = "function testSequence(expected, data) {\n" + " var request = {trackMessageLength: true, messageDelimiter: '|'};\n" + + " _request = {trackMessageLength: true, messageDelimiter: '|'};\n" + + " _handleProtocol = function(a,b) {return true;};" + " var response = {partialMessage: ''};\n" + " var messages = [];\n" + " for(var i = 0; i < data.length; i++) {\n" @@ -85,7 +87,7 @@ public class TrackMessageSizeUnitTests extends AbstractTestUIWithLog { } private String findMethodImplementation() { - String filename = "/VAADIN/jquery.atmosphere.js"; + String filename = "/VAADIN/vaadinPush.debug.js"; URL resourceURL = findResourceURL(filename, (VaadinServletService) VaadinService.getCurrent()); if (resourceURL == null) { @@ -141,7 +143,7 @@ public class TrackMessageSizeUnitTests extends AbstractTestUIWithLog { @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."; + return "Unit tests for _trackMessageSize in vaadinPush.debug.js. Implemented with testbench and a full Vaadin server side since the testing requires some file mangling."; } @Override 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/WebsocketReconnectTest.java b/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.java new file mode 100644 index 0000000000..075a18c0e7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/WebsocketReconnectTest.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.push; + +import java.util.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class WebsocketReconnectTest extends PushReconnectTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return WebsocketTest.getWebsocketBrowsers(); + } + + @Override + protected Class<?> getUIClass() { + return BasicPushWebsocket.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..d4eed99f19 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -0,0 +1,838 @@ +/* + * 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.URL; +import java.util.Collections; +import java.util.List; + +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.server.UIProvider; +import com.vaadin.testbench.TestBench; +import com.vaadin.testbench.TestBenchTestCase; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.UI; + +/** + * Base class for TestBench 3+ tests. All TB3+ tests in the project should + * extend this class. + * + * Provides: + * <ul> + * <li>Helpers for browser selection</li> + * <li>Hub connection setup and teardown</li> + * <li>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()}</li> + * <li>Generic helpers for creating TB3+ tests</li> + * </ul> + * + * @author Vaadin Ltd + */ +@RunWith(value = TB3Runner.class) +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; + + private boolean debug = false; + + private boolean push = false; + { + // Default browser to run on unless setDesiredCapabilities is called + desiredCapabilities = BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION); + } + + /** + * Connect to the hub using a remote web driver, set the canvas size and + * opens the initial URL as specified by {@link #getTestUrl()} + * + * @throws Exception + */ + @Before + public void setup() throws Exception { + setupDriver(); + } + + /** + * 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 { + if (runLocally()) { + setupLocalDriver(); + return; + } + DesiredCapabilities capabilities = getDesiredCapabilities(); + + WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL( + getHubURL()), capabilities)); + setDriver(dr); + + 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... + } + + } + + /** + * Override and return true to run the test locally. This method is only to + * be used for developing tests. + * + * @return true to run the test on a local browser, false to use the hub + */ + public boolean runLocally() { + return false; + } + + /** + * Creates a {@link WebDriver} instance used for running the test locally + * for debug purposes. Used only when {@link #runLocally()} is overridden to + * return true; + */ + protected abstract void setupLocalDriver(); + + /** + * Opens the given test (defined by {@link #getTestUrl()}, optionally with + * debug window and/or push (depending on {@link #isDebug()} and + * {@link #isPush()}. + */ + protected void openTestURL() { + driver.get(getTestUrl()); + } + + /** + * Returns the full URL to be used for the test + * + * @return the full URL for the test + */ + 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 what port the test is running on + * + * @return The port teh test is running on, by default 8888 + */ + protected abstract int 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 + * 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 List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + + } + + /** + * 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 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 + * The part following :: of the vaadin locator string + * @return + */ + protected WebElement vaadinElement(String vaadinLocator) { + return driver.findElement(vaadinLocator(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 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 up to 10s 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<Boolean> condition) { + waitUntil(condition, 10); + } + + /** + * Waits the given number of seconds 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<Boolean> condition, + long timeoutInSeconds) { + new WebDriverWait(driver, timeoutInSeconds).until(condition); + } + + /** + * Waits up to 10s 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<Boolean> condition) { + waitUntilNot(condition, 10); + } + + /** + * Waits the given number of seconds 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<Boolean> condition, + long timeoutInSeconds) { + waitUntil(ExpectedConditions.not(condition), timeoutInSeconds); + } + + protected void waitForElementToBePresent(By by) { + waitUntil(ExpectedConditions.not(ExpectedConditions + .invisibilityOfElementLocated(by))); + } + + /** + * 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(); + } + + /** + * 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 <T> void assertGreaterOrEqual(String message, + Comparable<T> 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 <T> void assertGreater(String message, Comparable<T> 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 <T> void assertLessThanOrEqual(String message, + Comparable<T> 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 <T> void assertLessThan(String message, + Comparable<T> a, T b) throws AssertionError { + if (a.compareTo(b) < 0) { + return; + } + throw new AssertionError(decorate(message, a, b)); + } + + private static <T> String decorate(String message, Comparable<T> 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. + * + * @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(); + 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 (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. + * + * 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() { + 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) { + } + 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; + } + if (UIProvider.class.isAssignableFrom(cls)) { + return true; + } + if (LegacyApplication.class.isAssignableFrom(cls)) { + return true; + } + + return false; + } + + /** + * 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 final boolean isDebug() { + return debug; + } + + /** + * 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 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 final void setPush(boolean push) { + this.push = push; + } + + /** + * 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 #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 (isPush()) { + 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() + ":" + getDeploymentPort(); + } + + /** + * 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 + */ + public static DesiredCapabilities safari(int version) { + DesiredCapabilities c = DesiredCapabilities.safari(); + c.setPlatform(Platform.MAC); + 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 + */ + public 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 + */ + public 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 + */ + public 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 + */ + public 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/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/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java new file mode 100644 index 0000000000..e8a974343b --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java @@ -0,0 +1,76 @@ +/* + * 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.Collections; +import java.util.List; + +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 + * + * <pre> + * @Parameters + * public static Collection<DesiredCapabilities> getBrowsersForTest() { + * } + * </pre> + * + * @author Vaadin Ltd + */ +public abstract class MultiBrowserTest extends PrivateTB3Configuration { + + public static final int TESTED_SAFARI_VERSION = 7; + public static final int TESTED_CHROME_VERSION = 29; + public static final int TESTED_FIREFOX_VERSION = 24; + + static List<DesiredCapabilities> allBrowsers = new ArrayList<DesiredCapabilities>(); + static { + allBrowsers.add(BrowserUtil.ie(8)); + allBrowsers.add(BrowserUtil.ie(9)); + allBrowsers.add(BrowserUtil.ie(10)); + allBrowsers.add(BrowserUtil.ie(11)); + allBrowsers.add(BrowserUtil.firefox(TESTED_FIREFOX_VERSION)); + // Uncomment once we have the capability to run on Safari 6 + // allBrowsers.add(BrowserUtil.safari(TESTED_SAFARI_VERSION)); + allBrowsers.add(BrowserUtil.chrome(TESTED_CHROME_VERSION)); + // Re-enable this when it is possible to run on a modern Opera version + // (15+) + // allBrowsers.add(BrowserUtil.opera(15)); + } + + /** + * @return all supported browsers which are actively tested + */ + public static List<DesiredCapabilities> getAllBrowsers() { + return Collections.unmodifiableList(allBrowsers); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // Return a copy so sub classes can do + // super.getBrowseresToTest().remove(something) + return new ArrayList<DesiredCapabilities>(getAllBrowsers()); + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java new file mode 100755 index 0000000000..0bb76889a0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTestWithProxy.java @@ -0,0 +1,106 @@ +/* + * 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.util.concurrent.atomic.AtomicInteger; + +import org.junit.After; +import org.junit.Before; + +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.Session; + +public abstract class MultiBrowserTestWithProxy extends MultiBrowserTest { + + private static AtomicInteger availablePort = new AtomicInteger(2000); + private Session proxySession; + private Integer proxyPort = null; + private JSch jsch; + private static String sshDir = System.getProperty("user.home") + "/.ssh/"; + private String[] publicKeys = new String[] { + System.getProperty("sshkey.file"), sshDir + "id_rsa", + sshDir + "id_dsa", sshDir + "id_rsa2" }; + + @Before + public void setupInitialProxy() throws JSchException { + connectProxy(); + } + + @After + public void teardownProxy() { + disconnectProxy(); + } + + protected Integer getProxyPort() { + if (proxyPort == null) { + // Assumes we can use any port >= 2000 + proxyPort = availablePort.addAndGet(1); + } + return proxyPort; + } + + /** + * Disconnects the proxy if active + */ + protected void disconnectProxy() { + if (proxySession == null) { + return; + } + proxySession.disconnect(); + proxySession = null; + } + + /** + * Ensure the proxy is active. Does nothing if the proxy is already active. + */ + protected void connectProxy() throws JSchException { + if (proxySession != null) { + return; + } + + createProxy(getProxyPort()); + } + + private void createProxy(int proxyPort) throws JSchException { + if (jsch == null) { + jsch = new JSch(); + + String keyFile = null; + for (String publicKey : publicKeys) { + if (publicKey != null) { + if (new File(publicKey).exists()) { + keyFile = publicKey; + break; + } + } + } + jsch.addIdentity(keyFile); + } + proxySession = jsch.getSession("localhost"); + proxySession.setConfig("StrictHostKeyChecking", "no"); + proxySession.setPortForwardingL("0.0.0.0", proxyPort, + super.getDeploymentHostname(), super.getDeploymentPort()); + proxySession.connect(); + } + + @Override + protected String getBaseURL() { + return "http://" + getDeploymentHostname() + ":" + getProxyPort(); + } + +} 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..912d7d010e --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/ParallelScheduler.java @@ -0,0 +1,69 @@ +/* + * 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.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<Future<Object>> fResults = new ArrayList<Future<Object>>(); + private ExecutorService fService; + + /** + * 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) { + fResults.add(fService.submit(new Callable<Object>() { + @Override + public Object call() throws Exception { + childStatement.run(); + return null; + } + })); + } + + @Override + public void finished() { + for (Future<Object> 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..caa35732d6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -0,0 +1,161 @@ +/* + * 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; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxBinary; +import org.openqa.selenium.firefox.FirefoxDriver; + +import com.vaadin.testbench.TestBench; + +/** + * 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 static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port"; + 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=<path>"); + } + 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; + } + + @Override + protected int getDeploymentPort() { + String portString = getProperty(PORT_PROPERTY); + + int port = 8888; + if (portString != null && !"".equals(portString)) { + port = Integer.parseInt(portString); + } + + return port; + } + + /** + * 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<NetworkInterface> interfaces = NetworkInterface + .getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface current = interfaces.nextElement(); + if (!current.isUp() || current.isLoopback() + || current.isVirtual()) { + continue; + } + Enumeration<InetAddress> 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."); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#setupLocalDriver() + */ + @Override + protected void setupLocalDriver() { + String firefoxPath = getProperty("firefox.path"); + WebDriver driver; + if (firefoxPath != null) { + driver = new FirefoxDriver( + new FirefoxBinary(new File(firefoxPath)), null); + } else { + driver = new FirefoxDriver(); + } + setDriver(TestBench.createDriver(driver)); + setDesiredCapabilities(BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + } +} 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..a51421d3d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/ScreenshotTB3Test.java @@ -0,0 +1,416 @@ +/* + * 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(); + screenshotBaseName = className + "-" + testMethod; + }; + }; + + /** + * Contains a list of screenshot identifiers for which + * {@link #compareScreen(String)} has failed during the test + */ + private List<String> screenshotFailures = new ArrayList<String>(); + + /** + * 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<File> alternativeFiles = findReferenceAlternatives(mainReference); + List<File> failedReferenceAlternatives = new ArrayList<File>(); + + 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 { + // Ensure we use the correct browser version (e.g. if running IE11 + // and only an IE 10 reference was available, then mainReference + // will be for IE 10, not 11) + String originalName = getScreenshotReferenceName(identifier); + File exactVersionFile = new File(originalName); + + if (!exactVersionFile.equals(mainReference)) { + // Rename png+html to have the correct version + File correctPng = getErrorFileFromReference(exactVersionFile); + File producedPng = getErrorFileFromReference(mainReference); + File correctHtml = htmlFromPng(correctPng); + File producedHtml = htmlFromPng(producedPng); + + producedPng.renameTo(correctPng); + producedHtml.renameTo(correctHtml); + referenceToKeep = exactVersionFile; + screenshotFailures.add(exactVersionFile.getName()); + } 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 + File failureHtml = htmlFromPng(failurePng); + + failurePng.delete(); + failureHtml.delete(); + } + } + } + + /** + * Returns a new File which points to a .html file instead of the given .png + * file + * + * @param png + * @return + */ + private static File htmlFromPng(File png) { + return new File(png.getParentFile(), png.getName().replaceAll( + "\\.png$", ".png.html")); + } + + /** + * + * @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<File> findReferenceAlternatives(File reference) { + List<File> files = new ArrayList<File>(); + 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/ServletIntegrationTests.java b/uitest/src/com/vaadin/tests/tb3/ServletIntegrationTests.java new file mode 100644 index 0000000000..c511b99e6e --- /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.AbstractServletIntegrationTest; +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, AbstractServletIntegrationTest.class, + "com.vaadin.tests.integration", new String[] {}); + } + } +} 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..4e084ab0ed --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/TB3Runner.java @@ -0,0 +1,162 @@ +/* + * 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.util.ArrayList; +import java.util.Collection; +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; +import org.junit.runners.Parameterized; +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 { + + /** + * 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(service)); + } + + @Override + protected List<FrameworkMethod> computeTestMethods() { + List<FrameworkMethod> tests = new LinkedList<FrameworkMethod>(); + + if (!AbstractTB3Test.class.isAssignableFrom(getTestClass() + .getJavaClass())) { + throw new RuntimeException(getClass().getName() + " only supports " + + AbstractTB3Test.class.getName()); + } + + try { + AbstractTB3Test testClassInstance = (AbstractTB3Test) getTestClass() + .getOnlyConstructor().newInstance(); + Collection<DesiredCapabilities> desiredCapabilites = testClassInstance + .getBrowsersToTest(); + if (testClassInstance.runLocally()) { + desiredCapabilites = new ArrayList<DesiredCapabilities>(); + desiredCapabilites.add(BrowserUtil + .firefox(MultiBrowserTest.TESTED_FIREFOX_VERSION)); + } + for (DesiredCapabilities capabilities : desiredCapabilites) { + + // 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; + } + + /* + * (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)); + } + + } +} 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..e1c8edfd60 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java @@ -0,0 +1,238 @@ +/* + * 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.concurrent.ExecutorService; +import java.util.concurrent.Executors; +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 { + + /** + * 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(service)); + } + + /** + * 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 <T> List<Class<? extends T>> findClasses(Class<T> baseClass, + String basePackage, String[] ignoredPackages) throws IOException { + List<Class<? extends T>> classes = new ArrayList<Class<? extends T>>(); + 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<Class<? extends T>>() { + + @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 <T> void findPackages(File parent, String javaPackage, + Class<T> baseClass, Collection<Class<? extends T>> 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 <T> void findClassesInJar(JarURLConnection juc, + String javaPackage, Class<T> baseClass, + Collection<Class<? extends T>> result) throws IOException { + String javaPackageDir = javaPackage.replace('.', '/'); + Enumeration<JarEntry> 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 <T> void addClassIfMatches( + Collection<Class<? extends T>> result, + String fullyQualifiedClassName, Class<T> 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/src/com/vaadin/tests/tb3/WebsocketTest.java b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java new file mode 100644 index 0000000000..26fef667cd --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/WebsocketTest.java @@ -0,0 +1,59 @@ +/* + * 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.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<DesiredCapabilities> websocketBrowsers = new ArrayList<DesiredCapabilities>(); + 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 List<DesiredCapabilities> getWebsocketBrowsers() { + return Collections.unmodifiableList(websocketBrowsers); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getBrowserToRunOn() + */ + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return new ArrayList<DesiredCapabilities>(getWebsocketBrowsers()); + } +} diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket12727.java b/uitest/src/com/vaadin/tests/tickets/Ticket12727.java new file mode 100644 index 0000000000..40711c6b7f --- /dev/null +++ b/uitest/src/com/vaadin/tests/tickets/Ticket12727.java @@ -0,0 +1,51 @@ +package com.vaadin.tests.tickets; + +import java.util.ArrayList; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.Panel; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +/** + * Test for #12727: Panels get unnecessary scroll bars in WebKit when content is + * 100% wide. + */ +@SuppressWarnings("serial") +public class Ticket12727 extends UI { + + @Override + protected void init(VaadinRequest request) { + Panel panel = new Panel(); + + VerticalLayout content = new VerticalLayout(); + panel.setContent(content); + + GridLayout gridLayout = new GridLayout(); + gridLayout.setHeight(null); + gridLayout.setWidth(100, Unit.PERCENTAGE); + content.addComponent(gridLayout); + + ListSelect listSelect = new ListSelect(); + + listSelect.setWidth(100, Unit.PERCENTAGE); + listSelect.setHeight(500, Unit.PIXELS); + + gridLayout.addComponent(listSelect); + + ArrayList<String> values = new ArrayList<String>(); + values.add("Value 1"); + values.add("Value 2"); + values.add("Value 3"); + + ComboBox comboBox = new ComboBox(null, values); + gridLayout.addComponent(comboBox); + + gridLayout.setMargin(true); + + setContent(panel); + } +} diff --git a/uitest/src/com/vaadin/tests/util/LoremIpsum.java b/uitest/src/com/vaadin/tests/util/LoremIpsum.java index 3dc775badf..c3eec32fd5 100644 --- a/uitest/src/com/vaadin/tests/util/LoremIpsum.java +++ b/uitest/src/com/vaadin/tests/util/LoremIpsum.java @@ -4,6 +4,15 @@ public class LoremIpsum { private static final String LOREM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi lacinia sollicitudin neque, vitae cursus eros scelerisque sit amet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin sollicitudin tempus lorem, sed consectetur nibh ultrices nec. Ut tempus laoreet dolor non molestie. Quisque consectetur tellus ut tortor imperdiet semper. In tempor odio eu metus hendrerit pharetra. Aliquam erat volutpat. Aliquam erat volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec sit amet turpis facilisis ipsum cursus viverra ut vitae turpis. Integer tincidunt sem id sem tristique a laoreet eros euismod. Ut quis leo vel neque pellentesque ullamcorper. Aliquam at fermentum justo. Sed eget laoreet elit. Pellentesque commodo dui quis metus ornare bibendum. Ut tempus, ipsum in euismod scelerisque, augue ante lacinia sem, scelerisque imperdiet felis lectus rhoncus felis.Fusce vitae nisl lorem, id ultricies massa. Phasellus augue eros, dapibus vel fermentum non, sodales id mi. Nulla tincidunt diam a justo ultricies vestibulum nec sed tellus. Morbi faucibus leo et odio condimentum at porttitor diam auctor. Aenean volutpat lacinia mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean malesuada ullamcorper elit ut eleifend. Etiam tempor, mauris id aliquet tempor, erat felis rutrum eros, a aliquam dolor nunc nec enim. Sed enim dolor, tristique ut tempus vitae, elementum at velit. Duis vulputate ultricies risus, ac gravida erat tincidunt posuere. Pellentesque dapibus tincidunt rhoncus. Phasellus eleifend molestie eros. Praesent id imperdiet urna. Etiam fermentum interdum quam, in tempus quam condimentum at.Curabitur eget ultrices augue. Suspendisse potenti. Nam hendrerit, dolor eget adipiscing lobortis, enim risus dignissim orci, a imperdiet tellus nulla id nibh. Praesent eu dui sit amet nulla interdum dignissim vel quis ante. Sed a lectus metus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus eget ultrices neque. Cras adipiscing condimentum justo adipiscing consequat. In accumsan mollis sapien ut euismod. Nulla sodales pulvinar leo, nec condimentum leo vestibulum ut. Phasellus risus metus, aliquet quis porta at, imperdiet vitae metus. Proin nec odio odio. Quisque nec elit id lacus iaculis ullamcorper sit amet vel ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In non lacus sed libero euismod rhoncus. Suspendisse augue massa, ullamcorper at accumsan at, porttitor ac odio.Morbi imperdiet, lectus vehicula eleifend ornare, lectus arcu ullamcorper augue, a imperdiet eros augue id justo. Integer eget pretium lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras vehicula leo eget metus consectetur viverra. Nullam a mi nisl, in lacinia metus. Curabitur mollis eleifend augue, consectetur imperdiet velit sagittis aliquet. In tempor tempor orci eu faucibus. Mauris nisi neque, vulputate eu dignissim eget, aliquet sed nibh. Mauris rhoncus elit eget lectus dignissim bibendum. Phasellus sed nunc lacus, nec aliquet elit. Fusce blandit, sem vitae gravida elementum, sem orci porttitor eros, id porta tortor massa ut velit. Nulla pretium mi at tortor porttitor sollicitudin.Ut gravida est at lectus eleifend non ultrices ligula blandit. Sed purus lectus, adipiscing ut mollis vel, interdum quis diam. Phasellus eget nibh augue. Fusce justo felis, facilisis in auctor ut, cursus et enim. Praesent hendrerit venenatis elit, iaculis cursus ligula auctor in. Proin mollis malesuada dolor at elementum. Maecenas sit amet leo odio. Integer ac enim in justo eleifend dapibus. Pellentesque consequat, libero congue sagittis pulvinar, odio eros porta quam, et aliquet dolor turpis non lacus. Sed eu risus nunc. Aliquam tempus nulla a purus auctor mattis. Nullam adipiscing nisl nec purus porttitor rutrum. Sed pellentesque tincidunt posuere. Nulla varius cursus eros. Phasellus vel neque at metus tempus placerat laoreet ac dolor. Nulla faucibus leo nisi, vel placerat lectus.Donec non leo lacinia metus euismod dignissim suscipit ut neque. Donec iaculis, lacus ut luctus bibendum, mi libero tristique sem, vel consectetur risus ligula in turpis. Nulla lorem justo, porttitor non sollicitudin at, pharetra non ante. Phasellus tristique, purus at luctus auctor, nisl neque congue lacus, eget convallis mauris libero sit amet arcu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tellus quam, lobortis vitae commodo id, ultrices a augue. Nam tellus erat, varius vel iaculis et, fermentum ut tellus. Donec id urna orci. Curabitur eleifend hendrerit libero, id tempor dolor faucibus eu. Quisque aliquam sapien a tortor mollis sollicitudin. Duis augue erat, sagittis eget consequat vel, volutpat et augue. Sed vehicula mattis nisi, non porta elit imperdiet vitae. Curabitur scelerisque mollis lectus, consequat suscipit est ultricies sit amet. Aenean in sem libero, id adipiscing urna. Aenean eleifend posuere lorem in aliquet. Praesent arcu est, tristique quis adipiscing ac, tincidunt nec dui. Nunc sed leo quis justo posuere suscipit. Fusce vitae lectus vitae urna sodales aliquam.Sed velit purus, ullamcorper non interdum quis, facilisis eget tortor. Etiam vestibulum venenatis aliquet. Fusce felis felis, venenatis id tincidunt at, vehicula et erat. Curabitur eu sagittis nisl. Curabitur nisi sapien, venenatis nec pulvinar ut, tempor id diam. Suspendisse metus libero, placerat in fermentum a, aliquam id arcu. Nulla quis accumsan massa. Curabitur consectetur pulvinar sapien non consequat. Etiam sem dolor, posuere id laoreet a, tempor vel nisl. Fusce eu lacus orci. Pellentesque tellus dui, pulvinar nec egestas vitae, adipiscing euismod nunc. Mauris consequat felis sit amet justo pellentesque venenatis. Donec dignissim porta dolor, eget pellentesque lorem porta eu. Donec eget enim eu leo mattis ornare in ut libero. Maecenas sit amet ante mauris.Praesent ultrices diam id lectus viverra sed lobortis risus adipiscing. Nulla in risus est. Proin vitae dolor ligula, a placerat enim. Integer hendrerit erat tincidunt leo malesuada sit amet tincidunt justo mattis. Morbi ut neque urna, ut blandit erat. Donec eleifend justo ac augue ultrices consectetur. In rutrum, leo ac porttitor volutpat, neque mi lacinia diam, id fermentum risus neque vitae risus. Suspendisse in justo libero, eget ultrices nisl. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In sollicitudin, arcu et convallis fermentum, est tellus pellentesque neque, ac faucibus tellus orci non purus. Ut aliquet facilisis ullamcorper. Cras justo ipsum, mollis vel ultricies non, consectetur a libero.Aliquam erat volutpat. Nunc ut mauris eu lorem consequat placerat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse sapien nisi, pellentesque ut porttitor eget, auctor vitae massa. Fusce et euismod massa. In dolor enim, commodo vitae scelerisque sit amet, vulputate quis nibh. Donec ut mollis elit. Nullam placerat sem at urna euismod tempus vitae a mi. Curabitur ac sem non tortor dapibus euismod in et augue. Phasellus elit nisi, ornare eget aliquam et, convallis vitae eros. Vivamus vitae facilisis quam. Nullam a dolor sit amet ante sodales vulputate. Sed vel elit libero. Vestibulum vestibulum porttitor orci, a elementum risus congue in. Mauris ut justo sed dolor rhoncus viverra nec non eros. Phasellus dignissim, mi id laoreet venenatis, enim lacus pharetra arcu, sit amet consectetur velit elit hendrerit arcu. Integer hendrerit suscipit pretium. Proin orci quam, vehicula vel accumsan tempor, facilisis tempus tortor.Etiam et nunc id odio lobortis ornare ac eget lorem. Proin tristique iaculis felis, ut gravida lacus congue ut. Etiam nibh turpis, congue vel ornare ut, feugiat ut mi. Etiam id ante eget turpis laoreet dapibus. Vivamus accumsan sem at est lacinia sagittis vitae a erat. Etiam mollis justo et felis faucibus sodales. Etiam placerat felis sed ante sollicitudin dignissim. Nunc fringilla nunc in lacus ultricies rutrum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed venenatis porta turpis dignissim tempor. Etiam consequat vulputate elementum. Sed augue lacus, aliquam eu ornare vel, aliquam at turpis.Ut lacinia velit odio. Nulla sapien tellus, fringilla dignissim porta sed, elementum eget diam. Quisque pulvinar commodo massa, vitae lobortis velit iaculis id. Vestibulum id dolor vel mauris auctor commodo id at odio. Suspendisse consectetur consequat erat. Aliquam in purus at sem pretium ultricies. In urna elit, porttitor vel gravida at, varius non nisi. Nullam id eros at lorem posuere ullamcorper eget in dui. Sed sit amet mi vel quam vestibulum imperdiet. Ut ullamcorper purus nibh, a commodo tortor. Phasellus pretium, nulla ut venenatis euismod, augue arcu volutpat nulla, id semper est purus eget urna. Vivamus pharetra diam ac ante cursus tempus.Cras in rhoncus felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In semper leo sit amet nisi rutrum et interdum odio fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras sollicitudin dui non risus iaculis a lobortis odio consequat. Sed consectetur nisl eu nisi pulvinar fermentum. Etiam placerat tincidunt pellentesque. Etiam luctus auctor nulla ac pulvinar. Pellentesque sit amet eros est. Sed hendrerit sem rhoncus purus rhoncus ullamcorper. Integer vitae commodo sem. Donec orci lectus, gravida sit amet viverra ut, suscipit eu odio. Vivamus ac dolor sit amet augue porttitor imperdiet nec quis mauris. Etiam luctus pharetra lectus sed mattis. Proin tincidunt ultricies dolor, at sagittis ante tincidunt ac.Morbi sit amet sem ut leo ornare luctus at sed odio. Donec vestibulum consequat consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Integer sit amet leo eget ipsum eleifend commodo et vel sapien. Donec vulputate facilisis nisi in bibendum. Vestibulum justo magna, mollis in varius a, malesuada id nisl. Vestibulum fermentum leo at ipsum euismod scelerisque. Donec id diam eget sapien varius ultricies. Quisque mollis vehicula lorem, vitae suscipit lorem gravida vel. Cras ipsum odio, pellentesque vitae molestie at, facilisis eget felis. Morbi gravida velit eget ante posuere id pharetra dolor vehicula. Praesent lectus sem, pretium sit amet eleifend non, ultricies vitae eros.Etiam consequat felis quis elit semper sed lobortis risus faucibus. Quisque diam ante, gravida ut mollis tristique, auctor ac mauris. Phasellus vestibulum sapien et justo sagittis sed dignissim dui sollicitudin. Maecenas egestas quam et odio mattis eu posuere est sagittis. Nulla nec posuere turpis. In mauris sapien, pharetra et placerat eu, dictum quis justo. Curabitur sit amet varius nulla. Cras feugiat erat quis ante aliquam blandit. In ac libero id massa dapibus ultrices. Donec non massa orci.In gravida justo vitae eros ultrices fringilla. Sed mi quam, lobortis eu pharetra nec, pulvinar eu justo. Sed ornare diam sed nulla pellentesque at tincidunt lacus cursus. Donec vel neque et urna euismod suscipit. Proin in tortor eget felis euismod ultrices. Nunc ut orci elit, vitae pellentesque ligula. Vivamus in mi felis, at congue nulla. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mattis, ligula id sollicitudin posuere, eros odio pellentesque felis, in auctor libero mi nec massa. Praesent fringilla pretium tempus. Sed quis leo nulla, a pretium mi. Sed malesuada quam eget lorem tristique eget accumsan libero auctor. Vestibulum metus nisl, rutrum vel ullamcorper scelerisque, ultrices cursus purus. Aliquam convallis sollicitudin elit at mattis. Phasellus vitae magna id quam laoreet gravida quis ac metus.Duis lobortis arcu a elit porta laoreet. Pellentesque at condimentum sapien. Maecenas rutrum eleifend quam, eu pellentesque quam tincidunt ac. Vivamus fermentum justo ac dui dapibus ut tempus massa congue. Phasellus fermentum placerat enim, et dignissim mi feugiat in. Etiam odio diam, mollis vitae viverra a, egestas eget arcu. Curabitur purus lectus, accumsan quis lobortis ut, faucibus ac magna. Vivamus consectetur, ligula sit amet convallis rhoncus, risus lorem scelerisque arcu, eu fermentum felis leo sit amet eros. In hac habitasse platea dictumst. Sed congue pretium erat, vel hendrerit velit dapibus ut. Aliquam porta porttitor nunc facilisis pretium. Aliquam tincidunt porttitor tincidunt. Sed at erat a arcu elementum dignissim nec et ipsum. In et magna erat. In hac habitasse platea dictumst. Nulla sit amet enim vitae magna ullamcorper auctor ac id lectus. Fusce id sapien massa.Fusce porta nisl non leo iaculis sed elementum purus viverra. Aenean vitae erat elit. Proin id tincidunt nibh. Fusce faucibus dignissim laoreet. Etiam volutpat ultricies magna in euismod. Quisque luctus malesuada massa, ac ullamcorper dui luctus quis. Mauris a felis ut urna blandit semper egestas vel dui. Nulla facilisi. Ut dapibus bibendum bibendum. Curabitur id facilisis tellus. Vestibulum arcu orci, pretium vestibulum accumsan ut, feugiat eget eros. Mauris dapibus sem a massa ornare id posuere purus ornare. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus mollis, orci ac eleifend pharetra, risus turpis euismod urna, ut congue neque nunc ut felis. Aliquam a nisi leo. Nulla consequat faucibus ligula consectetur tristique. Duis at lacus orci, eget pulvinar tortor.Aenean nisi justo, dictum ac sagittis a, mollis ut orci. Donec faucibus congue neque ut gravida. Nam interdum nunc vel ipsum molestie elementum. Aliquam a eros non mi accumsan lacinia ut eu justo. Donec id ipsum purus, sed congue nunc. Donec euismod ante quis metus interdum feugiat. Sed nec dictum neque. Vivamus sed felis non lorem placerat facilisis eu sit amet nisi. Morbi dolor dolor, malesuada eu congue at, sollicitudin ut metus. In sit amet ipsum purus, ut dignissim dolor. Pellentesque quis velit velit. Aenean dapibus ipsum eu felis placerat volutpat. Donec auctor dictum ligula ut facilisis. Aliquam vulputate nunc nec diam ultricies auctor dictum dui fringilla. Cras urna metus, porttitor et sodales eu, tempus non mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.Etiam tempor, mi ut tempor adipiscing, nunc lorem gravida odio, scelerisque aliquet ante massa id nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus eu nisl urna. Quisque vel leo in lorem bibendum bibendum ut eget massa. Morbi dictum, metus eu pellentesque lobortis, augue nisi facilisis velit, sit amet feugiat risus nunc vitae elit. Fusce blandit mi a augue gravida eu tristique sem consequat. Suspendisse non malesuada nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque commodo lorem id ipsum cursus posuere. Proin euismod facilisis est, vel imperdiet lectus commodo blandit. Proin luctus dapibus purus, id vulputate mauris tincidunt vel. Vestibulum volutpat molestie nulla faucibus malesuada. Aenean ut ornare lectus.Maecenas vel mauris in dolor imperdiet gravida eu nec mi. Vestibulum varius sem et nibh aliquet eu posuere tellus luctus. Fusce blandit, odio ut gravida semper, tellus lorem porta felis, vitae posuere mi lorem eget magna. Sed tristique nisi ut ipsum adipiscing molestie. Donec volutpat nunc eget neque posuere aliquam. Vivamus vel sem lectus. In volutpat dictum eros. Curabitur mollis pretium arcu ut rhoncus. Vivamus eros risus, sagittis posuere suscipit sit amet, consectetur eget elit. Mauris porttitor feugiat magna, sed lobortis ante porttitor at. Etiam non enim quam, nec tempus erat. Ut porta pharetra nibh vel laoreet. Sed euismod elit eget sem tempus non sodales massa cursus. Aliquam erat volutpat. Nulla a tortor ornare nibh feugiat venenatis. Mauris interdum mattis odio eget porta. Maecenas ac ullamcorper velit. Nulla id sagittis ligula. Aliquam pharetra, diam ut euismod pellentesque, sapien ligula sagittis nisi, sed dictum dolor purus sit amet elit.Aenean quis metus velit. In at fermentum nunc. Cras in magna sapien, sed vestibulum lacus. Sed pellentesque, massa sed malesuada tincidunt, erat tortor consectetur lacus, vel congue arcu enim id libero. Donec elit neque, egestas a faucibus ut, tempor nec diam. Donec turpis est, vulputate id venenatis vitae, vulputate sit amet elit. Ut semper nibh orci. Fusce nibh nisi, tristique eu dapibus id, faucibus nec augue. Sed sagittis malesuada leo, pretium porttitor ante lacinia in. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.Sed quis libero ante, ac consequat nisl. Cras nisl urna, ultrices eu dapibus sed, pretium quis diam. Curabitur aliquam, dolor et convallis viverra, purus orci commodo neque, a sagittis felis tellus quis mi. In mi orci, tempus ut sodales imperdiet, condimentum ac tortor. Phasellus ornare, tortor eget egestas ultricies, est risus ultricies lorem, ac tempus nibh ligula ac ante. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec fermentum nibh vitae tortor laoreet sed rutrum arcu suscipit. Fusce iaculis nisl in justo pretium a interdum ipsum dignissim. Sed sed semper metus. Aenean ante turpis, fermentum vestibulum dapibus eget, dictum id leo. Nam nec lorem erat.Cras dolor nulla, suscipit nec viverra ac, egestas vitae enim. Quisque vel laoreet sem. Sed non felis at nisl ultricies pharetra vitae a lorem. Suspendisse tempor arcu id massa laoreet congue. Nam eu turpis justo, nec adipiscing tortor. Etiam mattis lorem tincidunt diam molestie semper. Vivamus rutrum est in tortor egestas consequat. Sed vitae ultrices leo. Aenean pulvinar malesuada enim, eget elementum purus bibendum a. Vivamus sit amet mauris mauris, placerat varius lorem. Sed diam tortor, posuere non convallis molestie, dictum quis libero. Nulla quis tellus a nunc semper elementum vel sed odio. Cras ac mattis lectus. Proin placerat imperdiet sodales. Fusce quis magna dolor, eget porttitor lectus. Mauris elementum lorem vitae lectus porta scelerisque nec a sapien. Vivamus dapibus volutpat leo nec vehicula. Praesent ac diam ipsum.Pellentesque nec ullamcorper nulla. Nam lectus dolor, porttitor vitae varius sed, egestas a arcu. Suspendisse malesuada venenatis erat nec consequat. Morbi consequat magna a neque ultrices eget aliquet sapien ultrices. Aenean vel diam ipsum, ac scelerisque dui. Morbi quis arcu neque, eget auctor enim. Etiam pretium est sit amet nunc porta ornare vel quis sapien. Aliquam pulvinar pharetra risus, vel mollis mauris cursus sed. In sagittis nisl ac nunc placerat bibendum. Proin in risus lorem, sed fringilla eros.Proin luctus aliquam metus vitae euismod. Maecenas hendrerit sollicitudin hendrerit. Etiam magna elit, fringilla ut suscipit at, viverra eget ante. Morbi consequat, dui non tristique varius, eros ipsum vulputate sem, eu tristique nibh lacus vel felis. Maecenas eget eros a urna consectetur interdum. Integer est nibh, semper sed feugiat quis, lacinia eget diam. In ultricies mollis lectus sed imperdiet. Proin sed magna nec tortor blandit lacinia in sit amet nibh. Nullam ultrices tempor lacus, vel tincidunt eros vulputate euismod. Praesent justo nibh, convallis ut vehicula consequat, molestie posuere nulla. Mauris sollicitudin egestas vestibulum. Suspendisse auctor imperdiet eros, sit amet dignissim magna dapibus in. Praesent ultrices sem et risus interdum vel pharetra dolor tristique. Proin eleifend nunc eget risus venenatis posuere. Sed est nisi, interdum porta dapibus a, laoreet ac mi. Praesent sit amet varius lectus. Phasellus suscipit lacinia velit, sed tempus odio varius at. Fusce eleifend elementum aliquet. Proin ultricies libero at ipsum condimentum rhoncus.Quisque convallis, arcu at vehicula imperdiet, velit eros posuere sem, sit amet pulvinar purus massa a tellus. Maecenas cursus neque in dolor facilisis ac aliquam ligula eleifend. Fusce quis faucibus nisl. Fusce pulvinar magna vel enim scelerisque id cursus tortor faucibus. Nunc est turpis, iaculis ac sodales non, euismod vitae nunc. Fusce felis purus, iaculis dapibus mollis quis, condimentum consequat eros. Ut a lectus nec mi lacinia fringilla. Donec eget metus lectus, et rhoncus enim. Donec pharetra malesuada enim at rutrum. Vestibulum tincidunt gravida viverra. Vestibulum commodo sem nisl.Vivamus iaculis mollis arcu, quis dapibus risus semper quis. Quisque consectetur ullamcorper arcu id lacinia. Proin non tellus tellus. Nunc vehicula, arcu in pharetra feugiat, ante ante viverra urna, at convallis ligula odio id purus. Morbi quis orci non ante imperdiet luctus. Maecenas et ipsum est, at viverra sem. Morbi placerat ultrices imperdiet. Nullam id arcu at quam mollis hendrerit eu ac lectus. Etiam a neque sed turpis vestibulum posuere. Ut elementum tincidunt nulla at pellentesque. Integer nisl nunc, faucibus non sollicitudin eu, vestibulum ut nulla. In auctor est blandit purus rhoncus et sagittis eros convallis. Mauris sodales ultricies varius. Nulla facilisi. Donec ut nisl nunc, id accumsan erat. Praesent gravida molestie lobortis. In suscipit nisi sed elit sagittis tristique. Pellentesque vitae ante elit. Nullam diam est, ultrices vitae molestie at, tempus et magna. In hac habitasse platea dictumst.Vestibulum id tristique quam. Vivamus dui nulla, pretium eget elementum et, pulvinar a diam. Sed sed arcu sapien, et pharetra nisl. Nunc dignissim, lectus ac fringilla cursus, risus ante pretium justo, nec molestie sem urna id velit. Aenean tincidunt felis sed risus vestibulum ultricies. Aliquam lacinia scelerisque hendrerit. Morbi tincidunt molestie sapien sed faucibus. Vivamus et nisl velit, in semper libero. Duis elementum, dolor eget euismod porttitor, tortor eros tristique risus, eget posuere purus leo venenatis leo. Quisque in elit hendrerit felis accumsan gravida id sed sem.Sed massa turpis, interdum eget adipiscing a, tempor non enim. Vivamus sit amet purus tortor, quis tincidunt nunc. Nam vehicula dolor vitae est bibendum sed condimentum nisl pretium. Aenean pellentesque egestas lacinia. Vestibulum id felis sapien, vestibulum pharetra mauris. Donec quis ligula quis risus ultrices pharetra ac et quam. Nunc aliquam adipiscing mauris id euismod. Suspendisse potenti. Ut pharetra tristique pellentesque. Fusce tristique nisl vitae eros adipiscing lobortis. Ut porttitor porttitor est, vel euismod mi feugiat quis. Sed bibendum lacus vel sem hendrerit a ultricies sapien mattis.Vestibulum a tempus urna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean tincidunt interdum dui, in accumsan ante placerat non. Aliquam suscipit eros eget quam ullamcorper consequat. Nulla facilisi. Phasellus porttitor interdum quam nec mattis. Etiam vitae diam vel est tempus aliquam eu et tellus. Phasellus lobortis porttitor mi, eu mollis augue tempus eu. Morbi a urna id nibh faucibus dictum. Sed hendrerit fringilla nunc vel elementum. Donec vel massa vitae nibh imperdiet vestibulum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum in velit lorem, eu posuere felis. Maecenas ornare posuere faucibus. Donec dignissim ante eu neque suscipit interdum. Pellentesque ultrices dictum quam, tempor tempus leo posuere eget. Vestibulum dictum interdum urna, at feugiat neque venenatis ac. Donec tempus dictum enim, nec tempor neque rhoncus vel.Sed mollis luctus leo sed mattis. Vestibulum tempor mattis vehicula. Duis id elementum libero. Integer condimentum tincidunt molestie. Aenean quam tortor, rutrum sit amet placerat sed, sollicitudin eget turpis. In hac habitasse platea dictumst. Mauris lacinia mollis rhoncus. Fusce nec tellus elementum magna congue ultricies. Nulla consequat, dui nec facilisis hendrerit, ligula sapien viverra velit, at tempor risus leo vestibulum risus. Cras volutpat molestie orci ullamcorper gravida. Nullam est nisi, tempus et tincidunt ut, dapibus vitae nibh. Nam scelerisque purus sit amet odio imperdiet mattis. Integer ut ultrices odio.Cras placerat turpis nisl. Quisque consectetur urna vel nunc faucibus dictum. Nunc ac varius mauris. In ut egestas purus. Sed arcu nibh, mollis vitae dapibus eget, consectetur sit amet eros. Curabitur tincidunt purus sagittis neque adipiscing pretium. Aliquam tempor ullamcorper lectus. Cras quis elit et sapien euismod dapibus vitae in urna. Aliquam adipiscing urna non elit suscipit hendrerit. Mauris euismod tincidunt tortor eu vestibulum. Praesent ac quam massa. Fusce vitae viverra justo. Phasellus vel posuere augue. Praesent sagittis auctor odio in cursus. Sed vel lacus velit, vitae eleifend leo. Donec dapibus ornare mauris ut imperdiet. Nullam a sem felis, in commodo ligula. Nunc sed justo id metus bibendum pretium. Fusce lacinia lorem at leo ultricies porta.Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi non ipsum nisi, at porta ipsum. Nulla dolor lacus, auctor eget tincidunt et, tempor in velit. Cras vel diam facilisis dolor sagittis sodales. In hac habitasse platea dictumst. Donec dignissim vulputate tempor. Fusce tristique vestibulum vehicula. Integer nec erat a risus semper ultrices nec ac eros. Phasellus egestas, risus eget suscipit iaculis, mi magna posuere urna, in sollicitudin odio leo nec lorem. Ut at enim nunc, eget pellentesque ipsum. Nam at ipsum et magna tempor gravida vestibulum ut diam. Aenean aliquam scelerisque blandit. Cras sapien sem, consectetur a laoreet at, mattis vel lorem. Maecenas enim mauris, hendrerit ac imperdiet in, hendrerit a justo. Vestibulum justo metus, adipiscing at pulvinar at, scelerisque at velit. Aliquam sodales feugiat tortor ullamcorper cursus. Quisque tortor felis, sodales eu bibendum in, pellentesque eget urna.Nullam ultricies congue nisi nec blandit. Nulla nisl mi, aliquet vel dictum in, pellentesque fringilla arcu. Nam vulputate iaculis pellentesque. Morbi faucibus, augue vitae aliquam fringilla, ipsum tellus lacinia ligula, a luctus mauris orci id nulla. Vestibulum commodo, diam eget tincidunt iaculis, leo ante suscipit ligula, convallis scelerisque quam augue quis libero. Pellentesque vulputate ultricies eros a porta. In hac habitasse platea dictumst. Quisque at sem vel nisl pellentesque pellentesque at imperdiet turpis. Sed quis sem non nulla pellentesque placerat. Etiam sed ultricies nisl. Nunc vel leo augue, vitae fringilla urna. Suspendisse eget dolor enim, sed interdum lorem. Etiam imperdiet, nunc a tempor elementum, ipsum ante sodales tortor, id dignissim arcu diam vitae metus.Sed tincidunt fringilla mauris a lobortis. Morbi mollis elementum purus ac auctor. Etiam malesuada sapien vehicula magna fringilla sit amet porta sem scelerisque. Vestibulum malesuada ante nunc. Curabitur laoreet commodo mauris eu tempor. Sed hendrerit, lorem vel scelerisque aliquam, metus ligula ultricies ante, at luctus neque risus ut nisi. Suspendisse lectus sapien, tempor eget volutpat non, tempor at orci. Aenean eu est metus, vel convallis augue. Integer aliquam turpis id neque posuere tincidunt. Morbi at ante felis, ac semper diam. Etiam iaculis sapien a mauris tempus semper. Nunc ut leo nec massa tincidunt sodales id sed justo. Fusce sed blandit turpis. Pellentesque scelerisque laoreet luctus.Integer lobortis sollicitudin sapien, vel consequat augue hendrerit ut. Quisque pretium, enim condimentum ornare viverra, est nisl convallis lacus, vel varius turpis mi a eros. Curabitur eget enim non quam condimentum lobortis id sit amet dolor. Aliquam in ligula ut nisi accumsan consectetur. Pellentesque blandit ultrices magna, eget posuere dui eleifend ut. Quisque ornare, ante eget iaculis rutrum, nisi dolor tincidunt diam, eget volutpat nibh sapien vel massa. Sed viverra pulvinar lectus et commodo. Sed lacus mauris, aliquet ut tristique at, feugiat sit amet lectus. Duis lacinia purus a lacus accumsan tristique. Donec felis nunc, egestas ut porttitor ac, vulputate at purus. Quisque euismod nibh sit amet metus ullamcorper a consequat ipsum luctus. Mauris vitae sapien tristique lorem mollis porta auctor vitae leo.Donec mauris nibh, elementum a tincidunt nec, volutpat vitae enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque at purus quis massa vulputate mollis ut eu risus. Cras libero diam, pharetra quis ultrices facilisis, tincidunt id arcu. Praesent at volutpat quam. Phasellus quis malesuada sapien. Nullam eu leo quam, bibendum sagittis turpis. Vestibulum sagittis accumsan enim ut tristique. Donec eu enim nisi. Curabitur mauris orci, fringilla et suscipit placerat, ullamcorper vel turpis. Mauris est arcu, gravida ac accumsan ac, tincidunt vel nibh. Mauris pulvinar massa tempor dui hendrerit vel elementum diam pulvinar. Sed felis leo, laoreet at laoreet nec, venenatis eu risus. Nunc a massa lacus. Vestibulum ut pellentesque sem. Donec consectetur, turpis consequat aliquam consectetur, leo nunc lobortis elit, at sagittis ipsum risus sed turpis. Vivamus at sollicitudin purus. Nulla facilisi.Morbi congue dignissim nibh ut commodo. Integer sed urna fermentum neque hendrerit aliquam ac et tortor. Phasellus massa sem, egestas sed tincidunt id, malesuada vel odio. Nulla arcu nisl, elementum at pretium interdum, pharetra at nulla. Vestibulum lectus ante, ultricies ac lacinia euismod, adipiscing at metus. Aliquam velit orci, posuere a dapibus dapibus, consectetur vitae est. Pellentesque suscipit pulvinar varius. Morbi sagittis blandit nulla, eu posuere arcu blandit eu. Nulla cursus nunc volutpat orci commodo aliquet. Quisque condimentum dui a mi facilisis tincidunt.Quisque ac nisi vitae ipsum condimentum luctus non quis erat. Pellentesque eget nunc sit amet ipsum pharetra vulputate ac in mi. Etiam consectetur nulla vitae risus pharetra a ornare ligula sagittis. Proin euismod mauris id lectus tincidunt luctus at sed ligula. Aenean porttitor hendrerit quam quis interdum. Suspendisse eu metus turpis, ut venenatis ipsum. Nulla ipsum orci, lacinia ac vestibulum ut, mattis quis eros. Pellentesque a velit et erat sodales ornare. Pellentesque pellentesque tortor eget magna facilisis accumsan. Praesent tincidunt posuere lacus sed sollicitudin. Praesent consectetur diam vel turpis elementum vehicula. Integer rutrum dignissim justo, ac dapibus quam fringilla non. Suspendisse porta elementum bibendum. Praesent at lorem at quam dignissim commodo. Etiam placerat euismod ipsum eu interdum. Aliquam in mi molestie justo varius venenatis eu aliquam quam. Integer feugiat, neque hendrerit egestas hendrerit, lectus ligula placerat enim, a faucibus ante ligula vitae mi. Praesent urna nunc, volutpat vitae scelerisque non, porta vel dolor. Aenean quam sem, dignissim at faucibus non, auctor sodales libero.Morbi justo elit, tempus ac cursus porta, eleifend nec odio. Ut nec quam velit. Duis elit nulla, placerat et rutrum quis, tempor non nisi. Quisque massa erat, pretium ut elementum sit amet, sodales vel metus. Phasellus sollicitudin sapien vel nisl faucibus ornare. Duis ut dolor arcu, vel semper felis. In quis orci mauris, id porttitor diam. Fusce ornare, dolor in posuere blandit, neque est mollis lacus, eu venenatis nisi orci vel diam. Etiam ornare sapien eu sapien tristique vitae consequat arcu consequat. Fusce a felis at dui sollicitudin pellentesque sit amet vel mi. Curabitur congue porttitor orci, eu auctor nibh mollis at. Nulla facilisi. Nam aliquet ullamcorper metus ac vulputate. Aenean feugiat purus vitae dui congue egestas. Curabitur sollicitudin leo eget nibh facilisis fermentum fermentum non nisi. Ut at libero eget est bibendum laoreet non eu ante. Proin pellentesque quam ut augue condimentum id suscipit risus tristique. Nunc laoreet risus elit.Suspendisse vel ante elit, eu feugiat diam. Etiam ultrices condimentum tempor. Donec eget porta lacus. Nunc in velit lacus, ut ultricies felis. Nulla id cursus metus. Praesent suscipit, orci a facilisis imperdiet, eros lectus eleifend nibh, sit amet auctor magna arcu ac enim. In malesuada volutpat felis a posuere. Aliquam mattis ipsum ut quam semper aliquet. Maecenas convallis consequat magna, blandit viverra nulla consectetur sit amet. Pellentesque id velit nec risus iaculis imperdiet ac accumsan metus. Suspendisse et sem massa. Vestibulum ac enim hendrerit est tincidunt ullamcorper.Curabitur placerat, libero id molestie vehicula, neque tortor vulputate sapien, ut blandit orci metus et nibh. Cras convallis justo a nibh iaculis ut convallis neque vestibulum. Duis gravida purus metus, nec viverra leo. In tincidunt elit sit amet orci lacinia non eleifend orci tincidunt. Praesent est metus, molestie a ullamcorper ultricies, cursus imperdiet augue. Sed vitae quam eu dui pellentesque dignissim. Curabitur convallis volutpat accumsan. Donec egestas malesuada est, vitae faucibus sem fermentum id. Donec porttitor rutrum vehicula. Nulla placerat risus in est egestas nec ultrices ligula auctor. Quisque erat lorem, ullamcorper vitae interdum sit amet, laoreet vel elit. Proin eu porta neque. Pellentesque eleifend, ipsum a sollicitudin ultrices, ligula nisl aliquet dui, eget fermentum quam mi vel."; public static String get(int len) { + if (len > LOREM.length()) { + StringBuilder builder = new StringBuilder(); + while (len > LOREM.length()) { + builder.append(LOREM); + len -= LOREM.length(); + } + builder.append(LOREM.substring(0, len)); + return builder.toString(); + } return LOREM.substring(0, len); } diff --git a/uitest/tb3test.xml b/uitest/tb3test.xml new file mode 100644 index 0000000000..dd0c12db91 --- /dev/null +++ b/uitest/tb3test.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<project name="tb3test" xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:ivy="antlib:org.apache.ivy.ant" basedir="."> + + <dirname property="tb3test.dir" file="${ant.file.tb3test}" /> + + <ivy:resolve file="${tb3test.dir}/ivy.xml" conf="build, build-provided" /> + <ivy:cachepath pathid="classpath.tb3.lib" conf="build, build-provided" /> + <path id="classpath.tb3"> + <path refid="classpath.tb3.lib" /> + <path location="${tb3test.dir}/result/classes" /> + </path> + + <target name="run-all-tb3-tests" unless="tests.tb3.skip" description="Run all the TB3 tests (except server tests) in the project"> + <antcall target="run-tb3-suite"> + <param name="junit.test.suite" value="com.vaadin.tests.tb3.AllTB3Tests" /> + </antcall> + </target> + + <target name="run-tb3-suite"> + <fail unless="junit.test.suite" message="Define suite to run using junit.test.suite" /> + <fail unless="com.vaadin.testbench.screenshot.directory" message="Define screenshot directory using -Dcom.vaadin.testbench.screenshot.directory" /> + <junit printsummary="withOutAndErr" fork="yes"> + <formatter usefile="false" type="plain" /> + <classpath refid="classpath.tb3" /> + + <jvmarg value="-Dcom.vaadin.testbench.screenshot.directory=${com.vaadin.testbench.screenshot.directory}" /> + <jvmarg value="-Djava.awt.headless=true" /> + <test name="${junit.test.suite}" /> + </junit> + + </target> + +</project> diff --git a/uitest/test.xml b/uitest/test.xml index 3baccb4117..b0db8d47f4 100644 --- a/uitest/test.xml +++ b/uitest/test.xml @@ -83,7 +83,7 @@ <fail unless="com.vaadin.testbench.deployment.url" message="The 'com.vaadin.testbench.deployment.url' property must be defined." /> </target> - <target name="run-tests" depends="compile-tests"> + <target name="run-tb2-tests" depends="check-parameters,compile-tests"> <fileset dir="${test-output-dir}" id="tests-fileset"> <include name="**/**.java" /> </fileset> @@ -161,12 +161,10 @@ <!-- ================================================================== --> <!-- The default target. --> - <target name="run-and-clean-up" depends="check-parameters,remove-error-screens,run-tests" /> + <target name="run-and-clean-up" depends="check-parameters,remove-error-screens,run-tb2-tests" /> - - <!-- Starts the server and runs all TestBench tests --> - <target name="test-package"> - <fail unless="war.file" message="No 'war.file' parameter given." /> + <!-- Runs all TestBench 2 tests --> + <target name="tb2-tests" unless="tests.tb2.skip"> <property name="test-output-dir" location="${test.xml.dir}/result/testbench-junit-classes" /> <property name="retries" value="2" /> @@ -177,15 +175,6 @@ <property name="com.vaadin.testbench.screenshot.block.error" value="0.025" /> <property name="com.vaadin.testbench.debug" value="false" /> - <parallel> - <daemons> - <ant antfile="${test.xml.dir}/vaadin-server.xml" inheritall="true" inheritrefs="true" target="deploy-and-start" /> - </daemons> - <sequential> - <ant antfile="${test.xml.dir}/vaadin-server.xml" target="wait-for-startup" /> - <antcall inheritall="true" inheritrefs="true" target="run-and-clean-up" /> - <echo message="All TestBench tests have been run" /> - </sequential> - </parallel> + <antcall inheritall="true" inheritrefs="true" target="run-tb2-tests" /> </target> </project> diff --git a/uitest/vaadin-server.xml b/uitest/vaadin-server.xml index 4e84a6f238..5e9090a536 100644 --- a/uitest/vaadin-server.xml +++ b/uitest/vaadin-server.xml @@ -8,7 +8,7 @@ <ivy:resolve log="download-only" file="${dir}/ivy.xml" /> <ivy:cachepath pathid="classpath.jetty" conf="jetty-run" /> - <java classname="org.mortbay.jetty.runner.Runner" fork="yes" output="${vaadin.basedir}/result/jetty.java.out" resultproperty="resultCode"> + <java classname="org.mortbay.jetty.runner.Runner" fork="yes" output="${vaadin.basedir}/result/jetty.java.out" resultproperty="resultCode" maxmemory="1024m"> <arg value="--port" /> <arg value="8888" /> <arg value="--out" /> |