test/jdk/java/awt/dnd/FileListBetweenJVMsTest/FileListBetweenJVMsTest.java
author serb
Wed, 27 Feb 2019 18:46:55 -0800
changeset 54231 e4813eded7cb
parent 47216 71c04702a3d5
permissions -rw-r--r--
8213110: Remove the use of applets in automatic tests Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    25
  @test
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    26
  @key headful
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
  @bug 5079469
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
  @summary DnD of File-List across JVM adds two empty items to the list
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    29
  @library ../../regtesthelpers
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    30
  @library ../../regtesthelpers/process
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    31
  @build Util
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    32
  @build ProcessResults ProcessCommunicator
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    33
  @run main/othervm FileListBetweenJVMsTest main
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import static java.lang.Thread.sleep;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import test.java.awt.regtesthelpers.process.ProcessCommunicator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import test.java.awt.regtesthelpers.process.ProcessResults;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import test.java.awt.regtesthelpers.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.event.InputEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
    44
public class FileListBetweenJVMsTest {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    // information related to the test in common
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static int VISIBLE_RAWS_IN_LIST=15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public void start() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        SourceFileListFrame sourceFrame = new SourceFileListFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        Util.waitForIdle(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        String [] args = new String [] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                String.valueOf(sourceFrame.getNextLocationX()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                String.valueOf(sourceFrame.getNextLocationY()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                String.valueOf(sourceFrame.getDragSourcePointX()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                String.valueOf(sourceFrame.getDragSourcePointY()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                String.valueOf(sourceFrame.getSourceFilesNumber())
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        ProcessResults processResults =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                ProcessCommunicator.executeChildProcess(this.getClass(), args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        verifyTestResults(processResults);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }// start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static void verifyTestResults(ProcessResults processResults) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        if ( InterprocessMessages.WRONG_FILES_NUMBER_ON_TARGET ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                processResults.getExitValue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            processResults.printProcessErrorOutput(System.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            throw new RuntimeException("TEST IS FAILED: Target has recieved" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                    " wrong number of files.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        processResults.verifyStdErr(System.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        processResults.verifyProcessExitValue(System.err);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        processResults.printProcessStandartOutput(System.out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    //We cannot make an instance of the applet without the default constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public FileListBetweenJVMsTest () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    //We need in this constructor to pass frame position between JVMs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public FileListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            int transferredFilesNumber)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            throws InterruptedException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                transferredFilesNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        Util.waitForIdle(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        final Robot robot = Util.createRobot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        sleep(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        robot.mousePress(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        sleep(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        sleep(100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                InputEvent.BUTTON1_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    enum InterprocessArguments {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        TARGET_FRAME_X_POSITION_ARGUMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        TARGET_FRAME_Y_POSITION_ARGUMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        DRAG_SOURCE_POINT_X_ARGUMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        DRAG_SOURCE_POINT_Y_ARGUMENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        FILES_IN_THE_LIST_NUMBER_ARGUMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        int extract (String [] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            return Integer.parseInt(args[this.ordinal()]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
54231
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
   124
    public static void main(final String [] args) {
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
   125
        if (args.length > 0 && args[0].equals("main")) {
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
   126
            new FileListBetweenJVMsTest().start();
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
   127
            return;
e4813eded7cb 8213110: Remove the use of applets in automatic tests
serb
parents: 47216
diff changeset
   128
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        int transferredFilesNumber = InterprocessArguments.FILES_IN_THE_LIST_NUMBER_ARGUMENT.extract(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            new FileListBetweenJVMsTest(targetFrameLocation, dragSourcePoint, transferredFilesNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
}// class FileListBetweenJVMsTest