Search in sources :

Example 21 with Event

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

the class DNDListComponentViewTest method testOnStartDragWhenTargetIsNotGrip.

@Test
public void testOnStartDragWhenTargetIsNotGrip() {
    final Event event = mock(Event.class);
    final HTMLElement parent = mock(HTMLElement.class);
    final HTMLElement target = mock(HTMLElement.class);
    event.target = target;
    target.parentNode = parent;
    target.classList = mock(DOMTokenList.class);
    when(target.classList.contains(GRIP)).thenReturn(false);
    view.onStartDrag(event);
    verify(view, never()).holdDraggingElement(parent);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) Test(org.junit.Test)

Example 22 with Event

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

the class DragAndDropHelperTest method testOnDragAreaMouseMove.

@Test
public void testOnDragAreaMouseMove() {
    final HTMLElement dragging = mock(HTMLElement.class);
    final HTMLElement oldElement = mock(HTMLElement.class);
    final MouseEvent event = mock(MouseEvent.class);
    final int newPosition = 2;
    final int oldPosition = 1;
    final int delta = 444;
    doReturn(dragging).when(helper).getDragging();
    doReturn(delta).when(helper).getDelta(event);
    doReturn(newPosition).when(helper).getNewPosition();
    doReturn(oldPosition).when(helper).position(dragging);
    doReturn(oldElement).when(helper).findElementByPosition(newPosition);
    doNothing().when(helper).swapElements(oldElement, dragging);
    doNothing().when(helper).setTop(dragging, delta);
    helper.onDragAreaMouseMove(event);
    verify(helper).swapElements(oldElement, dragging);
    verify(helper).setTop(dragging, delta);
}
Also used : MouseEvent(elemental2.dom.MouseEvent) HTMLElement(elemental2.dom.HTMLElement) Test(org.junit.Test)

Example 23 with Event

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

the class DragAndDropHelperTest method testOnDragAreaMouseUp.

@Test
public void testOnDragAreaMouseUp() {
    final Event event = mock(Event.class);
    doNothing().when(helper).refreshItemsPosition();
    helper.onDragAreaMouseUp(event);
    assertEquals(null, helper.getDragging());
    assertEquals(0, helper.getClickedYPosition());
    assertEquals(0, helper.getStartYPosition());
    verify(helper).refreshItemsPosition();
}
Also used : Event(elemental2.dom.Event) MouseEvent(elemental2.dom.MouseEvent) Test(org.junit.Test)

Example 24 with Event

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

the class DayTimeSelectorViewTest method testGetOnChangeHandler.

@Test
public void testGetOnChangeHandler() {
    final Event event = mock(Event.class);
    final Optional<Consumer<Event>> optionalConsumer = Optional.of(consumerEvent);
    doReturn(optionalConsumer).when(view).getOnValueChangedConsumer();
    view.getOnChangeHandler().onInvoke(event);
    verify(consumerEvent).accept(event);
}
Also used : Consumer(java.util.function.Consumer) Event(elemental2.dom.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Test(org.junit.Test)

Example 25 with Event

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

the class DocumentPreviewViewImpl method setState.

@Override
public void setState(DocumentPreviewState previewState, Collection<DocumentPreviewStateAction> previewActions) {
    state.className = resolveStateStyle(previewState);
    if (previewState.equals(DocumentPreviewState.STORED)) {
        document.classList.remove(DISABLED_ANCHOR_STYLE);
        document.href = presenter.getDocumentLink();
        document.download = presenter.getDocumentName();
    } else {
        document.classList.add(DISABLED_ANCHOR_STYLE);
        document.removeAttribute("href");
        document.removeAttribute("download");
    }
    clearActions();
    previewActions.forEach(action -> {
        if (actions.lastChild != null) {
            HTMLElement separator = (HTMLElement) doc.createElement("span");
            separator.textContent = "|";
            separator.className = CONTENT;
            actions.appendChild(separator);
        }
        HTMLAnchorElement anchor = (HTMLAnchorElement) doc.createElement("a");
        anchor.textContent = action.getLabel();
        anchor.onclick = event -> {
            action.execute();
            return null;
        };
        actions.appendChild(anchor);
    });
}
Also used : HTMLElement(elemental2.dom.HTMLElement) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement)

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