use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.
the class MapSelectionControlTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
ShapeViewExtStub shapeView = new ShapeViewExtStub(shapeEventHandler, hasControlPoints);
when(element.getUUID()).thenReturn(ELEMENT_UUID);
when(element.getContent()).thenReturn(new ViewImpl<>(definition, BoundsImpl.build(0, 0, 10, 10)));
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getCanvasRootUUID()).thenReturn(ROOT_UUID);
when(canvasHandler.getCanvas()).thenReturn(canvas);
when(canvas.getLayer()).thenReturn(layer);
when(canvas.getShape(eq(ELEMENT_UUID))).thenReturn(shape);
when(canvas.getShapes()).thenReturn(Collections.singletonList(shape));
when(shape.getUUID()).thenReturn(ELEMENT_UUID);
when(shape.getShapeView()).thenReturn(shapeView);
when(shapeEventHandler.supports(eq(ViewEventType.MOUSE_CLICK))).thenReturn(true);
this.tested = new MapSelectionControl(e -> elementSelectedEvent.fire((CanvasSelectionEvent) e), e -> clearSelectionEvent.fire((CanvasClearSelectionEvent) e));
this.tested.setReadonly(false);
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.
the class MapSelectionControlTest method testOnClearSelectionEvent.
@Test
public void testOnClearSelectionEvent() {
tested.enable(canvasHandler);
tested.register(element);
tested.select(element);
CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
tested.onCanvasClearSelection(event);
assertTrue(tested.getSelectedItems().isEmpty());
verify(canvas, atLeastOnce()).draw();
verify(shape, times(1)).applyState(eq(ShapeState.SELECTED));
verify(shape, times(1)).applyState(eq(ShapeState.NONE));
verify(shape, never()).applyState(eq(ShapeState.INVALID));
verify(shape, never()).applyState(eq(ShapeState.HIGHLIGHT));
verify(clearSelectionEvent, never()).fire(any(CanvasClearSelectionEvent.class));
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.
the class ToolboxControlTest method testClearSelectionEvent.
@Test
public void testClearSelectionEvent() {
final CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
tested.onCanvasClearSelectionEvent(event);
verify(delegated, times(1)).destroy();
verify(delegated, never()).show(any(Element.class));
verify(delegated, never()).show(anyString());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.
the class AbstractSelectionAwareSessionCommandTest method testOnCanvasClearSelection.
@Test
public void testOnCanvasClearSelection() {
CanvasClearSelectionEvent event = new CanvasClearSelectionEvent(canvasHandler);
command.onCanvasClearSelectionEvent(event);
verify(command, times(1)).handleCanvasClearSelectionEvent(event);
event = new CanvasClearSelectionEvent(anotherCanvasHandler);
command.onCanvasClearSelectionEvent(event);
verify(command, never()).handleCanvasClearSelectionEvent(event);
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent in project kie-wb-common by kiegroup.
the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasClearSelectionEvent.
@Test
public void testHandleCanvasClearSelectionEvent() {
command.bind(session);
((AbstractSelectionAwareSessionCommand) command).handleCanvasClearSelectionEvent(new CanvasClearSelectionEvent(canvasHandler));
assertFalse(command.isEnabled());
verify(statusCallback, times(1)).execute();
}
Aggregations