aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/VLayout/VComponentSizingTest.java
blob: 16925e6339f875655c154a36768b862804abde6c (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
package com.vaadin.tests.layouts.layouttester.VLayout;

import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.util.List;

import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.VerticalLayoutElement;
import com.vaadin.tests.layouts.layouttester.BaseComponentSizingTest;

public class VComponentSizingTest extends BaseComponentSizingTest {

    @Override
    public void ComponentSizing() throws IOException, InterruptedException {
        openTestURL();
        sleep(500);

        // The layout is too high to fit into one screenshot, we need to scroll
        // down to see relevant content. And keep doing it since interacting
        // with the controls scrolls back up again.

        List<VerticalLayoutElement> layouts = $(VerticalLayoutElement.class)
                .all();
        assertEquals(5, layouts.size());
        VerticalLayoutElement lastLayout = layouts.get(4);

        compareScreen("initial");

        new Actions(driver).moveToElement(lastLayout).build().perform();
        compareScreen("scrolled");

        String[] states = { "setSize350px", "setSize_-1px", "setSize75Percent",
                "setSize100Percent" };
        List<ButtonElement> buttons = $(ButtonElement.class).all();
        int index = 0;
        // go through all buttons click them and see result
        for (ButtonElement btn : buttons) {
            btn.click();
            sleep(500);
            new Actions(driver).moveToElement(lastLayout).build().perform();
            compareScreen(states[index]);

            index++;
        }
    }
}