aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-09-07 08:31:20 +0000
committerArtur Signell <artur.signell@itmill.com>2009-09-07 08:31:20 +0000
commitaaccf91b3a0ceabb73ec43bc2fd5e055dcf6976b (patch)
tree92f9e952d36b4a58c9229481bd4473717aeb7651 /src/com
parentd2a8d5a64d4f74af2f84400196e786b55704a685 (diff)
downloadvaadin-framework-aaccf91b3a0ceabb73ec43bc2fd5e055dcf6976b.tar.gz
vaadin-framework-aaccf91b3a0ceabb73ec43bc2fd5e055dcf6976b.zip
Test case for #3289
svn changeset:8682/svn branch:6.1
Diffstat (limited to 'src/com')
-rw-r--r--src/com/vaadin/tests/resources/ResourceDownload.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/com/vaadin/tests/resources/ResourceDownload.java b/src/com/vaadin/tests/resources/ResourceDownload.java
new file mode 100644
index 0000000000..44faa80330
--- /dev/null
+++ b/src/com/vaadin/tests/resources/ResourceDownload.java
@@ -0,0 +1,80 @@
+package com.vaadin.tests.resources;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import com.vaadin.terminal.StreamResource;
+import com.vaadin.terminal.StreamResource.StreamSource;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ResourceDownload extends TestBase {
+
+ @Override
+ public void setup() {
+
+ Button b = new Button("Download (_new)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_new");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download (_blank)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_blank");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download ()", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("");
+ }
+ });
+ addComponent(b);
+
+ b = new Button("Download (_top)", new ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ download("_top");
+ }
+ });
+ addComponent(b);
+
+ }
+
+ protected void download(String target) {
+ String filename = "filename";
+ StreamResource streamResource = new StreamResource(new StreamSource() {
+
+ public InputStream getStream() {
+ try {
+ return new FileInputStream("FIXME C:/temp/file.xls");
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }, filename + ".xls", this);
+ streamResource.setCacheTime(5000); // no cache (<=0) does not work with
+ // IE8
+ streamResource.setMIMEType("application/x-msexcel");
+
+ this.getMainWindow().open(streamResource, target);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Downloading with target _new should work, aswell as with target _blank and _top.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 3289;
+ }
+}