]> source.dussan.org Git - vaadin-framework.git/commitdiff
Improvements to #9087:
authorJohannes Dahlström <johannesd@vaadin.com>
Tue, 11 Sep 2012 07:52:56 +0000 (10:52 +0300)
committerJohannes Dahlström <johannesd@vaadin.com>
Tue, 11 Sep 2012 07:52:56 +0000 (10:52 +0300)
* Rename EmbeddedBrowser to BrowserFrame
* Add constructors to Flash and BrowserFrame
* Change getState() methods to protected
* JavaDoc improvements
* Make ImageClicks test deterministic

17 files changed:
client/src/com/vaadin/client/ui/browserframe/BrowserFrameConnector.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/browserframe/VBrowserFrame.java [new file with mode: 0644]
client/src/com/vaadin/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java [deleted file]
client/src/com/vaadin/client/ui/embeddedbrowser/VEmbeddedBrowser.java [deleted file]
server/src/com/vaadin/ui/AbstractEmbedded.java
server/src/com/vaadin/ui/BrowserFrame.java [new file with mode: 0644]
server/src/com/vaadin/ui/Embedded.java
server/src/com/vaadin/ui/EmbeddedBrowser.java [deleted file]
server/src/com/vaadin/ui/Flash.java
server/src/com/vaadin/ui/Image.java
shared/src/com/vaadin/shared/ui/browserframe/BrowserFrameState.java [new file with mode: 0644]
shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java [deleted file]
uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html [deleted file]
uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.java [deleted file]
uitest/src/com/vaadin/tests/components/image/ImageClicks.java

