use of com.google.gwt.event.dom.client.KeyDownHandler in project kie-wb-common by kiegroup.
the class AssignmentListItemWidgetViewImplTest method testDataTypeHandlerSpace.
@Test
public void testDataTypeHandlerSpace() {
view.init();
verify(customDataType, times(1)).setRegExp(eq(StringUtils.ALPHA_NUM_UNDERSCORE_DOT_REGEXP), anyString(), anyString());
verify(customDataType, times(1)).addKeyDownHandler(keyDownHandlerCaptor.capture());
KeyDownHandler handler = keyDownHandlerCaptor.getValue();
doReturn((int) ' ').when(keyDownEvent).getNativeKeyCode();
handler.onKeyDown(keyDownEvent);
verify(keyDownEvent, times(1)).preventDefault();
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project drools-wb by kiegroup.
the class ListBoxSingletonDOMElementFactoryTest method checkDOMElementCreationBlurHandler.
@Test
@SuppressWarnings("unchecked")
public void checkDOMElementCreationBlurHandler() {
final GridBodyCellRenderContext context = mock(GridBodyCellRenderContext.class);
final Consumer<ListBoxDOMElement<String, ListBox>> onCreation = mock(Consumer.class);
final Consumer<ListBoxDOMElement<String, ListBox>> onDisplay = mock(Consumer.class);
when(context.getTransform()).thenReturn(mock(Transform.class));
factory.attachDomElement(context, onCreation, onDisplay);
final ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
verify(listBox, times(4)).addDomHandler(handlerCaptor.capture(), any(DomEvent.Type.class));
// KeyDownHandlerCommon
Assertions.assertThat(handlerCaptor.getAllValues().get(0)).isInstanceOf(KeyDownHandlerCommon.class);
// KeyDownHandler - stopPropagation
final KeyDownEvent keyDownEventMock = mock(KeyDownEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(1)).isInstanceOf(KeyDownHandler.class);
((KeyDownHandler) handlerCaptor.getAllValues().get(1)).onKeyDown(keyDownEventMock);
verify(keyDownEventMock).stopPropagation();
// MouseDownHandler - stopPropagation
final MouseDownEvent mouseDownEventMock = mock(MouseDownEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(2)).isInstanceOf(MouseDownHandler.class);
((MouseDownHandler) handlerCaptor.getAllValues().get(2)).onMouseDown(mouseDownEventMock);
verify(mouseDownEventMock).stopPropagation();
// BlurHandler
final BlurEvent blurEventMock = mock(BlurEvent.class);
Assertions.assertThat(handlerCaptor.getAllValues().get(3)).isInstanceOf(BlurHandler.class);
((BlurHandler) handlerCaptor.getAllValues().get(3)).onBlur(blurEventMock);
verify(factory).flush();
verify(gridLayer).batch();
verify(gridLienzoPanel).setFocus(true);
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project drools-wb by kiegroup.
the class RuleModellerSelectorFilterTest method testKeyDownEvent_KeyEnter.
@Test
public void testKeyDownEvent_KeyEnter() {
verify(txtSearch).addKeyDownHandler(keyDownHandlerArgumentCaptor.capture());
final KeyDownHandler keyDownHandler = keyDownHandlerArgumentCaptor.getValue();
when(keyDownEvent.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER);
keyDownHandler.onKeyDown(keyDownEvent);
verify(filterChangeConsumer).accept(FILTER);
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project drools-wb by kiegroup.
the class RuleModellerSelectorFilterTest method testKeyDownEvent_KeyOther.
@Test
public void testKeyDownEvent_KeyOther() {
verify(txtSearch).addKeyDownHandler(keyDownHandlerArgumentCaptor.capture());
final KeyDownHandler keyDownHandler = keyDownHandlerArgumentCaptor.getValue();
when(keyDownEvent.getNativeKeyCode()).thenReturn(KeyCodes.KEY_A);
keyDownHandler.onKeyDown(keyDownEvent);
verify(filterChangeConsumer, never()).accept(anyString());
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerViewImplTest method testAddKeyDownHandlerAttachesToEditor.
@Test
public void testAddKeyDownHandlerAttachesToEditor() {
// Ensure nobody thinks its a good idea to attach to the RootPanel at some time in the future!
// See https://issues.jboss.org/browse/GUVNOR-3146
final KeyDownHandler handler = mock(KeyDownHandler.class);
view.addKeyDownHandler(handler);
verify(rootPanel, never()).addDomHandler(eq(handler), eq(KeyDownEvent.getType()));
verify(mockGridPanel).addKeyDownHandler(eq(handler));
}
Aggregations