Search in sources :

Example 6 with KeyboardEvent

use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImplTest method testKeyDownEventListenerEsc.

@Test
public void testKeyDownEventListenerEsc() {
    final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
    doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
    doReturn(true).when(view).isEscapeKeyPressed(keyboardEvent);
    doNothing().when(view).hide(false);
    view.manageButtonKeyDownEventListener(keyboardEvent);
    verify(view).hide(false);
    verify(view).reset();
    verify(view).onClosedByKeyboard();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 7 with KeyboardEvent

use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImplTest method testManagerButtonKeyDownEventListenerEsc.

@Test
public void testManagerButtonKeyDownEventListenerEsc() {
    final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
    doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
    doReturn(true).when(view).isEscapeKeyPressed(keyboardEvent);
    final ValueAndDataTypePopoverViewImpl.BootstrapSelectDropDownMonitor monitor = mock(ValueAndDataTypePopoverViewImpl.BootstrapSelectDropDownMonitor.class);
    doReturn(monitor).when(view).getMonitor();
    final elemental2.dom.Element menuElement = mock(elemental2.dom.Element.class);
    doReturn(menuElement).when(monitor).getMenuElement();
    view.manageButtonKeyDownEventListener(keyboardEvent);
    verify(view).hide(false);
    verify(view).reset();
    verify(view).onClosedByKeyboard();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 8 with KeyboardEvent

use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerTabKey.

@Test
public void testTypeSelectorKeyDownEventListenerTabKey() {
    final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
    doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
    doReturn(false).when(view).isEscapeKeyPressed(keyboardEvent);
    doReturn(true).when(view).isTabKeyPressed(keyboardEvent);
    view.typeSelectorKeyDownEventListener(keyboardEvent);
    verify(valueEditor).focus();
    verify(keyboardEvent).preventDefault();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 9 with KeyboardEvent

use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerWhenIsNotAHandledKey.

@Test
public void testTypeSelectorKeyDownEventListenerWhenIsNotAHandledKey() {
    final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
    doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
    doReturn(false).when(view).isEscapeKeyPressed(keyboardEvent);
    doReturn(false).when(view).isTabKeyPressed(keyboardEvent);
    view.typeSelectorKeyDownEventListener(keyboardEvent);
    verify(view, never()).hide(anyBoolean());
    verify(keyboardEvent, never()).preventDefault();
    verify(view, never()).onClosedByKeyboard();
    verify(view, never()).reset();
    verify(manageButton, never()).focus();
    verify(valueEditor, never()).focus();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Example 10 with KeyboardEvent

use of elemental2.dom.KeyboardEvent in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerShiftTabKey.

@Test
public void testTypeSelectorKeyDownEventListenerShiftTabKey() {
    final KeyboardEvent keyboardEvent = mock(KeyboardEvent.class);
    keyboardEvent.shiftKey = true;
    doReturn(false).when(view).isEnterKeyPressed(keyboardEvent);
    doReturn(false).when(view).isEscapeKeyPressed(keyboardEvent);
    doReturn(true).when(view).isTabKeyPressed(keyboardEvent);
    view.typeSelectorKeyDownEventListener(keyboardEvent);
    verify(manageButton).focus();
    verify(keyboardEvent).preventDefault();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Aggregations

KeyboardEvent (elemental2.dom.KeyboardEvent)21 Test (org.junit.Test)16 Event (org.jboss.errai.common.client.dom.Event)2 Button (org.jboss.errai.common.client.dom.Button)1