aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxIdenticalItems.java
blob: 7ea7d8af54a022a509c1f05f3f7e14a6780ea3ba (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
package com.vaadin.tests.components.combobox;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.ComboBox;

public class ComboBoxIdenticalItems extends AbstractReindeerTestUI {

    private Log log = new Log(5);

    @Override
    protected void setup(VaadinRequest request) {
        final ComboBox<String> select = new ComboBox<>("ComboBox");
        select.setItemCaptionGenerator(
                item -> item.startsWith("one") ? "One" : "Two");
        select.setItems("one-1", "one-2", "two");
        select.setEmptySelectionAllowed(false);
        select.addValueChangeListener(
                event -> log.log("Item " + select.getValue() + " selected"));

        addComponent(log);
        addComponent(select);
    }

    @Override
    protected String getTestDescription() {
        return "Keyboard selecting of a value is broken in combobox if two "
                + "items have the same caption. The first item's id is \"one-1\" "
                + "while the second one is \"one-2\". Selecting with mouse works "
                + "as expected but selecting with keyboard always returns the "
                + "object \"one-1\".";
    }

    @Override
    protected Integer getTicketNumber() {
        return 6125;
    }
}