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);
}
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);
}
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();
}
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);
}
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);
});
}
Aggregations