aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/themes/valo/WindowTitleOverflowTest.java
blob: 825d26f86dd5c17440cc39013ee667a7be64fc5f (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.themes.valo;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.openqa.selenium.WebElement;

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

public class WindowTitleOverflowTest extends MultiBrowserTest {

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

    private void openWindow(String caption) {
        $(ButtonElement.class).caption(caption).first().click();
    }

    private String getWindowHeaderMarginRight() {
        return getWindowHeader().getCssValue("margin-right");
    }

    private WebElement getWindowHeader() {
        return findElement(By.className("v-window-header"));
    }

    @Test
    public void headerMarginIsCorrectForResizable() {
        openWindow("Open Resizable");

        assertThat(getWindowHeaderMarginRight(), is("74px"));
    }

    @Test
    public void headerMarginIsCorrectForClosable() {
        openWindow("Open Closable");

        assertThat(getWindowHeaderMarginRight(), is("37px"));
    }

    @Test
    public void headerMarginIsCorrectForResizableAndClosable() {
        openWindow("Open Resizable and Closable");

        assertThat(getWindowHeaderMarginRight(), is("74px"));
    }

    @Test
    public void headerMarginIsCorrectForNonResizableAndNonClosable() {
        openWindow("Open Non-Resizable and Non-Closable");

        assertThat(getWindowHeaderMarginRight(), is("12px"));
    }
}