@Test public void testOnDragAreaMouseDown() { final int clientY = 123; final int startYPosition = 1; final MouseEvent mouseEvent = mock(MouseEvent.class); final Element dragGrabber = mock(Element.class); final Element target = mock(Element.class); final HTMLElement draggable = mock(HTMLElement.class); mouseEvent.clientY = clientY; mouseEvent.target = target; when(target.closest(".drag-grabber")).thenReturn(dragGrabber); when(dragGrabber.closest(DragAndDropHelper.DRAGGABLE_ITEM_CLASS)).thenReturn(draggable); doReturn(startYPosition).when(helper).getTop(draggable); helper.onDragAreaMouseDown(mouseEvent); assertEquals(startYPosition, helper.getStartYPosition()); assertEquals(clientY, helper.getClickedYPosition()); assertEquals(draggable, helper.getDragging()); }
Object onDragAreaMouseDown(final Event e) { final MouseEvent event = (MouseEvent) e; if (!Objects.isNull(event.target)) { final Element grabber = ((Element) event.target).closest(".drag-grabber"); if (Objects.isNull(grabber)) { return this; } draggingElement = (HTMLElement) grabber.closest(DRAGGABLE_ITEM_CLASS); clickedYPosition = (int) event.clientY; startYPosition = getTop(getDragging()); } return this; }
DragAndDropHelper { Object onDragAreaMouseDown(final Event e) { final MouseEvent event = (MouseEvent) e; if (!Objects.isNull(event.target)) { final Element grabber = ((Element) event.target).closest(".drag-grabber"); if (Objects.isNull(grabber)) { return this; } draggingElement = (HTMLElement) grabber.closest(DRAGGABLE_ITEM_CLASS); clickedYPosition = (int) event.clientY; startYPosition = getTop(getDragging()); } return this; } }
DragAndDropHelper { Object onDragAreaMouseDown(final Event e) { final MouseEvent event = (MouseEvent) e; if (!Objects.isNull(event.target)) { final Element grabber = ((Element) event.target).closest(".drag-grabber"); if (Objects.isNull(grabber)) { return this; } draggingElement = (HTMLElement) grabber.closest(DRAGGABLE_ITEM_CLASS); clickedYPosition = (int) event.clientY; startYPosition = getTop(getDragging()); } return this; } DragAndDropHelper(final HTMLElement dragArea,
                             final HTMLElement addButtonContainer); }
DragAndDropHelper { Object onDragAreaMouseDown(final Event e) { final MouseEvent event = (MouseEvent) e; if (!Objects.isNull(event.target)) { final Element grabber = ((Element) event.target).closest(".drag-grabber"); if (Objects.isNull(grabber)) { return this; } draggingElement = (HTMLElement) grabber.closest(DRAGGABLE_ITEM_CLASS); clickedYPosition = (int) event.clientY; startYPosition = getTop(getDragging()); } return this; } DragAndDropHelper(final HTMLElement dragArea,
                             final HTMLElement addButtonContainer);  }
DragAndDropHelper { Object onDragAreaMouseDown(final Event e) { final MouseEvent event = (MouseEvent) e; if (!Objects.isNull(event.target)) { final Element grabber = ((Element) event.target).closest(".drag-grabber"); if (Objects.isNull(grabber)) { return this; } draggingElement = (HTMLElement) grabber.closest(DRAGGABLE_ITEM_CLASS); clickedYPosition = (int) event.clientY; startYPosition = getTop(getDragging()); } return this; } DragAndDropHelper(final HTMLElement dragArea,
                             final HTMLElement addButtonContainer);   }