author | alanb |
Thu, 01 Dec 2016 08:57:53 +0000 | |
changeset 42338 | a60f280f803c |
parent 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
12523 | 1 |
/* |
30469 | 2 |
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
12523 | 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 |
* Portions Copyright (c) 2012 IBM Corporation |
|
26 |
*/ |
|
27 |
||
28 |
||
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
39541
diff
changeset
|
29 |
/* |
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
39541
diff
changeset
|
30 |
* @test |
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
39541
diff
changeset
|
31 |
* @key headful |
12523 | 32 |
* @bug 7129742 |
33 |
* @summary Focus in non-editable TextArea is not shown on Linux. |
|
39541
2d0b64d48027
8160650: Couple awt and swing tests have wrong require jtreg arguments
mcherkas
parents:
32286
diff
changeset
|
34 |
* @requires (os.family == "linux" | os.family == "solaris") |
31660
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
30469
diff
changeset
|
35 |
* @modules java.desktop/sun.awt |
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
30469
diff
changeset
|
36 |
* java.desktop/java.awt.peer |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40128
diff
changeset
|
37 |
* java.desktop/sun.awt.X11:open |
12523 | 38 |
* @author Sean Chou |
39 |
*/ |
|
40 |
||
41 |
import java.awt.FlowLayout; |
|
42 |
import java.awt.TextArea; |
|
27763
1fba965925e8
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents:
14856
diff
changeset
|
43 |
import java.awt.Robot; |
12523 | 44 |
import java.lang.reflect.Field; |
45 |
||
46 |
import javax.swing.JFrame; |
|
47 |
import javax.swing.JTextArea; |
|
48 |
import javax.swing.SwingUtilities; |
|
49 |
import javax.swing.text.DefaultCaret; |
|
50 |
||
30469 | 51 |
import sun.awt.AWTAccessor; |
52 |
import sun.awt.AWTAccessor.ComponentAccessor; |
|
53 |
||
12523 | 54 |
|
55 |
public class bug7129742 { |
|
56 |
||
57 |
public static DefaultCaret caret = null; |
|
58 |
public static JFrame frame = null; |
|
59 |
public static boolean fastreturn = false; |
|
60 |
||
61 |
public static void main(String[] args) throws Exception { |
|
27763
1fba965925e8
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents:
14856
diff
changeset
|
62 |
Robot robot = new Robot(); |
12523 | 63 |
|
64 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
65 |
@Override |
|
66 |
public void run() { |
|
67 |
frame = new JFrame("Test"); |
|
68 |
TextArea textArea = new TextArea("Non-editable textArea"); |
|
69 |
textArea.setEditable(false); |
|
70 |
frame.setLayout(new FlowLayout()); |
|
71 |
frame.add(textArea); |
|
72 |
frame.pack(); |
|
73 |
frame.setVisible(true); |
|
74 |
||
75 |
try { |
|
30469 | 76 |
ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
77 |
Class XTextAreaPeerClzz = acc.getPeer(textArea).getClass(); |
|
12523 | 78 |
System.out.println(XTextAreaPeerClzz.getName()); |
79 |
if (!XTextAreaPeerClzz.getName().equals("sun.awt.X11.XTextAreaPeer")) { |
|
80 |
fastreturn = true; |
|
81 |
return; |
|
82 |
} |
|
83 |
||
84 |
Field jtextField = XTextAreaPeerClzz.getDeclaredField("jtext"); |
|
85 |
jtextField.setAccessible(true); |
|
30469 | 86 |
JTextArea jtext = (JTextArea)jtextField.get(acc.getPeer(textArea)); |
12523 | 87 |
caret = (DefaultCaret) jtext.getCaret(); |
88 |
||
89 |
textArea.requestFocusInWindow(); |
|
90 |
} catch (NoSuchFieldException | SecurityException |
|
91 |
| IllegalArgumentException | IllegalAccessException e) { |
|
92 |
/* These exceptions mean the implementation of XTextAreaPeer is |
|
93 |
* changed, this testcase is not valid any more, fix it or remove. |
|
94 |
*/ |
|
95 |
frame.dispose(); |
|
96 |
throw new RuntimeException("This testcase is not valid any more!"); |
|
97 |
} |
|
98 |
} |
|
99 |
}); |
|
27763
1fba965925e8
8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
yan
parents:
14856
diff
changeset
|
100 |
robot.waitForIdle(); |
12523 | 101 |
|
102 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
103 |
@Override |
|
104 |
public void run() { |
|
105 |
try{ |
|
106 |
if (fastreturn) { |
|
107 |
return; |
|
108 |
} |
|
109 |
boolean passed = caret.isActive(); |
|
110 |
System.out.println("is caret visible : " + passed); |
|
111 |
||
112 |
if (!passed) { |
|
113 |
throw new RuntimeException("The test for bug 71297422 failed"); |
|
114 |
} |
|
115 |
} finally { |
|
116 |
frame.dispose(); |
|
117 |
} |
|
118 |
} |
|
119 |
}); |
|
120 |
} |
|
121 |
||
122 |
} |