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/Ticket2119.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/Ticket2119.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/tickets/Ticket2119.java | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2119.java b/uitest/src/com/vaadin/tests/tickets/Ticket2119.java new file mode 100644 index 0000000000..38cc567295 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tickets/Ticket2119.java @@ -0,0 +1,97 @@ +package com.vaadin.tests.tickets; + +import com.vaadin.Application; +import com.vaadin.data.Property; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.server.ExternalResource; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.UI.LegacyWindow; +import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; + +/** + * Test case for Ticket 2119. + */ +public class Ticket2119 extends Application.LegacyApplication { + + private ObjectProperty<String> globalValue; + + @Override + public void init() { + globalValue = new ObjectProperty<String>(null, String.class); + LegacyWindow main = createWindow(); + setMainWindow(main); + } + + @Override + public LegacyWindow getWindow(String name) { + if (!isRunning()) { + return null; + } + // If we already have the requested window, use it + LegacyWindow w = super.getWindow(name); + if (w == null) { + // If no window found, create it + w = createWindow(); + addWindow(w); + w.open(new ExternalResource(w.getURL())); + } + return w; + } + + private LegacyWindow createWindow() { + LegacyWindow main = new LegacyWindow("Test for ticket XXX"); + main.setContent(testLayout()); + return main; + } + + private Layout testLayout() { + final Layout layout = new VerticalLayout(); + final Label label = new Label( + "Instructions to reproduce:\n" + + " - Open this application in two browser windows\n" + + " - Click the Button in first Window\n" + + " - Go to the second Window\n" + + " - Click the arrow in the Select\n" + + " --> The opened list correctly shows the new value but the old one is shown in the \"input\" part"); + label.setContentMode(ContentMode.PREFORMATTED); + layout.addComponent(label); + + final Select select = new Select("Test Select"); + select.setWidth("100px"); + select.setImmediate(true); + select.setNullSelectionAllowed(false); + select.addItem("1"); + select.addItem("2"); + select.addItem("3"); + + final ObjectProperty<String> valueProperty = new ObjectProperty<String>( + "1", String.class); + select.setPropertyDataSource(valueProperty); + layout.addComponent(select); + + globalValue.addListener(new Property.ValueChangeListener() { + @Override + public void valueChange(Property.ValueChangeEvent event) { + Object value = event.getProperty().getValue(); + valueProperty.setValue((null != value) ? value.toString() + : null); + } + }); + + final Button changeValueButton = new Button("Change Value to 2"); + changeValueButton.addListener(new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent event) { + globalValue.setValue("2"); + } + }); + + layout.addComponent(changeValueButton); + + return layout; + } +} |