use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.
the class RadioButtonTest method doClick.
private void doClick(Element elm) {
NativeEvent e = Document.get().createMouseDownEvent(0, 25, 25, 25, 25, false, false, false, false, NativeEvent.BUTTON_LEFT);
elm.dispatchEvent(e);
e = Document.get().createMouseUpEvent(0, 25, 25, 25, 25, false, false, false, false, NativeEvent.BUTTON_LEFT);
elm.dispatchEvent(e);
e = Document.get().createClickEvent(0, 25, 25, 25, 25, false, false, false, false);
elm.dispatchEvent(e);
}
use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.
the class HyperlinkTest method testLinkTraversal.
public void testLinkTraversal() {
final String testHistoryToken = TEST_HISTORY_TOKEN;
Hyperlink link = new Hyperlink("foobar", testHistoryToken);
HandlerRegistration registration = null;
try {
RootPanel.get().add(link);
registration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
assertEquals(testHistoryToken, event.getValue());
assertEquals(testHistoryToken, History.getToken());
}
});
Document document = Document.get();
NativeEvent event = document.createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
link.getElement().dispatchEvent(event);
} finally {
RootPanel.get().remove(link);
if (registration != null) {
registration.removeHandler();
}
}
}
use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.
the class MenuBarTest method testEscapeKey.
public void testEscapeKey() {
// Create a menu bar with children.
MenuBar l0 = new MenuBar();
l0.setAutoOpen(true);
MenuBar l1 = new MenuBar();
l1.setAutoOpen(true);
MenuBar l2 = new MenuBar();
l2.setAutoOpen(true);
MenuItem item2 = l2.addItem("l2", BLANK_COMMAND);
MenuItem item1 = l1.addItem("l1", l2);
MenuItem item0 = l0.addItem("l0", l1);
RootPanel.get().add(l0);
// Open l2.
l0.itemOver(item0, true);
l1.itemOver(item1, true);
l2.itemOver(item2, true);
assertTrue(l0.getPopup().isShowing());
assertEquals(item0, l0.getSelectedItem());
assertTrue(l1.getPopup().isShowing());
assertEquals(item1, l1.getSelectedItem());
// Escape from the menu.
NativeEvent event = Document.get().createKeyDownEvent(false, false, false, false, KeyCodes.KEY_ESCAPE);
l1.getElement().dispatchEvent(event);
/* assertNull(l0.getPopup());
assertNull(l0.getSelectedItem());
assertNull(l1.getPopup());*/
}
use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.
the class DefaultSelectionEventManagerTest method testHandleSelectionEventToggle.
public void testHandleSelectionEventToggle() {
org.gwtproject.view.client.SingleSelectionModel<String> model = new SingleSelectionModel<String>();
display.setSelectionModel(model);
model.setSelected("test 0", true);
// Toggle a different value.
NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
org.gwtproject.view.client.CellPreviewEvent<String> event = new CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
assertEquals("test 1", model.getSelectedObject());
// Toggle the same value.
manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
assertNull(model.getSelectedObject());
}
use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.
the class DefaultSelectionEventManagerTest method testHandleSelectionEventSelect.
public void testHandleSelectionEventSelect() {
org.gwtproject.view.client.SingleSelectionModel<String> model = new org.gwtproject.view.client.SingleSelectionModel<String>();
display.setSelectionModel(model);
model.setSelected("test 0", true);
// Select the same value.
NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
org.gwtproject.view.client.CellPreviewEvent<String> event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(0, 0, null), "test 0", false, false);
manager.handleSelectionEvent(event, SelectAction.SELECT, model);
assertEquals("test 0", model.getSelectedObject());
// Select a different value.
event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
manager.handleSelectionEvent(event, SelectAction.SELECT, model);
assertEquals("test 1", model.getSelectedObject());
}
Aggregations