1 /* 2 * Copyright (c) 2009, 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 @bug 5098433 27 @summary REG: DnD of File-List between JVM is broken for non ASCII file names - Win32 28 @author Denis Fokin: area=dnd 29 @library ../../regtesthelpers 30 @library ../../regtesthelpers/process 31 @build Util 32 @build ProcessResults ProcessCommunicator 33 34 35 @run applet/othervm DragUnicodeBetweenJVMTest.html 36 */ 37 38 /** 39 * DragUnicodeBetweenJVMTest.java 40 * 41 * summary: The test drags a list of files (DataFlavor.javaFileListFlavor) from one jvm to another. 42 * The files have Unicode names. The list on target side must be equal to 43 * the list on the source side. 44 */ 45 46 47 import java.awt.*; 48 import java.awt.event.*; 49 import java.applet.Applet; 50 51 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 52 import test.java.awt.regtesthelpers.process.ProcessResults; 53 import test.java.awt.regtesthelpers.Util; 54 import static java.lang.Thread.sleep; 55 56 public class DragUnicodeBetweenJVMTest extends Applet 57 { 58 59 public void init() { 60 setLayout(new BorderLayout()); 61 }//End init() 62 63 public void start() { 64 65 String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); 66 if (!toolkit.equals("sun.awt.windows.WToolkit")){ 67 System.out.println("This test is for Windows only. Passed."); 68 return; 69 } 70 else{ 71 System.out.println("Toolkit = " + toolkit); 72 } 73 74 final Frame sourceFrame = new Frame("Source frame"); 75 final SourcePanel sourcePanel = new SourcePanel(); 76 sourceFrame.add(sourcePanel); 77 sourceFrame.pack(); 78 sourceFrame.addWindowListener( new WindowAdapter() { 79 @Override 80 public void windowClosing(WindowEvent e) { 81 sourceFrame.dispose(); 159 e.printStackTrace(); 160 } 161 162 Util.drag(robot, dragSourcePoint, new Point (AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(targetPanel), 163 AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(targetPanel)), 164 InputEvent.BUTTON1_MASK); 165 } 166 167 168 enum InterprocessArguments { 169 TARGET_FRAME_X_POSITION_ARGUMENT, 170 TARGET_FRAME_Y_POSITION_ARGUMENT, 171 DRAG_SOURCE_POINT_X_ARGUMENT, 172 DRAG_SOURCE_POINT_Y_ARGUMENT; 173 174 int extract (String [] args) { 175 return Integer.parseInt(args[this.ordinal()]); 176 } 177 } 178 179 public static void main (String [] args) { 180 Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args), 181 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args)); 182 Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args), 183 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args)); 184 185 try { 186 new DragUnicodeBetweenJVMTest(targetFrameLocation, dragSourcePoint); 187 } catch (InterruptedException e) { 188 e.printStackTrace(); 189 } 190 } 191 192 193 } | 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 5098433 28 @summary REG: DnD of File-List between JVM is broken for non ASCII file names - Win32 29 @library ../../regtesthelpers 30 @library ../../regtesthelpers/process 31 @build Util 32 @build ProcessResults ProcessCommunicator 33 @run main/othervm DragUnicodeBetweenJVMTest main 34 */ 35 36 import java.awt.*; 37 import java.awt.event.*; 38 39 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 40 import test.java.awt.regtesthelpers.process.ProcessResults; 41 import test.java.awt.regtesthelpers.Util; 42 import static java.lang.Thread.sleep; 43 44 public class DragUnicodeBetweenJVMTest { 45 46 public void start() { 47 48 String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); 49 if (!toolkit.equals("sun.awt.windows.WToolkit")){ 50 System.out.println("This test is for Windows only. Passed."); 51 return; 52 } 53 else{ 54 System.out.println("Toolkit = " + toolkit); 55 } 56 57 final Frame sourceFrame = new Frame("Source frame"); 58 final SourcePanel sourcePanel = new SourcePanel(); 59 sourceFrame.add(sourcePanel); 60 sourceFrame.pack(); 61 sourceFrame.addWindowListener( new WindowAdapter() { 62 @Override 63 public void windowClosing(WindowEvent e) { 64 sourceFrame.dispose(); 142 e.printStackTrace(); 143 } 144 145 Util.drag(robot, dragSourcePoint, new Point (AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(targetPanel), 146 AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(targetPanel)), 147 InputEvent.BUTTON1_MASK); 148 } 149 150 151 enum InterprocessArguments { 152 TARGET_FRAME_X_POSITION_ARGUMENT, 153 TARGET_FRAME_Y_POSITION_ARGUMENT, 154 DRAG_SOURCE_POINT_X_ARGUMENT, 155 DRAG_SOURCE_POINT_Y_ARGUMENT; 156 157 int extract (String [] args) { 158 return Integer.parseInt(args[this.ordinal()]); 159 } 160 } 161 162 public static void main(final String [] args) { 163 if (args.length > 0 && args[0].equals("main")) { 164 new DragUnicodeBetweenJVMTest().start(); 165 return; 166 } 167 Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args), 168 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args)); 169 Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args), 170 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args)); 171 172 try { 173 new DragUnicodeBetweenJVMTest(targetFrameLocation, dragSourcePoint); 174 } catch (InterruptedException e) { 175 e.printStackTrace(); 176 } 177 } 178 } |