aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/notification/NotificationsHtmlAllowed.java
blob: ba11695c06f72b3f2590425853d2e50a9dbeee1b (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
package com.vaadin.tests.components.notification;

import com.vaadin.server.Page;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Notification;
import com.vaadin.v7.ui.TextArea;
import com.vaadin.v7.ui.TextField;

public class NotificationsHtmlAllowed extends TestBase
        implements ClickListener {

    private TextArea messageField;
    private CheckBox htmlAllowedBox;
    private TextField captionField;

    @Override
    protected void setup() {
        captionField = new TextField("Caption", "Hello <u>world</u>");
        addComponent(captionField);
        captionField.focus();

        messageField = new TextArea("Message",
                "Hello <i>world</i>\nWith a newline <br/>And a html line break");
        messageField.setRows(10);
        addComponent(messageField);

        htmlAllowedBox = new CheckBox("Html content allowed", true);
        addComponent(htmlAllowedBox);

        Button showNotification = new Button("Show notification", this);
        addComponent(showNotification);
    }

    @Override
    protected String getDescription() {
        return "Test case for htmlAllowed in notifications";
    }

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

    @Override
    public void buttonClick(ClickEvent event) {
        Notification n = makeNotification();
        n.show(Page.getCurrent());
    }

    private Notification makeNotification() {
        Notification n = new Notification(captionField.getValue(),
                messageField.getValue(), Notification.TYPE_HUMANIZED_MESSAGE,
                htmlAllowedBox.getValue());
        return n;
    }
}