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

import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.ComboBox;

public class ComboBoxIdenticalItems extends TestBase {

    private Log log = new Log(5);

    @Override
    public void setup() {
        final ComboBox select = new ComboBox("ComboBox");
        select.addContainerProperty("caption", String.class, null);
        Item item = select.addItem("one-1");
        item.getItemProperty("caption").setValue("One");
        item = select.addItem("one-2");
        item.getItemProperty("caption").setValue("One");
        item = select.addItem("two");
        item.getItemProperty("caption").setValue("Two");
        select.setItemCaptionPropertyId("caption");
        select.setNullSelectionAllowed(false);
        select.setImmediate(true);
        select.addListener(new Property.ValueChangeListener() {
            private static final long serialVersionUID = -7932700771673919620L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                log.log("Item " + select.getValue() + " selected");

            }
        });

        addComponent(log);
        addComponent(select);
    }

    @Override
    protected String getDescription() {
        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() {
        // TODO Auto-generated method stub
        return null;
    }
}