]> source.dussan.org Git - vaadin-framework.git/commitdiff
Yet another layout tester, copied from V7 for reporting bugs in 6.7
authorLeif Åstrand <leif@vaadin.com>
Tue, 10 Jan 2012 11:33:14 +0000 (11:33 +0000)
committerLeif Åstrand <leif@vaadin.com>
Tue, 10 Jan 2012 11:33:14 +0000 (11:33 +0000)
svn changeset:22567/svn branch:6.7

tests/testbench/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java

index ff3c304600948c43ac66c9c7a063500f5bec5af1..d8b01c409985ed53915fe666aa05cb3a940f3cd8 100644 (file)
@@ -11,21 +11,17 @@ import com.vaadin.tests.components.TestBase;
 import com.vaadin.tests.util.TestUtils;
 import com.vaadin.ui.AbstractOrderedLayout;
 import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.NativeSelect;
 import com.vaadin.ui.VerticalLayout;
 
 public class OrderedLayoutCases extends TestBase {
-    private static final String[] dimensionValues = { "-1px", "5px", "350px",
+    private static final String[] dimensionValues = { "-1px", "5px", "300px",
             "800px", "100%", "50%" };
 
     private static class SampleChild extends VerticalLayout {
         public SampleChild() {
-            setStyleName("sampleChild");
+            setStyleName("showBorders");
             addComponent(createSimpleSelector("Child width",
                     new ValueChangeListener() {
                         public void valueChange(ValueChangeEvent event) {
@@ -105,24 +101,18 @@ public class OrderedLayoutCases extends TestBase {
     }
 
     private AbstractOrderedLayout currentLayout;
-    private HorizontalLayout sizeBar;
 
     @Override
-    protected void setup() {
-        TestUtils
-                .injectCSS(
-                        getMainWindow(),
-                        ".sampleChild, .theLayout {border: 1px solid black;}"
-                                + ".theLayout > div > div:first-child {background: aqua;}"
-                                + ".theLayout > div > div:first-child + div {background: yellow;}"
-                                + ".theLayout > div > div:first-child + div + div {background: lightgrey;}");
+    public void setup() {
+        TestUtils.injectCSS(getMainWindow(),
+                ".showBorders {border: 1px solid black};");
 
         currentLayout = new HorizontalLayout();
         for (int i = 0; i < 3; i++) {
             currentLayout.addComponent(new SampleChild());
         }
 
-        sizeBar = new HorizontalLayout();
+        HorizontalLayout sizeBar = new HorizontalLayout();
         sizeBar.setSpacing(true);
 
         sizeBar.addComponent(createSimpleSelector("Layout width",
@@ -139,20 +129,6 @@ public class OrderedLayoutCases extends TestBase {
                                 .toString());
                     }
                 }, dimensionValues));
-        sizeBar.addComponent(createSimpleSelector("Spacing",
-                new ValueChangeListener() {
-                    public void valueChange(ValueChangeEvent event) {
-                        currentLayout.setSpacing(Boolean.parseBoolean(event
-                                .getProperty().getValue().toString()));
-                    }
-                }, "false", "true"));
-        sizeBar.addComponent(createSimpleSelector("Margin",
-                new ValueChangeListener() {
-                    public void valueChange(ValueChangeEvent event) {
-                        currentLayout.setMargin(Boolean.parseBoolean(event
-                                .getProperty().getValue().toString()));
-                    }
-                }, "false", "true"));
         sizeBar.addComponent(createSimpleSelector("Direction",
                 new ValueChangeListener() {
                     public void valueChange(ValueChangeEvent event) {
@@ -169,7 +145,7 @@ public class OrderedLayoutCases extends TestBase {
                             newLayout.addComponent(currentLayout
                                     .getComponent(0));
                         }
-                        newLayout.setStyleName("theLayout");
+                        newLayout.setStyleName("showBorders");
 
                         newLayout.setHeight(currentLayout.getHeight(),
                                 currentLayout.getHeightUnits());
@@ -181,149 +157,15 @@ public class OrderedLayoutCases extends TestBase {
                     }
                 }, "Horizontal", "Vertical"));
 
-        HorizontalLayout caseBar = new HorizontalLayout();
-        caseBar.addComponent(new Button("Undefined without relative",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // width: 350px to middle child
-                        setChildState(1, 0, 2);
-                    }
-                }));
-        caseBar.addComponent(new Button("Undefined with relative",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // width: 100% to middle child
-                        setChildState(1, 0, 4);
-                    }
-                }));
-        caseBar.addComponent(new Button("Fixed with overflow",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // layout width: 350px
-                        setState(sizeBar, 0, 2);
-                        // layout margin enabled
-                        setState(sizeBar, 3, 1);
-                    }
-                }));
-        caseBar.addComponent(new Button("Fixed with extra space",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // Layout width: 800px
-                        setState(sizeBar, 0, 3);
-                        // layout margin enabled
-                        setState(sizeBar, 3, 1);
-                        // width: 350px to middle child
-                        setChildState(1, 0, 2);
-                    }
-                }));
-
-        caseBar.addComponent(new Button("Expand with alignment",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // Layout width: 800px
-                        setState(sizeBar, 0, 3);
-                        // Layout height: 350px
-                        setState(sizeBar, 1, 2);
-                        // Expand: 1 to middle child
-                        setChildState(1, 3, 1);
-                        // Align bottom left to middle child
-                        setChildState(1, 4, 6);
-                    }
-                }));
-
-        caseBar.addComponent(new Button("Multiple expands",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // Layout width: 800px
-                        setState(sizeBar, 0, 3);
-                        // Layout height: 350px
-                        setState(sizeBar, 1, 2);
-                        // Width 350px to middle child
-                        setChildState(1, 0, 2);
-                        // Apply to left and middle child
-                        for (int i = 0; i < 2; i++) {
-                            // Expand: 1
-                            setChildState(i, 3, 1);
-                            // Align: middle center
-                            setChildState(i, 4, 5);
-                        }
-                    }
-                }));
-
-        caseBar.addComponent(new Button("Fixed + relative height",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // Layout height: 100%
-                        setState(sizeBar, 1, 4);
-                        // Height: 350px to left child
-                        setChildState(0, 1, 2);
-                        // Height: 100% to middle child
-                        setChildState(1, 1, 4);
-                        // Alignment: bottom left to right child
-                        setChildState(2, 4, 7);
-                    }
-                }));
-
-        caseBar.addComponent(new Button("Undefined + relative height",
-                new ClickListener() {
-                    public void buttonClick(ClickEvent event) {
-                        resetState();
-                        // Height: 350px to left child
-                        setChildState(0, 1, 2);
-                        // Height: 100% to middle child
-                        setChildState(1, 1, 4);
-                        // Alignment: bottom left to right child
-                        setChildState(2, 4, 7);
-                    }
-                }));
-
-        caseBar.setSpacing(true);
-
-        addComponent(caseBar);
         addComponent(sizeBar);
         addComponent(currentLayout);
 
         getLayout().setSpacing(true);
