diff options
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOS.java | 45 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java | 39 |
2 files changed, 84 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOS.java b/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOS.java new file mode 100644 index 0000000000..a62b6bba88 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOS.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.extensions; + +import com.vaadin.server.FileDownloader; +import com.vaadin.server.StreamResource; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; + +import java.io.*; + +public class IframeIsOpenedInNonIOS extends AbstractTestUI { + + public static final String FILE_CONTENT = "New text file"; + public static final String FILE_NAME = "textfile.txt"; + + @Override + protected void setup(VaadinRequest request) { + final Label errorLabel = new Label("No error"); + Button button = new Button("Download"); + FileDownloader downloader = new FileDownloader(new StreamResource(new StreamResource.StreamSource() { + @Override + public InputStream getStream () { + return createSomeFile(); + } + }, FILE_NAME)); + downloader.extend(button); + + addComponents(errorLabel, button); + } + + private InputStream createSomeFile() { + return new ByteArrayInputStream(FILE_CONTENT.getBytes()); + } + + @Override + protected Integer getTicketNumber() { + return 15366; + } + + @Override + public String getDescription() { + return "IFrame with a file is not shown in iOS"; + } +} diff --git a/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java b/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java new file mode 100644 index 0000000000..c544b495ab --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/IframeIsOpenedInNonIOSTest.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.extensions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; + +import java.util.List; + +public class IframeIsOpenedInNonIOSTest extends MultiBrowserTest { + + @Test + public void fileOpenedInNewTab() { + openTestURL(); + + $(ButtonElement.class).caption("Download").first().click(); + + List<WebElement> iframes = driver.findElements(By.tagName("iframe")); + boolean containsFileIframe = false; + for (WebElement iframe : iframes) { + containsFileIframe = containsFileIframe | + iframe.getAttribute("src").contains(IframeIsOpenedInNonIOS.FILE_NAME); + } + + Assert.assertTrue("page doesn't contain iframe with the file", containsFileIframe); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + //once running ios is possible, this test should be fixed to exclude it from the browsers list + + //The test is failing in all IEs for some reason even though the iframe is in place. + //Probably related to some IE driver issue + return getBrowsersExcludingIE(); + } +} |