diff options
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/embeddedbrowser')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html | 67 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java | 116 |
2 files changed, 183 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html b/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html new file mode 100644 index 0000000000..2d76cd48b2 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.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="" /> +<title>EmbeddedBrowserIsVisible</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">EmbeddedBrowserIsVisible</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.embeddedbrowser.EmbeddedBrowserIsVisible?restartApplication</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>show_initial</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>show_hello</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>show_lorem</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[2]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>show_alternative_text</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentsembeddedbrowserEmbeddedBrowserIsVisible::/VVerticalLayout[0]/VVerticalLayout[0]/VHorizontalLayout[0]/VButton[1]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>show_lorem2</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java b/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java new file mode 100644 index 0000000000..2eaf712676 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java @@ -0,0 +1,116 @@ +package com.vaadin.tests.components.embeddedbrowser; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; + +import com.vaadin.server.StreamResource; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.EmbeddedBrowser; +import com.vaadin.ui.HorizontalLayout; + +public class EmbeddedBrowserIsVisible extends TestBase { + + @Override + protected void setup() { + + HorizontalLayout buttonLayout = new HorizontalLayout(); + addComponent(buttonLayout); + + Button page1 = new Button("Hello World"); + buttonLayout.addComponent(page1); + + Button page2 = new Button("Lorem ipsum"); + buttonLayout.addComponent(page2); + + Button page3 = new Button("null"); + buttonLayout.addComponent(page3); + + final EmbeddedBrowser browser = new EmbeddedBrowser(); + browser.setDebugId("browser"); + browser.setWidth("600px"); + browser.setHeight("300px"); + browser.setAlternateText("Browser alternative text"); + final TextSource textSource = new TextSource("initial"); + final StreamResource textResource = new StreamResource(textSource, + "initial.txt"); + textResource.setMIMEType("text/plain"); + browser.setSource(textResource); + addComponent(browser); + + page1.addListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + TextSource helloSource = new TextSource("Hello World"); + StreamResource helloResource = new StreamResource(helloSource, + "helloworld.txt"); + helloResource.setMIMEType("text/plain"); + browser.setSource(helloResource); + } + }); + + page2.addListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + TextSource helloSource = new TextSource("Lorem Ipsum"); + StreamResource helloResource = new StreamResource(helloSource, + "loremipsum.txt"); + helloResource.setMIMEType("text/plain"); + browser.setSource(helloResource); + } + }); + + page3.addListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + browser.setSource(null); + } + }); + } + + @Override + protected String getDescription() { + return "Embedded browser should be visible for all browsers"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + + public class TextSource implements StreamResource.StreamSource { + private String text; + + public TextSource(String text) { + this.text = text; + } + + @Override + public InputStream getStream() { + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 200; ++i) { + sb.append(text); + sb.append("\n"); + } + + ByteArrayInputStream istream; + try { + istream = new ByteArrayInputStream(sb.toString().getBytes( + "UTF-8")); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + return istream; // new DownloadStream (istream,null,null); + + } + } + +} |