author | pchelko |
Mon, 20 Jan 2014 14:23:51 +0400 | |
changeset 23263 | dcf3b071fc36 |
parent 5506 | 202f599c92aa |
child 38383 | c76fffbf4ef5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23263
dcf3b071fc36
8032058: [TEST_BUG] [macosx] java/awt/dnd/Button2DragTest sometimes fail
pchelko
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2006, 2014, 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 |
/* |
|
25 |
test |
|
26 |
@bug 4955110 |
|
27 |
@summary tests that a drag ends on button2 release |
|
28 |
@author Alexander.Gerasimov area=dnd |
|
29 |
@library ../../regtesthelpers |
|
30 |
@build Util |
|
31 |
@run applet/othervm Button2DragTest.html |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
/** |
|
36 |
* Button2DragTest.java |
|
37 |
* |
|
38 |
* summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec |
|
39 |
* (does not depend on the user drop action) |
|
40 |
* |
|
41 |
*/ |
|
42 |
||
43 |
import java.applet.Applet; |
|
44 |
import java.awt.*; |
|
45 |
import java.awt.event.*; |
|
46 |
import java.awt.datatransfer.*; |
|
47 |
import java.awt.dnd.*; |
|
48 |
import test.java.awt.regtesthelpers.Util; |
|
49 |
||
50 |
||
51 |
public class Button2DragTest extends Applet { |
|
52 |
||
53 |
private volatile boolean dropSuccess; |
|
54 |
||
55 |
private Frame frame; |
|
56 |
||
57 |
||
58 |
public void init() { |
|
59 |
// Set up the environment -- set the layout manager, add |
|
60 |
// buttons, etc. |
|
61 |
setLayout(new BorderLayout()); |
|
62 |
||
63 |
frame = new Frame(); |
|
64 |
||
65 |
final DragSourceListener dragSourceListener = new DragSourceAdapter() { |
|
66 |
public void dragDropEnd(DragSourceDropEvent e) { |
|
67 |
dropSuccess = e.getDropSuccess(); |
|
68 |
System.err.println("Drop was successful: " + dropSuccess); |
|
69 |
} |
|
70 |
}; |
|
71 |
DragGestureListener dragGestureListener = new DragGestureListener() { |
|
72 |
public void dragGestureRecognized(DragGestureEvent dge) { |
|
73 |
dge.startDrag(null, new StringSelection("OK"), dragSourceListener); |
|
74 |
} |
|
75 |
}; |
|
76 |
new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_MOVE, |
|
77 |
dragGestureListener); |
|
78 |
||
79 |
DropTargetAdapter dropTargetListener = new DropTargetAdapter() { |
|
80 |
public void drop(DropTargetDropEvent dtde) { |
|
81 |
dtde.acceptDrop(DnDConstants.ACTION_MOVE); |
|
82 |
dtde.dropComplete(true); |
|
83 |
System.err.println("Drop"); |
|
84 |
} |
|
85 |
}; |
|
86 |
new DropTarget(frame, dropTargetListener); |
|
87 |
} |
|
88 |
||
89 |
||
90 |
public void start() { |
|
91 |
//Get things going. Request focus, set size, et cetera |
|
92 |
setSize(200,200); |
|
93 |
setVisible(true); |
|
94 |
validate(); |
|
95 |
||
96 |
//What would normally go into main() will probably go here. |
|
97 |
//Use System.out.println for diagnostic messages that you want |
|
98 |
//to read after the test is done. |
|
99 |
||
100 |
frame.setBounds(100, 100, 200, 200); |
|
101 |
frame.setVisible(true); |
|
102 |
||
103 |
Robot robot = Util.createRobot(); |
|
104 |
||
105 |
Util.waitForIdle(robot); |
|
106 |
||
107 |
Point startPoint = frame.getLocationOnScreen(); |
|
108 |
Point endPoint = new Point(startPoint); |
|
109 |
startPoint.translate(50, 50); |
|
110 |
endPoint.translate(150, 150); |
|
111 |
||
112 |
Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK); |
|
113 |
||
114 |
Util.waitForIdle(robot); |
|
23263
dcf3b071fc36
8032058: [TEST_BUG] [macosx] java/awt/dnd/Button2DragTest sometimes fail
pchelko
parents:
5506
diff
changeset
|
115 |
robot.delay(500); |
2 | 116 |
|
117 |
if (dropSuccess) { |
|
118 |
System.err.println("test passed"); |
|
119 |
} else { |
|
120 |
throw new RuntimeException("test failed: drop was not successful"); |
|
121 |
} |
|
122 |
} |
|
123 |
||
124 |
} |