diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-25 23:31:19 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-04-02 13:34:22 +0300 |
commit | fb30fffdcb4c1e1e07e4ec8c1dc68f8104c911ee (patch) | |
tree | 70978f5238df68b9cf036bd323a74d2d10922337 /server/tests | |
parent | dd157ae121433673c85c3c10b013af404fe2204b (diff) | |
download | vaadin-framework-fb30fffdcb4c1e1e07e4ec8c1dc68f8104c911ee.tar.gz vaadin-framework-fb30fffdcb4c1e1e07e4ec8c1dc68f8104c911ee.zip |
Enable setting default alignment for VerticalLayout, HorizontalLayout, GridLayout (#11421)
Change-Id: I56b14a6a027dc700748f2bd7219b47e1134bb56a
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java | 46 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java | 68 |
2 files changed, 114 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java b/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java new file mode 100644 index 0000000000..2faa65d1f2 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/gridlayout/DefaultAlignment.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.server.component.gridlayout; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.ui.Alignment; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; + +public class DefaultAlignment { + + private GridLayout gridLayout; + + @Before + public void setup() { + gridLayout = new GridLayout(2, 2); + } + + @Test + public void testDefaultAlignment() { + Label label = new Label("A label"); + TextField tf = new TextField("A TextField"); + gridLayout.addComponent(label); + gridLayout.addComponent(tf); + Assert.assertEquals(Alignment.TOP_LEFT, + gridLayout.getComponentAlignment(label)); + Assert.assertEquals(Alignment.TOP_LEFT, + gridLayout.getComponentAlignment(tf)); + } + + @Test + public void testAlteredDefaultAlignment() { + Label label = new Label("A label"); + TextField tf = new TextField("A TextField"); + gridLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); + gridLayout.addComponent(label); + gridLayout.addComponent(tf); + Assert.assertEquals(Alignment.MIDDLE_CENTER, + gridLayout.getComponentAlignment(label)); + Assert.assertEquals(Alignment.MIDDLE_CENTER, + gridLayout.getComponentAlignment(tf)); + } +} diff --git a/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java new file mode 100644 index 0000000000..701373aba0 --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/orderedlayout/DefaultAlignment.java @@ -0,0 +1,68 @@ +package com.vaadin.tests.server.component.orderedlayout; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.ui.AbstractOrderedLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class DefaultAlignment { + + private VerticalLayout verticalLayout; + private HorizontalLayout horizontalLayout; + + @Before + public void setup() { + verticalLayout = new VerticalLayout(); + horizontalLayout = new HorizontalLayout(); + } + + @Test + public void testDefaultAlignmentVerticalLayout() { + testDefaultAlignment(verticalLayout); + } + + @Test + public void testDefaultAlignmentHorizontalLayout() { + testDefaultAlignment(horizontalLayout); + } + + public void testDefaultAlignment(AbstractOrderedLayout layout) { + Label label = new Label("A label"); + TextField tf = new TextField("A TextField"); + layout.addComponent(label); + layout.addComponent(tf); + Assert.assertEquals(Alignment.TOP_LEFT, + layout.getComponentAlignment(label)); + Assert.assertEquals(Alignment.TOP_LEFT, + layout.getComponentAlignment(tf)); + } + + @Test + public void testAlteredDefaultAlignmentVerticalLayout() { + testAlteredDefaultAlignment(verticalLayout); + } + + @Test + public void testAlteredDefaultAlignmentHorizontalLayout() { + testAlteredDefaultAlignment(horizontalLayout); + } + + public void testAlteredDefaultAlignment(AbstractOrderedLayout layout) { + Label label = new Label("A label"); + TextField tf = new TextField("A TextField"); + layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); + layout.addComponent(label); + layout.addComponent(tf); + Assert.assertEquals(Alignment.MIDDLE_CENTER, + layout.getComponentAlignment(label)); + Assert.assertEquals(Alignment.MIDDLE_CENTER, + layout.getComponentAlignment(tf)); + } +} |