aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/tabsheet/AddAndRemoveTabs.java
blob: 4b5d216906c00833d870d6426d328858a493de49 (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.components.tabsheet;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TabSheet;

public class AddAndRemoveTabs extends TestBase {
    private TabSheet tabSheet;

    private int counter = 0;

    @Override
    public void setup() {
        tabSheet = new TabSheet();
        addTab();
        addComponent(tabSheet);

        Button addTabBtn = new Button("Add new tab",
                new Button.ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        addTab();
                    }

                });
        addComponent(addTabBtn);
    }

    private void addTab() {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setCaption("Test " + counter);

        Button closeTab = new Button("Close tab", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                tabSheet.removeComponent(layout);

            }

        });

        layout.addComponent(closeTab);

        tabSheet.addComponent(layout);
        counter++;
    }

    @Override
    protected String getDescription() {
        return "Removing all tabs and then adding new tabs should work properly and without javascript errors. All new tabs should be displayed and not only the first one";
    }

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

}