diff options
author | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-08-30 17:24:36 +0300 |
commit | 7b25b3886ea95bc6495506fbe9472e45fcbde684 (patch) | |
tree | 0b93cb65dab437feb46720659a63b8f1ef48f7f4 /uitest/src/com/vaadin/tests/appengine | |
parent | 8941056349e302e687e40e94c13709e75f256d73 (diff) | |
download | vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.tar.gz vaadin-framework-7b25b3886ea95bc6495506fbe9472e45fcbde684.zip |
Renamed tests -> uitest and tests/testbench -> uitest/src (#9299)
Diffstat (limited to 'uitest/src/com/vaadin/tests/appengine')
-rw-r--r-- | uitest/src/com/vaadin/tests/appengine/GAESyncTest.java | 156 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/appengine/img1.png | bin | 0 -> 7433 bytes |
2 files changed, 156 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/appengine/GAESyncTest.java b/uitest/src/com/vaadin/tests/appengine/GAESyncTest.java new file mode 100644 index 0000000000..a7d2b03415 --- /dev/null +++ b/uitest/src/com/vaadin/tests/appengine/GAESyncTest.java @@ -0,0 +1,156 @@ +package com.vaadin.tests.appengine; + +import com.google.apphosting.api.DeadlineExceededException; +import com.vaadin.Application; +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.ClassResource; +import com.vaadin.server.DownloadStream; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Embedded; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI.LegacyWindow; + +public class GAESyncTest extends Application.LegacyApplication { + + /** + * + */ + private static final long serialVersionUID = -3724319151122707926l; + + @Override + public void init() { + setMainWindow(new IntrWindow(this)); + + } + + @Override + public void terminalError(com.vaadin.server.Terminal.ErrorEvent event) { + Throwable t = event.getThrowable(); + // Was this caused by a GAE timeout? + while (t != null) { + if (t instanceof DeadlineExceededException) { + getMainWindow().showNotification("Bugger!", + "Deadline Exceeded", Notification.TYPE_ERROR_MESSAGE); + return; + } + t = t.getCause(); + } + + super.terminalError(event); + + } + + private class IntrWindow extends LegacyWindow { + private int n = 0; + private static final long serialVersionUID = -6521351715072191625l; + TextField tf; + Label l; + Application app; + GridLayout gl; + + private IntrWindow(Application app) { + + this.app = app; + tf = new TextField("Echo thingie"); + tf.setImmediate(true); + tf.addListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + IntrWindow.this.showNotification((String) event + .getProperty().getValue()); + + } + + }); + addComponent(tf); + + l = new Label("" + n); + addComponent(l); + + { + Button b = new Button("Slow", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + try { + Thread.sleep(15000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + }); + addComponent(b); + } + + { + Button b = new Button("Add", new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + if (getUI() == getMainWindow()) { + getUI().getPage().showNotification( + new Notification("main")); + try { + Thread.sleep((5000)); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + addImage(); + } + + }); + addComponent(b); + } + + gl = new GridLayout(30, 50); + addComponent(gl); + + } + + private void addImage() { + ClassResource res = new ClassResource("img1.png") { + + private static final long serialVersionUID = 1L; + + @Override + public DownloadStream getStream() { + try { + Thread.sleep((long) (Math.random() * 5000)); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return super.getStream(); + } + + }; + res.setCacheTime(0); + Embedded emb = new Embedded("" + n, res); + emb.setWidth("30px"); + emb.setHeight("5px"); + gl.addComponent(emb); + l.setValue("" + n++); + } + + } + + @Override + public LegacyWindow getWindow(String name) { + LegacyWindow w = super.getWindow(name); + if (w == null) { + w = new IntrWindow(this); + addWindow(w); + } + return w; + + } + +} diff --git a/uitest/src/com/vaadin/tests/appengine/img1.png b/uitest/src/com/vaadin/tests/appengine/img1.png Binary files differnew file mode 100644 index 0000000000..d249324e0c --- /dev/null +++ b/uitest/src/com/vaadin/tests/appengine/img1.png |