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();
}
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));
}
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();
}
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);
}
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);
}
Aggregations