use of com.ait.lienzo.client.core.event.NodeMouseExitHandler in project kie-wb-common by kiegroup.
the class AbstractActionsToolboxViewTest method testAddButton.
@SuppressWarnings("unchecked")
protected void testAddButton(final String title) {
// Verify tootlip.
verify(toolboxTooltip, times(1)).createItem(eq(title));
verify(buttonItem, times(1)).tooltip(any());
// 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.DEFAULT));
}
use of com.ait.lienzo.client.core.event.NodeMouseExitHandler in project kie-wb-common by kiegroup.
the class ViewEventHandlerManagerTest method testMouseEXitHandler.
@Test
@SuppressWarnings("unchecked")
public void testMouseEXitHandler() {
final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
when(shape.addNodeMouseExitHandler(any(NodeMouseExitHandler.class))).thenReturn(handlerRegistration);
tested.addHandler(ViewEventType.MOUSE_EXIT, clickHandler);
final ArgumentCaptor<NodeMouseExitHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
verify(shape, times(1)).addNodeMouseExitHandler(clickHandlerArgumentCaptor.capture());
final NodeMouseExitHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
final NodeMouseExitEvent clickEvent = mock(NodeMouseExitEvent.class);
final MouseEvent mouseEvent = mock(MouseEvent.class);
final int x = 102;
final int y = 410;
when(clickEvent.getX()).thenReturn(x);
when(clickEvent.getY()).thenReturn(y);
when(clickEvent.isShiftKeyDown()).thenReturn(true);
when(clickEvent.isAltKeyDown()).thenReturn(true);
when(clickEvent.isMetaKeyDown()).thenReturn(true);
when(clickEvent.getMouseEvent()).thenReturn(mouseEvent);
when(mouseEvent.getClientX()).thenReturn(x);
when(mouseEvent.getClientY()).thenReturn(y);
nodeCLickHandler.onNodeMouseExit(clickEvent);
final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
final MouseExitEvent viewEvent = (MouseExitEvent) eventArgumentCaptor.getValue();
assertEquals(x, viewEvent.getX(), 0d);
assertEquals(y, viewEvent.getY(), 0d);
assertEquals(x, viewEvent.getClientX(), 0d);
assertEquals(y, viewEvent.getClientY(), 0d);
assertTrue(viewEvent.isAltKeyDown());
assertTrue(viewEvent.isMetaKeyDown());
assertTrue(viewEvent.isShiftKeyDown());
assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_EXIT));
}
use of com.ait.lienzo.client.core.event.NodeMouseExitHandler in project kie-wb-common by kiegroup.
the class LienzoMultipleSelectionControlTest method testCustomSelectionShapeProvider.
@Test
public void testCustomSelectionShapeProvider() {
final com.ait.lienzo.client.core.shape.Shape shape = mock(com.ait.lienzo.client.core.shape.Shape.class);
final HandlerRegistration enterHandlerReg = mock(HandlerRegistration.class);
final HandlerRegistration exitHandlerReg = mock(HandlerRegistration.class);
when(delegateShapeProvider.getShape()).thenReturn(shape);
when(shape.addNodeMouseEnterHandler(any(NodeMouseEnterHandler.class))).thenReturn(enterHandlerReg);
when(shape.addNodeMouseExitHandler(any(NodeMouseExitHandler.class))).thenReturn(exitHandlerReg);
// Test location.
final Point2D location = new Point2D(10d, 20d);
delegateShapeProvider.setLocation(location);
verify(delegateShapeProvider, times(1)).setLocation(eq(location));
// Test build & event handlers.
assertEquals(selectionShapeProvider, selectionShapeProvider.build());
verify(delegateShapeProvider, times(1)).build();
ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
ArgumentCaptor<NodeMouseExitHandler> enterExitArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
verify(shape, times(1)).addNodeMouseEnterHandler(enterHandlerArgumentCaptor.capture());
verify(shape, times(1)).addNodeMouseExitHandler(enterExitArgumentCaptor.capture());
enterHandlerArgumentCaptor.getValue().onNodeMouseEnter(mock(NodeMouseEnterEvent.class));
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.MOVE));
enterExitArgumentCaptor.getValue().onNodeMouseExit(mock(NodeMouseExitEvent.class));
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.DEFAULT));
// Test shape move to top.
selectionShapeProvider.moveShapeToTop();
verify(shape, times(1)).moveToTop();
// Test clear.
selectionShapeProvider.clear();
verify(delegateShapeProvider, times(1)).clear();
verify(enterHandlerReg, times(1)).removeHandler();
verify(exitHandlerReg, times(1)).removeHandler();
}
use of com.ait.lienzo.client.core.event.NodeMouseExitHandler 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));
}
Aggregations