author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 25569 | 2bea87828632 |
permissions | -rw-r--r-- |
25569
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25569
diff
changeset
|
2 |
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
25569
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
4 |
* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
10 |
* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
15 |
* accompanied this code). |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
16 |
* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
20 |
* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
23 |
* questions. |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
24 |
*/ |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
25 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
26 |
import java.awt.*; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
27 |
import java.awt.datatransfer.*; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
28 |
import java.awt.event.*; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
29 |
import java.util.Properties; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
30 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
31 |
/* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
32 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25569
diff
changeset
|
33 |
* @key headful |
25569
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
34 |
* @summary To make sure that System & Primary clipboards should behave independently |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
35 |
* @author Jitender(jitender.singh@eng.sun.com) area=AWT |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
36 |
* @author dmitriy.ermashov@oracle.com |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
37 |
* @library ../../../../lib/testlibrary |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
38 |
* @build ExtendedRobot |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
39 |
* @run main IndependenceAWTTest |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
40 |
*/ |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
41 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
42 |
public class IndependenceAWTTest { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
43 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
44 |
Frame frame; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
45 |
Panel panel; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
46 |
TextField tf1, tf2, tf3; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
47 |
Clipboard sClip, pClip; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
48 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
49 |
public static void main (String[] args) throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
50 |
new IndependenceAWTTest().doTest(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
51 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
52 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
53 |
public IndependenceAWTTest() { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
54 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
55 |
frame = new Frame(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
56 |
frame.setSize(200, 200); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
57 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
58 |
// This textfield will be used to update the contents of clipboards |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
59 |
tf1 = new TextField(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
60 |
tf1.addFocusListener(new FocusAdapter() { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
61 |
public void focusGained(FocusEvent fe) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
62 |
tf1.setText("Clipboards_Independance_Testing"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
63 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
64 |
}); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
65 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
66 |
// TextFields to get the contents of clipboard |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
67 |
tf2 = new TextField(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
68 |
tf3 = new TextField(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
69 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
70 |
panel = new Panel(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
71 |
panel.setLayout(new BorderLayout()); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
72 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
73 |
panel.add(tf2, BorderLayout.NORTH); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
74 |
panel.add(tf3, BorderLayout.SOUTH); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
75 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
76 |
frame.add(tf1, BorderLayout.NORTH); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
77 |
frame.add(panel, BorderLayout.CENTER); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
78 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
79 |
frame.setVisible(true); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
80 |
tf1.requestFocus(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
81 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
82 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
83 |
public void checkSecurity() { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
84 |
SecurityManager sm = System.getSecurityManager(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
85 |
if (sm == null) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
86 |
System.out.println("security manager is not there"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
87 |
getPrimaryClipboard(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
88 |
} else { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
89 |
sm.checkPermission(new AWTPermission("accessClipboard")); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
90 |
getPrimaryClipboard(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
91 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
92 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
93 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
94 |
// Get System Selection i.e. Primary Clipboard |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
95 |
private void getPrimaryClipboard() { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
96 |
Properties ps = System.getProperties(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
97 |
String operSys = ps.getProperty("os.name"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
98 |
try { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
99 |
pClip = Toolkit.getDefaultToolkit().getSystemSelection(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
100 |
if (pClip == null) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
101 |
if ((operSys.substring(0,3)).equalsIgnoreCase("Win") || operSys.toLowerCase().contains("os x")) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
102 |
System.out.println(operSys + "Operating system does not support system selection "); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
103 |
else |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
104 |
throw new RuntimeException("Method getSystemSelection() is returning null on X11 platform"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
105 |
} catch(HeadlessException e) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
106 |
System.out.println("Headless exception thrown " + e); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
107 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
108 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
109 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
110 |
// Method to get the contents of both of the clipboards |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
111 |
public void getClipboardsContent() throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
112 |
sClip = Toolkit.getDefaultToolkit().getSystemClipboard(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
113 |
Transferable tp; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
114 |
Transferable ts; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
115 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
116 |
StringSelection content = new StringSelection(tf1.getText()); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
117 |
sClip.setContents(content,content); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
118 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
119 |
tp = pClip.getContents(this); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
120 |
ts = sClip.getContents(this); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
121 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
122 |
// Paste the contents of System clipboard on textfield tf2 while the paste the contents of |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
123 |
// of primary clipboard on textfiled tf3 |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
124 |
if ((ts != null) && (ts.isDataFlavorSupported(DataFlavor.stringFlavor))) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
125 |
tf2.setBackground(Color.white); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
126 |
tf2.setForeground(Color.black); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
127 |
tf2.setText((String) ts.getTransferData(DataFlavor.stringFlavor)); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
128 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
129 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
130 |
if ((tp != null) && (tp.isDataFlavorSupported(DataFlavor.stringFlavor))) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
131 |
tf3.setBackground(Color.white); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
132 |
tf3.setForeground(Color.black); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
133 |
tf3.setText((String) tp.getTransferData(DataFlavor.stringFlavor)); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
134 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
135 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
136 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
137 |
// Method to compare the Contents return by system & primary clipboard |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
138 |
public void compareText (boolean mustEqual) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
139 |
if ((tf2.getText()).equals(tf3.getText())) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
140 |
if (mustEqual) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
141 |
System.out.println("Selected text & clipboard contents are same\n"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
142 |
else |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
143 |
throw new RuntimeException("Selected text & clipboard contents are same\n"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
144 |
} else { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
145 |
if (mustEqual) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
146 |
throw new RuntimeException("Selected text & clipboard contents differs\n"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
147 |
else |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
148 |
System.out.println("Selected text & clipboard contents differs\n"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
149 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
150 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
151 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
152 |
public void doTest() throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
153 |
checkSecurity(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
154 |
ExtendedRobot robot = new ExtendedRobot(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
155 |
robot.waitForIdle(1000); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
156 |
frame.setLocation(100, 100); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
157 |
robot.waitForIdle(1000); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
158 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
159 |
if (pClip != null) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
160 |
Point ttf1Center = tf1.getLocationOnScreen(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
161 |
ttf1Center.translate(tf1.getWidth()/2, tf1.getHeight()/2); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
162 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
163 |
robot.glide(new Point(0, 0), ttf1Center); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
164 |
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
165 |
robot.waitForIdle(20); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
166 |
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
167 |
robot.waitForIdle(20); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
168 |
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
169 |
robot.waitForIdle(20); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
170 |
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
171 |
robot.waitForIdle(2000); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
172 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
173 |
getClipboardsContent(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
174 |
compareText(true); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
175 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
176 |
//Change the text selection to update the contents of primary clipboard |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
177 |
robot.mouseMove(ttf1Center); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
178 |
robot.mousePress(MouseEvent.BUTTON1_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
179 |
robot.delay(200); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
180 |
robot.mouseMove(ttf1Center.x + 15, ttf1Center.y); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
181 |
robot.mouseRelease(MouseEvent.BUTTON1_MASK); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
182 |
robot.waitForIdle(2000); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
183 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
184 |
getClipboardsContent(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
185 |
compareText(false); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
186 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
187 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
188 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
189 |