aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-01-23 08:52:48 +0000
committerMarc Englund <marc.englund@itmill.com>2009-01-23 08:52:48 +0000
commitf4108eb0c20b72a6344b6d00fc296e6cb5fa1660 (patch)
treef0a1d6a1b017e2945216a0dc223564777b380080 /src
parent9c72d0f4831eeac9201dac319d9c331cdbd5c0bd (diff)
downloadvaadin-framework-f4108eb0c20b72a6344b6d00fc296e6cb5fa1660.tar.gz
vaadin-framework-f4108eb0c20b72a6344b6d00fc296e6cb5fa1660.zip
Expanded testcase for #2470
svn changeset:6622/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/tests/components/embedded/EmbeddedImageRefresh.java58
1 files changed, 37 insertions, 21 deletions
diff --git a/src/com/itmill/toolkit/tests/components/embedded/EmbeddedImageRefresh.java b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedImageRefresh.java
index 94510ae33e..db7f8b3467 100644
--- a/src/com/itmill/toolkit/tests/components/embedded/EmbeddedImageRefresh.java
+++ b/src/com/itmill/toolkit/tests/components/embedded/EmbeddedImageRefresh.java
@@ -7,6 +7,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Date;
import javax.imageio.ImageIO;
@@ -36,47 +37,62 @@ public class EmbeddedImageRefresh extends TestBase {
// Attach it to a resource.
final MyImageSource imageSource = new MyImageSource();
- final StreamResource imageResource = new StreamResource(imageSource, "testimage.png", this);
+ final StreamResource imageResource = new StreamResource(imageSource,
+ "testimage.png", this);
imageResource.setCacheTime(0);
embedded.setSource(imageResource);
// The button requests repainting the embedded.
- Button button = new Button ("Click to Update");
+ Button button = new Button("refr");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- embedded.requestRepaint();
- }
+ embedded.requestRepaint();
+ }
});
addComponent(button);
-
- // Replace the resource. This is a workaround for
- // the problem, but can't say it works very nicely either.
- Button button2 = new Button ("Click to Replace");
- button2.addListener(new Button.ClickListener() {
+ button = new Button("refr name");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ ((StreamResource) embedded.getSource()).setFilename(new Date()
+ .getTime()
+ + ".png");
+ embedded.requestRepaint();
+ }
+ });
+ addComponent(button);
+ button = new Button("200x200");
+ button.addListener(new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ embedded.setWidth("200px");
+ embedded.setHeight("200px");
+ }
+ });
+ addComponent(button);
+ button = new Button("undef");
+ button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
- final StreamResource imageResource =
- new StreamResource(imageSource, "testimage.png",
- getMainWindow().getApplication());
- embedded.setSource(imageResource);
- }
+ embedded.setSizeUndefined();
+ }
});
- addComponent(button2);
+ addComponent(button);
+
}
public class MyImageSource implements StreamResource.StreamSource {
public MyImageSource() {
}
-
+
int intervalPos(int pos, int resolution, int cells) {
- return (int) Math.round(pos*resolution/(cells*1.0));
+ return (int) Math.round(pos * resolution / (cells * 1.0));
}
public InputStream getStream() {
// Create an image and draw some background on it.
- BufferedImage image = new BufferedImage (640, 480, BufferedImage.TYPE_INT_RGB);
+ BufferedImage image = new BufferedImage(640, 480,
+ BufferedImage.TYPE_INT_RGB);
Graphics drawable = image.getGraphics();
-
- // Background
+
+ // Background
drawable.setColor(Color.white);
drawable.fillRect(0, 0, 640, 480);
@@ -111,7 +127,7 @@ public class EmbeddedImageRefresh extends TestBase {
drawable.setColor(Color.black);
}
drawable.fillRect(gridx + 1, gridy + 1, gridxnext - gridx
- - 1, gridynext - gridy - 1);
+ - 1, gridynext - gridy - 1);
}
}