aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/window/CloseSubWindowTest.java
blob: 48ac923082722205bb67a2b96fc2fa26c4739e27 (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
package com.vaadin.tests.components.window;

import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class CloseSubWindowTest extends MultiBrowserTest {

    @Override
    public void setup() throws Exception {
        super.setup();
        openTestURL();
        openSubWindow();
    }

    @Test
    public void testClosingFromClickHandler() throws Exception {
        $(WindowElement.class).$(ButtonElement.class).first().click();
        assertLogText();
    }

    @Test
    public void testClosingFromTitleBar() throws Exception {
        $(WindowElement.class).first()
                .findElement(By.className("v-window-closebox")).click();
        assertLogText();
    }

    @Test
    public void testClosingByRemovingFromUI() throws Exception {
        $(WindowElement.class).$(ButtonElement.class).get(1).click();
        assertLogText();
    }

    private void openSubWindow() {
        $(ButtonElement.class).id("opensub").click();
    }

    private void assertLogText() {
        Assert.assertEquals("Unexpected log contents,",
                "1. Window 'Sub-window' closed", getLogRow(0));
    }
}