Search in sources :

Example 1 with ViewEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent in project kie-wb-common by kiegroup.

the class ViewEventHandlerManagerTest method testClickHandler.

@Test
@SuppressWarnings("unchecked")
public void testClickHandler() {
    final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
    final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(node.addNodeMouseClickHandler(any(NodeMouseClickHandler.class))).thenReturn(handlerRegistration);
    tested.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
    final ArgumentCaptor<NodeMouseClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseClickHandler.class);
    verify(node, times(1)).addNodeMouseClickHandler(clickHandlerArgumentCaptor.capture());
    final NodeMouseClickHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseClickEvent clickEvent = mock(NodeMouseClickEvent.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.isButtonLeft()).thenReturn(true);
    when(clickEvent.isButtonRight()).thenReturn(true);
    when(clickEvent.isButtonMiddle()).thenReturn(true);
    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.onNodeMouseClick(clickEvent);
    final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
    verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
    final MouseClickEvent viewEvent = (MouseClickEvent) eventArgumentCaptor.getValue();
    assertEquals(x, viewEvent.getX(), 0d);
    assertEquals(y, viewEvent.getY(), 0d);
    assertEquals(x, viewEvent.getClientX(), 0d);
    assertEquals(y, viewEvent.getClientY(), 0d);
    assertTrue(viewEvent.isButtonLeft());
    assertTrue(viewEvent.isButtonRight());
    assertTrue(viewEvent.isButtonMiddle());
    assertTrue(viewEvent.isAltKeyDown());
    assertTrue(viewEvent.isMetaKeyDown());
    assertTrue(viewEvent.isShiftKeyDown());
    assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_CLICK));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) NodeMouseClickHandler(com.ait.lienzo.client.core.event.NodeMouseClickHandler) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) ViewEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent) 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) Test(org.junit.Test)

Example 2 with ViewEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent 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));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) ViewEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent) NodeMouseExitHandler(com.ait.lienzo.client.core.event.NodeMouseExitHandler) MouseExitEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseExitEvent) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent) NodeMouseExitEvent(com.ait.lienzo.client.core.event.NodeMouseExitEvent) Test(org.junit.Test)

Example 3 with ViewEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent in project kie-wb-common by kiegroup.

the class ViewEventHandlerManagerTest method testDoubleClickHandler.

@Test
@SuppressWarnings("unchecked")
public void testDoubleClickHandler() {
    final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
    final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(node.addNodeMouseDoubleClickHandler(any(NodeMouseDoubleClickHandler.class))).thenReturn(handlerRegistration);
    tested.addHandler(ViewEventType.MOUSE_DBL_CLICK, clickHandler);
    final ArgumentCaptor<NodeMouseDoubleClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseDoubleClickHandler.class);
    verify(node, times(1)).addNodeMouseDoubleClickHandler(clickHandlerArgumentCaptor.capture());
    final NodeMouseDoubleClickHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseDoubleClickEvent clickEvent = mock(NodeMouseDoubleClickEvent.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.isButtonLeft()).thenReturn(true);
    when(clickEvent.isButtonRight()).thenReturn(true);
    when(clickEvent.isButtonMiddle()).thenReturn(true);
    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.onNodeMouseDoubleClick(clickEvent);
    final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
    verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
    final MouseDoubleClickEvent viewEvent = (MouseDoubleClickEvent) eventArgumentCaptor.getValue();
    assertEquals(x, viewEvent.getX(), 0d);
    assertEquals(y, viewEvent.getY(), 0d);
    assertEquals(x, viewEvent.getClientX(), 0d);
    assertEquals(y, viewEvent.getClientY(), 0d);
    assertTrue(viewEvent.isButtonLeft());
    assertTrue(viewEvent.isButtonRight());
    assertTrue(viewEvent.isButtonMiddle());
    assertTrue(viewEvent.isAltKeyDown());
    assertTrue(viewEvent.isMetaKeyDown());
    assertTrue(viewEvent.isShiftKeyDown());
    assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_DBL_CLICK));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) ViewEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent) MouseDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) Test(org.junit.Test)

Example 4 with ViewEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent in project kie-wb-common by kiegroup.

the class ViewEventHandlerManagerTest method testMouseEnterHandler.

@Test
@SuppressWarnings("unchecked")
public void testMouseEnterHandler() {
    final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
    final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
    when(shape.addNodeMouseEnterHandler(any(NodeMouseEnterHandler.class))).thenReturn(handlerRegistration);
    tested.addHandler(ViewEventType.MOUSE_ENTER, clickHandler);
    final ArgumentCaptor<NodeMouseEnterHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
    verify(shape, times(1)).addNodeMouseEnterHandler(clickHandlerArgumentCaptor.capture());
    final NodeMouseEnterHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
    final NodeMouseEnterEvent clickEvent = mock(NodeMouseEnterEvent.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.onNodeMouseEnter(clickEvent);
    final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
    verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
    final MouseEnterEvent viewEvent = (MouseEnterEvent) 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_ENTER));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseEvent(com.google.gwt.event.dom.client.MouseEvent) ViewEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) NodeMouseEnterEvent(com.ait.lienzo.client.core.event.NodeMouseEnterEvent) MouseEnterEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent) NodeMouseEnterHandler(com.ait.lienzo.client.core.event.NodeMouseEnterHandler) Test(org.junit.Test)

Aggregations

MouseEvent (com.google.gwt.event.dom.client.MouseEvent)4 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)4 Test (org.junit.Test)4 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)4 NodeMouseClickEvent (com.ait.lienzo.client.core.event.NodeMouseClickEvent)1 NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)1 NodeMouseDoubleClickEvent (com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent)1 NodeMouseDoubleClickHandler (com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler)1 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 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)1 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)1 MouseEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)1 MouseExitEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseExitEvent)1