diff --git a/client/src/com/vaadin/client/ui/browserframe/BrowserFrameConnector.java b/client/src/com/vaadin/client/ui/browserframe/BrowserFrameConnector.java
new file mode 100644 (file)
index 0000000..c22d922
--- /dev/null
@@ -0,0 +1,38 @@
+package com.vaadin.client.ui.browserframe;
+
+import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.shared.ui.AbstractEmbeddedState;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.browserframe.BrowserFrameState;
+
+@Connect(com.vaadin.ui.BrowserFrame.class)
+public class BrowserFrameConnector extends AbstractComponentConnector {
+
+    @Override
+    protected void init() {
+        super.init();
+    }
+
+    @Override
+    public VBrowserFrame getWidget() {
+        return (VBrowserFrame) super.getWidget();
+    }
+
+    @Override
+    public BrowserFrameState getState() {
+        return (BrowserFrameState) super.getState();
+    }
+
+    @Override
+    public void onStateChanged(StateChangeEvent stateChangeEvent) {
+
+        super.onStateChanged(stateChangeEvent);
+
+        getWidget().setAlternateText(getState().alternateText);
+        getWidget().setSource(
+                getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE));
+        getWidget().setName(getConnectorId());
+    }
+
+}
diff --git a/client/src/com/vaadin/client/ui/browserframe/VBrowserFrame.java b/client/src/com/vaadin/client/ui/browserframe/VBrowserFrame.java
new file mode 100644 (file)
index 0000000..da2c981
--- /dev/null
@@ -0,0 +1,120 @@
+package com.vaadin.client.ui.browserframe;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.IFrameElement;
+import com.google.gwt.user.client.ui.Widget;
+
+public class VBrowserFrame extends Widget {
+
+    protected IFrameElement iframe;
+    protected Element altElement;
+    protected String altText;
+
+    public VBrowserFrame() {
+        Element root = Document.get().createDivElement();
+        setElement(root);
+
+        setStylePrimaryName("v-browserframe");
+
+        createAltTextElement();
+    }
+
+    /**
+     * Always creates new iframe inside widget. Will replace previous iframe.
+     * 
+     * @return
+     */
+    protected IFrameElement createIFrameElement(String src) {
+        String name = null;
+
+        // Remove alt text
+        if (altElement != null) {
+            getElement().removeChild(altElement);
+            altElement = null;
+        }
+
+        // Remove old iframe
+        if (iframe != null) {
+            name = iframe.getAttribute("name");
+            getElement().removeChild(iframe);
+            iframe = null;
+        }
+
+        iframe = Document.get().createIFrameElement();
+        iframe.setSrc(src);
+        iframe.setFrameBorder(0);
+        iframe.setAttribute("width", "100%");
+        iframe.setAttribute("height", "100%");
+        iframe.setAttribute("allowTransparency", "true");
+
+        getElement().appendChild(iframe);
+
+        // Reset old attributes (except src)
+        if (name != null) {
+            iframe.setName(name);
+        }
+
+        return iframe;
+    }
+
+    protected void createAltTextElement() {
+        if (iframe != null) {
+            return;
+        }
+
+        if (altElement == null) {
+            altElement = Document.get().createSpanElement();
+            getElement().appendChild(altElement);
+        }
+
+        if (altText != null) {
+            altElement.setInnerText(altText);
+        } else {
+            altElement.setInnerText("");
+        }
+    }
+
+    public void setAlternateText(String altText) {
+        if (this.altText != altText) {
+            this.altText = altText;
+            if (altElement != null) {
+                if (altText != null) {
+                    altElement.setInnerText(altText);
+                } else {
+                    altElement.setInnerText("");
+                }
+            }
+        }
+    }
+
+    /**
+     * Set the source (the "src" attribute) of iframe. Will replace old iframe
+     * with new.
+     * 
+     * @param source
+     *            Source of iframe.
+     */
+    public void setSource(String source) {
+
+        if (source == null) {
+            if (iframe != null) {
+                getElement().removeChild(iframe);
+                iframe = null;
+            }
+            createAltTextElement();
+            setAlternateText(altText);
+            return;
+        }
+
+        if (iframe == null || iframe.getSrc() != source) {
+            createIFrameElement(source);
+        }
+    }
+
+    public void setName(String name) {
+        if (iframe != null) {
+            iframe.setName(name);
+        }
+    }
+}
diff --git a/client/src/com/vaadin/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java b/client/src/com/vaadin/client/ui/embeddedbrowser/EmbeddedBrowserConnector.java
deleted file mode 100644 (file)
index 10445db..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.vaadin.client.ui.embeddedbrowser;
-
-import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractComponentConnector;
-import com.vaadin.shared.ui.AbstractEmbeddedState;
-import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState;
-
-@Connect(com.vaadin.ui.EmbeddedBrowser.class)
-public class EmbeddedBrowserConnector extends AbstractComponentConnector {
-
-    @Override
-    protected void init() {
-        super.init();
-    }
-
-    @Override
-    public VEmbeddedBrowser getWidget() {
-        return (VEmbeddedBrowser) super.getWidget();
-    }
-
-    @Override
-    public EmbeddedBrowserState getState() {
-        return (EmbeddedBrowserState) super.getState();
-    }
-
-    @Override
-    public void onStateChanged(StateChangeEvent stateChangeEvent) {
-
-        super.onStateChanged(stateChangeEvent);
-
-        getWidget().setAlternateText(getState().alternateText);
-        getWidget().setSource(
-                getResourceUrl(AbstractEmbeddedState.SOURCE_RESOURCE));
-        getWidget().setName(getConnectorId());
-    }
-
-}
diff --git a/client/src/com/vaadin/client/ui/embeddedbrowser/VEmbeddedBrowser.java b/client/src/com/vaadin/client/ui/embeddedbrowser/VEmbeddedBrowser.java
deleted file mode 100644 (file)
index 3fe1c44..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.vaadin.client.ui.embeddedbrowser;
-
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.IFrameElement;
-import com.google.gwt.user.client.ui.Widget;
-
-public class VEmbeddedBrowser extends Widget {
-
-    protected IFrameElement iframe;
-    protected Element altElement;
-    protected String altText;
-
-    public VEmbeddedBrowser() {
-        Element root = Document.get().createDivElement();
-        setElement(root);
-
-        setStylePrimaryName("v-embeddedbrowser");
-
-        createAltTextElement();
-    }
-
-    /**
-     * Always creates new iframe inside widget. Will replace previous iframe.
-     * 
-     * @return
-     */
-    protected IFrameElement createIFrameElement(String src) {
-        String name = null;
-
-        // Remove alt text
-        if (altElement != null) {
-            getElement().removeChild(altElement);
-            altElement = null;
-        }
-
-        // Remove old iframe
-        if (iframe != null) {
-            name = iframe.getAttribute("name");
-            getElement().removeChild(iframe);
-            iframe = null;
-        }
-
-        iframe = Document.get().createIFrameElement();
-        iframe.setSrc(src);
-        iframe.setFrameBorder(0);
-        iframe.setAttribute("width", "100%");
-        iframe.setAttribute("height", "100%");
-        iframe.setAttribute("allowTransparency", "true");
-
-        getElement().appendChild(iframe);
-
-        // Reset old attributes (except src)
-        if (name != null) {
-            iframe.setName(name);
-        }
-
-        return iframe;
-    }
-
-    protected void createAltTextElement() {
-        if (iframe != null) {
-            return;
-        }
-
-        if (altElement == null) {
-            altElement = Document.get().createSpanElement();
-            getElement().appendChild(altElement);
-        }
-
-        if (altText != null) {
-            altElement.setInnerText(altText);
-        } else {
-            altElement.setInnerText("");
-        }
-    }
-
-    public void setAlternateText(String altText) {
-        if (this.altText != altText) {
-            this.altText = altText;
-            if (altElement != null) {
-                if (altText != null) {
-                    altElement.setInnerText(altText);
-                } else {
-                    altElement.setInnerText("");
-                }
-            }
-        }
-    }
-
-    /**
-     * Set the source (the "src" attribute) of iframe. Will replace old iframe
-     * with new.
-     * 
-     * @param source
-     *            Source of iframe.
-     */
-    public void setSource(String source) {
-
-        if (source == null) {
-            if (iframe != null) {
-                getElement().removeChild(iframe);
-                iframe = null;
-            }
-            createAltTextElement();
-            setAlternateText(altText);
-            return;
-        }
-
-        if (iframe == null || iframe.getSrc() != source) {
-            createIFrameElement(source);
-        }
-    }
-
-    public void setName(String name) {
-        if (iframe != null) {
-            iframe.setName(name);
-        }
-    }
-}
index 5c72141ef90db5dd9b6bf5728e7c7aeaa14b105d..7dcf7ca0917d69998a779f83a23c6725ab21cefa 100644 (file)
@@ -19,7 +19,7 @@ import com.vaadin.shared.ui.AbstractEmbeddedState;
 public abstract class AbstractEmbedded extends AbstractComponent {
 
     @Override
-    public AbstractEmbeddedState getState() {
+    protected AbstractEmbeddedState getState() {
         return (AbstractEmbeddedState) super.getState();
     }
 
diff --git a/server/src/com/vaadin/ui/BrowserFrame.java b/server/src/com/vaadin/ui/BrowserFrame.java
new file mode 100644 (file)
index 0000000..e79e03c
--- /dev/null
@@ -0,0 +1,51 @@
+package com.vaadin.ui;
+
+import com.vaadin.server.Resource;
+import com.vaadin.shared.ui.browserframe.BrowserFrameState;
+
+/**
+ * A component displaying an embedded web page. Implemented as a HTML
+ * <code>iframe</code> element.
+ * 
+ * @author Vaadin Ltd.
+ * @version
+ * @VERSION@
+ * @since 7.0
+ */
+public class BrowserFrame extends AbstractEmbedded {
+
+    /**
+     * Creates a new empty browser frame.
+     */
+    public BrowserFrame() {
+
+    }
+
+    /**
+     * Creates a new empty browser frame with the given caption.
+     * 
+     * @param caption
+     *            The caption for the component
+     */
+    public BrowserFrame(String caption) {
+        setCaption(caption);
+    }
+
+    /**
+     * Creates a new browser frame with the given caption and content.
+     * 
+     * @param caption
+     *            The caption for the component.
+     * @param source
+     *            A Resource representing the Web page that should be displayed.
+     */
+    public BrowserFrame(String caption, Resource source) {
+        this(caption);
+        setSource(source);
+    }
+
+    @Override
+    protected BrowserFrameState getState() {
+        return (BrowserFrameState) super.getState();
+    }
+}
index 3bcd7a26a016b8d299686d26755b4f378b31f518..d61fd442924d522d67114f73aeb8ae762d42e8bd 100644 (file)
@@ -34,9 +34,14 @@ import com.vaadin.shared.ui.embedded.EmbeddedServerRpc;
 /**
  * Component for embedding external objects.
  * <p>
- * As of Vaadin 7.0, the {@link Image}, {@link Flash}, and
- * {@link EmbeddedBrowser} components should be used instead of
- * <code>Embedded</code> whenever appropriate.
+ * As of Vaadin 7.0, the {@link Image}, {@link Flash}, and {@link BrowserFrame}
+ * components should be used instead of <code>Embedded</code> for displaying
+ * images, Adobe Flash objects, and embedded web pages, respectively.
+ * <code>Embedded</code> is still useful for displaying other multimedia content
+ * such as applets and PDF documents.
+ * 
+ * @see Video
+ * @see Audio
  * 
  * @author Vaadin Ltd.
  * @since 3.0
@@ -60,7 +65,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent {
     /**
      * Browser ("iframe") type.
      * 
-     * @deprecated As of 7.0, use the {@link EmbeddedBrowser} component instead.
+     * @deprecated As of 7.0, use the {@link BrowserFrame} component instead.
      */
     @Deprecated
     public static final int TYPE_BROWSER = 2;
diff --git a/server/src/com/vaadin/ui/EmbeddedBrowser.java b/server/src/com/vaadin/ui/EmbeddedBrowser.java
deleted file mode 100644 (file)
index 4e2ae18..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.vaadin.ui;
-
-import com.vaadin.shared.ui.embeddedbrowser.EmbeddedBrowserState;
-
-/**
- * Component for embedding browser "iframe".
- * 
- * @author Vaadin Ltd.
- * @version
- * @VERSION@
- * @since 7.0
- */
-public class EmbeddedBrowser extends AbstractEmbedded {
-
-    @Override
-    public EmbeddedBrowserState getState() {
-        return (EmbeddedBrowserState) super.getState();
-    }
-}
index 430018289a41d63f51f835827dfcd270811d7159..726b6c21c4aa815e2ddba5fbe65fdcaa42cb7640 100644 (file)
@@ -6,10 +6,11 @@ package com.vaadin.ui;
 
 import java.util.HashMap;
 
+import com.vaadin.server.Resource;
 import com.vaadin.shared.ui.flash.FlashState;
 
 /**
- * Component for embedding flash objects.
+ * A component for displaying Adobe® Flash® content.
  * 
  * @author Vaadin Ltd.
  * @version
@@ -19,8 +20,39 @@ import com.vaadin.shared.ui.flash.FlashState;
 @SuppressWarnings("serial")
 public class Flash extends AbstractEmbedded {
 
+    /**
+     * Creates a new empty Flash component.
+     */
+    public Flash() {
+
+    }
+
+    /**
+     * Creates a new empty Flash component with the given caption
+     * 
+     * @param caption
+     *            The caption for the component
+     */
+    public Flash(String caption) {
+        setCaption(caption);
+    }
+
+    /**
+     * Creates a new Flash component with the given caption and content.
+     * 
+     * @param caption
+     *            The caption for the component
+     * @param source
+     *            A Resource representing the Flash content that should be
+     *            displayed
+     */
+    public Flash(String caption, Resource source) {
+        this(caption);
+        setSource(source);
+    }
+
     @Override
-    public FlashState getState() {
+    protected FlashState getState() {
         return (FlashState) super.getState();
     }
 
index 178e557cf3452de6b088872f33e4f9d280bdb9a1..c1b27704d4a4cfdec361c3f8ea1db7de88c17030 100644 (file)
@@ -61,7 +61,7 @@ public class Image extends AbstractEmbedded {
     }
 
     @Override
-    public ImageState getState() {
+    protected ImageState getState() {
         return (ImageState) super.getState();
     }
 
diff --git a/shared/src/com/vaadin/shared/ui/browserframe/BrowserFrameState.java b/shared/src/com/vaadin/shared/ui/browserframe/BrowserFrameState.java
new file mode 100644 (file)
index 0000000..1c36420
--- /dev/null
@@ -0,0 +1,7 @@
+package com.vaadin.shared.ui.browserframe;
+
+import com.vaadin.shared.ui.AbstractEmbeddedState;
+
+public class BrowserFrameState extends AbstractEmbeddedState {
+
+}
diff --git a/shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java b/shared/src/com/vaadin/shared/ui/embeddedbrowser/EmbeddedBrowserState.java
deleted file mode 100644 (file)
index cca4717..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.vaadin.shared.ui.embeddedbrowser;
-
-import com.vaadin.shared.ui.AbstractEmbeddedState;
-
-public class EmbeddedBrowserState extends AbstractEmbeddedState {
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.html
new file mode 100644 (file)
index 0000000..93b8558
--- /dev/null
@@ -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>BrowserFrameIsVisible</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">BrowserFrameIsVisible</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.browserframe.BrowserFrameIsVisible?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>screenCapture</td>
+       <td></td>
+       <td>show_initial</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/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=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/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=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/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=runcomvaadintestscomponentsbrowserframeBrowserFrameIsVisible::/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/browserframe/BrowserFrameIsVisible.java b/uitest/src/com/vaadin/tests/components/browserframe/BrowserFrameIsVisible.java
new file mode 100644 (file)
index 0000000..4e9c133
--- /dev/null
@@ -0,0 +1,116 @@
+package com.vaadin.tests.components.browserframe;
+
+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.BrowserFrame;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.HorizontalLayout;
+
+public class BrowserFrameIsVisible 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 BrowserFrame browser = new BrowserFrame();
+        browser.setId("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.addClickListener(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.addClickListener(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.addClickListener(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);
+
+        }
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html b/uitest/src/com/vaadin/tests/components/embeddedbrowser/EmbeddedBrowserIsVisible.html
deleted file mode 100644 (file)
index 2d76cd4..0000000
+++ /dev/null
@@ -1,67 +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>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
deleted file mode 100644 (file)
index 2eaf712..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-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);
-
-        }
-    }
-
-}
index e2d983b7ced5860f7c188a21b0b4309944324891..e50b8c3a4f73ee49d9caf8d0e6121d563487a8b3 100644 (file)
@@ -7,6 +7,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Random;
 
 import javax.imageio.ImageIO;
 
@@ -19,6 +20,8 @@ import com.vaadin.ui.Label;
 
 public class ImageClicks extends TestBase {
 
+    private final Random rng = new Random(0);
+
     private int clickCounter = 0;
 
     @Override
@@ -32,7 +35,7 @@ public class ImageClicks extends TestBase {
         final StreamResource imageResource = new StreamResource(imageSource,
                 "testimage.png");
         image.setSource(imageResource);
-        image.addListener(new ClickListener() {
+        image.addClickListener(new ClickListener() {
 
             @Override
             public void click(ClickEvent event) {
@@ -107,7 +110,7 @@ public class ImageClicks extends TestBase {
                     }
 
                     // Cell
-                    if (Math.random() < 0.5f) {
+                    if (rng.nextFloat() < 0.5f) {
                         drawable.setColor(Color.white);
                     } else {
                         drawable.setColor(Color.black);