use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class ListSelectorViewImplTest method testOnKeyDownWhenEscapeIsPressedOnIEOrEdge.
@Test
public void testOnKeyDownWhenEscapeIsPressedOnIEOrEdge() {
final Event event = mock(Event.class);
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(keyboardEvent).when(view).asElemental2Event(event);
keyboardEvent.key = "Esc";
view.onKeyDown().call(event);
verify(view).hide();
verify(view).returnFocusToPanel();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class ListSelectorViewImplTest method testOnKeyDownWhenEscapeIsPressedOnOtherBrowser.
@Test
public void testOnKeyDownWhenEscapeIsPressedOnOtherBrowser() {
final Event event = mock(Event.class);
final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
doReturn(keyboardEvent).when(view).asElemental2Event(event);
keyboardEvent.key = "Escape";
view.onKeyDown().call(event);
verify(view).hide();
verify(view).returnFocusToPanel();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerEnterKey.
@Test
public void testKeyDownEventListenerEnterKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doNothing().when(view).hide();
doNothing().when(view).onClosedByKeyboard();
doReturn(true).when(view).isEnterKeyPressed(event);
view.keyDownEventListener(event);
verify(view).hide();
verify(event).stopPropagation();
verify(view).onClosedByKeyboard();
verify(view, never()).isEscapeKeyPressed(event);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerWhenIsNotKeyboardEvent.
@Test
public void testKeyDownEventListenerWhenIsNotKeyboardEvent() {
final Event event = mock(Event.class);
view.keyDownEventListener(event);
verify(view, never()).hide();
verify(event, never()).stopPropagation();
verify(view, never()).onClosedByKeyboard();
verify(view, never()).isEscapeKeyPressed(any());
verify(view, never()).reset();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImpl method keyDownEventListener.
public void keyDownEventListener(final Object event) {
if (event instanceof KeyboardEvent) {
final KeyboardEvent keyEvent = (KeyboardEvent) event;
if (isEnterKeyPressed(keyEvent)) {
hide();
keyEvent.stopPropagation();
onClosedByKeyboard();
} else if (isEscapeKeyPressed(keyEvent)) {
reset();
hide();
onClosedByKeyboard();
}
}
}
Aggregations