oracle.add("Cat");
oracle.add("Dog");
oracle.add("Horse");
oracle.add("Canary");
SuggestBox box = new SuggestBox(oracle);
RootPanel.get().add(box);
final List events = new ArrayList();
box.addValueChangeHandler(new ValueChangeHandler() {
@Override
public void onValueChange(ValueChangeEvent event) {
events.add(event);
}
});
box.addSelectionHandler(new SelectionHandler() {
@Override
public void onSelection(SelectionEvent event) {
events.add(event);
finishTest();
}
});
box.getElement().dispatchEvent(Document.get().createChangeEvent());
assertEquals(1, events.size());
box.getElement().setAttribute("value", "Ca");
box.getElement().dispatchEvent(Document.get().createKeyUpEvent(false, false, false, false, 'C'));
//System.out.println("X=" + box.getElement().getParentElement().getInnerHTML());
List<Element> elmts = find(box.getElement(), "item");
assertEquals(2, elmts.size());
elmts.get(0).dispatchEvent(Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false));
// event fired as finally..
//assertEquals(2, events.size());
}