Search in sources :

Example 6 with NodeMouseClickHandler

use of com.ait.lienzo.client.core.event.NodeMouseClickHandler in project kie-wb-common by kiegroup.

the class AbstractActionsToolboxViewTest method testAddButton.

@SuppressWarnings("unchecked")
protected void testAddButton(final Consumer<MouseClickEvent> clickEventConsumer) {
    // Verify tootlip.
    verify(toolboxTooltip, times(1)).createItem(eq("title1"));
    verify(buttonItem, times(1)).tooltip(any(TooltipItem.class));
    // Verify mouse enter.
    final ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
    verify(buttonItem, times(1)).onMouseEnter(enterHandlerArgumentCaptor.capture());
    final NodeMouseEnterHandler enterHandler = enterHandlerArgumentCaptor.getValue();
    final NodeMouseEnterEvent mouseEnterEvent = mock(NodeMouseEnterEvent.class);
    enterHandler.onNodeMouseEnter(mouseEnterEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.POINTER));
    // Verify mouse exit.
    final ArgumentCaptor<NodeMouseExitHandler> exitHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
    verify(buttonItem, times(1)).onMouseExit(exitHandlerArgumentCaptor.capture());
    final NodeMouseExitHandler exitHandler = exitHandlerArgumentCaptor.getValue();
    final NodeMouseExitEvent mouseExitEvent = mock(NodeMouseExitEvent.class);
    exitHandler.onNodeMouseExit(mouseExitEvent);
    verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.AUTO));
    // Verify mouse click.
    final ArgumentCaptor<NodeMouseClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseClickHandler.class);
    verify(buttonItem, times(1)).onClick(clickHandlerArgumentCaptor.capture());
    final NodeMouseClickHandler clickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseClickEvent mouseClickEvent = mock(NodeMouseClickEvent.class);
    when(mouseClickEvent.getMouseEvent()).thenReturn(mock(MouseEvent.class));
    clickHandler.onNodeMouseClick(mouseClickEvent);
    verify(clickEventConsumer, times(1)).accept(any(MouseClickEvent.class));
}
Also used : NodeMouseClickHandler(com.ait.lienzo.client.core.event.NodeMouseClickHandler) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseExitHandler(com.ait.lienzo.client.core.event.NodeMouseExitHandler) NodeMouseEnterHandler(com.ait.lienzo.client.core.event.NodeMouseEnterHandler) TooltipItem(org.kie.workbench.common.stunner.lienzo.toolbox.items.TooltipItem) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent) NodeMouseClickEvent(com.ait.lienzo.client.core.event.NodeMouseClickEvent) NodeMouseClickEvent(com.ait.lienzo.client.core.event.NodeMouseClickEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)

Aggregations

NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)6 Test (org.junit.Test)5 NodeMouseClickEvent (com.ait.lienzo.client.core.event.NodeMouseClickEvent)2 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)2 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)2 NodeMouseEnterEvent (com.ait.lienzo.client.core.event.NodeMouseEnterEvent)1 NodeMouseEnterHandler (com.ait.lienzo.client.core.event.NodeMouseEnterHandler)1 NodeMouseExitEvent (com.ait.lienzo.client.core.event.NodeMouseExitEvent)1 NodeMouseExitHandler (com.ait.lienzo.client.core.event.NodeMouseExitHandler)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)1 TooltipItem (org.kie.workbench.common.stunner.lienzo.toolbox.items.TooltipItem)1