1967N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1967N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1967N/A *
1967N/A * This code is free software; you can redistribute it and/or modify it
1967N/A * under the terms of the GNU General Public License version 2 only, as
1967N/A * published by the Free Software Foundation.
1967N/A *
1967N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1967N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1967N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1967N/A * version 2 for more details (a copy is included in the LICENSE file that
1967N/A * accompanied this code).
1967N/A *
1967N/A * You should have received a copy of the GNU General Public License version
1967N/A * 2 along with this work; if not, write to the Free Software Foundation,
1967N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1967N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1967N/A */
1967N/A
1967N/A/*
1967N/A test
1967N/A @bug 5098433
1967N/A @summary REG: DnD of File-List between JVM is broken for non ASCII file names - Win32
1967N/A @author Denis Fokin: area=dnd
1967N/A @library ../../regtesthelpers
1967N/A @library ../../regtesthelpers/process
1967N/A @build Util
1967N/A @build ProcessResults ProcessCommunicator
1967N/A
1967N/A
1967N/A @run applet/othervm DragUnicodeBetweenJVMTest.html
1967N/A*/
1967N/A
1967N/A/**
1967N/A * DragUnicodeBetweenJVMTest.java
1967N/A *
1967N/A * summary: The test drags a list of files (DataFlavor.javaFileListFlavor) from one jvm to another.
1967N/A * The files have Unicode names. The list on target side must be equal to
1967N/A * the list on the source side.
1967N/A */
1967N/A
1967N/A
1967N/Aimport java.awt.*;
1967N/Aimport java.awt.event.*;
1967N/Aimport java.applet.Applet;
1967N/A
1967N/Aimport test.java.awt.regtesthelpers.process.ProcessCommunicator;
1967N/Aimport test.java.awt.regtesthelpers.process.ProcessResults;
1967N/Aimport test.java.awt.regtesthelpers.Util;
1967N/Aimport static java.lang.Thread.sleep;
1967N/A
1967N/Apublic class DragUnicodeBetweenJVMTest extends Applet
1967N/A{
1967N/A
1967N/A public void init() {
1967N/A setLayout(new BorderLayout());
1967N/A }//End init()
1967N/A
1967N/A public void start() {
1967N/A
1967N/A String toolkit = Toolkit.getDefaultToolkit().getClass().getName();
1967N/A if (!toolkit.equals("sun.awt.windows.WToolkit")){
1967N/A System.out.println("This test is for Windows only. Passed.");
1967N/A return;
1967N/A }
1967N/A else{
1967N/A System.out.println("Toolkit = " + toolkit);
1967N/A }
1967N/A
1967N/A final Frame sourceFrame = new Frame("Source frame");
1967N/A final SourcePanel sourcePanel = new SourcePanel();
1967N/A sourceFrame.add(sourcePanel);
1967N/A sourceFrame.pack();
1967N/A sourceFrame.addWindowListener( new WindowAdapter() {
1967N/A @Override
1967N/A public void windowClosing(WindowEvent e) {
1967N/A sourceFrame.dispose();
1967N/A }
1967N/A });
1967N/A sourceFrame.setVisible(true);
1967N/A
1967N/A Util.waitForIdle(null);
1967N/A
1967N/A NextFramePositionCalculator positionCalculator = new NextFramePositionCalculator(sourceFrame);
1967N/A
1967N/A String [] args = new String [] {
1967N/A String.valueOf(positionCalculator.getNextLocationX()),
1967N/A String.valueOf(positionCalculator.getNextLocationY()),
1967N/A String.valueOf(AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(sourcePanel)),
1967N/A String.valueOf(AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(sourcePanel)),
1967N/A };
1967N/A
1967N/A
1967N/A ProcessResults processResults =
1967N/A // ProcessCommunicator.executeChildProcess(this.getClass()," -cp \"C:\\Documents and Settings\\df153228\\IdeaProjects\\UnicodeTestDebug\\out\\production\\UnicodeTestDebug\" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 ", args);
1967N/A ProcessCommunicator.executeChildProcess(this.getClass(), args);
1967N/A
1967N/A verifyTestResults(processResults);
1967N/A
1967N/A }// start()
1967N/A
1967N/A
1967N/A
1967N/A private static void verifyTestResults(ProcessResults processResults) {
1967N/A if ( InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED ==
1967N/A processResults.getExitValue())
1967N/A {
1967N/A processResults.printProcessErrorOutput(System.err);
1967N/A throw new RuntimeException("TEST IS FAILED: Target has recieved" +
1967N/A " broken file list.");
1967N/A }
1967N/A processResults.verifyStdErr(System.err);
1967N/A processResults.verifyProcessExitValue(System.err);
1967N/A processResults.printProcessStandartOutput(System.out);
1967N/A }
1967N/A
1967N/A //We cannot make an instance of the applet without the default constructor
1967N/A public DragUnicodeBetweenJVMTest () {
1967N/A super();
1967N/A }
1967N/A
1967N/A //We need in this constructor to pass frame position between JVMs
1967N/A public DragUnicodeBetweenJVMTest (Point targetFrameLocation, Point dragSourcePoint)
1967N/A throws InterruptedException
1967N/A {
1967N/A final Frame targetFrame = new Frame("Target frame");
1967N/A final TargetPanel targetPanel = new TargetPanel(targetFrame);
1967N/A targetFrame.add(targetPanel);
1967N/A targetFrame.addWindowListener( new WindowAdapter() {
1967N/A @Override
1967N/A public void windowClosing(WindowEvent e) {
1967N/A targetFrame.dispose();
1967N/A }
1967N/A });
1967N/A targetFrame.setLocation(targetFrameLocation);
1967N/A targetFrame.pack();
1967N/A targetFrame.setVisible(true);
1967N/A
1967N/A doTest(dragSourcePoint, targetPanel);
1967N/A }
1967N/A
1967N/A private void doTest(Point dragSourcePoint, TargetPanel targetPanel) {
1967N/A Util.waitForIdle(null);
1967N/A
1967N/A final Robot robot = Util.createRobot();
1967N/A
1967N/A robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
1967N/A try {
1967N/A sleep(100);
1967N/A robot.mousePress(InputEvent.BUTTON1_MASK);
1967N/A sleep(100);
1967N/A robot.mouseRelease(InputEvent.BUTTON1_MASK);
1967N/A sleep(100);
1967N/A } catch (InterruptedException e) {
1967N/A e.printStackTrace();
1967N/A }
1967N/A
1967N/A Util.drag(robot, dragSourcePoint, new Point (AbsoluteComponentCenterCalculator.calculateXCenterCoordinate(targetPanel),
1967N/A AbsoluteComponentCenterCalculator.calculateYCenterCoordinate(targetPanel)),
1967N/A InputEvent.BUTTON1_MASK);
1967N/A }
1967N/A
1967N/A
1967N/A enum InterprocessArguments {
1967N/A TARGET_FRAME_X_POSITION_ARGUMENT,
1967N/A TARGET_FRAME_Y_POSITION_ARGUMENT,
1967N/A DRAG_SOURCE_POINT_X_ARGUMENT,
1967N/A DRAG_SOURCE_POINT_Y_ARGUMENT;
1967N/A
1967N/A int extract (String [] args) {
1967N/A return Integer.parseInt(args[this.ordinal()]);
1967N/A }
1967N/A }
1967N/A
1967N/A public static void main (String [] args) {
1967N/A Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
1967N/A InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
1967N/A Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
1967N/A InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
1967N/A
1967N/A try {
1967N/A new DragUnicodeBetweenJVMTest(targetFrameLocation, dragSourcePoint);
1967N/A } catch (InterruptedException e) {
1967N/A e.printStackTrace();
1967N/A }
1967N/A }
1967N/A
1967N/A
1967N/A}