From 62116c175f865217252931c909f194c84e515fdf Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 17 Dec 2010 08:29:27 +0000 Subject: [PATCH] Test for #6170 svn changeset:16551/svn branch:6.5 --- .../ComboBoxInvalidNullSelection.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java new file mode 100644 index 0000000000..2fcb44d4f2 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java @@ -0,0 +1,76 @@ +package com.vaadin.tests.components.combobox; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.data.util.IndexedContainer; +import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ComboBox; + +public class ComboBoxInvalidNullSelection extends TestBase { + + private static final Object CAPTION = "C"; + private IndexedContainer ds1; + private IndexedContainer ds2; + private ComboBox combo; + private Log log = new Log(5); + + @Override + protected void setup() { + + createDataSources(); + + Button b = new Button("Swap data source"); + b.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + if (combo.getContainerDataSource() == ds1) { + combo.setContainerDataSource(ds2); + } else { + combo.setContainerDataSource(ds1); + } + combo.setValue("Item 3"); + } + }); + + combo = new ComboBox(); + combo.setImmediate(true); + combo.setContainerDataSource(ds1); + combo.addListener(new ValueChangeListener() { + + public void valueChange(ValueChangeEvent event) { + log.log("Value is now: " + combo.getValue()); + } + }); + addComponent(log); + addComponent(b); + addComponent(combo); + addComponent(new Button("Dummy for TestBench")); + } + + private void createDataSources() { + ds1 = new IndexedContainer(); + ds1.addContainerProperty(CAPTION, String.class, ""); + ds1.addItem("Item 1"); + ds1.addItem("Item 2"); + ds1.addItem("Item 3"); + ds1.addItem("Item 4"); + + ds2 = new IndexedContainer(); + ds2.addContainerProperty(CAPTION, String.class, ""); + ds2.addItem("Item 3"); + + } + + @Override + protected String getDescription() { + return "Select \"Item 3\" in the ComboBox, change the data source, focus and blur the ComboBox. The value should temporarily change to null when changing data source but not when focusing and blurring the ComboBox"; + } + + @Override + protected Integer getTicketNumber() { + return 6170; + } + +} -- 2.39.5