Search in sources :

Example 66 with Event

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

the class DNDListComponentViewTest method testSetupDragAreaHandlers.

@Test
public void testSetupDragAreaHandlers() {
    final Event event = mock(Event.class);
    doNothing().when(view).onStartDrag(any());
    doNothing().when(view).onDrag(any());
    doNothing().when(view).onDrop();
    dragArea.onmousedown.onInvoke(event);
    dragArea.onmousemove.onInvoke(event);
    dragArea.onmouseup.onInvoke(event);
    dragArea.onmouseout.onInvoke(event);
    final InOrder inOrder = Mockito.inOrder(view);
    inOrder.verify(view).onStartDrag(event);
    inOrder.verify(view).onDrag(event);
    inOrder.verify(view, times(2)).onDrop();
}
Also used : InOrder(org.mockito.InOrder) Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) Test(org.junit.Test)

Example 67 with Event

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

the class DNDListComponentViewTest method testUpdateDraggingElementYWhenDraggingYPositionIsGreaterThanMin.

@Test
public void testUpdateDraggingElementYWhenDraggingYPositionIsGreaterThanMin() {
    final Event event = mock(Event.class);
    final HTMLElement draggingElement = mock(HTMLElement.class);
    final HTMLElement siblingElement = mock(HTMLElement.class);
    final HTMLElement getDependentElement0 = mock(HTMLElement.class);
    final HTMLElement getDependentElement1 = mock(HTMLElement.class);
    final HTMLElement getDependentElement2 = mock(HTMLElement.class);
    final List<HTMLElement> dependentElements = asList(getDependentElement0, getDependentElement1, getDependentElement2);
    final int newDraggingYPosition = 10;
    draggingElement.offsetTop = 30;
    draggingElement.style = mock(CSSStyleDeclaration.class);
    when(draggingElement.getAttribute(DATA_Y_POSITION)).thenReturn("2");
    when(presenter.getItemHeight()).thenReturn(50);
    when(dragArea.querySelector(".kie-dnd-draggable[data-y-position=\"1\"]")).thenReturn(siblingElement);
    doNothing().when(view).clearHover();
    doNothing().when(view).refreshItemsPosition();
    doReturn(draggingElement).when(view).getDragging();
    doReturn(newDraggingYPosition).when(view).getNewDraggingYPosition(event);
    doReturn(dependentElements).when(view).getDependentElements();
    view.updateDraggingElementY(event);
    // update dragging element y
    verify(siblingElement).setAttribute(DATA_Y_POSITION, 5);
    verify(draggingElement).setAttribute(DATA_Y_POSITION, 1);
    verify(getDependentElement0).setAttribute(DATA_Y_POSITION, 2);
    verify(getDependentElement1).setAttribute(DATA_Y_POSITION, 3);
    verify(getDependentElement2).setAttribute(DATA_Y_POSITION, 4);
    verify(view).clearHover();
    verify(view).refreshItemsPosition();
    // set CSS top
    verify(draggingElement.style).setProperty("top", "10px");
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 68 with Event

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

the class DNDListComponentViewTest method testUpdateDraggingElementX.

@Test
public void testUpdateDraggingElementX() {
    final MouseEvent event = mock(MouseEvent.class);
    final HTMLElement draggingElement = mock(HTMLElement.class);
    final DOMRect rect = mock(DOMRect.class);
    event.x = 100;
    rect.left = 25;
    draggingElement.style = mock(CSSStyleDeclaration.class);
    dragArea.offsetWidth = 300;
    when(presenter.getIndentationSize()).thenReturn(50);
    when(dragArea.getBoundingClientRect()).thenReturn(rect);
    doReturn(draggingElement).when(view).getDragging();
    view.updateDraggingElementX(event);
    verify(draggingElement.style).setProperty("width", "calc(100% - 65px)");
}
Also used : MouseEvent(elemental2.dom.MouseEvent) HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 69 with Event

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

the class DNDListComponentViewTest method testUpdateDraggingElementXWhenNewDraggingXPositionIsLessThanZero.

@Test
public void testUpdateDraggingElementXWhenNewDraggingXPositionIsLessThanZero() {
    final MouseEvent event = mock(MouseEvent.class);
    final HTMLElement draggingElement = mock(HTMLElement.class);
    final DOMRect rect = mock(DOMRect.class);
    event.x = -1000;
    rect.left = 25;
    draggingElement.style = mock(CSSStyleDeclaration.class);
    dragArea.offsetWidth = 300;
    when(presenter.getIndentationSize()).thenReturn(50);
    when(dragArea.getBoundingClientRect()).thenReturn(rect);
    doReturn(draggingElement).when(view).getDragging();
    view.updateDraggingElementX(event);
    verify(draggingElement.style).setProperty("width", "calc(100% - 0px)");
}
Also used : MouseEvent(elemental2.dom.MouseEvent) HTMLElement(elemental2.dom.HTMLElement) DOMRect(elemental2.dom.DOMRect) CSSStyleDeclaration(elemental2.dom.CSSStyleDeclaration) Test(org.junit.Test)

Example 70 with Event

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

the class DataTypeListViewTest method testOnReadOnlyMessageCloseButtonClick.

@Test
public void testOnReadOnlyMessageCloseButtonClick() {
    final ClickEvent event = mock(ClickEvent.class);
    readOnlyMessage.classList = mock(DOMTokenList.class);
    view.onReadOnlyMessageCloseButtonClick(event);
    verify(readOnlyMessage.classList).add(HIDDEN_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) 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