--- /dev/null 2014-07-31 16:13:19.122792434 +0400 +++ new/test/java/awt/reliability/TaskXDragDrop.java 2014-07-31 17:27:57.066614968 +0400 @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +import java.awt.*; +import java.awt.dnd.DnDConstants; + +/* + * @test + * @summary Testcase to test the reliability of XDnD implementation. Opens a + * native window and drags and drops between java and the native + * windows. Checks if the events are properly triggered and the drag + * and drop occurs successfully. Tries to drag large amount of data + * and checks if there is any memory leak issue. This testcase has + * been taken from XDnD Tiger testsuite. + * @author Girish R (girish.ramachandran@sun.com), AWT-SQE + * @library ../../../lib/testlibrary + * @build ExtendedRobot + * @run shell TaskXDragDrop.sh + */ + +public class TaskXDragDrop extends Task { + + Point javaPoint; + Point nativePoint; + + public static void main (String[] args) throws Exception { + new TaskXDragDrop(GUIXDnDJava.class, new ExtendedRobot()).runTask(); + System.exit(0); + } + + /** + * Initializes the GUI. Adds listeners to the GUI. + */ + public TaskXDragDrop(Class guiClass, ExtendedRobot robot) throws Exception { + super(guiClass, robot); + + gui.startChild(); + gui.dragDropEnd = false; + gui.dropSuccess = false; + gui.dropAction = 0; + gui.dropData = new String(""); + } + + /** + * Took the test from XDnD tests. + * Open the native window and wait for the test to complete. + */ + public void task() throws Exception { + //EventQueue.invokeAndWait(gui::requestFocus); + //robot.waitForIdle(1000); + + javaPoint = new Point(6, 200); + Dimension d = gui.getSize(); + javaPoint.translate(d.width / 2, d.height / 2); + + nativePoint = new Point(650, javaPoint.y); + + robot.dragAndDrop(javaPoint, nativePoint); + //robot.waitForIdle(1000); + robot.dragAndDrop(nativePoint, javaPoint); + //robot.waitForIdle(1000); + + if (!(GUIXDnDJava.data + GUIXDnDJava.data).equals(((String) (gui.dropData)).trim())) + throw new RuntimeException("Incorrect drop data: " + gui.dropData); + + if (!gui.dragDropEnd) + throw new RuntimeException("TEST FAIL: dragDropEnd() method is not called"); + + gui.destroyProcess(); + EventQueue.invokeAndWait(gui::dispose); + } + + public void verifyFailed() { + if (gui.dropSuccess == false) + throw new RuntimeException("Drop is NOT successful"); + + if (gui.dropAction != DnDConstants.ACTION_MOVE) + throw new RuntimeException("Drop Action is wrong"); + } +} +