Search in sources :

Example 6 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class ShapeGlyphDragHandlerTest method testDestroy.

@Test
public void testDestroy() throws Exception {
    Callback callback = mock(Callback.class);
    tested.show(glyphDragItem, 11, 33, callback);
    tested.destroy();
    verify(proxyPanel, times(1)).destroy();
    verify(proxyPanel, never()).clear();
    verify(moveHandlerReg, times(1)).removeHandler();
    verify(upHandlerReg, times(1)).removeHandler();
    verify(rootPanel, times(1)).remove(eq(proxyPanel));
    assertTrue(handlerRegistrations.isEmpty());
}
Also used : Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) Test(org.junit.Test)

Example 7 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class ShapeGlyphDragHandlerTest method testProxyhHandlers.

@Test
public void testProxyhHandlers() throws Exception {
    Callback callback = mock(Callback.class);
    tested.show(glyphDragItem, 11, 33, callback);
    // Check keyboard event handling.
    assertEquals(keyHandlerReg, handlerRegistrations.get(2));
    // Check mouse move event handling.
    assertEquals(moveHandlerReg, handlerRegistrations.get(0));
    MouseMoveEvent moveEvent = mock(MouseMoveEvent.class);
    when(moveEvent.getX()).thenReturn(7);
    when(moveEvent.getY()).thenReturn(9);
    when(moveEvent.getClientX()).thenReturn(3);
    when(moveEvent.getClientY()).thenReturn(5);
    tested.onMouseMove(moveEvent, callback);
    verify(proxyStyle, times(1)).setLeft(eq(7d), eq(Style.Unit.PX));
    verify(proxyStyle, times(1)).setTop(eq(9d), eq(Style.Unit.PX));
    verify(callback, times(1)).onMove(eq(3), eq(5));
    // Check mouse up event handling.
    assertEquals(upHandlerReg, handlerRegistrations.get(1));
    MouseUpEvent upEvent = mock(MouseUpEvent.class);
    when(upEvent.getX()).thenReturn(7);
    when(upEvent.getY()).thenReturn(9);
    when(upEvent.getClientX()).thenReturn(3);
    when(upEvent.getClientY()).thenReturn(5);
    tested.onMouseUp(upEvent, callback);
    verify(moveHandlerReg, times(1)).removeHandler();
    verify(upHandlerReg, times(1)).removeHandler();
    verify(rootPanel, times(1)).remove(eq(proxyPanel));
    verify(callback, times(1)).onComplete(eq(3), eq(5));
    assertTrue(handlerRegistrations.isEmpty());
}
Also used : Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) MouseMoveEvent(com.google.gwt.event.dom.client.MouseMoveEvent) MouseUpEvent(com.google.gwt.event.dom.client.MouseUpEvent) Test(org.junit.Test)

Aggregations

Callback (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback)7 Test (org.junit.Test)6 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)2 ShapeGlyphDragHandler (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler)2 Item (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Item)2 Glyph (org.kie.workbench.common.stunner.core.definition.shape.Glyph)2 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)1 MouseMoveEvent (com.google.gwt.event.dom.client.MouseMoveEvent)1 MouseUpEvent (com.google.gwt.event.dom.client.MouseUpEvent)1 EventHandler (org.jboss.errai.ui.shared.api.annotations.EventHandler)1 DMNShapeFactory (org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory)1 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)1