modules/graphics/src/test/java/test/javafx/scene/input/DragAndDropTest.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:

*** 21,31 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package javafx.scene.input; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import java.security.AccessControlContext; --- 21,31 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package test.javafx.scene.input; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import java.security.AccessControlContext;
*** 47,67 **** import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; ! import com.sun.javafx.pgstub.StubToolkit; import com.sun.javafx.tk.TKClipboard; import com.sun.javafx.tk.TKDragGestureListener; import com.sun.javafx.tk.TKDragSourceListener; import com.sun.javafx.tk.TKDropTargetListener; import com.sun.javafx.tk.Toolkit; ! import com.sun.javafx.test.MouseEventGenerator; import javafx.event.Event; import javafx.geometry.Point3D; import javafx.scene.SubScene; import javafx.scene.image.Image; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; --- 47,82 ---- import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; ! import test.com.sun.javafx.pgstub.StubToolkit; import com.sun.javafx.tk.TKClipboard; import com.sun.javafx.tk.TKDragGestureListener; import com.sun.javafx.tk.TKDragSourceListener; import com.sun.javafx.tk.TKDropTargetListener; import com.sun.javafx.tk.Toolkit; ! import test.com.sun.javafx.test.MouseEventGenerator; import javafx.event.Event; import javafx.geometry.Point3D; import javafx.scene.SubScene; import javafx.scene.image.Image; + import javafx.scene.input.ClipboardContent; + import javafx.scene.input.ClipboardContent; + import javafx.scene.input.DataFormat; + import javafx.scene.input.DataFormat; + import javafx.scene.input.DragEvent; + import javafx.scene.input.DragEvent; + import javafx.scene.input.Dragboard; + import javafx.scene.input.Dragboard; + import javafx.scene.input.DragboardShim; + import javafx.scene.input.MouseEvent; + import javafx.scene.input.MouseEvent; + import javafx.scene.input.PickResult; + import javafx.scene.input.PickResult; + import javafx.scene.input.TransferMode; + import javafx.scene.input.TransferMode; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue;
*** 94,104 **** @Test public void testShortConstructor() { Rectangle node = new Rectangle(10, 10); node.setTranslateX(3); node.setTranslateY(2); node.setTranslateZ(50); ! Dragboard db = new Dragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33); DragEvent e = new DragEvent(DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40, --- 109,119 ---- @Test public void testShortConstructor() { Rectangle node = new Rectangle(10, 10); node.setTranslateX(3); node.setTranslateY(2); node.setTranslateZ(50); ! Dragboard db = DragboardShim.getDragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33); DragEvent e = new DragEvent(DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40,
*** 123,133 **** assertNull(e.getAcceptedTransferMode()); assertFalse(e.isConsumed()); } @Test public void testShortConstructorWithoutPickResult() { ! Dragboard db = new Dragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); DragEvent e = new DragEvent(DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40, TransferMode.LINK, gsrc, gtrg, null); --- 138,148 ---- assertNull(e.getAcceptedTransferMode()); assertFalse(e.isConsumed()); } @Test public void testShortConstructorWithoutPickResult() { ! Dragboard db = DragboardShim.getDragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); DragEvent e = new DragEvent(DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40, TransferMode.LINK, gsrc, gtrg, null);
*** 152,162 **** node.setTranslateX(3); node.setTranslateY(2); node.setTranslateZ(50); Rectangle n1 = new Rectangle(10, 10); Rectangle n2 = new Rectangle(10, 10); ! Dragboard db = new Dragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33); DragEvent e = new DragEvent(n1, n2, DragEvent.DRAG_ENTERED, db, --- 167,177 ---- node.setTranslateX(3); node.setTranslateY(2); node.setTranslateZ(50); Rectangle n1 = new Rectangle(10, 10); Rectangle n2 = new Rectangle(10, 10); ! Dragboard db = DragboardShim.getDragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33); DragEvent e = new DragEvent(n1, n2, DragEvent.DRAG_ENTERED, db,
*** 182,192 **** } @Test public void testLongConstructorWithoutPickResult() { Rectangle n1 = new Rectangle(10, 10); Rectangle n2 = new Rectangle(10, 10); ! Dragboard db = new Dragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); DragEvent e = new DragEvent(n1, n2, DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40, TransferMode.LINK, gsrc, gtrg, null); --- 197,207 ---- } @Test public void testLongConstructorWithoutPickResult() { Rectangle n1 = new Rectangle(10, 10); Rectangle n2 = new Rectangle(10, 10); ! Dragboard db = DragboardShim.getDragboard(new ClipboardImpl()); Rectangle gsrc = new Rectangle(10, 10); Rectangle gtrg = new Rectangle(10, 10); DragEvent e = new DragEvent(n1, n2, DragEvent.DRAG_ENTERED, db, 10, 20, 30, 40, TransferMode.LINK, gsrc, gtrg, null);
*** 204,243 **** assertEquals(0, e.getPickResult().getIntersectedPoint().getZ(), 10e-20); } @Test public void shortConstructorMakesDropAccepted() { DragEvent e = new DragEvent(DragEvent.DRAG_DROPPED, ! new Dragboard(new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DROPPED, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } ! @Test public void shortConstructorMakesDoneAccepted() { DragEvent e = new DragEvent(DragEvent.DRAG_DONE, ! new Dragboard(new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DONE, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } @Test public void longConstructorMakesDropAccepted() { DragEvent e = new DragEvent(new Rectangle(), new Rectangle(), DragEvent.DRAG_DROPPED, ! new Dragboard(new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DROPPED, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } @Test public void longConstructorMakesDoneAccepted() { DragEvent e = new DragEvent(new Rectangle(), new Rectangle(), DragEvent.DRAG_DONE, ! new Dragboard(new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DONE, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } --- 219,263 ---- assertEquals(0, e.getPickResult().getIntersectedPoint().getZ(), 10e-20); } @Test public void shortConstructorMakesDropAccepted() { DragEvent e = new DragEvent(DragEvent.DRAG_DROPPED, ! DragboardShim.getDragboard( ! new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DROPPED, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } ! @Test ! public void shortConstructorMakesDoneAccepted() { DragEvent e = new DragEvent(DragEvent.DRAG_DONE, ! DragboardShim.getDragboard( ! new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DONE, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } @Test public void longConstructorMakesDropAccepted() { DragEvent e = new DragEvent(new Rectangle(), new Rectangle(), DragEvent.DRAG_DROPPED, ! DragboardShim.getDragboard( ! new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DROPPED, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); } @Test public void longConstructorMakesDoneAccepted() { DragEvent e = new DragEvent(new Rectangle(), new Rectangle(), DragEvent.DRAG_DONE, ! DragboardShim.getDragboard( ! new ClipboardImpl()), 10, 20, 30, 40, TransferMode.LINK, new Rectangle(), new Rectangle(), null); assertSame(DragEvent.DRAG_DONE, e.getEventType()); assertTrue(e.isAccepted()); assertSame(TransferMode.LINK, e.getAcceptedTransferMode()); }