aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutSizeChangePropagation.java
blob: b8f898e1f306344a8f99c697baaf7be25a55939d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.vaadin.tests.layouts;

import com.vaadin.tests.components.TestBase;
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.CssLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

public class CssLayoutSizeChangePropagation extends TestBase {

    @Override
    protected void setup() {
        getLayout().setSizeFull();
        final VerticalLayout sp = new VerticalLayout();

        sp.setHeight("100%");

        final CssLayout cssLayout = new CssLayout() {
            @Override
            protected String getCss(Component c) {
                return "background-color: yellow;";
            }
        };
        cssLayout.setSizeFull();
        Label l = new Label("bö");
        l.setSizeFull();
        cssLayout.addComponent(l);

        sp.addComponent(cssLayout);

        Button button = new Button("b");
        button.addClickListener(new ClickListener() {
            boolean bool = true;

            @Override
            public void buttonClick(ClickEvent event) {
                sp.setExpandRatio(cssLayout, bool ? 1 : 0);
                bool = !bool;
            }
        });

        sp.addComponent(button);
        sp.setExpandRatio(button, 1);

        getLayout().addComponent(sp);

    }

    @Override
    protected String getDescription() {
        return "Upper part of view should become yellow on button click.";
    }

    @Override
    protected Integer getTicketNumber() {
        return 4351;
    }

}