|
1 | | - /* |
2 | | - * Copyright (c) 2009, 2013, 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 | 1 | /* |
25 | | - test |
26 | | - @bug 6242241 |
27 | | - @summary Tests basic DnD functionality in an applet |
28 | | - @requires (os.family == "windows") |
29 | | - @author Your Name: Alexey Utkin area=dnd |
30 | | - @run applet/manual=yesno DnDFileGroupDescriptor.html |
31 | | -*/ |
32 | | - |
33 | | -import java.applet.Applet; |
34 | | -import java.awt.*; |
35 | | - |
36 | | -public class DnDFileGroupDescriptor extends Applet { |
37 | | - public void init() { |
38 | | - setLayout(new BorderLayout()); |
| 2 | + * Copyright (c) 2009, 2024, 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 | +import java.awt.BorderLayout; |
| 25 | +import java.awt.Color; |
| 26 | +import java.awt.Component; |
| 27 | +import java.awt.Frame; |
| 28 | +import java.awt.Panel; |
39 | 29 |
|
40 | | - String[] instructions = { |
41 | | - "The applet window contains a red field.", |
42 | | - "1. Start MS Outlook program. Find and open ", |
43 | | - " the mail form with attachments.", |
44 | | - "2. Select attachments from the mail and drag into a red field of applet.", |
45 | | - " When the mouse enters the field during the drag, the application ", |
46 | | - " should change the cursor form to OLE-copy and field color to yellow.", |
47 | | - "3. Release the mouse button (drop attachments) over the field.", |
48 | | - "", |
49 | | - "File paths in temporary folder should appear.", |
50 | | - "", |
51 | | - "You should be able to repeat this operation multiple times.", |
52 | | - "Please, select \"Pass\" just in case of success or \"Fail\" for another." |
53 | | - }; |
54 | | - Sysout.createDialogWithInstructions( instructions ); |
| 30 | +/* |
| 31 | + * @test |
| 32 | + * @bug 6242241 |
| 33 | + * @summary Tests TransferFlavor that supports DnD of MS Outlook attachments. |
| 34 | + * @requires (os.family == "windows") |
| 35 | + * @library /java/awt/regtesthelpers |
| 36 | + * @build PassFailJFrame |
| 37 | + * @run main/manual DnDFileGroupDescriptor |
| 38 | + */ |
| 39 | + |
| 40 | +public class DnDFileGroupDescriptor { |
| 41 | + private static final String INSTRUCTIONS = """ |
| 42 | + When the test starts, a RED panel appears. |
| 43 | + 1. Start MS Outlook program. Find and open the mail form with attachments. |
| 44 | +
|
| 45 | + 2. Select attachments from the mail and drag into a red field of applet. |
| 46 | + When the mouse enters the field during the process of drag, the application |
| 47 | + should change the cursor form to OLE-copy and field color to yellow. |
| 48 | +
|
| 49 | + 3. Release the mouse button (drop attachments) over the field. |
| 50 | + File paths in temporary folder should appear. |
| 51 | + You should be able to repeat this operation multiple times. |
| 52 | +
|
| 53 | + If the above is the case then press PASS, else FAIL. |
| 54 | + """; |
| 55 | + |
| 56 | + public static void main(String[] args) throws Exception { |
| 57 | + PassFailJFrame.builder() |
| 58 | + .title("Test Instructions") |
| 59 | + .instructions(INSTRUCTIONS) |
| 60 | + .rows((int) INSTRUCTIONS.lines().count() + 2) |
| 61 | + .columns(40) |
| 62 | + .testUI(DnDFileGroupDescriptor::createUI) |
| 63 | + .build() |
| 64 | + .awaitAndCheck(); |
55 | 65 | } |
56 | 66 |
|
57 | | - public void start() { |
58 | | - Panel mainPanel; |
59 | | - Component dropTarget; |
60 | | - |
61 | | - mainPanel = new Panel(); |
| 67 | + private static Frame createUI() { |
| 68 | + Frame frame = new Frame("Test MS Outlook Mail Attachments DnD"); |
| 69 | + Panel mainPanel = new Panel(); |
62 | 70 | mainPanel.setLayout(new BorderLayout()); |
63 | 71 |
|
64 | | - mainPanel.setBackground(Color.blue); |
65 | | - dropTarget = new DnDTarget(Color.red, Color.yellow); |
66 | | - |
| 72 | + Component dropTarget = new DnDTarget(Color.RED, Color.YELLOW); |
67 | 73 | mainPanel.add(dropTarget, "Center"); |
68 | | - add(mainPanel); |
69 | 74 |
|
70 | | - setSize(200,200); |
| 75 | + frame.add(mainPanel); |
| 76 | + frame.setSize(400, 200); |
| 77 | + frame.setAlwaysOnTop(true); |
| 78 | + return frame; |
71 | 79 | } |
72 | 80 | } |
73 | | - |
74 | | -/**************************************************** |
75 | | - Standard Test Machinery |
76 | | - DO NOT modify anything below -- it's a standard |
77 | | - chunk of code whose purpose is to make user |
78 | | - interaction uniform, and thereby make it simpler |
79 | | - to read and understand someone else's test. |
80 | | - ****************************************************/ |
81 | | - |
82 | | -class Sysout |
83 | | - { |
84 | | - private static TestDialog dialog; |
85 | | - |
86 | | - public static void createDialogWithInstructions( String[] instructions ) |
87 | | - { |
88 | | - dialog = new TestDialog( new Frame(), "Instructions" ); |
89 | | - dialog.printInstructions( instructions ); |
90 | | - dialog.show(); |
91 | | - println( "Any messages for the tester will display here." ); |
92 | | - } |
93 | | - |
94 | | - public static void createDialog( ) |
95 | | - { |
96 | | - dialog = new TestDialog( new Frame(), "Instructions" ); |
97 | | - String[] defInstr = { "Instructions will appear here. ", "" } ; |
98 | | - dialog.printInstructions( defInstr ); |
99 | | - dialog.show(); |
100 | | - println( "Any messages for the tester will display here." ); |
101 | | - } |
102 | | - |
103 | | - |
104 | | - public static void printInstructions( String[] instructions ) |
105 | | - { |
106 | | - dialog.printInstructions( instructions ); |
107 | | - } |
108 | | - |
109 | | - |
110 | | - public static void println( String messageIn ) |
111 | | - { |
112 | | - dialog.displayMessage( messageIn ); |
113 | | - } |
114 | | - |
115 | | - }// Sysout class |
116 | | - |
117 | | -class TestDialog extends Dialog |
118 | | - { |
119 | | - |
120 | | - TextArea instructionsText; |
121 | | - TextArea messageText; |
122 | | - int maxStringLength = 80; |
123 | | - |
124 | | - //DO NOT call this directly, go through Sysout |
125 | | - public TestDialog( Frame frame, String name ) |
126 | | - { |
127 | | - super( frame, name ); |
128 | | - int scrollBoth = TextArea.SCROLLBARS_BOTH; |
129 | | - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); |
130 | | - add( "North", instructionsText ); |
131 | | - |
132 | | - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); |
133 | | - add("South", messageText); |
134 | | - |
135 | | - pack(); |
136 | | - |
137 | | - show(); |
138 | | - }// TestDialog() |
139 | | - |
140 | | - //DO NOT call this directly, go through Sysout |
141 | | - public void printInstructions( String[] instructions ) |
142 | | - { |
143 | | - //Clear out any current instructions |
144 | | - instructionsText.setText( "" ); |
145 | | - |
146 | | - //Go down array of instruction strings |
147 | | - |
148 | | - String printStr, remainingStr; |
149 | | - for( int i=0; i < instructions.length; i++ ) |
150 | | - { |
151 | | - //chop up each into pieces maxSringLength long |
152 | | - remainingStr = instructions[ i ]; |
153 | | - while( remainingStr.length() > 0 ) |
154 | | - { |
155 | | - //if longer than max then chop off first max chars to print |
156 | | - if( remainingStr.length() >= maxStringLength ) |
157 | | - { |
158 | | - //Try to chop on a word boundary |
159 | | - int posOfSpace = remainingStr. |
160 | | - lastIndexOf( ' ', maxStringLength - 1 ); |
161 | | - |
162 | | - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; |
163 | | - |
164 | | - printStr = remainingStr.substring( 0, posOfSpace + 1 ); |
165 | | - remainingStr = remainingStr.substring( posOfSpace + 1 ); |
166 | | - } |
167 | | - //else just print |
168 | | - else |
169 | | - { |
170 | | - printStr = remainingStr; |
171 | | - remainingStr = ""; |
172 | | - } |
173 | | - |
174 | | - instructionsText.append( printStr + "\n" ); |
175 | | - |
176 | | - }// while |
177 | | - |
178 | | - }// for |
179 | | - |
180 | | - }//printInstructions() |
181 | | - |
182 | | - //DO NOT call this directly, go through Sysout |
183 | | - public void displayMessage( String messageIn ) |
184 | | - { |
185 | | - messageText.append( messageIn + "\n" ); |
186 | | - } |
187 | | - |
188 | | - }// TestDialog class |
0 commit comments