1 /*
2 * Copyright (c) 2007, 2014, 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 6887703
27 @summary Unsigned applet can retrieve the dragged information before drop action occurs
28 @author : area=dnd
29 @run applet DragInterceptorAppletTest.html
30 */
31
32 /**
33 * DragInterceptorAppletTest.java
34 *
35 * summary: Unsigned applet can retrieve the dragged information before drop action occurs
36 */
37
38 import static java.lang.Thread.sleep;
39
40 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
41 import test.java.awt.regtesthelpers.process.ProcessResults;
42 import test.java.awt.regtesthelpers.Util;
43 import java.applet.Applet;
44 import java.awt.*;
45 import java.awt.event.InputEvent;
46
47 public class DragInterceptorAppletTest extends Applet {
48
49 public void init() {
50 setLayout(new BorderLayout());
51 }//End init()
52
53 public void start() {
54
55 SourceFrame sourceFrame = new SourceFrame();
56
57 Util.waitForIdle(null);
58
59 String [] args = new String [] {
60 String.valueOf(sourceFrame.getNextLocationX()),
61 String.valueOf(sourceFrame.getNextLocationY()),
62 String.valueOf(sourceFrame.getDragSourcePointX()),
63 String.valueOf(sourceFrame.getDragSourcePointY()),
64 };
65 String classpath = System.getProperty("java.class.path");
66 ProcessResults processResults =
67 ProcessCommunicator.executeChildProcess(this.getClass(),classpath,args);
68
69 verifyTestResults(processResults);
70
71 }// start()
121 sleep(100);
122
123 Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
124 InputEvent.BUTTON1_MASK);
125
126 sleep(2000);
127 ProcessCommunicator.destroyProcess();
128 }
129
130 enum InterprocessArguments {
131 TARGET_FRAME_X_POSITION_ARGUMENT,
132 TARGET_FRAME_Y_POSITION_ARGUMENT,
133 DRAG_SOURCE_POINT_X_ARGUMENT,
134 DRAG_SOURCE_POINT_Y_ARGUMENT;
135
136 int extract (String [] args) {
137 return Integer.parseInt(args[this.ordinal()]);
138 }
139 }
140
141 public static void main (String [] args) {
142 Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
143 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
144 Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
145 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
146 try {
147 new DragInterceptorAppletTest(targetFrameLocation, dragSourcePoint);
148 } catch (InterruptedException e) {
149 e.printStackTrace();
150 throw new RuntimeException(e);
151 }
152 }
153
154 }// class DragInterceptorAppletTest
|
1 /*
2 * Copyright (c) 2007, 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 6887703
28 @summary Unsigned applet can retrieve the dragged information before drop action occurs
29 @library ../../regtesthelpers
30 @library ../../regtesthelpers/process
31 @build Util
32 @build ProcessResults ProcessCommunicator
33 @run main/othervm DragInterceptorAppletTest main
34 */
35
36 import java.awt.Point;
37 import java.awt.Robot;
38 import java.awt.event.InputEvent;
39
40 import test.java.awt.regtesthelpers.Util;
41 import test.java.awt.regtesthelpers.process.ProcessCommunicator;
42 import test.java.awt.regtesthelpers.process.ProcessResults;
43
44 import static java.lang.Thread.sleep;
45
46 public class DragInterceptorAppletTest {
47
48 public void start() {
49
50 SourceFrame sourceFrame = new SourceFrame();
51
52 Util.waitForIdle(null);
53
54 String [] args = new String [] {
55 String.valueOf(sourceFrame.getNextLocationX()),
56 String.valueOf(sourceFrame.getNextLocationY()),
57 String.valueOf(sourceFrame.getDragSourcePointX()),
58 String.valueOf(sourceFrame.getDragSourcePointY()),
59 };
60 String classpath = System.getProperty("java.class.path");
61 ProcessResults processResults =
62 ProcessCommunicator.executeChildProcess(this.getClass(),classpath,args);
63
64 verifyTestResults(processResults);
65
66 }// start()
116 sleep(100);
117
118 Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
119 InputEvent.BUTTON1_MASK);
120
121 sleep(2000);
122 ProcessCommunicator.destroyProcess();
123 }
124
125 enum InterprocessArguments {
126 TARGET_FRAME_X_POSITION_ARGUMENT,
127 TARGET_FRAME_Y_POSITION_ARGUMENT,
128 DRAG_SOURCE_POINT_X_ARGUMENT,
129 DRAG_SOURCE_POINT_Y_ARGUMENT;
130
131 int extract (String [] args) {
132 return Integer.parseInt(args[this.ordinal()]);
133 }
134 }
135
136 public static void main(final String[] args) {
137 if (args.length > 0 && args[0].equals("main")) {
138 new DragInterceptorAppletTest().start();
139 return;
140 }
141 Point dragSourcePoint = new Point(InterprocessArguments.DRAG_SOURCE_POINT_X_ARGUMENT.extract(args),
142 InterprocessArguments.DRAG_SOURCE_POINT_Y_ARGUMENT.extract(args));
143 Point targetFrameLocation = new Point(InterprocessArguments.TARGET_FRAME_X_POSITION_ARGUMENT.extract(args),
144 InterprocessArguments.TARGET_FRAME_Y_POSITION_ARGUMENT.extract(args));
145 try {
146 new DragInterceptorAppletTest(targetFrameLocation, dragSourcePoint);
147 } catch (InterruptedException e) {
148 e.printStackTrace();
149 throw new RuntimeException(e);
150 }
151 }
152
153 }// class DragInterceptorAppletTest
|