author | serb |
Wed, 21 Feb 2018 12:49:00 -0800 | |
changeset 49096 | eaef201ec301 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
16710 | 1 |
/* |
45028
b0ea3c0bfb81
8179889: Fix typographic errors in copyright headers
ihse
parents:
40128
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
16710 | 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 |
/** |
|
49096
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
25 |
* @test |
eaef201ec301
8198333: ProblemList should be updated for headless mode
serb
parents:
47216
diff
changeset
|
26 |
* @summary JVM crash if the frame is disposed in DropTargetListener |
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
37704
diff
changeset
|
27 |
* @key headful |
16710 | 28 |
* @author Petr Pchelko |
29 |
* @library ../../regtesthelpers |
|
30 |
* @build Util |
|
31 |
* @compile DisposeFrameOnDragTest.java |
|
32 |
* @run main/othervm DisposeFrameOnDragTest |
|
33 |
*/ |
|
34 |
import java.awt.AWTException; |
|
35 |
import java.awt.Point; |
|
36 |
import java.awt.Robot; |
|
37 |
import java.awt.dnd.DropTargetAdapter; |
|
38 |
import java.awt.dnd.DropTargetDragEvent; |
|
39 |
import java.awt.dnd.DropTargetDropEvent; |
|
40 |
import java.awt.event.InputEvent; |
|
41 |
import java.lang.reflect.InvocationTargetException; |
|
42 |
import java.util.TooManyListenersException; |
|
43 |
import javax.swing.JFrame; |
|
44 |
import javax.swing.JTextArea; |
|
45 |
import javax.swing.SwingUtilities; |
|
46 |
import test.java.awt.regtesthelpers.Util; |
|
47 |
||
48 |
public class DisposeFrameOnDragTest { |
|
49 |
||
50 |
private static JTextArea textArea; |
|
51 |
||
52 |
public static void main(String[] args) throws Throwable { |
|
53 |
||
54 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
55 |
@Override |
|
56 |
public void run() { |
|
57 |
constructTestUI(); |
|
58 |
} |
|
59 |
}); |
|
60 |
||
37704
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
61 |
Robot testRobot = null; |
16710 | 62 |
try { |
37704
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
63 |
testRobot = new Robot(); |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
64 |
} catch(AWTException ex) { |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
65 |
throw new RuntimeException("Error while creating Robot"); |
16710 | 66 |
} |
37704
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
67 |
|
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
68 |
Util.waitForIdle(testRobot); |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
69 |
|
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
70 |
Point loc = textArea.getLocationOnScreen(); |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
71 |
Util.drag(testRobot, |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
72 |
new Point((int) loc.x + 3, (int) loc.y + 3), |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
73 |
new Point((int) loc.x + 40, (int) loc.y + 40), |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
74 |
InputEvent.BUTTON1_MASK); |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
75 |
|
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
76 |
Util.waitForIdle(testRobot); |
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
77 |
|
20f112179039
8031423: Test java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java fails by Timeout on Windows
aghaisas
parents:
16710
diff
changeset
|
78 |
testRobot.delay(200); |
16710 | 79 |
} |
80 |
||
81 |
private static void constructTestUI() { |
|
82 |
final JFrame frame = new JFrame("Test frame"); |
|
83 |
textArea = new JTextArea("Drag Me!"); |
|
84 |
try { |
|
85 |
textArea.getDropTarget().addDropTargetListener(new DropTargetAdapter() { |
|
86 |
@Override |
|
87 |
public void drop(DropTargetDropEvent dtde) { |
|
88 |
//IGNORE |
|
89 |
} |
|
90 |
||
91 |
@Override |
|
92 |
public void dragOver(DropTargetDragEvent dtde) { |
|
93 |
frame.dispose(); |
|
94 |
} |
|
95 |
}); |
|
96 |
} catch (TooManyListenersException ex) { |
|
97 |
throw new RuntimeException(ex); |
|
98 |
} |
|
99 |
textArea.setSize(100, 100); |
|
100 |
textArea.setDragEnabled(true); |
|
101 |
textArea.select(0, textArea.getText().length()); |
|
102 |
frame.add(textArea); |
|
103 |
frame.setBounds(100, 100, 100, 100); |
|
104 |
frame.setVisible(true); |
|
105 |
} |
|
106 |
} |