aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxMixedUpdateTest.java
blob: 8644f829e3f5de6bc9ab1eb8251a1c99041a63f3 (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
package com.vaadin.tests.components.combobox;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.ComboBoxElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class ComboBoxMixedUpdateTest extends MultiBrowserTest {

    private ComboBoxElement comboBox;
    private ButtonElement reset;
    private ButtonElement show;

    @Override
    public void setup() throws Exception {
        super.setup();

        openTestURL();
        waitForElementPresent(By.className("v-filterselect"));
        comboBox = $(ComboBoxElement.class).first();
        reset = $(ButtonElement.class).id("reset");
        show = $(ButtonElement.class).id("show");
    }

    private void sendKeysToInput(CharSequence... keys) {
        comboBox.clear();
        // ensure mouse is located over the ComboBox to avoid hover issues
        new Actions(getDriver()).moveToElement(comboBox).perform();
        comboBox.sendKeys(keys);
    }

    @Test
    public void testMixedUpdateWorks() {
        comboBox.focus();
        sendKeysToInput("2", Keys.TAB);
        show.click();
        assertEquals("1. Bean value = 2 - ComboBox value = 2", getLogRow(0));
        reset.click();
        show.click();
        assertEquals("2. Bean value = 0 - ComboBox value = 0", getLogRow(0));
        sendKeysToInput("2", Keys.TAB);
        show.click();
        assertEquals("3. Bean value = 2 - ComboBox value = 2", getLogRow(0));
    }
}