From acb12abcf93396168f6edfc34b2bccf75d34ee19 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Fri, 6 Mar 2015 14:55:37 +0200 Subject: [PATCH] Convert browserframe, flash and requesthandler tests to TB4 Change-Id: Ic2089570fcfc9ec81f3d95722adc75ff75e8293f --- .../BrowserFrameIsVisibleTest.java | 22 +++++ .../components/flash/FlashIsVisibleTest.java | 25 ++++++ .../requesthandlers/AppResource404Test.java | 58 +++++++++++++ .../browserframe/BrowserFrameIsVisible.html | 67 --------------- .../components/flash/FlashIsVisible.html | 33 -------- .../tests/requesthandlers/AppResource404.html | 81 ------------------- 6 files changed, 105 insertions(+), 181 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisibleTest.java create mode 100644 uitest/src/com/vaadin/tests/components/flash/FlashIsVisibleTest.java create mode 100644 uitest/src/com/vaadin/tests/requesthandlers/AppResource404Test.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html delete mode 100644 uitest/tb2/com/vaadin/tests/components/flash/FlashIsVisible.html delete mode 100644 uitest/tb2/com/vaadin/tests/requesthandlers/AppResource404.html diff --git a/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisibleTest.java b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisibleTest.java new file mode 100644 index 0000000000..927b76d2c3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisibleTest.java @@ -0,0 +1,22 @@ +package com.vaadin.tests.components.browserframe; + +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class BrowserFrameIsVisibleTest extends MultiBrowserTest { + @Test + public void testBrowserFrameDisplaysFiles() throws Exception { + openTestURL(); + compareScreen("show_initial"); + $(ButtonElement.class).caption("Hello World").first().click(); + compareScreen("show_hello"); + $(ButtonElement.class).caption("Lorem ipsum").first().click(); + compareScreen("show_lorem"); + $(ButtonElement.class).caption("null").first().click(); + compareScreen("show_alternative_text"); + $(ButtonElement.class).caption("Lorem ipsum").first().click(); + compareScreen("show_lorem"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/flash/FlashIsVisibleTest.java b/uitest/src/com/vaadin/tests/components/flash/FlashIsVisibleTest.java new file mode 100644 index 0000000000..4a18d4d8a2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/flash/FlashIsVisibleTest.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.components.flash; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class FlashIsVisibleTest extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + // FF and PhantomJS fail at Flash and ShiftClick + return getBrowsersSupportingShiftClick(); + } + + @Test + public void testFlashIsCorrectlyDisplayed() throws Exception { + openTestURL(); + /* Allow the flash plugin to load before taking the screenshot */ + sleep(5000); + compareScreen("blue-circle"); + } +} diff --git a/uitest/src/com/vaadin/tests/requesthandlers/AppResource404Test.java b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404Test.java new file mode 100644 index 0000000000..f762573a09 --- /dev/null +++ b/uitest/src/com/vaadin/tests/requesthandlers/AppResource404Test.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.requesthandlers; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.LinkElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class AppResource404Test extends MultiBrowserTest { + @Test + public void testOpenExistingResource() throws Exception { + openTestURL(); + $(LinkElement.class).first().click(5, 5); + disableWaitingAndWait(); + Assert.assertFalse("Page contains the given text", driver + .getPageSource().contains("404")); + } + + @Test + public void testOpenNonExistingResource() { + openTestURL(); + $(LinkElement.class).get(1).click(5, 5); + disableWaitingAndWait(); + Assert.assertTrue( + "Page does not contain the given text", + driver.getPageSource().contains( + "/APP/connector/0/4/asdfasdf can not be found")); + } + + @Test + public void testOpenResourceWith404() { + openTestURL(); + $(LinkElement.class).get(2).click(5, 5); + disableWaitingAndWait(); + Assert.assertTrue("Page does not contain the given text", driver + .getPageSource().contains("HTTP ERROR 404")); + Assert.assertTrue("Page does not contain the given text", driver + .getPageSource().contains("Problem accessing /run/APP/")); + } + + @Test + public void testOpenResourceToUIProvider() { + openTestURL(); + $(LinkElement.class).get(3).click(5, 5); + disableWaitingAndWait(); + Assert.assertFalse("Page contains the given text", driver + .getPageSource().contains("can not be found")); + } + + protected void disableWaitingAndWait() { + testBench().disableWaitForVaadin(); + try { + sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/uitest/tb2/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html b/uitest/tb2/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html deleted file mode 100644 index 93b855838c..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -BrowserFrameIsVisible - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BrowserFrameIsVisible
open/run/com.vaadin.tests.components.browserframe.BrowserFrameIsVisible?restartApplication
screenCaptureshow_initial
clickvaadin=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[0]/domChild[0]/domChild[0]
screenCaptureshow_hello
clickvaadin=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]
screenCaptureshow_lorem
clickvaadin=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[2]/domChild[0]/domChild[0]
screenCaptureshow_alternative_text
clickvaadin=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]
screenCaptureshow_lorem2
- - diff --git a/uitest/tb2/com/vaadin/tests/components/flash/FlashIsVisible.html b/uitest/tb2/com/vaadin/tests/components/flash/FlashIsVisible.html deleted file mode 100644 index f3f8f50526..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/flash/FlashIsVisible.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.flash.FlashIsVisible
pause5000
screenCaptureblue-circle
- - diff --git a/uitest/tb2/com/vaadin/tests/requesthandlers/AppResource404.html b/uitest/tb2/com/vaadin/tests/requesthandlers/AppResource404.html deleted file mode 100644 index 543faa30dd..0000000000 --- a/uitest/tb2/com/vaadin/tests/requesthandlers/AppResource404.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - -CloseSubWindow - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CloseSubWindow
open/run/com.vaadin.tests.requesthandlers.AppResource404?restartApplication
mouseClickAndWaitvaadin=runcomvaadintestsrequesthandlersAppResource404::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VLink[0]/domChild[0]/domChild[0]57,3
assertTextNotPresent404
open/run/com.vaadin.tests.requesthandlers.AppResource404
mouseClickAndWaitvaadin=runcomvaadintestsrequesthandlersAppResource404::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VLink[0]/domChild[0]/domChild[0]72,9
assertTextPresent/APP/connector/0/4/asdfasdf can not be found
open/run/com.vaadin.tests.requesthandlers.AppResource404
mouseClickAndWaitvaadin=runcomvaadintestsrequesthandlersAppResource404::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[2]/VLink[0]/domChild[0]/domChild[0]97,5
assertTextPresentHTTP ERROR 404
assertTextPresentProblem accessing /run/APP/
open/run/com.vaadin.tests.requesthandlers.AppResource404
mouseClickAndWaitvaadin=runcomvaadintestsrequesthandlersAppResource404::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VLink[0]/domChild[0]/domChild[0]99,7
assertTextNotPresentcan not be found
- - -- 2.39.5