@Test public void dropRequiresDragStart() { StubAnchor a1 = new StubAnchor(); StubAnchor a2 = new StubAnchor(); a1.addDragStartHandler(e -> e.setData("text/plain", "foo")); a2.addDragOverHandler(e -> { }); try { a2.drop(); fail(); } catch (IllegalStateException ise) { assertThat(ise.getMessage(), is("No stub dragStart() was called")); } }
void drop() { if (currentOverOwner != owner) { dragOver(); } ensureCanBeDroppedOn(); currentDrop = new StubDropEvent(currentStart.mimeType, currentStart.data); owner.fireEvent(currentDrop); if (!currentDrop.prevented) { throw new IllegalStateException("addDropHandler should call preventDefault()"); } currentDraggable.fireEvent(new StubDragEndEvent()); reset(); }
StubDragLogic { void drop() { if (currentOverOwner != owner) { dragOver(); } ensureCanBeDroppedOn(); currentDrop = new StubDropEvent(currentStart.mimeType, currentStart.data); owner.fireEvent(currentDrop); if (!currentDrop.prevented) { throw new IllegalStateException("addDropHandler should call preventDefault()"); } currentDraggable.fireEvent(new StubDragEndEvent()); reset(); } }
StubDragLogic { void drop() { if (currentOverOwner != owner) { dragOver(); } ensureCanBeDroppedOn(); currentDrop = new StubDropEvent(currentStart.mimeType, currentStart.data); owner.fireEvent(currentDrop); if (!currentDrop.prevented) { throw new IllegalStateException("addDropHandler should call preventDefault()"); } currentDraggable.fireEvent(new StubDragEndEvent()); reset(); } StubDragLogic(HasAllDragAndDropHandlers owner); }
StubDragLogic { void drop() { if (currentOverOwner != owner) { dragOver(); } ensureCanBeDroppedOn(); currentDrop = new StubDropEvent(currentStart.mimeType, currentStart.data); owner.fireEvent(currentDrop); if (!currentDrop.prevented) { throw new IllegalStateException("addDropHandler should call preventDefault()"); } currentDraggable.fireEvent(new StubDragEndEvent()); reset(); } StubDragLogic(HasAllDragAndDropHandlers owner);  }
StubDragLogic { void drop() { if (currentOverOwner != owner) { dragOver(); } ensureCanBeDroppedOn(); currentDrop = new StubDropEvent(currentStart.mimeType, currentStart.data); owner.fireEvent(currentDrop); if (!currentDrop.prevented) { throw new IllegalStateException("addDropHandler should call preventDefault()"); } currentDraggable.fireEvent(new StubDragEndEvent()); reset(); } StubDragLogic(HasAllDragAndDropHandlers owner);  static HasAllDragAndDropHandlers currentDraggable; static StubDragStartEvent currentStart; static StubDragOverEvent currentOver; static HasAllDragAndDropHandlers currentOverOwner; static StubDropEvent currentDrop; }