1 /* 2 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 4899516 28 @summary Transferable has no DataFlavors when dragging from Gnome window to Swing 29 @library ../../regtesthelpers 30 @library ../../regtesthelpers/process 31 @build Util 32 @build ProcessResults ProcessCommunicator 33 @run main/othervm URIListBetweenJVMsTest main 34 */ 35 36 import static java.lang.Thread.sleep; 37 38 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 39 import test.java.awt.regtesthelpers.process.ProcessResults; 40 import test.java.awt.regtesthelpers.Util; 41 import java.awt.*; 42 import java.awt.event.InputEvent; 43 44 public class URIListBetweenJVMsTest { 45 46 // information related to the test in common 47 static int VISIBLE_RAWS_IN_LIST=15; 48 49 public void start() { 50 51 String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); 52 if (toolkit.equals("sun.awt.windows.WToolkit")){ 53 System.out.println("This test is not for the Windows platform. Passed."); 54 return; 55 } else { 56 System.out.println("Toolkit = " + toolkit); 57 } 58 59 SourceFileListFrame sourceFrame = new SourceFileListFrame(); 60 61 Util.waitForIdle(null); 62 63 String [] args = new String [] { 64 String.valueOf(sourceFrame.getNextLocationX()), 65 String.valueOf(sourceFrame.getNextLocationY()), 66 String.valueOf(sourceFrame.getDragSourcePointX()), 67 String.valueOf(sourceFrame.getDragSourcePointY()), 68 String.valueOf(sourceFrame.getSourceFilesNumber()) 69 }; 70 71 String classpath = System.getProperty("java.class.path"); 72 ProcessResults processResults = 73 ProcessCommunicator.executeChildProcess(this.getClass(), classpath, 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 URIListBetweenJVMsTest () { 94 super(); 95 } 96 97 //We need in this constructor to pass frame position between JVMs 98 public URIListBetweenJVMsTest (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 if (args.length > 0 && args[0].equals("main")) { 135 new URIListBetweenJVMsTest().start(); 136 return; 137 } 138 Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args), 139 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args)); 140 Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args), 141 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args)); 142 int transferredFilesNumber = InterprocessArguments.FILES_IN_THE_LIST_NUMBER_ARGUMENT.extract(args); 143 144 try { 145 new URIListBetweenJVMsTest(targetFrameLocation, dragSourcePoint, transferredFilesNumber); 146 } catch (InterruptedException e) { 147 e.printStackTrace(); 148 } 149 150 } 151 152 153 }// class URIListBetweenJVMsTest