// Add an event listener.
EventListener listener = new EventListener() {
@Override
public void onBrowserEvent(Event event) {
Context context = new Context(3, 4, "key");
cell.onBrowserEvent(context, parent, "test-x", event, null);
}
};
DOM.sinkEvents(parent, Event.ONCLICK);
DOM.setEventListener(parent, listener);
// Fire the event on one of the inner cells.
NativeEvent event = Document.get().createClickEvent(0, 0, 0, 0, 0, false,
false, false, false);
Element.as(parent.getChild(2)).dispatchEvent(event);
innerCell.assertLastEventValue("test-x");
innerCell.assertLastParentElement(Element.as(parent.getChild(2)));
Context innerContext = innerCell.getLastContext();
assertEquals("key", innerContext.getKey());
assertEquals(3, innerContext.getIndex());
assertEquals(4, innerContext.getColumn());
// Fire the event to another cell that doesn't consume this event. Shouldn't respond
// to the event
MockCell<String> innerCell2 = (MockCell<String>) cells.get(1).getCell();
Element.as(parent.getChild(1)).dispatchEvent(event);