-        getLayout().getParent().setSizeFull();
+        getMainWindow().getContent().setSizeFull();
         getLayout().setSizeFull();
         getLayout().setExpandRatio(currentLayout, 1);
     }
 
-    private void resetState() {
-        for (int i = 0; i < sizeBar.getComponentCount(); i++) {
-            setState(sizeBar, i, 0);
-        }
-        for (int i = 0; i < 3; i++) {
-            // Child width and height -> -1px
-            SampleChild child = (SampleChild) currentLayout.getComponent(i);
-            for (int j = 0; j < child.getComponentCount(); j++) {
-                if (j == 4) {
-                    setState(child, j, 1);
-                } else {
-                    setState(child, j, 0);
-                }
-            }
-        }
-    }
-
-    private void setChildState(int childIndex, int selectIndex, int valueIndex) {
-        Component child = currentLayout.getComponent(childIndex);
-        setState(child, selectIndex, valueIndex);
-    }
-
-    private static void setState(Component container, int selectIndex, int value) {
-        NativeSelect select = (NativeSelect) ((AbstractOrderedLayout) container)
-                .getComponent(selectIndex);
-        select.setValue(new ArrayList<Object>(select.getItemIds()).get(value));
-    }
-
     private static NativeSelect createSimpleSelector(String caption,
             ValueChangeListener listener, String... values) {
         return createSimpleSelector(caption, listener, Arrays.asList(values),
@@ -343,6 +185,7 @@ public class OrderedLayoutCases extends TestBase {
 
     @Override
     protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
         return null;
     }