aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/actions/ActionsOnInvisibleComponents.java
blob: 0f4c179ceec7a14e9bbc5edd405ccaac174d3069 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.vaadin.tests.actions;

import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;

public class ActionsOnInvisibleComponents extends AbstractTestUIWithLog {

    private static final long serialVersionUID = -5993467736906948993L;

    @Override
    protected void setup(VaadinRequest request) {
        getContent().setId("test-root");
        log("'A' triggers a click on an invisible button");
        log("'B' triggers a click on a disabled button");
        log("'C' triggers a click on a visible and enabled button");

        Button invisibleButton = new Button("Invisible button with shortcut");
        invisibleButton.setClickShortcut(KeyCode.A);
        invisibleButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                log("Click event for invisible button");
            }
        });

        invisibleButton.setVisible(false);
        addComponent(invisibleButton);

        Button disabledButton = new Button("Disabled button with shortcut");
        disabledButton.setClickShortcut(KeyCode.B);
        disabledButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                log("Click event for disabled button");
            }
        });

        disabledButton.setEnabled(false);
        addComponent(disabledButton);

        Button enabledButton = new Button("Enabled button with shortcut");
        enabledButton.setClickShortcut(KeyCode.C);
        enabledButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                log("Click event for enabled button");
            }
        });

        addComponent(enabledButton);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
     */
    @Override
    protected String getTestDescription() {
        return "Test to ensure actions are not performed on disabled/invisible components";
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
     */
    @Override
    protected Integer getTicketNumber() {
        return 12743;
    }

}