aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldEventOrderTest.java
blob: 642a6c7a3955b40f34f27691e584095cb8257d01 (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
package com.vaadin.tests.components.datefield;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.Select;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.DateTimeFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class DateTimeFieldEventOrderTest extends SingleBrowserTest {

    @Test
    public void testEventOrderIsCorrect() {
        openTestURL();

        DateTimeFieldElement field = $(DateTimeFieldElement.class).first();

        field.findElement(By.className("v-datefield-button")).click();

        List<WebElement> timeSelects = findElement(
                By.className("v-datefield-calendarpanel-time"))
                        .findElements(By.tagName("select"));

        Select select = new Select(timeSelects.get(0));
        // select two different times to ensure a value change happens
        select.selectByValue("09");
        select.selectByValue("08");

        findElement(By.id("test-button")).click();
        waitUntil(new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver arg0) {
                return !" ".equals(getLogRow(1));
            }

            @Override
            public String toString() {
                // waiting for ...
                return "log row 1 to get content";
            }
        });

        assertEquals("The button click event should come second.",
                "2. Button Click Event", getLogRow(0));
        assertEquals("The value change event of DTF should come firstly.",
                "1. DateTimeField value change event", getLogRow(1));

    }
}