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.image.BufferedImage; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
29 |
import java.io.IOException; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
30 |
import java.util.Vector; |
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 |
/* |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
33 |
* @test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
25569
diff
changeset
|
34 |
* @key headful |
25569
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
35 |
* @summary To check Whether java.awt.Image can be transferred through the |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
36 |
* system clipboard |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
37 |
* @author Jitender(jitender.singh@eng.sun.com) area=AWT |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
38 |
* @author dmitriy.ermashov@oracle.com |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
39 |
* @library ../../../../lib/testlibrary |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
40 |
* @build ExtendedRobot |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
41 |
* @run main ImageTransferTest |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
42 |
*/ |
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 |
public class ImageTransferTest { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
45 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
46 |
TestFrame frame1, frame2; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
47 |
Image image1, image2; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
48 |
DataFlavor imageFlavor; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
49 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
50 |
public static void main(String[] args) throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
51 |
new ImageTransferTest().doTest(); |
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 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
54 |
class TestFrame extends Frame { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
55 |
boolean show; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
56 |
Image img; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
57 |
public TestFrame(boolean show, Image img){ |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
58 |
this.show = show; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
59 |
this.img = img; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
60 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
61 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
62 |
public void paint( Graphics g ){ |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
63 |
if (show) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
64 |
g.drawImage( this.img, 30, 30, this ); |
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 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
67 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
68 |
class TransferableObject implements Transferable, ClipboardOwner { |
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 |
Object data; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
71 |
DataFlavor[] dfs; |
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 |
public TransferableObject(Object data) throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
74 |
Vector v = new Vector(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
75 |
imageFlavor = new DataFlavor("image/x-java-Image;class=java.awt.Image"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
76 |
imageFlavor.setHumanPresentableName("Java Image Flavor Object"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
77 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
78 |
if( data instanceof java.awt.Image ) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
79 |
v.addElement(imageFlavor); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
80 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
81 |
dfs = new DataFlavor[v.size()]; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
82 |
v.copyInto(dfs); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
83 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
84 |
for (int j = 0; j < dfs.length; j++) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
85 |
System.out.println(" in constructor flavor : " + dfs[j]); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
86 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
87 |
this.data = data; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
88 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
89 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
90 |
public Object getTransferData(DataFlavor flavor) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
91 |
throws UnsupportedFlavorException,IOException { |
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 |
System.out.println(" **************"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
94 |
System.out.println(" The flavor passed to retrive the data :-" + flavor); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
95 |
System.out.println(" The flavors supported"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
96 |
for (int j = 0; j < dfs.length; j++) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
97 |
System.out.println(" jitu flavor : " + dfs[j]); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
98 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
99 |
System.out.println(" **************"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
100 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
101 |
if(!isDataFlavorSupported(flavor)) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
102 |
throw new UnsupportedFlavorException(flavor); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
103 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
104 |
if(imageFlavor.equals(flavor)){ |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
105 |
if( data instanceof java.awt.Image ) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
106 |
return data; |
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 |
return null; |
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 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
111 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
112 |
public DataFlavor[] getTransferDataFlavors() { return dfs; } |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
113 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
114 |
public boolean isDataFlavorSupported(DataFlavor flavor) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
115 |
for (int i = 0 ; i < dfs.length; i++) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
116 |
if (dfs[i].match(flavor)) return true; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
117 |
return false; |
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 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
120 |
public void lostOwnership(Clipboard clip,Transferable contents) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
121 |
System.out.println(" LostOwnership is invoked"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
122 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
123 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
124 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
125 |
ImageTransferTest() throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
126 |
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
127 |
Graphics g = img.createGraphics(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
128 |
g.setColor(Color.WHITE); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
129 |
g.fillRect(0, 0, 100, 100); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
130 |
g.setColor(Color.RED); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
131 |
g.fillRect(20, 20, 60, 60); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
132 |
g.dispose(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
133 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
134 |
image1 = img; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
135 |
frame1 = new TestFrame(true, image1); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
136 |
frame2 = new TestFrame(false, null); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
137 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
138 |
System.out.println("Inside contrucor..."); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
139 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
140 |
imageFlavor = new DataFlavor("image/x-java-Image;class=java.awt.Image"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
141 |
imageFlavor.setHumanPresentableName("Java Image Flavor Object"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
142 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
143 |
frame1.setBounds(10,350,200,200); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
144 |
frame2.setBounds(250,350,200,200); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
145 |
frame1.setVisible(true); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
146 |
frame2.setVisible(true); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
147 |
frame1.repaint(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
148 |
} |
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 |
public void compareImages() { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
151 |
if (image2 == image1) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
152 |
System.out.println("Pasted Image is same as that one copied !"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
153 |
else |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
154 |
if (image2 != image1) |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
155 |
throw new RuntimeException("Image retreived from the Clipboard is not the same " + |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
156 |
"image that was set to the Clipboard"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
157 |
} |
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 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
160 |
public void doTest() throws Exception { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
161 |
ExtendedRobot robot = new ExtendedRobot(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
162 |
robot.waitForIdle(2000); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
163 |
TransferableObject imagedata = new TransferableObject(image1); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
164 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
165 |
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
166 |
System.out.println("copying image..."); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
167 |
if (imagedata != null) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
168 |
clip.setContents(imagedata, imagedata); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
169 |
} else { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
170 |
System.out.println("Transferable object is null"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
171 |
} |
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 |
Transferable content = clip.getContents(this); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
174 |
if (content != null && (content.isDataFlavorSupported(imageFlavor))) { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
175 |
System.out.println("jitu after paste" + content); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
176 |
image2 = (Image) content.getTransferData(imageFlavor); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
177 |
} else { |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
178 |
System.out.println("Contents of the clipboard is null"); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
179 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
180 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
181 |
frame2.img = image2; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
182 |
frame2.show = true; |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
183 |
frame2.repaint(); |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
184 |
|
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
185 |
robot.waitForIdle(2000); |
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 |
compareImages(); |
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 |
} |
2bea87828632
8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff
changeset
|
190 |