0N/A/*
2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/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.
0N/A */
0N/A
0N/A/*
0N/A test
0N/A @bug 5079469
0N/A @summary DnD of File-List across JVM adds two empty items to the list
0N/A @author : area=dnd
0N/A @run applet FileListBetweenJVMsTest.html
0N/A*/
0N/A
0N/A/**
0N/A * FileListBetweenJVMsTest.java
0N/A *
0N/A * summary: DnD of File-List across JVM adds two empty items to the list
0N/A */
0N/A
0N/Aimport static java.lang.Thread.sleep;
0N/A
0N/Aimport test.java.awt.regtesthelpers.process.ProcessCommunicator;
0N/Aimport test.java.awt.regtesthelpers.process.ProcessResults;
0N/Aimport test.java.awt.regtesthelpers.Util;
0N/Aimport java.applet.Applet;
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.InputEvent;
0N/Aimport java.io.*;
0N/A
0N/Apublic class FileListBetweenJVMsTest extends Applet {
0N/A
0N/A // information related to the test in common
0N/A static int VISIBLE_RAWS_IN_LIST=15;
0N/A
0N/A public void init() {
0N/A setLayout(new BorderLayout());
0N/A
0N/A }//End init()
0N/A
0N/A public void start() {
0N/A
0N/A SourceFileListFrame sourceFrame = new SourceFileListFrame();
0N/A
0N/A Util.waitForIdle(null);
0N/A
0N/A String [] args = new String [] {
0N/A String.valueOf(sourceFrame.getNextLocationX()),
0N/A String.valueOf(sourceFrame.getNextLocationY()),
0N/A String.valueOf(sourceFrame.getDragSourcePointX()),
0N/A String.valueOf(sourceFrame.getDragSourcePointY()),
0N/A String.valueOf(sourceFrame.getSourceFilesNumber())
0N/A };
0N/A
0N/A ProcessResults processResults =
0N/A ProcessCommunicator.executeChildProcess(this.getClass(), args);
0N/A
0N/A verifyTestResults(processResults);
0N/A
0N/A }// start()
0N/A
0N/A private static void verifyTestResults(ProcessResults processResults) {
0N/A if ( InterprocessMessages.WRONG_FILES_NUMBER_ON_TARGET ==
0N/A processResults.getExitValue())
0N/A {
0N/A processResults.printProcessErrorOutput(System.err);
0N/A throw new RuntimeException("TEST IS FAILED: Target has recieved" +
0N/A " wrong number of files.");
0N/A }
0N/A processResults.verifyStdErr(System.err);
0N/A processResults.verifyProcessExitValue(System.err);
0N/A processResults.printProcessStandartOutput(System.out);
0N/A }
0N/A
0N/A //We cannot make an instance of the applet without the default constructor
0N/A public FileListBetweenJVMsTest () {
0N/A super();
0N/A }
0N/A
0N/A //We need in this constructor to pass frame position between JVMs
0N/A public FileListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint,
0N/A int transferredFilesNumber)
0N/A throws InterruptedException
0N/A {
0N/A TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation,
0N/A transferredFilesNumber);
0N/A
0N/A Util.waitForIdle(null);
0N/A
0N/A final Robot robot = Util.createRobot();
0N/A
0N/A robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
0N/A sleep(100);
0N/A robot.mousePress(InputEvent.BUTTON1_MASK);
0N/A sleep(100);
0N/A robot.mouseRelease(InputEvent.BUTTON1_MASK);
0N/A sleep(100);
0N/A
0N/A Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
0N/A InputEvent.BUTTON1_MASK);
0N/A
0N/A }
0N/A
0N/A enum InterprocessArguments {
0N/A TARGET_FRAME_X_POSITION_ARGUMENT,
0N/A TARGET_FRAME_Y_POSITION_ARGUMENT,
0N/A DRAG_SOURCE_POINT_X_ARGUMENT,
0N/A DRAG_SOURCE_POINT_Y_ARGUMENT,
0N/A FILES_IN_THE_LIST_NUMBER_ARGUMENT;
0N/A
0N/A int extract (String [] args) {
0N/A return Integer.parseInt(args[this.ordinal()]);
0N/A }
0N/A }
0N/A
0N/A public static void main (String [] args) {
0N/A Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
0N/A InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
0N/A Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
0N/A InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
0N/A int transferredFilesNumber = InterprocessArguments.FILES_IN_THE_LIST_NUMBER_ARGUMENT.extract(args);
0N/A
0N/A try {
0N/A new FileListBetweenJVMsTest(targetFrameLocation, dragSourcePoint, transferredFilesNumber);
0N/A } catch (InterruptedException e) {
0N/A e.printStackTrace();
0N/A }
0N/A
0N/A }
0N/A
0N/A
0N/A}// class FileListBetweenJVMsTest