aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
blob: f3bfa402da5e0c113ecad05e0bbf562d023d31db (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
package com.vaadin.tests.components.tabsheet;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.ui.TextField;

public class TabSheetDiscardsMovedComponents extends TestBase {

    private GridLayout grid = new GridLayout();
    private TabSheet tabSheet = new TabSheet();

    @Override
    public void setup() {
        tabSheet.addTab(new Label("The tabSheet"), "Initial content");
        tabSheet.setSizeUndefined();

        grid.setColumns(2);
        TextField textField = new TextField("Text field");
        textField.setValue("Text");
        addTestComponent(textField);
        addTestComponent(new Button("Button"));

        addComponent(tabSheet);
        addComponent(grid);
    }

    private void addTestComponent(final Component component) {
        grid.addComponent(component);
        grid.addComponent(new Button("Move to tab", event -> {
            tabSheet.addTab(component);
            grid.removeComponent(event.getButton());
        }));
    }

    @Override
    protected String getDescription() {
        return "Moving an already rendered component to a tabsheet and not immediately selecting the new tab should cause no problems";
    }

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

}