Search in sources :

Example 21 with KeyDownHandler

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();
}
Also used : KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Example 22 with KeyDownHandler

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);
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) EventHandler(com.google.gwt.event.shared.EventHandler) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) GridBodyCellRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Transform(com.ait.lienzo.client.core.types.Transform) MouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler) Test(org.junit.Test)

Example 23 with KeyDownHandler

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);
}
Also used : KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Example 24 with KeyDownHandler

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());
}
Also used : KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Example 25 with KeyDownHandler

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));
}
Also used : KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) Test(org.junit.Test)

Aggregations

KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)25 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)15 Test (org.junit.Test)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)3 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)3 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 CanFocus (org.rstudio.core.client.widget.CanFocus)3 FindTextBox (org.rstudio.core.client.widget.FindTextBox)3 MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)2 MouseDownHandler (com.google.gwt.event.dom.client.MouseDownHandler)2 EventHandler (com.google.gwt.event.shared.EventHandler)2 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)2 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)2 RSConnectPublishButton (org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton)2 Transform (com.ait.lienzo.client.core.types.Transform)1 AccountInfo (com.google.gerrit.client.info.AccountInfo)1