Search in sources :

Example 31 with Event

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

the class AbstractPopoverViewImplTest method testKeyDownEventListenerEscKey.

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

Example 32 with Event

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

the class MenuInitializerTest method testBodyDropdownProperties.

@Test
public void testBodyDropdownProperties() {
    final JQueryEvent event = mock(JQueryEvent.class);
    final HTMLElement target = mock(HTMLElement.class);
    final double left = 1;
    final double top = 1;
    final double zIndex = 1051;
    final JSONObject expectedJSONObject = mock(JSONObject.class);
    // Mock "JSONObject" since it relies on a native implementation.
    doReturn(expectedJSONObject).when(initializer).makeJsonObject();
    event.target = target;
    doReturn(left).when(initializer).offsetLeft(target);
    doReturn(top).when(initializer).offsetTop(target);
    doReturn(top).when(initializer).offsetTop(target);
    final JSONObject actualJSONObject = initializer.bodyDropdownProperties(event);
    verify(expectedJSONObject).put("position", new JSONString("absolute"));
    verify(expectedJSONObject).put("left", new JSONNumber(left));
    verify(expectedJSONObject).put("top", new JSONNumber(top));
    verify(expectedJSONObject).put("z-index", new JSONNumber(zIndex));
    assertEquals(expectedJSONObject, actualJSONObject);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString) Test(org.junit.Test)

Example 33 with Event

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

the class MenuInitializerTest method testMoveDropDownToKebabContainer.

@Test
public void testMoveDropDownToKebabContainer() {
    final HTMLElement modalInElement = mock(HTMLElement.class);
    final HTMLElement target = mock(HTMLElement.class);
    final JQuery jQueryModalIn = mock(JQuery.class);
    final JQuery jQueryTarget = mock(JQuery.class);
    final JQuery jQueryCSS = mock(JQuery.class);
    final JQuery jQueryDetach = mock(JQuery.class);
    final JQueryEvent event = mock(JQueryEvent.class);
    final JSONObject jsonObjectProperties = mock(JSONObject.class);
    final JavaScriptObject javaScriptObjectProperties = mock(JavaScriptObject.class);
    event.target = target;
    doReturn(jsonObjectProperties).when(initializer).emptyProperties();
    doReturn(modalInElement).when(initializer).body();
    when(jsonObjectProperties.getJavaScriptObject()).thenReturn(javaScriptObjectProperties);
    when(jQueryTarget.css(javaScriptObjectProperties)).thenReturn(jQueryCSS);
    when(jQueryCSS.detach()).thenReturn(jQueryDetach);
    when(initializer.jQuery(kebabMenu)).thenReturn(jQueryModalIn);
    when(initializer.jQuery(target)).thenReturn(jQueryTarget);
    initializer.moveDropDownToKebabContainer().call(event);
    verify(jQueryModalIn).append(jQueryDetach);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 34 with Event

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

the class ValueAndDataTypePopoverViewImplTest method testManagerButtonKeyDownEventWhenIsNotKeyboardEvent.

@Test
public void testManagerButtonKeyDownEventWhenIsNotKeyboardEvent() {
    final Event event = mock(Event.class);
    view.manageButtonKeyDownEventListener(event);
    verify(view, never()).hide(false);
    verify(view, never()).reset();
    verify(view, never()).onClosedByKeyboard();
}
Also used : ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) Test(org.junit.Test)

Example 35 with Event

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

the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerWhenIsNotAKeyboardEvent.

@Test
public void testTypeSelectorKeyDownEventListenerWhenIsNotAKeyboardEvent() {
    final Event event = mock(Event.class);
    view.typeSelectorKeyDownEventListener(event);
    verify(view, never()).hide(anyBoolean());
    verify(event, never()).preventDefault();
    verify(view, never()).onClosedByKeyboard();
    verify(view, never()).reset();
    verify(manageButton, never()).focus();
    verify(valueEditor, never()).focus();
}
Also used : ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)50 HTMLElement (elemental2.dom.HTMLElement)27 Event (elemental2.dom.Event)26 KeyboardEvent (elemental2.dom.KeyboardEvent)19 Element (elemental2.dom.Element)18 MouseEvent (elemental2.dom.MouseEvent)16 HTMLDivElement (elemental2.dom.HTMLDivElement)15 HTMLInputElement (elemental2.dom.HTMLInputElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)7 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)7 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)7 DOMRect (elemental2.dom.DOMRect)5 DOMTokenList (elemental2.dom.DOMTokenList)5 DomGlobal (elemental2.dom.DomGlobal)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4