summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/application/RefreshStatePreserve.java
blob: f4d7f2a4e42e6eaf86c77d908eff4a770b98f6f1 (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
package com.vaadin.tests.application;

import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.server.Page.FragmentChangedEvent;
import com.vaadin.server.Page.FragmentChangedListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Label;

@PreserveOnRefresh
public class RefreshStatePreserve extends AbstractTestUI {

    private Log log = new Log(5);

    @Override
    protected void setup(VaadinRequest request) {
        // Internal parameter sent by vaadinBootstrap.js,
        addComponent(new Label("window.name: " + request.getParameter("wn")));
        addComponent(new Label("UI id: " + getUIId()));
        addComponent(log);

        log.log("Initial fragment: " + getPage().getFragment());
        getPage().addFragmentChangedListener(new FragmentChangedListener() {
            @Override
            public void fragmentChanged(FragmentChangedEvent event) {
                log.log("Fragment changed to " + event.getFragment());
            }
        });
    }

    @Override
    protected String getTestDescription() {
        return "Refreshing the browser window should preserve the state";
    }

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