]> source.dussan.org Git - vaadin-framework.git/commitdiff
test case for #5279 and #4607
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 30 Jun 2010 20:34:36 +0000 (20:34 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Wed, 30 Jun 2010 20:34:36 +0000 (20:34 +0000)
svn changeset:13981/svn branch:6.4

tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java
new file mode 100644 (file)
index 0000000..1384bc2
--- /dev/null
@@ -0,0 +1,107 @@
+package com.vaadin.tests.components.combobox;\r
+\r
+import com.vaadin.data.Item;\r
+import com.vaadin.data.Property;\r
+import com.vaadin.data.Property.ValueChangeEvent;\r
+import com.vaadin.data.util.IndexedContainer;\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Button;\r
+import com.vaadin.ui.ComboBox;\r
+import com.vaadin.ui.HorizontalLayout;\r
+import com.vaadin.ui.Label;\r
+import com.vaadin.ui.Table;\r
+import com.vaadin.ui.Button.ClickEvent;\r
+\r
+public class ComboBoxDataSourceChange extends TestBase {\r
+\r
+    private ComboBox cb2;\r
+\r
+    @Override\r
+    protected void setup() {\r
+        final IndexedContainer ds1 = new IndexedContainer();\r
+        // ds1.addContainerProperty("caption", String.class, "");\r
+        for (int i = 0; i < 32; i++) {\r
+            Item addItem = ds1.addItem("ds1-" + i);\r
+        }\r
+\r
+        final IndexedContainer ds2 = new IndexedContainer();\r
+        // ds2.addContainerProperty("caption", String.class, "");\r
+        for (int i = 0; i < 32; i++) {\r
+            Item addItem = ds2.addItem("ds2-" + i);\r
+        }\r
+\r
+        HorizontalLayout hl = new HorizontalLayout();\r
+        hl.setWidth("100%");\r
+\r
+        cb2 = new ComboBox();\r
+        cb2.setImmediate(true);\r
+        hl.addComponent(cb2);\r
+        HorizontalLayout state = new HorizontalLayout();\r
+        hl.addComponent(state);\r
+\r
+        final Label currentValue = new Label();\r
+        currentValue.setCaption("Current Value:");\r
+        currentValue.setSizeUndefined();\r
+        final Label currentDS = new Label();\r
+        currentDS.setCaption("Current DS:");\r
+        currentDS.setSizeUndefined();\r
+        state.addComponent(currentValue);\r
+        state.addComponent(currentDS);\r
+\r
+        Table t = new Table("ds1");\r
+        t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);\r
+        t.setContainerDataSource(ds1);\r
+        state.addComponent(t);\r
+\r
+        Button b = new Button("Use ds1");\r
+        b.addListener(new Button.ClickListener() {\r
+\r
+            public void buttonClick(ClickEvent event) {\r
+                cb2.setContainerDataSource(ds1);\r
+                currentDS.setValue("ds1");\r
+            }\r
+        });\r
+        state.addComponent(b);\r
+\r
+        t = new Table("ds2");\r
+        t.setContainerDataSource(ds2);\r
+        t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);\r
+        state.addComponent(t);\r
+\r
+        b = new Button("Use ds2");\r
+        b.addListener(new Button.ClickListener() {\r
+\r
+            public void buttonClick(ClickEvent event) {\r
+                cb2.setContainerDataSource(ds2);\r
+                currentDS.setValue("ds2");\r
+            }\r
+        });\r
+        state.addComponent(b);\r
+\r
+        addComponent(hl);\r
+\r
+        cb2.addListener(new Property.ValueChangeListener() {\r
+            public void valueChange(ValueChangeEvent event) {\r
+                currentValue.setValue(event.getProperty().getValue());\r
+            }\r
+        });\r
+    }\r
+\r
+    private void populate(ComboBox cb) {\r
+        for (int i = 1; i < 10; i++) {\r
+            cb.addItem("Item " + i);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return "A test for combobox and its container changes.";\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        // TODO should be list of integers applies for #5279\r
+        return 4607;\r
+    }\r
+\r
+}\r