aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/menubar/MenuBarHtmlItems.java
blob: 068043c31cb6112b15137bacbc8b55cf74de51bd (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
package com.vaadin.tests.components.menubar;

import java.util.Arrays;
import java.util.List;

import com.vaadin.server.Resource;
import com.vaadin.server.ThemeResource;
import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.ui.Component;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.MenuItem;

public class MenuBarHtmlItems extends ComponentTestCase<MenuBar> {

    @Override
    protected Class<MenuBar> getTestClass() {
        return MenuBar.class;
    }

    @Override
    protected void initializeComponents() {
        MenuBar m = new MenuBar();
        MenuItem submenu = m.addItem("Item <u>1</u>", getMenuIcon(), null);
        MenuItem subsubmenu = submenu.addItem("<b>Bold</b> item", null);
        subsubmenu.addItem("<i><u>I</u>talic</i> item", getMenuIcon(), null);
        submenu.addItem(
                "<span style='font-size: 30px'>Big</span> <span style='font-size: 8px'>disabled</span> item",
                null).setEnabled(false);

        m.addItem("<span style='font-size: 30px'>Big</span> item", null);

        addTestComponent(m);
    }

    private Resource getMenuIcon() {
        return new ThemeResource("../runo/icons/16/user.png");
    }

    @Override
    protected List<Component> createActions() {
        return Arrays.asList(createSwitchHtmlAction());
    }

    private Component createSwitchHtmlAction() {
        return createBooleanAction("Html content allowed", false,
                new Command<MenuBar, Boolean>() {
                    @Override
                    public void execute(MenuBar c, Boolean value, Object data) {
                        c.setHtmlContentAllowed(value.booleanValue());
                    }
                });
    }

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

    @Override
    protected String getTestDescription() {
        return "A menu containing items with embedded html. Items should chould either render the html or show it as plain text depending on the setting.";
    }

}