]> source.dussan.org Git - vaadin-framework.git/commitdiff
test case for #5227
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 24 Jun 2010 16:57:11 +0000 (16:57 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 24 Jun 2010 16:57:11 +0000 (16:57 +0000)
svn changeset:13926/svn branch:6.4

tests/src/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java [new file with mode: 0644]

diff --git a/tests/src/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java b/tests/src/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
new file mode 100644 (file)
index 0000000..87b04ff
--- /dev/null
@@ -0,0 +1,80 @@
+package com.vaadin.tests.layouts;
+
+import com.vaadin.terminal.Sizeable;
+import com.vaadin.tests.components.AbstractTestCase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase {
+    private int cols;
+
+    @Override
+    protected String getDescription() {
+        return "Buttons should stay stacked on left when clicking new button";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5227;
+    }
+
+    @Override
+    public void init() {
+        final VerticalLayout mainLayout = new VerticalLayout();
+
+        mainLayout.setSpacing(true);
+        mainLayout.setMargin(true);
+        mainLayout.setHeight(100, Sizeable.UNITS_PERCENTAGE);
+        mainLayout.setWidth(100, Sizeable.UNITS_PERCENTAGE);
+        setMainWindow(new Window("Vaadin Test", mainLayout));
+
+        cols = 1;
+        final GridLayout gl = new GridLayout(cols, 3);
+        gl.setWidth("1000px");
+        // textfield spreads across all cols
+        final TextField textfield = new TextField();
+        textfield.setWidth(100, Sizeable.UNITS_PERCENTAGE);
+        Button b1 = new Button("new button");
+        Button b2 = new Button("nothing");
+        gl.addComponent(textfield, 0, 0);
+        gl.addComponent(b1, 0, 1);
+        gl.addComponent(b2, 0, 2);
+        b1.setWidth(270, Sizeable.UNITS_PIXELS);
+        b2.setWidth(270, Sizeable.UNITS_PIXELS);
+        b1.addListener(new Button.ClickListener() {
+            public void buttonClick(Button.ClickEvent event) {
+                cols++;
+                gl.setColumns(cols);
+                Button b1 = new Button("new button" + cols);
+                Button b2 = new Button("nothing" + cols);
+                gl.addComponent(b1, cols - 1, 1);
+                gl.addComponent(b2, cols - 1, 2);
+                b1.setWidth(270, Sizeable.UNITS_PIXELS);
+                b2.setWidth(270, Sizeable.UNITS_PIXELS);
+                // adjust expand ratios...
+                if (cols > 0) {
+                    // next to last colum 0, last column 100
+                    gl.setColumnExpandRatio(cols - 2, 0);
+                    gl.setColumnExpandRatio(cols - 1, 100);
+                }
+                gl.removeComponent(textfield);
+                gl.addComponent(textfield, 0, 0, cols - 1, 0);
+            }
+        });
+        gl.setSizeFull();
+        mainLayout.addComponent(gl);
+        mainLayout.setExpandRatio(gl, 100);
+        Button restart = new Button("restart");
+        mainLayout.addComponent(restart);
+        restart.addListener(new Button.ClickListener() {
+            public void buttonClick(Button.ClickEvent event) {
+                mainLayout.getWindow().getApplication().close();
+            }
+        });
+
+    }
+
+}