author | serb |
Wed, 27 Feb 2019 18:46:55 -0800 | |
changeset 54231 | e4813eded7cb |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 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 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
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 | 27 |
@bug 5079469 |
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 | 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 |
||
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
44 |
public class FileListBetweenJVMsTest { |
2 | 45 |
|
46 |
// information related to the test in common |
|
47 |
static int VISIBLE_RAWS_IN_LIST=15; |
|
48 |
||
49 |
public void start() { |
|
50 |
||
51 |
SourceFileListFrame sourceFrame = new SourceFileListFrame(); |
|
52 |
||
53 |
Util.waitForIdle(null); |
|
54 |
||
55 |
String [] args = new String [] { |
|
56 |
String.valueOf(sourceFrame.getNextLocationX()), |
|
57 |
String.valueOf(sourceFrame.getNextLocationY()), |
|
58 |
String.valueOf(sourceFrame.getDragSourcePointX()), |
|
59 |
String.valueOf(sourceFrame.getDragSourcePointY()), |
|
60 |
String.valueOf(sourceFrame.getSourceFilesNumber()) |
|
61 |
}; |
|
62 |
||
63 |
ProcessResults processResults = |
|
64 |
ProcessCommunicator.executeChildProcess(this.getClass(), args); |
|
65 |
||
66 |
verifyTestResults(processResults); |
|
67 |
||
68 |
}// start() |
|
69 |
||
70 |
private static void verifyTestResults(ProcessResults processResults) { |
|
71 |
if ( InterprocessMessages.WRONG_FILES_NUMBER_ON_TARGET == |
|
72 |
processResults.getExitValue()) |
|
73 |
{ |
|
74 |
processResults.printProcessErrorOutput(System.err); |
|
75 |
throw new RuntimeException("TEST IS FAILED: Target has recieved" + |
|
76 |
" wrong number of files."); |
|
77 |
} |
|
78 |
processResults.verifyStdErr(System.err); |
|
79 |
processResults.verifyProcessExitValue(System.err); |
|
80 |
processResults.printProcessStandartOutput(System.out); |
|
81 |
} |
|
82 |
||
83 |
//We cannot make an instance of the applet without the default constructor |
|
84 |
public FileListBetweenJVMsTest () { |
|
85 |
super(); |
|
86 |
} |
|
87 |
||
88 |
//We need in this constructor to pass frame position between JVMs |
|
89 |
public FileListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint, |
|
90 |
int transferredFilesNumber) |
|
91 |
throws InterruptedException |
|
92 |
{ |
|
93 |
TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation, |
|
94 |
transferredFilesNumber); |
|
95 |
||
96 |
Util.waitForIdle(null); |
|
97 |
||
98 |
final Robot robot = Util.createRobot(); |
|
99 |
||
100 |
robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY()); |
|
101 |
sleep(100); |
|
102 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
103 |
sleep(100); |
|
104 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
105 |
sleep(100); |
|
106 |
||
107 |
Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(), |
|
108 |
InputEvent.BUTTON1_MASK); |
|
109 |
||
110 |
} |
|
111 |
||
112 |
enum InterprocessArguments { |
|
113 |
TARGET_FRAME_X_POSITION_ARGUMENT, |
|
114 |
TARGET_FRAME_Y_POSITION_ARGUMENT, |
|
115 |
DRAG_SOURCE_POINT_X_ARGUMENT, |
|
116 |
DRAG_SOURCE_POINT_Y_ARGUMENT, |
|
117 |
FILES_IN_THE_LIST_NUMBER_ARGUMENT; |
|
118 |
||
119 |
int extract (String [] args) { |
|
120 |
return Integer.parseInt(args[this.ordinal()]); |
|
121 |
} |
|
122 |
} |
|
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 | 129 |
Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args), |
130 |
InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args)); |
|
131 |
Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args), |
|
132 |
InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args)); |
|
133 |
int transferredFilesNumber = InterprocessArguments.FILES_IN_THE_LIST_NUMBER_ARGUMENT.extract(args); |
|
134 |
||
135 |
try { |
|
136 |
new FileListBetweenJVMsTest(targetFrameLocation, dragSourcePoint, transferredFilesNumber); |
|
137 |
} catch (InterruptedException e) { |
|
138 |
e.printStackTrace(); |
|
139 |
} |
|
140 |
||
141 |
} |
|
142 |
||
143 |
||
144 |
}// class FileListBetweenJVMsTest |