Package com.vaadin.tests.server.component.orderedlayout

Source Code of com.vaadin.tests.server.component.orderedlayout.DefaultAlignment

package com.vaadin.tests.server.component.orderedlayout;

import org.junit.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));
    }
}
TOP

Related Classes of com.vaadin.tests.server.component.orderedlayout.DefaultAlignment

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.