aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxHeightTest.java
blob: 5d78fb5a66da2dc1a864a5b5b0d6149d3c54e801 (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
package com.vaadin.tests.components.combobox;

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

import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class ComboBoxHeightTest extends SingleBrowserTest {

    @Test
    public void testPopupHeight() {
        openTestURL();
        assertPopupHeight();
    }

    @Test
    public void testPopupHeightCustomTheme() {
        openTestURL("theme=tests-valo-combobox-height");
        assertPopupHeight();
    }

    private void assertPopupHeight() {
        ComboBoxElement comboBox = $(ComboBoxElement.class).first();

        comboBox.openPopup();
        WebElement suggestionPopup = comboBox.getSuggestionPopup();

        int suggestionPopupBottom = suggestionPopup.getLocation().getY()
                + suggestionPopup.getSize().getHeight();

        assertGreaterOrEqual(
                "Combo box suggestion popup should not exceed the browser's viewport",
                driver.manage().window().getSize().getHeight(),
                suggestionPopupBottom);
    }
}