aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/panel/PanelShouldNotScroll.java
blob: 15ca0d521ed8c638d65deb031c476a7ea29223ac (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
package com.vaadin.tests.components.panel;

import com.vaadin.shared.ui.label.ContentMode;
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.Panel;
import com.vaadin.ui.VerticalLayout;

public class PanelShouldNotScroll extends TestBase {

    private Button addMore;

    @Override
    protected void setup() {
        final CssLayout pl = new CssLayout();
        final Panel p = new Panel(pl);
        p.setSizeFull();
        p.setHeight("600px");
        pl.addComponent(foo());
        addMore = new Button("Add");
        addMore.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                pl.removeComponent(addMore);
                pl.addComponent(foo());
                pl.addComponent(addMore);
            }
        });
        pl.addComponent(addMore);
        addComponent(p);
        ((VerticalLayout) getMainWindow().getContent()).setSizeFull();
    }

    private Component foo() {
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        Panel panel = new Panel(layout);
        layout.addComponent(new Label(
                "fooooooooo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>"
                        + "foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>foo<br/>",
                ContentMode.HTML));
        return panel;
    }

    @Override
    protected String getDescription() {
        return "adding a panel to the bottom of the scrolling panel should not scroll up to the top";
    }

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

}