Skip to content

Commit f224212

Browse files
Victor RudometovPaul Hohensee
Victor Rudometov
authored and
Paul Hohensee
committed
8306871: Open source more AWT Drag & Drop tests
Backport-of: b5a48277ab5b42c4b13db7ddb5418a17ada512ec
1 parent e3e7722 commit f224212

File tree

6 files changed

+1915
-0
lines changed

6 files changed

+1915
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2001, 2023, 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 4420658
27+
@summary No ClassCastException should be thrown when getComponent()
28+
is called on an event with a non-Component source.
29+
The result should be null.
30+
@run main ObjectSourceTest
31+
*/
32+
33+
import java.awt.Component;
34+
import java.awt.Panel;
35+
import java.awt.event.HierarchyEvent;
36+
import java.lang.reflect.InvocationTargetException;
37+
38+
39+
public class ObjectSourceTest {
40+
static Panel panel;
41+
42+
public static void main(String args[]) throws InterruptedException,
43+
InvocationTargetException {
44+
panel = new Panel();
45+
46+
HierarchyEvent he = new HierarchyEvent(panel, HierarchyEvent.ANCESTOR_MOVED,
47+
panel, panel);
48+
Object obj = new Object();
49+
he.setSource(obj);
50+
51+
Component comp = he.getComponent();
52+
if (comp != null) {
53+
throw new RuntimeException("ObjectSourceTest failed. comp != null");
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)