aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/elements/notification/NotificationCloseEventTest.java
blob: e8db79d95cf84f128e5db99799a6b07d4968416a (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
package com.vaadin.tests.elements.notification;

import org.junit.Assert;
import org.junit.Test;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class NotificationCloseEventTest extends SingleBrowserTest {

    @Override
    protected Class<?> getUIClass() {
        return NotificationGetTypeAndDescription.class;
    }

    @Test
    public void testCloseByUser() {
        openTestURL();
        ButtonElement error = $(ButtonElement.class).caption("error").first();
        error.click();
        $(NotificationElement.class).get(0).close();
        Assert.assertEquals("1. Notification (error) closed by user",
                getLogRow(0));
    }

    @Test
    public void testCloseByServer() {
        openTestURL();
        ButtonElement warning = $(ButtonElement.class).caption("warning")
                .first();
        warning.click();
        ButtonElement close = $(ButtonElement.class)
                .caption("Hide all notifications").first();
        close.click();

        Assert.assertEquals("1. Notification (warning) closed from server",
                getLogRow(0));
    }

    @Test
    public void notificationsStayAwayAfterRefresh() {
        openTestURL();
        ButtonElement warning = $(ButtonElement.class).caption("warning")
                .first();
        warning.click();
        $(NotificationElement.class).first().close();
        openTestURL();

        Assert.assertEquals(0, $(NotificationElement.class).all().size());
    }
}