RestrictedMousePanMediator extends AbstractMediator { protected void onMouseDown(final NodeMouseDownEvent event) { m_last = new Point2D(event.getX(), event.getY()); m_dragging = true; Transform transform = getTransform(); if (transform == null) { setTransform(transform = new Transform()); } m_inverseTransform = transform.getInverse(); m_inverseTransform.transform(m_last, m_last); setCursor(Style.Cursor.MOVE); } RestrictedMousePanMediator(final GridLayer gridLayer); protected  RestrictedMousePanMediator(); boolean isDragging(); TransformMediator getTransformMediator(); void setTransformMediator(final TransformMediator transformMediator); @Override void cancel(); @Override boolean handleEvent(final GwtEvent<?> event);  }
@Test public void testOnMouseDown() throws Exception { final NodeMouseDownEvent downEvent = mock(NodeMouseDownEvent.class); final Transform transform = mock(Transform.class); final Viewport viewport = mock(Viewport.class); final DivElement element = mock(DivElement.class); final Style style = mock(Style.class); final ArgumentCaptor<Point2D> point = ArgumentCaptor.forClass(Point2D.class); doReturn(123).when(downEvent).getX(); doReturn(987).when(downEvent).getY(); doReturn(NodeMouseDownEvent.getType()).when(downEvent).getAssociatedType(); doReturn(style).when(element).getStyle(); doReturn(transform).when(transform).getInverse(); doReturn(transform).when(viewport).getTransform(); doReturn(element).when(viewport).getElement(); doReturn(viewport).when(mediator).getViewport(); doReturn(viewport).when(mediator).getLayerViewport(); mediator.onMouseDown(downEvent); verify(transform).transform(point.capture(), point.capture()); assertEquals("Expected X coordinate of the event", 123.0, point.getAllValues().get(0).getX(), 0.0); assertEquals("Expected Y coordinate of the event", 987.0, point.getAllValues().get(0).getY(), 0.0); assertEquals("Expected the same point to be transformed", point.getAllValues().get(0), point.getAllValues().get(1)); verify(mediator).setCursor(Style.Cursor.MOVE); }