aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaTextFieldCursorPositionTest.java
blob: fdbdf3fb33bfca8f652fb6a0bade1d22b92cd5f8 (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
package com.vaadin.tests.components.textarea;

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

import org.junit.Test;

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

public class TextAreaTextFieldCursorPositionTest extends SingleBrowserTest {

    @Test
    public void positionUpdatedWithoutTextChanges() {
        openTestURL();
        $(ButtonElement.class).id(TextAreaTextFieldCursorPosition.GET_POSITION)
                .click();
        assertEquals("2. TextField position: -1", getLogRow(0));
        assertEquals("1. TextArea position: -1", getLogRow(1));

        $(TextFieldElement.class).first().focus();
        $(TextAreaElement.class).first().focus();
        $(ButtonElement.class).id(TextAreaTextFieldCursorPosition.GET_POSITION)
                .click();
        assertTrue(getLogRow(0).startsWith("4. TextField position:"));
        assertNotEquals("4. TextField position: -1", getLogRow(0));
        assertNotEquals("3. TextArea position: -1", getLogRow(1));
    }
}