aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/v7/tests/components/textfield/TextChangeEventsTest.java
blob: 47cc3c1a2693849dca43b280652b133905f694b9 (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
package com.vaadin.v7.tests.components.textfield;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.vaadin.testbench.elements.TextAreaElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class TextChangeEventsTest extends SingleBrowserTest {

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

        TextAreaElement taDefault = $(TextAreaElement.class)
                .caption("Default text area").first();
        taDefault.sendKeys("abc");
        assertEquals(
                "1. Text change event for Default text area, text content currently:'abc' Cursor at index:3",
                getLogRow(0));

        TextAreaElement taTimeout = $(TextAreaElement.class)
                .caption("Timeout 3s").first();
        taTimeout.sendKeys("abc");
        assertEquals(
                "2. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3",
                getLogRow(0));

    }

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

        TextFieldElement tfDefault = $(TextFieldElement.class)
                .caption("Default").first();
        tfDefault.sendKeys("abc");
        assertEquals(
                "1. Text change event for Default, text content currently:'abc' Cursor at index:3",
                getLogRow(0));

        TextFieldElement tfEager = $(TextFieldElement.class).caption("Eager")
                .first();
        tfEager.sendKeys("abc");
        assertEquals(
                "2. Text change event for Eager, text content currently:'abc' Cursor at index:3",
                getLogRow(0));

        TextFieldElement tfTimeout = $(TextFieldElement.class)
                .caption("Timeout 3s").first();
        tfTimeout.sendKeys("abc");
        assertEquals(
                "3. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3",
                getLogRow(0));

    }
}