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/tickets/Ticket1921.java | |
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/tickets/Ticket1921.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/tickets/Ticket1921.java | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket1921.java b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java new file mode 100644 index 0000000000..ac5f990915 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tickets/Ticket1921.java @@ -0,0 +1,124 @@ +package com.vaadin.tests.tickets; + +import java.io.IOException; +import java.util.Map; + +import com.vaadin.Application; +import com.vaadin.server.RequestHandler; +import com.vaadin.server.WrappedRequest; +import com.vaadin.server.WrappedResponse; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; +import com.vaadin.ui.UI.LegacyWindow; +import com.vaadin.ui.VerticalLayout; + +public class Ticket1921 extends Application.LegacyApplication implements + RequestHandler { + + int state = -1; + int round = 1; + Button button; + VerticalLayout outer, inner; + + @Override + public void init() { + + outer = new VerticalLayout(); + setMainWindow(new LegacyWindow("#1921", outer)); + setTheme("tests-tickets"); + inner = new VerticalLayout(); + outer.addComponent(inner); + button = new Button("foo", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + newState(); + } + }); + inner.addComponent(button); + + outer.setStyleName("red"); + inner.setStyleName("blue"); + + newState(); + + addRequestHandler(this); + } + + public void newState() { + + if (state >= 6) { + state = 0; + round++; + } else { + state++; + } + + button.setCaption("state " + round + "." + state); + + switch (state) { + + case 0: + outer.setMargin(true); + inner.setMargin(true); + inner.setSizeFull(); + outer.setSizeFull(); + button.setSizeFull(); + break; + + case 1: + button.setSizeUndefined(); + break; + + case 2: + inner.setMargin(false); + break; + + case 3: + outer.setMargin(false); + break; + + case 4: + inner.setMargin(true); + break; + + case 5: + inner.addComponent(new Label("Added at " + button.getCaption())); + break; + + case 6: + outer.addComponent(new Label("Added at " + button.getCaption())); + break; + + } + } + + @Override + public boolean handleRequest(Application application, + WrappedRequest request, WrappedResponse response) + throws IOException { + Map<String, String[]> parameters = request.getParameterMap(); + String[] s = parameters.get("state"); + if (s == null || s.length != 1) { + return false; + } + String v[] = s[0].split("\\."); + if (v == null || v.length != 2) { + return false; + } + try { + int rr = Integer.parseInt(v[0]); + int rs = Integer.parseInt(v[1]); + if (rr < round || (rr == round && rs < state)) { + getMainWindow().showNotification( + "Already past requested " + s[0]); + return false; + } + while (round < rr || state < rs) { + newState(); + } + } catch (NumberFormatException ignored) { + } + return false; + } +} |