]> source.dussan.org Git - vaadin-framework.git/commitdiff
test case for #4299
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Mar 2010 09:33:44 +0000 (09:33 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 11 Mar 2010 09:33:44 +0000 (09:33 +0000)
svn changeset:11773/svn branch:6.3

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

diff --git a/tests/src/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java b/tests/src/com/vaadin/tests/components/table/TableCacheBuildEfficiency.java
new file mode 100644 (file)
index 0000000..e9055bf
--- /dev/null
@@ -0,0 +1,59 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Property;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class TableCacheBuildEfficiency extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "On each add, row property values should be queried only once (one log row for first addition).";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 4299;
+    }
+
+    @Override
+    protected void setup() {
+
+        final CssLayout log = new CssLayout();
+        log.setWidth("100%");
+
+        final Table table = new Table() {
+            @Override
+            public Property getContainerProperty(Object itemId,
+                    Object propertyId) {
+                log("Fetched container property \"" + propertyId
+                        + "\" for item \"" + itemId + "\"");
+                return super.getContainerProperty(itemId, propertyId);
+            }
+
+            private void log(String string) {
+                log.addComponent(new Label(string));
+
+            }
+        };
+
+        table.addContainerProperty("foo", String.class, "bar");
+
+        Button b = new Button("Click to add row", new Button.ClickListener() {
+
+            public void buttonClick(ClickEvent event) {
+                table.addItem();
+
+            }
+        });
+
+        getLayout().addComponent(table);
+        getLayout().addComponent(b);
+        getLayout().addComponent(log);
+
+    }
+}