Search in sources :

Example 36 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project kie-wb-common by kiegroup.

the class ZoomLevelSelectorViewTest method testOnDropDownKeyEvents.

@Test
public void testOnDropDownKeyEvents() {
    tested.init(presenter);
    KeyDownEvent keyDownEvent = mock(KeyDownEvent.class);
    tested.onDropDownKeyDown(keyDownEvent);
    verify(keyDownEvent, times(1)).preventDefault();
    verify(keyDownEvent, times(1)).stopPropagation();
    KeyUpEvent keyUpEvent = mock(KeyUpEvent.class);
    tested.onDropDownKeyUp(keyUpEvent);
    verify(keyUpEvent, times(1)).preventDefault();
    verify(keyUpEvent, times(1)).stopPropagation();
    KeyPressEvent keyPressEvent = mock(KeyPressEvent.class);
    tested.onDropDownKeyPress(keyPressEvent);
    verify(keyPressEvent, times(1)).preventDefault();
    verify(keyPressEvent, times(1)).stopPropagation();
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) Test(org.junit.Test)

Example 37 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project kie-wb-common by kiegroup.

the class ScrollableLienzoPanelViewTest method testSetPresenter.

@Test
@SuppressWarnings("unchecked")
public void testSetPresenter() {
    when(tested.isRemoteCommunicationEnabled()).thenReturn(true);
    tested.setPresenter(presenter);
    verify(presenter, times(3)).register(any(HandlerRegistration.class));
    ArgumentCaptor<KeyDownHandler> downCaptor = ArgumentCaptor.forClass(KeyDownHandler.class);
    verify(tested, times(1)).addKeyDownHandler(downCaptor.capture());
    KeyDownHandler downHandler = downCaptor.getValue();
    KeyDownEvent keyDownEvent = mock(KeyDownEvent.class);
    when(keyDownEvent.getNativeKeyCode()).thenReturn(11);
    downHandler.onKeyDown(keyDownEvent);
    verify(presenter, times(1)).onKeyDown(eq(11));
    ArgumentCaptor<KeyPressHandler> pressCaptor = ArgumentCaptor.forClass(KeyPressHandler.class);
    verify(tested, times(1)).addKeyPressHandler(pressCaptor.capture());
    KeyPressHandler pressHandler = pressCaptor.getValue();
    KeyPressEvent kePressEvent = mock(KeyPressEvent.class);
    when(kePressEvent.getUnicodeCharCode()).thenReturn(33);
    pressHandler.onKeyPress(kePressEvent);
    verify(presenter, times(1)).onKeyPress(eq(33));
    ArgumentCaptor<KeyUpHandler> upCaptor = ArgumentCaptor.forClass(KeyUpHandler.class);
    verify(tested, times(1)).addKeyUpHandler(upCaptor.capture());
    KeyUpHandler upHandler = upCaptor.getValue();
    KeyUpEvent keyUpEvent = mock(KeyUpEvent.class);
    when(keyUpEvent.getNativeKeyCode()).thenReturn(55);
    upHandler.onKeyUp(keyUpEvent);
    verify(presenter, times(1)).onKeyUp(eq(55));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) Test(org.junit.Test)

Example 38 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project kie-wb-common by kiegroup.

the class CardFrameComponentViewTest method testOnTitleInputKeyDownEventWhenIsEnter.

@Test
public void testOnTitleInputKeyDownEventWhenIsEnter() {
    final KeyDownEvent event = mock(KeyDownEvent.class);
    when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_ENTER);
    cardFrameView.onTitleInputKeyDownEvent(event);
    verify(event).preventDefault();
    verify(presenter).changeTitle();
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) Test(org.junit.Test)

Example 39 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent in project kie-wb-common by kiegroup.

the class CardFrameComponentViewTest method testOnTitleInputKeyDownEventWhenIsNotEnterAndIsNotEscape.

@Test
public void testOnTitleInputKeyDownEventWhenIsNotEnterAndIsNotEscape() {
    final KeyDownEvent event = mock(KeyDownEvent.class);
    when(event.getNativeKeyCode()).thenReturn(KeyCodes.KEY_CTRL);
    cardFrameView.onTitleInputKeyDownEvent(event);
    verify(event, never()).preventDefault();
    verifyNoMoreInteractions(presenter);
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) Test(org.junit.Test)

Example 40 with KeyDownEvent

use of com.google.gwt.event.dom.client.KeyDownEvent 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)

Aggregations

KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)46 Test (org.junit.Test)30 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)15 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)5 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)3 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 FindTextBox (org.rstudio.core.client.widget.FindTextBox)3 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 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 CanFocus (org.rstudio.core.client.widget.CanFocus)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