aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java
blob: b5454acb82170d37e3ac82a0f6d69415c71cb482 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.vaadin.tests.components.combobox;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

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

import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.testbench.elements.UIElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class ComboboxPopupScrollingTest extends MultiBrowserTest {

    @Test
    public void testNoScrollbarsValo() {
        testNoScrollbars("valo");
    }

    @Test
    public void testNoScrollbarsChameleon() {
        testNoScrollbars("chameleon");
    }

    @Test
    public void testNoScrollbarsRuno() {
        testNoScrollbars("runo");
    }

    @Test
    public void testNoScrollbarsReindeer() {
        testNoScrollbars("reindeer");
    }

    @Test
    public void testComboBoxTracksScrolledPage() {
        openTestURL("theme=valo");

        ComboBoxElement cb = $(ComboBoxElement.class).last();
        cb.openPopup();
        WebElement popup = cb.getSuggestionPopup();
        Point comboLocation = cb.getLocation();
        Point popupLocation = popup.getLocation();

        // scroll page
        $(UIElement.class).first().scroll(100);

        // make sure animation frame is handled
        sleep(500);

        Point newComboLocation = cb.getLocation();
        Point newPopupLocation = popup.getLocation();
        assertNotEquals("ComboBox didn't move on the page", 0,
                newComboLocation.y - comboLocation.y);
        assertEquals("Popup didn't move with the combo box",
                newComboLocation.y - comboLocation.y,
                newPopupLocation.y - popupLocation.y, 1);
    }

    private void testNoScrollbars(String theme) {
        openTestURL("theme=" + theme);

        for (ComboBoxElement cb : $(ComboBoxElement.class).all()) {
            String caption = cb.getCaption();
            cb.openPopup();
            WebElement popup = cb.getSuggestionPopup();
            WebElement scrollable = popup
                    .findElement(By.className("v-filterselect-suggestmenu"));
            assertNoHorizontalScrollbar(scrollable, caption);
            assertNoVerticalScrollbar(scrollable, caption);
        }
    }

}