use of org.kie.workbench.common.stunner.core.client.canvas.controls.SelectionControl in project kie-wb-common by kiegroup.
the class AbstractCanvasShortcutsControlImplTest method mockSelectedElements.
private List<Element> mockSelectedElements(final String... selectedIds) {
final Index index = mock(Index.class);
doReturn(index).when(canvasHandlerMock).getGraphIndex();
final EditorSession session = mock(EditorSession.class);
final SelectionControl selectionControl = mock(SelectionControl.class);
final KeyboardControl keyboardControl = mock(KeyboardControl.class);
doReturn(selectionControl).when(session).getSelectionControl();
doReturn(keyboardControl).when(session).getKeyboardControl();
doReturn(Arrays.asList(selectedIds)).when(selectionControl).getSelectedItems();
canvasShortcutsControl.bind(session);
final List<Element> selectedElements = new ArrayList<>();
for (final String id : selectedIds) {
final Element element = mock(Element.class);
doReturn(element).when(index).get(id);
selectedElements.add(element);
}
return selectedElements;
}
use of org.kie.workbench.common.stunner.core.client.canvas.controls.SelectionControl in project kie-wb-common by kiegroup.
the class DiagramViewerTest method testOpen.
@Test
@SuppressWarnings("unchecked")
public void testOpen() {
tested.open(diagram, callback);
assertEquals(diagram, tested.getInstance());
verify(canvasHandler, times(1)).handle(eq(canvas));
verify(canvasHandler, times(1)).draw(eq(diagram), any(ParameterizedCommand.class));
verify(callback, times(1)).afterCanvasInitialized();
verify(mediatorsControlInstance, times(1)).init(eq(canvas));
verify(selectionControlInstance, times(1)).init(eq(canvasHandler));
verify(view, times(1)).setWidget(eq(canvasViewWidget));
ArgumentCaptor<CanvasShapeListener> shapeListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasShapeListener.class);
ArgumentCaptor<CanvasElementListener> elementListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasElementListener.class);
verify(canvas, times(1)).addRegistrationListener(shapeListenerArgumentCaptor.capture());
verify(canvasHandler, times(1)).addRegistrationListener(elementListenerArgumentCaptor.capture());
DefaultCanvasShapeListener shapeListener = (DefaultCanvasShapeListener) shapeListenerArgumentCaptor.getValue();
Iterator<CanvasControl<AbstractCanvas>> canvasControls = shapeListener.getCanvasControls().iterator();
assertTrue(canvasControls.next() instanceof MediatorsControl);
assertFalse(canvasControls.hasNext());
DefaultCanvasElementListener elementListener = (DefaultCanvasElementListener) elementListenerArgumentCaptor.getValue();
Iterator<CanvasControl<AbstractCanvasHandler>> canvasHandlerControls1 = elementListener.getCanvasControls().iterator();
assertTrue(canvasHandlerControls1.next() instanceof SelectionControl);
assertFalse(canvasHandlerControls1.hasNext());
}
Aggregations