J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | * have any questions. |
| 22 | */ |
| 23 | |
| 24 | /* |
| 25 | test |
| 26 | @bug 5079469 |
| 27 | @summary DnD of File-List across JVM adds two empty items to the list |
| 28 | @author : area=dnd |
| 29 | @run applet FileListBetweenJVMsTest.html |
| 30 | */ |
| 31 | |
| 32 | /** |
| 33 | * FileListBetweenJVMsTest.java |
| 34 | * |
| 35 | * summary: DnD of File-List across JVM adds two empty items to the list |
| 36 | */ |
| 37 | |
| 38 | import static java.lang.Thread.sleep; |
| 39 | |
| 40 | import test.java.awt.regtesthelpers.process.ProcessCommunicator; |
| 41 | import test.java.awt.regtesthelpers.process.ProcessResults; |
| 42 | import test.java.awt.regtesthelpers.Util; |
| 43 | import java.applet.Applet; |
| 44 | import java.awt.*; |
| 45 | import java.awt.event.InputEvent; |
| 46 | import java.io.*; |
| 47 | |
| 48 | public class FileListBetweenJVMsTest extends Applet { |
| 49 | |
| 50 | // information related to the test in common |
| 51 | static int VISIBLE_RAWS_IN_LIST=15; |
| 52 | |
| 53 | public void init() { |
| 54 | setLayout(new BorderLayout()); |
| 55 | |
| 56 | }//End init() |
| 57 | |
| 58 | public void start() { |
| 59 | |
| 60 | SourceFileListFrame sourceFrame = new SourceFileListFrame(); |
| 61 | |
| 62 | Util.waitForIdle(null); |
| 63 | |
| 64 | String [] args = new String [] { |
| 65 | String.valueOf(sourceFrame.getNextLocationX()), |
| 66 | String.valueOf(sourceFrame.getNextLocationY()), |
| 67 | String.valueOf(sourceFrame.getDragSourcePointX()), |
| 68 | String.valueOf(sourceFrame.getDragSourcePointY()), |
| 69 | String.valueOf(sourceFrame.getSourceFilesNumber()) |
| 70 | }; |
| 71 | |
| 72 | ProcessResults processResults = |
| 73 | ProcessCommunicator.executeChildProcess(this.getClass(), args); |
| 74 | |
| 75 | verifyTestResults(processResults); |
| 76 | |
| 77 | }// start() |
| 78 | |
| 79 | private static void verifyTestResults(ProcessResults processResults) { |
| 80 | if ( InterprocessMessages.WRONG_FILES_NUMBER_ON_TARGET == |
| 81 | processResults.getExitValue()) |
| 82 | { |
| 83 | processResults.printProcessErrorOutput(System.err); |
| 84 | throw new RuntimeException("TEST IS FAILED: Target has recieved" + |
| 85 | " wrong number of files."); |
| 86 | } |
| 87 | processResults.verifyStdErr(System.err); |
| 88 | processResults.verifyProcessExitValue(System.err); |
| 89 | processResults.printProcessStandartOutput(System.out); |
| 90 | } |
| 91 | |
| 92 | //We cannot make an instance of the applet without the default constructor |
| 93 | public FileListBetweenJVMsTest () { |
| 94 | super(); |
| 95 | } |
| 96 | |
| 97 | //We need in this constructor to pass frame position between JVMs |
| 98 | public FileListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint, |
| 99 | int transferredFilesNumber) |
| 100 | throws InterruptedException |
| 101 | { |
| 102 | TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation, |
| 103 | transferredFilesNumber); |
| 104 | |
| 105 | Util.waitForIdle(null); |
| 106 | |
| 107 | final Robot robot = Util.createRobot(); |
| 108 | |
| 109 | robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY()); |
| 110 | sleep(100); |
| 111 | robot.mousePress(InputEvent.BUTTON1_MASK); |
| 112 | sleep(100); |
| 113 | robot.mouseRelease(InputEvent.BUTTON1_MASK); |
| 114 | sleep(100); |
| 115 | |
| 116 | Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(), |
| 117 | InputEvent.BUTTON1_MASK); |
| 118 | |
| 119 | } |
| 120 | |
| 121 | enum InterprocessArguments { |
| 122 | TARGET_FRAME_X_POSITION_ARGUMENT, |
| 123 | TARGET_FRAME_Y_POSITION_ARGUMENT, |
| 124 | DRAG_SOURCE_POINT_X_ARGUMENT, |
| 125 | DRAG_SOURCE_POINT_Y_ARGUMENT, |
| 126 | FILES_IN_THE_LIST_NUMBER_ARGUMENT; |
| 127 | |
| 128 | int extract (String [] args) { |
| 129 | return Integer.parseInt(args[this.ordinal()]); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | public static void main (String [] args) { |
| 134 | Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args), |
| 135 | InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args)); |
| 136 | Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args), |
| 137 | InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args)); |
| 138 | int transferredFilesNumber = InterprocessArguments.FILES_IN_THE_LIST_NUMBER_ARGUMENT.extract(args); |
| 139 | |
| 140 | try { |
| 141 | new FileListBetweenJVMsTest(targetFrameLocation, dragSourcePoint, transferredFilesNumber); |
| 142 | } catch (InterruptedException e) { |
| 143 | e.printStackTrace(); |
| 144 | } |
| 145 | |
| 146 | } |
| 147 | |
| 148 | |
| 149 | }// class FileListBetweenJVMsTest |