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