aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testbench/com/vaadin/tests/components/root/RootsInMultipleTabs.java
blob: ae3182401d3a0171df04030749e336a22eddfaec (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
package com.vaadin.tests.components.root;

import com.vaadin.Application;
import com.vaadin.RootRequiresMoreInformationException;
import com.vaadin.terminal.AbstractRootProvider;
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.tests.components.AbstractTestApplication;
import com.vaadin.ui.Label;
import com.vaadin.ui.Root;

public class RootsInMultipleTabs extends AbstractTestApplication {
    private int numberOfRootsOpened;

    public static class TabRoot extends Root {
        @Override
        protected void init(WrappedRequest request) {
            RootsInMultipleTabs application = (RootsInMultipleTabs) getApplication();
            String message = "This is root number "
                    + ++application.numberOfRootsOpened;

            addComponent(new Label(message));
        }
    }

    public RootsInMultipleTabs() {
        addRootProvider(new AbstractRootProvider() {
            @Override
            public Class<? extends Root> getRootClass(Application application,
                    WrappedRequest request)
                    throws RootRequiresMoreInformationException {
                return TabRoot.class;
            }
        });
    }

    @Override
    protected String getTestDescription() {
        return "Opening the same application again (e.g. in a new tab) should create a new Root.";
    }

    @Override
    protected Integer getTicketNumber() {
        return Integer.valueOf(7894);
    }
}