~ubuntu-branches/ubuntu/natty/openjdk-6/natty-security

« back to all changes in this revision

Viewing changes to patches/openjdk/6578583-modality-broken-vista.patch

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-22 12:07:52 UTC
  • mfrom: (0.69.4)
  • Revision ID: package-import@ubuntu.com-20111022120752-3draavcem7z20r9a
Tags: 6b22-1.10.4-0ubuntu1~11.04.1
* SECURITY UPDATE: IcedTea6 1.10.4 Release:
  - Security fixes:
    - S7000600, CVE-2011-3547: InputStream skip() information leak.
    - S7019773, CVE-2011-3548: mutable static AWTKeyStroke.ctor.
    - S7023640, CVE-2011-3551: Java2D TransformHelper integer overflow.
    - S7032417, CVE-2011-3552: excessive default UDP socket limit under
      SecurityManager.
    - S7046794, CVE-2011-3553: JAX-WS stack-traces information leak.
    - S7046823, CVE-2011-3544: missing SecurityManager checks in scripting
      engine.
    - S7055902, CVE-2011-3521: IIOP deserialization code execution.
    - S7057857, CVE-2011-3554: insufficient pack200 JAR files uncompress
      error checks.
    - S7064341, CVE-2011-3389: HTTPS: block-wise chosen-plaintext attack
      against SSL/TLS (BEAST).
    - S7070134, CVE-2011-3558: HotSpot crashes with sigsegv from
      PorterStemmer.
    - S7077466, CVE-2011-3556: RMI DGC server remote code execution.
    - S7083012, CVE-2011-3557: RMI registry privileged code execution.
    - S7096936, CVE-2011-3560: missing checkSetFactory calls in
      HttpsURLConnection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# HG changeset patch
 
2
# User dcherepanov
 
3
# Date 1205521233 -10800
 
4
# Node ID 15ba7093f8e64e1facdfc48b8929edc6a4fbb0d3
 
5
# Parent  92e3f57c933b45c678abcbccaa47de059dfe926a
 
6
6578583: Regression: Modality is broken in windows vista home premium from jdk1.7 b02 onwards.
 
7
Summary: WS_DISABLED style should be used to fix some modality bugs
 
8
Reviewed-by: art, son
 
9
 
 
10
diff -r 92e3f57c933b -r 15ba7093f8e6 src/windows/native/sun/windows/awt_Component.cpp
 
11
--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Component.cpp   Fri Mar 14 20:40:09 2008 +0300
 
12
+++ openjdk/jdk/src/windows/native/sun/windows/awt_Component.cpp        Fri Mar 14 22:00:33 2008 +0300
 
13
@@ -5425,7 +5425,13 @@
 
14
 void AwtComponent::Enable(BOOL bEnable)
 
15
 {
 
16
     sm_suppressFocusAndActivation = TRUE;
 
17
+
 
18
+    if (bEnable && IsTopLevel()) {
 
19
+        // we should not enable blocked toplevels
 
20
+        bEnable = !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd()));
 
21
+    }
 
22
     ::EnableWindow(GetHWnd(), bEnable);
 
23
+
 
24
     sm_suppressFocusAndActivation = FALSE;
 
25
     CriticalSection::Lock l(GetLock());
 
26
     VerifyState();
 
27
diff -r 92e3f57c933b -r 15ba7093f8e6 src/windows/native/sun/windows/awt_Dialog.cpp
 
28
--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Dialog.cpp      Fri Mar 14 20:40:09 2008 +0300
 
29
+++ openjdk/jdk/src/windows/native/sun/windows/awt_Dialog.cpp   Fri Mar 14 22:00:33 2008 +0300
 
30
@@ -273,6 +273,10 @@
 
31
         {
 
32
             HWND blocker = AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(hWnd));
 
33
             HWND topMostBlocker = blocker;
 
34
+            HWND prevForegroundWindow = ::GetForegroundWindow();
 
35
+            if (::IsWindow(blocker)) {
 
36
+                ::BringWindowToTop(hWnd);
 
37
+            }
 
38
             while (::IsWindow(blocker)) {
 
39
                 topMostBlocker = blocker;
 
40
                 ::BringWindowToTop(blocker);
 
41
@@ -282,7 +286,7 @@
 
42
                 // no beep/flash if the mouse was clicked in the taskbar menu
 
43
                 // or the dialog is currently inactive
 
44
                 if ((::WindowFromPoint(mhs->pt) == hWnd) &&
 
45
-                    (::GetForegroundWindow() == topMostBlocker))
 
46
+                    (prevForegroundWindow == topMostBlocker))
 
47
                 {
 
48
                     ::MessageBeep(MB_OK);
 
49
                     // some heuristics: 3 times x 64 milliseconds
 
50
@@ -292,6 +296,7 @@
 
51
                     ::BringWindowToTop(topMostBlocker);
 
52
                     ::SetForegroundWindow(topMostBlocker);
 
53
                 }
 
54
+                return 1;
 
55
             }
 
56
         }
 
57
     }
 
58
diff -r 92e3f57c933b -r 15ba7093f8e6 src/windows/native/sun/windows/awt_Window.cpp
 
59
--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Window.cpp      Fri Mar 14 20:40:09 2008 +0300
 
60
+++ openjdk/jdk/src/windows/native/sun/windows/awt_Window.cpp   Fri Mar 14 22:00:33 2008 +0300
 
61
@@ -180,7 +180,6 @@
 
62
     }
 
63
 
 
64
     ::RemoveProp(GetHWnd(), ModalBlockerProp);
 
65
-    ::RemoveProp(GetHWnd(), ModalSaveWSEXProp);
 
66
 
 
67
     if (m_grabbedWindow == this) {
 
68
         Ungrab();
 
69
@@ -1455,20 +1454,17 @@
 
70
     if (!::IsWindow(window)) {
 
71
         return;
 
72
     }
 
73
-    DWORD exStyle = ::GetWindowLong(window, GWL_EXSTYLE);
 
74
+
 
75
     if (::IsWindow(blocker)) {
 
76
-        // save WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles
 
77
-        DWORD saveStyle = exStyle & (AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
 
78
-        ::SetProp(window, ModalSaveWSEXProp, reinterpret_cast<HANDLE>(saveStyle));
 
79
-        ::SetWindowLong(window, GWL_EXSTYLE, (exStyle | AWT_WS_EX_NOACTIVATE) & ~WS_EX_APPWINDOW);
 
80
         ::SetProp(window, ModalBlockerProp, reinterpret_cast<HANDLE>(blocker));
 
81
+        ::EnableWindow(window, FALSE);
 
82
     } else {
 
83
-        // restore WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles
 
84
-        DWORD saveStyle = reinterpret_cast<DWORD>(::GetProp(window, ModalSaveWSEXProp));
 
85
-        ::SetWindowLong(window, GWL_EXSTYLE,
 
86
-                        (exStyle & ~(AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW)) | saveStyle);
 
87
-        ::RemoveProp(window, ModalSaveWSEXProp);
 
88
         ::RemoveProp(window, ModalBlockerProp);
 
89
+         AwtComponent *comp = AwtComponent::GetComponent(window);
 
90
+         // we don't expect to be called with non-java HWNDs
 
91
+         DASSERT(comp && comp->IsTopLevel());
 
92
+         // we should not unblock disabled toplevels
 
93
+         ::EnableWindow(window, comp->isEnabled());
 
94
     }
 
95
 }
 
96
 
 
97
diff -r 92e3f57c933b -r 15ba7093f8e6 src/windows/native/sun/windows/awt_Window.h
 
98
--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Window.h        Fri Mar 14 20:40:09 2008 +0300
 
99
+++ openjdk/jdk/src/windows/native/sun/windows/awt_Window.h     Fri Mar 14 22:00:33 2008 +0300
 
100
@@ -33,7 +33,6 @@
 
101
 
 
102
 // property name tagging windows disabled by modality
 
103
 static LPCTSTR ModalBlockerProp = TEXT("SunAwtModalBlockerProp");
 
104
-static LPCTSTR ModalSaveWSEXProp = TEXT("SunAwtModalSaveWSEXProp");
 
105
 static LPCTSTR ModalDialogPeerProp = TEXT("SunAwtModalDialogPeerProp");
 
106
 
 
107
 #ifndef WH_MOUSE_LL
 
108
diff -r 92e3f57c933b -r 15ba7093f8e6 test/java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java
 
109
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
 
110
+++ openjdk/jdk/test/java/awt/Modal/WsDisabledStyle/CloseBlocker/CloseBlocker.java      Fri Mar 14 22:00:33 2008 +0300
 
111
@@ -0,0 +1,466 @@
 
112
+/*
 
113
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
 
114
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
115
+ *
 
116
+ * This code is free software; you can redistribute it and/or modify it
 
117
+ * under the terms of the GNU General Public License version 2 only, as
 
118
+ * published by the Free Software Foundation.
 
119
+ *
 
120
+ * This code is distributed in the hope that it will be useful, but WITHOUT
 
121
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
122
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
123
+ * version 2 for more details (a copy is included in the LICENSE file that
 
124
+ * accompanied this code).
 
125
+ *
 
126
+ * You should have received a copy of the GNU General Public License version
 
127
+ * 2 along with this work; if not, write to the Free Software Foundation,
 
128
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
129
+ *
 
130
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 
131
+ * CA 95054 USA or visit www.sun.com if you need additional information or
 
132
+ * have any questions.
 
133
+ */
 
134
+
 
135
+/*
 
136
+  @test %I% %E%
 
137
+  @bug 4080029
 
138
+  @summary Modal Dialog block input to all frame windows not just its parent.
 
139
+  @author dmitry.cherepanov: area=awt.modal
 
140
+  @run main/manual CloseBlocker
 
141
+*/
 
142
+
 
143
+/**
 
144
+ * ManualMainTest.java
 
145
+ *
 
146
+ * summary: The test opens and closes blocker dialog, the test verifies
 
147
+ *          that active window is correct when the dialog is closed.
 
148
+ */
 
149
+
 
150
+import java.awt.*;
 
151
+import java.awt.event.*;
 
152
+
 
153
+public class CloseBlocker
 
154
+{
 
155
+
 
156
+    private static void init()
 
157
+    {
 
158
+        //*** Create instructions for the user here ***
 
159
+
 
160
+        String[] instructions =
 
161
+        {
 
162
+            " the test will be run 6 times, to start next test just close all ",
 
163
+            " windows of previous; the instructions are the same for all tests: ",
 
164
+            " 1) there are two frames (one the frames has 'show modal' button), ",
 
165
+            " 2) press the button to show a dialog, ",
 
166
+            " 3) close the dialog (an alternative scenario - activate another",
 
167
+            "    native window before closing the dialog), ",
 
168
+            " 4) the frame with button should become next active window, ",
 
169
+            "    if it's true, then the test passed, otherwise, it failed. ",
 
170
+            " Press 'pass' button only after all of the 6 tests are completed, ",
 
171
+            " the number of the currently executed test is displayed on the ",
 
172
+            " output window. "
 
173
+        };
 
174
+        Sysout.createDialog( );
 
175
+        Sysout.printInstructions( instructions );
 
176
+
 
177
+        test(true, true, false);
 
178
+        test(true, true, true);
 
179
+        test(false, true, false); // 3rd parameter has no affect for ownerless
 
180
+
 
181
+        test(true, false, false);
 
182
+        test(true, false, true);
 
183
+        test(false, false, false); // 3rd parameter has no affect for ownerless
 
184
+
 
185
+    }//End  init()
 
186
+
 
187
+    private static final Object obj = new Object();
 
188
+    private static int counter = 0;
 
189
+
 
190
+    /*
 
191
+     * The ownerless parameter indicates whether the blocker dialog
 
192
+     * has owner. The usual parameter indicates whether the blocker
 
193
+     * dialog is a Java dialog (non-native dialog like file dialog).
 
194
+     */
 
195
+    private static void test(final boolean ownerless, final boolean usual, final boolean initiallyOwnerIsActive) {
 
196
+
 
197
+        Sysout.print(" * test #" + (++counter) + " is running ... ");
 
198
+
 
199
+        final Frame active = new Frame();
 
200
+        final Frame nonactive = new Frame();
 
201
+        Button button = new Button("show modal");
 
202
+        button.addActionListener(new ActionListener() {
 
203
+               public void actionPerformed(ActionEvent ae) {
 
204
+                    Dialog dialog = null;
 
205
+                    Frame parent = ownerless ? null : (initiallyOwnerIsActive? active : nonactive);
 
206
+                    if (usual) {
 
207
+                        dialog = new Dialog(parent, "Sample", true);
 
208
+                    } else {
 
209
+                        dialog = new FileDialog(parent, "Sample", FileDialog.LOAD);
 
210
+                    }
 
211
+                    dialog.addWindowListener(new WindowAdapter(){
 
212
+                        public void windowClosing(WindowEvent e){
 
213
+                                e.getWindow().dispose();
 
214
+                        }
 
215
+                    });
 
216
+                    dialog.setBounds(200, 200, 200, 200);
 
217
+                    dialog.setVisible(true);
 
218
+                }
 
219
+        });
 
220
+
 
221
+        active.add(button);
 
222
+        active.setBounds(200, 400, 200, 200);
 
223
+        WindowAdapter adapter = new WindowAdapter(){
 
224
+              public void windowClosing(WindowEvent e){
 
225
+                    active.dispose();
 
226
+                    nonactive.dispose();
 
227
+                    synchronized(obj) {
 
228
+                        obj.notify();
 
229
+                    }
 
230
+                }
 
231
+             };
 
232
+        active.addWindowListener(adapter);
 
233
+        active.setVisible(true);
 
234
+
 
235
+        nonactive.setBounds(400, 400, 200, 200);
 
236
+        nonactive.addWindowListener(adapter);
 
237
+        nonactive.setVisible(true);
 
238
+
 
239
+        synchronized(obj) {
 
240
+            try{
 
241
+                obj.wait();
 
242
+            } catch(Exception e) {
 
243
+                throw new RuntimeException(e);
 
244
+            }
 
245
+        }
 
246
+
 
247
+        Sysout.println(" completed. ");
 
248
+
 
249
+    }
 
250
+
 
251
+    /*****************************************************
 
252
+     * Standard Test Machinery Section
 
253
+     * DO NOT modify anything in this section -- it's a
 
254
+     * standard chunk of code which has all of the
 
255
+     * synchronisation necessary for the test harness.
 
256
+     * By keeping it the same in all tests, it is easier
 
257
+     * to read and understand someone else's test, as
 
258
+     * well as insuring that all tests behave correctly
 
259
+     * with the test harness.
 
260
+     * There is a section following this for test-defined
 
261
+     * classes
 
262
+     ******************************************************/
 
263
+    private static boolean theTestPassed = false;
 
264
+    private static boolean testGeneratedInterrupt = false;
 
265
+    private static String failureMessage = "";
 
266
+
 
267
+    private static Thread mainThread = null;
 
268
+
 
269
+    private static int sleepTime = 300000;
 
270
+
 
271
+    public static void main( String args[] ) throws InterruptedException
 
272
+    {
 
273
+        mainThread = Thread.currentThread();
 
274
+        try
 
275
+        {
 
276
+            init();
 
277
+        }
 
278
+        catch( TestPassedException e )
 
279
+        {
 
280
+            //The test passed, so just return from main and harness will
 
281
+            // interepret this return as a pass
 
282
+            return;
 
283
+        }
 
284
+        //At this point, neither test passed nor test failed has been
 
285
+        // called -- either would have thrown an exception and ended the
 
286
+        // test, so we know we have multiple threads.
 
287
+
 
288
+        //Test involves other threads, so sleep and wait for them to
 
289
+        // called pass() or fail()
 
290
+        try
 
291
+        {
 
292
+            Thread.sleep( sleepTime );
 
293
+            //Timed out, so fail the test
 
294
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
 
295
+        }
 
296
+        catch (InterruptedException e)
 
297
+        {
 
298
+            if( ! testGeneratedInterrupt ) throw e;
 
299
+
 
300
+            //reset flag in case hit this code more than once for some reason (just safety)
 
301
+            testGeneratedInterrupt = false;
 
302
+            if ( theTestPassed == false )
 
303
+            {
 
304
+                throw new RuntimeException( failureMessage );
 
305
+            }
 
306
+        }
 
307
+
 
308
+    }//main
 
309
+
 
310
+    public static synchronized void setTimeoutTo( int seconds )
 
311
+    {
 
312
+        sleepTime = seconds * 1000;
 
313
+    }
 
314
+
 
315
+    public static synchronized void pass()
 
316
+    {
 
317
+        Sysout.println( "The test passed." );
 
318
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
319
+        //first check if this is executing in main thread
 
320
+        if ( mainThread == Thread.currentThread() )
 
321
+        {
 
322
+            //Still in the main thread, so set the flag just for kicks,
 
323
+            // and throw a test passed exception which will be caught
 
324
+            // and end the test.
 
325
+            theTestPassed = true;
 
326
+            throw new TestPassedException();
 
327
+        }
 
328
+        //pass was called from a different thread, so set the flag and interrupt
 
329
+        // the main thead.
 
330
+        theTestPassed = true;
 
331
+        testGeneratedInterrupt = true;
 
332
+        mainThread.interrupt();
 
333
+    }//pass()
 
334
+
 
335
+    public static synchronized void fail()
 
336
+    {
 
337
+        //test writer didn't specify why test failed, so give generic
 
338
+        fail( "it just plain failed! :-)" );
 
339
+    }
 
340
+
 
341
+    public static synchronized void fail( String whyFailed )
 
342
+    {
 
343
+        Sysout.println( "The test failed: " + whyFailed );
 
344
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
345
+        //check if this called from main thread
 
346
+        if ( mainThread == Thread.currentThread() )
 
347
+        {
 
348
+            //If main thread, fail now 'cause not sleeping
 
349
+            throw new RuntimeException( whyFailed );
 
350
+        }
 
351
+        theTestPassed = false;
 
352
+        testGeneratedInterrupt = true;
 
353
+        failureMessage = whyFailed;
 
354
+        mainThread.interrupt();
 
355
+    }//fail()
 
356
+
 
357
+}// class ManualMainTest
 
358
+
 
359
+//This exception is used to exit from any level of call nesting
 
360
+// when it's determined that the test has passed, and immediately
 
361
+// end the test.
 
362
+class TestPassedException extends RuntimeException
 
363
+{
 
364
+}
 
365
+
 
366
+//*********** End Standard Test Machinery Section **********
 
367
+
 
368
+
 
369
+//************ Begin classes defined for the test ****************
 
370
+
 
371
+// make listeners in a class defined here, and instantiate them in init()
 
372
+
 
373
+/* Example of a class which may be written as part of a test
 
374
+class NewClass implements anInterface
 
375
+ {
 
376
+   static int newVar = 0;
 
377
+
 
378
+   public void eventDispatched(AWTEvent e)
 
379
+    {
 
380
+      //Counting events to see if we get enough
 
381
+      eventCount++;
 
382
+
 
383
+      if( eventCount == 20 )
 
384
+       {
 
385
+         //got enough events, so pass
 
386
+
 
387
+         ManualMainTest.pass();
 
388
+       }
 
389
+      else if( tries == 20 )
 
390
+       {
 
391
+         //tried too many times without getting enough events so fail
 
392
+
 
393
+         ManualMainTest.fail();
 
394
+       }
 
395
+
 
396
+    }// eventDispatched()
 
397
+
 
398
+ }// NewClass class
 
399
+
 
400
+*/
 
401
+
 
402
+
 
403
+//************** End classes defined for the test *******************
 
404
+
 
405
+
 
406
+
 
407
+
 
408
+/****************************************************
 
409
+ Standard Test Machinery
 
410
+ DO NOT modify anything below -- it's a standard
 
411
+  chunk of code whose purpose is to make user
 
412
+  interaction uniform, and thereby make it simpler
 
413
+  to read and understand someone else's test.
 
414
+ ****************************************************/
 
415
+
 
416
+/**
 
417
+ This is part of the standard test machinery.
 
418
+ It creates a dialog (with the instructions), and is the interface
 
419
+  for sending text messages to the user.
 
420
+ To print the instructions, send an array of strings to Sysout.createDialog
 
421
+  WithInstructions method.  Put one line of instructions per array entry.
 
422
+ To display a message for the tester to see, simply call Sysout.println
 
423
+  with the string to be displayed.
 
424
+ This mimics System.out.println but works within the test harness as well
 
425
+  as standalone.
 
426
+ */
 
427
+
 
428
+class Sysout
 
429
+{
 
430
+    private static TestDialog dialog;
 
431
+
 
432
+    public static void createDialogWithInstructions( String[] instructions )
 
433
+    {
 
434
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
435
+        dialog.printInstructions( instructions );
 
436
+        dialog.setVisible(true);
 
437
+        println( "Any messages for the tester will display here." );
 
438
+    }
 
439
+
 
440
+    public static void createDialog( )
 
441
+    {
 
442
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
443
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
 
444
+        dialog.printInstructions( defInstr );
 
445
+        dialog.setVisible(true);
 
446
+        println( "Any messages for the tester will display here." );
 
447
+    }
 
448
+
 
449
+
 
450
+    public static void printInstructions( String[] instructions )
 
451
+    {
 
452
+        dialog.printInstructions( instructions );
 
453
+    }
 
454
+
 
455
+
 
456
+    public static void println( String messageIn )
 
457
+    {
 
458
+        dialog.displayMessage( messageIn, true );
 
459
+    }
 
460
+
 
461
+    public static void print( String messageIn )
 
462
+    {
 
463
+        dialog.displayMessage( messageIn, false );
 
464
+    }
 
465
+
 
466
+}// Sysout  class
 
467
+
 
468
+/**
 
469
+  This is part of the standard test machinery.  It provides a place for the
 
470
+   test instructions to be displayed, and a place for interactive messages
 
471
+   to the user to be displayed.
 
472
+  To have the test instructions displayed, see Sysout.
 
473
+  To have a message to the user be displayed, see Sysout.
 
474
+  Do not call anything in this dialog directly.
 
475
+  */
 
476
+class TestDialog extends Dialog implements ActionListener
 
477
+{
 
478
+
 
479
+    TextArea instructionsText;
 
480
+    TextArea messageText;
 
481
+    int maxStringLength = 80;
 
482
+    Panel  buttonP = new Panel();
 
483
+    Button passB = new Button( "pass" );
 
484
+    Button failB = new Button( "fail" );
 
485
+
 
486
+    //DO NOT call this directly, go through Sysout
 
487
+    public TestDialog( Frame frame, String name )
 
488
+    {
 
489
+        super( frame, name );
 
490
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
 
491
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
 
492
+        add( "North", instructionsText );
 
493
+
 
494
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
 
495
+        add("Center", messageText);
 
496
+
 
497
+        passB = new Button( "pass" );
 
498
+        passB.setActionCommand( "pass" );
 
499
+        passB.addActionListener( this );
 
500
+        buttonP.add( "East", passB );
 
501
+
 
502
+        failB = new Button( "fail" );
 
503
+        failB.setActionCommand( "fail" );
 
504
+        failB.addActionListener( this );
 
505
+        buttonP.add( "West", failB );
 
506
+
 
507
+        add( "South", buttonP );
 
508
+        pack();
 
509
+
 
510
+        setVisible(true);
 
511
+    }// TestDialog()
 
512
+
 
513
+    //DO NOT call this directly, go through Sysout
 
514
+    public void printInstructions( String[] instructions )
 
515
+    {
 
516
+        //Clear out any current instructions
 
517
+        instructionsText.setText( "" );
 
518
+
 
519
+        //Go down array of instruction strings
 
520
+
 
521
+        String printStr, remainingStr;
 
522
+        for( int i=0; i < instructions.length; i++ )
 
523
+        {
 
524
+            //chop up each into pieces maxSringLength long
 
525
+            remainingStr = instructions[ i ];
 
526
+            while( remainingStr.length() > 0 )
 
527
+            {
 
528
+                //if longer than max then chop off first max chars to print
 
529
+                if( remainingStr.length() >= maxStringLength )
 
530
+                {
 
531
+                    //Try to chop on a word boundary
 
532
+                    int posOfSpace = remainingStr.
 
533
+                        lastIndexOf( ' ', maxStringLength - 1 );
 
534
+
 
535
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
 
536
+
 
537
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
 
538
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
 
539
+                }
 
540
+                //else just print
 
541
+                else
 
542
+                {
 
543
+                    printStr = remainingStr;
 
544
+                    remainingStr = "";
 
545
+                }
 
546
+
 
547
+                instructionsText.append( printStr + "\n" );
 
548
+
 
549
+            }// while
 
550
+
 
551
+        }// for
 
552
+
 
553
+    }//printInstructions()
 
554
+
 
555
+    //DO NOT call this directly, go through Sysout
 
556
+    public void displayMessage( String messageIn, boolean nextLine )
 
557
+    {
 
558
+        messageText.append( messageIn + (nextLine? "\n" : "") );
 
559
+        System.out.println(messageIn);
 
560
+    }
 
561
+
 
562
+    //catch presses of the passed and failed buttons.
 
563
+    //simply call the standard pass() or fail() static methods of
 
564
+    //ManualMainTest
 
565
+    public void actionPerformed( ActionEvent e )
 
566
+    {
 
567
+        if( e.getActionCommand() == "pass" )
 
568
+        {
 
569
+            CloseBlocker.pass();
 
570
+        }
 
571
+        else
 
572
+        {
 
573
+            CloseBlocker.fail();
 
574
+        }
 
575
+    }
 
576
+
 
577
+}// TestDialog  class
 
578
diff -r 92e3f57c933b -r 15ba7093f8e6 test/java/awt/Modal/WsDisabledStyle/OverBlocker/OverBlocker.java
 
579
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
 
580
+++ openjdk/jdk/test/java/awt/Modal/WsDisabledStyle/OverBlocker/OverBlocker.java        Fri Mar 14 22:00:33 2008 +0300
 
581
@@ -0,0 +1,456 @@
 
582
+/*
 
583
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
 
584
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
585
+ *
 
586
+ * This code is free software; you can redistribute it and/or modify it
 
587
+ * under the terms of the GNU General Public License version 2 only, as
 
588
+ * published by the Free Software Foundation.
 
589
+ *
 
590
+ * This code is distributed in the hope that it will be useful, but WITHOUT
 
591
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
592
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
593
+ * version 2 for more details (a copy is included in the LICENSE file that
 
594
+ * accompanied this code).
 
595
+ *
 
596
+ * You should have received a copy of the GNU General Public License version
 
597
+ * 2 along with this work; if not, write to the Free Software Foundation,
 
598
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
599
+ *
 
600
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 
601
+ * CA 95054 USA or visit www.sun.com if you need additional information or
 
602
+ * have any questions.
 
603
+ */
 
604
+
 
605
+/*
 
606
+  @test %I% %E%
 
607
+  @bug 4080029
 
608
+  @summary Modal Dialog block input to all frame windows not just its parent.
 
609
+  @author dmitry.cherepanov: area=awt.modal
 
610
+  @run main/manual OverBlocker
 
611
+*/
 
612
+
 
613
+/**
 
614
+ * OverBlocker.java
 
615
+ *
 
616
+ * summary: The test verifies that if user tries to activate the blocked dialog
 
617
+ *          then the blocker dialog appears over the other windows
 
618
+ */
 
619
+
 
620
+import java.awt.*;
 
621
+import java.awt.event.*;
 
622
+
 
623
+public class OverBlocker
 
624
+{
 
625
+
 
626
+    private static void init()
 
627
+    {
 
628
+        //*** Create instructions for the user here ***
 
629
+
 
630
+        String[] instructions =
 
631
+        {
 
632
+            " the test will be run 4 times, to start next test just close all ",
 
633
+            " windows of previous; the instructions are the same for all tests: ",
 
634
+            " 1) there is a frame with 'show modal' button, ",
 
635
+            " 2) press the button to show a dialog, ",
 
636
+            " 3) activate any non-Java application, move the app over the dialog, ",
 
637
+            " 4) click on the frame by mouse, ",
 
638
+            " 5) make sure that the dialog comes up from the application and ",
 
639
+            "    now the dialog overlaps the app as well as the frame, ",
 
640
+            "    if it's true, then the test passed, otherwise, it failed. ",
 
641
+            " Press 'pass' button only after all of the 4 tests are completed, ",
 
642
+            " the number of the currently executed test is displayed on the ",
 
643
+            " output window. "
 
644
+        };
 
645
+        Sysout.createDialog( );
 
646
+        Sysout.printInstructions( instructions );
 
647
+
 
648
+        test(false, true);
 
649
+        test(true, true);
 
650
+        test(true, false);
 
651
+        test(false, false);
 
652
+
 
653
+    }//End  init()
 
654
+
 
655
+    private static final Object obj = new Object();
 
656
+    private static int counter = 0;
 
657
+
 
658
+    /*
 
659
+     * The ownerless parameter indicates whether the blocker dialog
 
660
+     * has owner. The usual parameter indicates whether the blocker
 
661
+     * dialog is a Java dialog (non-native dialog like file dialog).
 
662
+     */
 
663
+    private static void test(final boolean ownerless, final boolean usual) {
 
664
+
 
665
+        Sysout.print(" * test #" + (++counter) + " is running ... ");
 
666
+
 
667
+        final Frame frame = new Frame();
 
668
+        Button button = new Button("show modal");
 
669
+        button.addActionListener(new ActionListener() {
 
670
+              public void actionPerformed(ActionEvent ae) {
 
671
+                    Dialog dialog = null;
 
672
+                    Frame parent = ownerless ? null : frame;
 
673
+                    if (usual) {
 
674
+                        dialog = new Dialog(parent, "Sample", true);
 
675
+                    } else {
 
676
+                        dialog = new FileDialog(parent, "Sample", FileDialog.LOAD);
 
677
+                    }
 
678
+                    dialog.addWindowListener(new WindowAdapter(){
 
679
+                            public void windowClosing(WindowEvent e){
 
680
+                                e.getWindow().dispose();
 
681
+                            }
 
682
+                       });
 
683
+                    dialog.setBounds(200, 200, 200, 200);
 
684
+                    dialog.setVisible(true);
 
685
+                }
 
686
+            });
 
687
+        frame.add(button);
 
688
+        frame.setBounds(400, 400, 200, 200);
 
689
+        frame.addWindowListener(new WindowAdapter(){
 
690
+              public void windowClosing(WindowEvent e){
 
691
+                    e.getWindow().dispose();
 
692
+                    synchronized(obj) {
 
693
+                        obj.notify();
 
694
+                    }
 
695
+                }
 
696
+             });
 
697
+        frame.setVisible(true);
 
698
+
 
699
+        synchronized(obj) {
 
700
+            try{
 
701
+                obj.wait();
 
702
+            } catch(Exception e) {
 
703
+                throw new RuntimeException(e);
 
704
+            }
 
705
+        }
 
706
+
 
707
+        Sysout.println(" completed. ");
 
708
+
 
709
+    }
 
710
+
 
711
+    /*****************************************************
 
712
+     * Standard Test Machinery Section
 
713
+     * DO NOT modify anything in this section -- it's a
 
714
+     * standard chunk of code which has all of the
 
715
+     * synchronisation necessary for the test harness.
 
716
+     * By keeping it the same in all tests, it is easier
 
717
+     * to read and understand someone else's test, as
 
718
+     * well as insuring that all tests behave correctly
 
719
+     * with the test harness.
 
720
+     * There is a section following this for test-defined
 
721
+     * classes
 
722
+     ******************************************************/
 
723
+    private static boolean theTestPassed = false;
 
724
+    private static boolean testGeneratedInterrupt = false;
 
725
+    private static String failureMessage = "";
 
726
+
 
727
+    private static Thread mainThread = null;
 
728
+
 
729
+    private static int sleepTime = 300000;
 
730
+
 
731
+    public static void main( String args[] ) throws InterruptedException
 
732
+    {
 
733
+        mainThread = Thread.currentThread();
 
734
+        try
 
735
+        {
 
736
+            init();
 
737
+        }
 
738
+        catch( TestPassedException e )
 
739
+        {
 
740
+            //The test passed, so just return from main and harness will
 
741
+            // interepret this return as a pass
 
742
+            return;
 
743
+        }
 
744
+        //At this point, neither test passed nor test failed has been
 
745
+        // called -- either would have thrown an exception and ended the
 
746
+        // test, so we know we have multiple threads.
 
747
+
 
748
+        //Test involves other threads, so sleep and wait for them to
 
749
+        // called pass() or fail()
 
750
+        try
 
751
+        {
 
752
+            Thread.sleep( sleepTime );
 
753
+            //Timed out, so fail the test
 
754
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
 
755
+        }
 
756
+        catch (InterruptedException e)
 
757
+        {
 
758
+            if( ! testGeneratedInterrupt ) throw e;
 
759
+
 
760
+            //reset flag in case hit this code more than once for some reason (just safety)
 
761
+            testGeneratedInterrupt = false;
 
762
+            if ( theTestPassed == false )
 
763
+            {
 
764
+                throw new RuntimeException( failureMessage );
 
765
+            }
 
766
+        }
 
767
+
 
768
+    }//main
 
769
+
 
770
+    public static synchronized void setTimeoutTo( int seconds )
 
771
+    {
 
772
+        sleepTime = seconds * 1000;
 
773
+    }
 
774
+
 
775
+    public static synchronized void pass()
 
776
+    {
 
777
+        Sysout.println( "The test passed." );
 
778
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
779
+        //first check if this is executing in main thread
 
780
+        if ( mainThread == Thread.currentThread() )
 
781
+        {
 
782
+            //Still in the main thread, so set the flag just for kicks,
 
783
+            // and throw a test passed exception which will be caught
 
784
+            // and end the test.
 
785
+            theTestPassed = true;
 
786
+            throw new TestPassedException();
 
787
+        }
 
788
+        //pass was called from a different thread, so set the flag and interrupt
 
789
+        // the main thead.
 
790
+        theTestPassed = true;
 
791
+        testGeneratedInterrupt = true;
 
792
+        mainThread.interrupt();
 
793
+    }//pass()
 
794
+
 
795
+    public static synchronized void fail()
 
796
+    {
 
797
+        //test writer didn't specify why test failed, so give generic
 
798
+        fail( "it just plain failed! :-)" );
 
799
+    }
 
800
+
 
801
+    public static synchronized void fail( String whyFailed )
 
802
+    {
 
803
+        Sysout.println( "The test failed: " + whyFailed );
 
804
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
805
+        //check if this called from main thread
 
806
+        if ( mainThread == Thread.currentThread() )
 
807
+        {
 
808
+            //If main thread, fail now 'cause not sleeping
 
809
+            throw new RuntimeException( whyFailed );
 
810
+        }
 
811
+        theTestPassed = false;
 
812
+        testGeneratedInterrupt = true;
 
813
+        failureMessage = whyFailed;
 
814
+        mainThread.interrupt();
 
815
+    }//fail()
 
816
+
 
817
+}// class ManualMainTest
 
818
+
 
819
+//This exception is used to exit from any level of call nesting
 
820
+// when it's determined that the test has passed, and immediately
 
821
+// end the test.
 
822
+class TestPassedException extends RuntimeException
 
823
+{
 
824
+}
 
825
+
 
826
+//*********** End Standard Test Machinery Section **********
 
827
+
 
828
+
 
829
+//************ Begin classes defined for the test ****************
 
830
+
 
831
+// make listeners in a class defined here, and instantiate them in init()
 
832
+
 
833
+/* Example of a class which may be written as part of a test
 
834
+class NewClass implements anInterface
 
835
+ {
 
836
+   static int newVar = 0;
 
837
+
 
838
+   public void eventDispatched(AWTEvent e)
 
839
+    {
 
840
+      //Counting events to see if we get enough
 
841
+      eventCount++;
 
842
+
 
843
+      if( eventCount == 20 )
 
844
+       {
 
845
+         //got enough events, so pass
 
846
+
 
847
+         ManualMainTest.pass();
 
848
+       }
 
849
+      else if( tries == 20 )
 
850
+       {
 
851
+         //tried too many times without getting enough events so fail
 
852
+
 
853
+         ManualMainTest.fail();
 
854
+       }
 
855
+
 
856
+    }// eventDispatched()
 
857
+
 
858
+ }// NewClass class
 
859
+
 
860
+*/
 
861
+
 
862
+
 
863
+//************** End classes defined for the test *******************
 
864
+
 
865
+
 
866
+
 
867
+
 
868
+/****************************************************
 
869
+ Standard Test Machinery
 
870
+ DO NOT modify anything below -- it's a standard
 
871
+  chunk of code whose purpose is to make user
 
872
+  interaction uniform, and thereby make it simpler
 
873
+  to read and understand someone else's test.
 
874
+ ****************************************************/
 
875
+
 
876
+/**
 
877
+ This is part of the standard test machinery.
 
878
+ It creates a dialog (with the instructions), and is the interface
 
879
+  for sending text messages to the user.
 
880
+ To print the instructions, send an array of strings to Sysout.createDialog
 
881
+  WithInstructions method.  Put one line of instructions per array entry.
 
882
+ To display a message for the tester to see, simply call Sysout.println
 
883
+  with the string to be displayed.
 
884
+ This mimics System.out.println but works within the test harness as well
 
885
+  as standalone.
 
886
+ */
 
887
+
 
888
+class Sysout
 
889
+{
 
890
+    private static TestDialog dialog;
 
891
+
 
892
+    public static void createDialogWithInstructions( String[] instructions )
 
893
+    {
 
894
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
895
+        dialog.printInstructions( instructions );
 
896
+        dialog.setVisible(true);
 
897
+        println( "Any messages for the tester will display here." );
 
898
+    }
 
899
+
 
900
+    public static void createDialog( )
 
901
+    {
 
902
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
903
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
 
904
+        dialog.printInstructions( defInstr );
 
905
+        dialog.setVisible(true);
 
906
+        println( "Any messages for the tester will display here." );
 
907
+    }
 
908
+
 
909
+
 
910
+    public static void printInstructions( String[] instructions )
 
911
+    {
 
912
+        dialog.printInstructions( instructions );
 
913
+    }
 
914
+
 
915
+
 
916
+    public static void println( String messageIn )
 
917
+    {
 
918
+        dialog.displayMessage( messageIn, true );
 
919
+    }
 
920
+
 
921
+    public static void print( String messageIn )
 
922
+    {
 
923
+        dialog.displayMessage( messageIn, false );
 
924
+    }
 
925
+
 
926
+}// Sysout  class
 
927
+
 
928
+/**
 
929
+  This is part of the standard test machinery.  It provides a place for the
 
930
+   test instructions to be displayed, and a place for interactive messages
 
931
+   to the user to be displayed.
 
932
+  To have the test instructions displayed, see Sysout.
 
933
+  To have a message to the user be displayed, see Sysout.
 
934
+  Do not call anything in this dialog directly.
 
935
+  */
 
936
+class TestDialog extends Dialog implements ActionListener
 
937
+{
 
938
+
 
939
+    TextArea instructionsText;
 
940
+    TextArea messageText;
 
941
+    int maxStringLength = 80;
 
942
+    Panel  buttonP = new Panel();
 
943
+    Button passB = new Button( "pass" );
 
944
+    Button failB = new Button( "fail" );
 
945
+
 
946
+    //DO NOT call this directly, go through Sysout
 
947
+    public TestDialog( Frame frame, String name )
 
948
+    {
 
949
+        super( frame, name );
 
950
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
 
951
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
 
952
+        add( "North", instructionsText );
 
953
+
 
954
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
 
955
+        add("Center", messageText);
 
956
+
 
957
+        passB = new Button( "pass" );
 
958
+        passB.setActionCommand( "pass" );
 
959
+        passB.addActionListener( this );
 
960
+        buttonP.add( "East", passB );
 
961
+
 
962
+        failB = new Button( "fail" );
 
963
+        failB.setActionCommand( "fail" );
 
964
+        failB.addActionListener( this );
 
965
+        buttonP.add( "West", failB );
 
966
+
 
967
+        add( "South", buttonP );
 
968
+        pack();
 
969
+
 
970
+        setVisible(true);
 
971
+    }// TestDialog()
 
972
+
 
973
+    //DO NOT call this directly, go through Sysout
 
974
+    public void printInstructions( String[] instructions )
 
975
+    {
 
976
+        //Clear out any current instructions
 
977
+        instructionsText.setText( "" );
 
978
+
 
979
+        //Go down array of instruction strings
 
980
+
 
981
+        String printStr, remainingStr;
 
982
+        for( int i=0; i < instructions.length; i++ )
 
983
+        {
 
984
+            //chop up each into pieces maxSringLength long
 
985
+            remainingStr = instructions[ i ];
 
986
+            while( remainingStr.length() > 0 )
 
987
+            {
 
988
+                //if longer than max then chop off first max chars to print
 
989
+                if( remainingStr.length() >= maxStringLength )
 
990
+                {
 
991
+                    //Try to chop on a word boundary
 
992
+                    int posOfSpace = remainingStr.
 
993
+                        lastIndexOf( ' ', maxStringLength - 1 );
 
994
+
 
995
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
 
996
+
 
997
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
 
998
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
 
999
+                }
 
1000
+                //else just print
 
1001
+                else
 
1002
+                {
 
1003
+                    printStr = remainingStr;
 
1004
+                    remainingStr = "";
 
1005
+                }
 
1006
+
 
1007
+                instructionsText.append( printStr + "\n" );
 
1008
+
 
1009
+            }// while
 
1010
+
 
1011
+        }// for
 
1012
+
 
1013
+    }//printInstructions()
 
1014
+
 
1015
+    //DO NOT call this directly, go through Sysout
 
1016
+    public void displayMessage( String messageIn, boolean nextLine )
 
1017
+    {
 
1018
+        messageText.append( messageIn + (nextLine? "\n" : "") );
 
1019
+        System.out.println(messageIn);
 
1020
+    }
 
1021
+
 
1022
+    //catch presses of the passed and failed buttons.
 
1023
+    //simply call the standard pass() or fail() static methods of
 
1024
+    //ManualMainTest
 
1025
+    public void actionPerformed( ActionEvent e )
 
1026
+    {
 
1027
+        if( e.getActionCommand() == "pass" )
 
1028
+        {
 
1029
+            OverBlocker.pass();
 
1030
+        }
 
1031
+        else
 
1032
+        {
 
1033
+            OverBlocker.fail();
 
1034
+        }
 
1035
+    }
 
1036
+
 
1037
+}// TestDialog  class
 
1038
diff -r 92e3f57c933b -r 15ba7093f8e6 test/java/awt/Modal/WsDisabledStyle/Winkey/Winkey.java
 
1039
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
 
1040
+++ openjdk/jdk/test/java/awt/Modal/WsDisabledStyle/Winkey/Winkey.java  Fri Mar 14 22:00:33 2008 +0300
 
1041
@@ -0,0 +1,403 @@
 
1042
+/*
 
1043
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
 
1044
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
1045
+ *
 
1046
+ * This code is free software; you can redistribute it and/or modify it
 
1047
+ * under the terms of the GNU General Public License version 2 only, as
 
1048
+ * published by the Free Software Foundation.
 
1049
+ *
 
1050
+ * This code is distributed in the hope that it will be useful, but WITHOUT
 
1051
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
1052
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
1053
+ * version 2 for more details (a copy is included in the LICENSE file that
 
1054
+ * accompanied this code).
 
1055
+ *
 
1056
+ * You should have received a copy of the GNU General Public License version
 
1057
+ * 2 along with this work; if not, write to the Free Software Foundation,
 
1058
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
1059
+ *
 
1060
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 
1061
+ * CA 95054 USA or visit www.sun.com if you need additional information or
 
1062
+ * have any questions.
 
1063
+ */
 
1064
+
 
1065
+/*
 
1066
+  @test %I% %E%
 
1067
+  @bug 6572263 6571808
 
1068
+  @summary  PIT:FileDialog minimized to taskbar(through 'Show Desktop')selecting the fileDialog using windowList
 
1069
+  @author dmitry.cherepanov: area=awt.modal
 
1070
+  @run main/manual Winkey
 
1071
+*/
 
1072
+
 
1073
+/**
 
1074
+ * Winkey.java
 
1075
+ *
 
1076
+ * summary: the test verifies that pressing combination of Windows key
 
1077
+ *          and M key to minimize all windows doesn't break AWT modality
 
1078
+ */
 
1079
+
 
1080
+import java.awt.*;
 
1081
+import java.awt.event.*;
 
1082
+
 
1083
+public class Winkey
 
1084
+{
 
1085
+
 
1086
+    private static void init()
 
1087
+    {
 
1088
+        //*** Create instructions for the user here ***
 
1089
+
 
1090
+        String[] instructions =
 
1091
+        {
 
1092
+            " 1. there is a frame with a 'show modal' button, ",
 
1093
+            " 2. press the button to show a modal dialog, ",
 
1094
+            " 3. the modal dialog will be shown over the frame, ",
 
1095
+            " 4. please verify that all (5.1, 5.2.1, 5.2.2) the following tests pass: ",
 
1096
+            " ",
 
1097
+            " 5.1. press combination Windows Key and M key to minimize all windows, ",
 
1098
+            " 5.2. press combination Windows Key and D key to show desktop, ",
 
1099
+            "      5.2.1. restore the dialog by choosing this one in the ALT-TAB list, ",
 
1100
+            "      5.2.2. restore the dialog by mouse click on taskbar (on java or any other item)",
 
1101
+            " ",
 
1102
+            " 6. make sure that the dialog and the frame are visible, ",
 
1103
+            "    the bounds of the windows should be the same as before, ",
 
1104
+            "    if it's true, then the test passed; otherwise, it failed. "
 
1105
+        };
 
1106
+        Sysout.createDialog( );
 
1107
+        Sysout.printInstructions( instructions );
 
1108
+
 
1109
+        final Frame frame = new Frame();
 
1110
+        Button button = new Button("show modal");
 
1111
+        button.addActionListener(new ActionListener() {
 
1112
+                public void actionPerformed(ActionEvent ae) {
 
1113
+                    FileDialog dialog = new FileDialog((Frame)null, "Sample", FileDialog.LOAD);
 
1114
+                    dialog.setVisible(true);
 
1115
+                }
 
1116
+            });
 
1117
+        frame.add(button);
 
1118
+        frame.setBounds(400, 400, 200, 200);
 
1119
+        frame.setVisible(true);
 
1120
+
 
1121
+    }//End  init()
 
1122
+
 
1123
+    /*****************************************************
 
1124
+     * Standard Test Machinery Section
 
1125
+     * DO NOT modify anything in this section -- it's a
 
1126
+     * standard chunk of code which has all of the
 
1127
+     * synchronisation necessary for the test harness.
 
1128
+     * By keeping it the same in all tests, it is easier
 
1129
+     * to read and understand someone else's test, as
 
1130
+     * well as insuring that all tests behave correctly
 
1131
+     * with the test harness.
 
1132
+     * There is a section following this for test-defined
 
1133
+     * classes
 
1134
+     ******************************************************/
 
1135
+    private static boolean theTestPassed = false;
 
1136
+    private static boolean testGeneratedInterrupt = false;
 
1137
+    private static String failureMessage = "";
 
1138
+
 
1139
+    private static Thread mainThread = null;
 
1140
+
 
1141
+    private static int sleepTime = 300000;
 
1142
+
 
1143
+    public static void main( String args[] ) throws InterruptedException
 
1144
+    {
 
1145
+        mainThread = Thread.currentThread();
 
1146
+        try
 
1147
+        {
 
1148
+            init();
 
1149
+        }
 
1150
+        catch( TestPassedException e )
 
1151
+        {
 
1152
+            //The test passed, so just return from main and harness will
 
1153
+            // interepret this return as a pass
 
1154
+            return;
 
1155
+        }
 
1156
+        //At this point, neither test passed nor test failed has been
 
1157
+        // called -- either would have thrown an exception and ended the
 
1158
+        // test, so we know we have multiple threads.
 
1159
+
 
1160
+        //Test involves other threads, so sleep and wait for them to
 
1161
+        // called pass() or fail()
 
1162
+        try
 
1163
+        {
 
1164
+            Thread.sleep( sleepTime );
 
1165
+            //Timed out, so fail the test
 
1166
+            throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
 
1167
+        }
 
1168
+        catch (InterruptedException e)
 
1169
+        {
 
1170
+            if( ! testGeneratedInterrupt ) throw e;
 
1171
+
 
1172
+            //reset flag in case hit this code more than once for some reason (just safety)
 
1173
+            testGeneratedInterrupt = false;
 
1174
+            if ( theTestPassed == false )
 
1175
+            {
 
1176
+                throw new RuntimeException( failureMessage );
 
1177
+            }
 
1178
+        }
 
1179
+
 
1180
+    }//main
 
1181
+
 
1182
+    public static synchronized void setTimeoutTo( int seconds )
 
1183
+    {
 
1184
+        sleepTime = seconds * 1000;
 
1185
+    }
 
1186
+
 
1187
+    public static synchronized void pass()
 
1188
+    {
 
1189
+        Sysout.println( "The test passed." );
 
1190
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
1191
+        //first check if this is executing in main thread
 
1192
+        if ( mainThread == Thread.currentThread() )
 
1193
+        {
 
1194
+            //Still in the main thread, so set the flag just for kicks,
 
1195
+            // and throw a test passed exception which will be caught
 
1196
+            // and end the test.
 
1197
+            theTestPassed = true;
 
1198
+            throw new TestPassedException();
 
1199
+        }
 
1200
+        //pass was called from a different thread, so set the flag and interrupt
 
1201
+        // the main thead.
 
1202
+        theTestPassed = true;
 
1203
+        testGeneratedInterrupt = true;
 
1204
+        mainThread.interrupt();
 
1205
+    }//pass()
 
1206
+
 
1207
+    public static synchronized void fail()
 
1208
+    {
 
1209
+        //test writer didn't specify why test failed, so give generic
 
1210
+        fail( "it just plain failed! :-)" );
 
1211
+    }
 
1212
+
 
1213
+    public static synchronized void fail( String whyFailed )
 
1214
+    {
 
1215
+        Sysout.println( "The test failed: " + whyFailed );
 
1216
+        Sysout.println( "The test is over, hit  Ctl-C to stop Java VM" );
 
1217
+        //check if this called from main thread
 
1218
+        if ( mainThread == Thread.currentThread() )
 
1219
+        {
 
1220
+            //If main thread, fail now 'cause not sleeping
 
1221
+            throw new RuntimeException( whyFailed );
 
1222
+        }
 
1223
+        theTestPassed = false;
 
1224
+        testGeneratedInterrupt = true;
 
1225
+        failureMessage = whyFailed;
 
1226
+        mainThread.interrupt();
 
1227
+    }//fail()
 
1228
+
 
1229
+}// class ManualMainTest
 
1230
+
 
1231
+//This exception is used to exit from any level of call nesting
 
1232
+// when it's determined that the test has passed, and immediately
 
1233
+// end the test.
 
1234
+class TestPassedException extends RuntimeException
 
1235
+{
 
1236
+}
 
1237
+
 
1238
+//*********** End Standard Test Machinery Section **********
 
1239
+
 
1240
+
 
1241
+//************ Begin classes defined for the test ****************
 
1242
+
 
1243
+// make listeners in a class defined here, and instantiate them in init()
 
1244
+
 
1245
+/* Example of a class which may be written as part of a test
 
1246
+class NewClass implements anInterface
 
1247
+ {
 
1248
+   static int newVar = 0;
 
1249
+
 
1250
+   public void eventDispatched(AWTEvent e)
 
1251
+    {
 
1252
+      //Counting events to see if we get enough
 
1253
+      eventCount++;
 
1254
+
 
1255
+      if( eventCount == 20 )
 
1256
+       {
 
1257
+         //got enough events, so pass
 
1258
+
 
1259
+         ManualMainTest.pass();
 
1260
+       }
 
1261
+      else if( tries == 20 )
 
1262
+       {
 
1263
+         //tried too many times without getting enough events so fail
 
1264
+
 
1265
+         ManualMainTest.fail();
 
1266
+       }
 
1267
+
 
1268
+    }// eventDispatched()
 
1269
+
 
1270
+ }// NewClass class
 
1271
+
 
1272
+*/
 
1273
+
 
1274
+
 
1275
+//************** End classes defined for the test *******************
 
1276
+
 
1277
+
 
1278
+
 
1279
+
 
1280
+/****************************************************
 
1281
+ Standard Test Machinery
 
1282
+ DO NOT modify anything below -- it's a standard
 
1283
+  chunk of code whose purpose is to make user
 
1284
+  interaction uniform, and thereby make it simpler
 
1285
+  to read and understand someone else's test.
 
1286
+ ****************************************************/
 
1287
+
 
1288
+/**
 
1289
+ This is part of the standard test machinery.
 
1290
+ It creates a dialog (with the instructions), and is the interface
 
1291
+  for sending text messages to the user.
 
1292
+ To print the instructions, send an array of strings to Sysout.createDialog
 
1293
+  WithInstructions method.  Put one line of instructions per array entry.
 
1294
+ To display a message for the tester to see, simply call Sysout.println
 
1295
+  with the string to be displayed.
 
1296
+ This mimics System.out.println but works within the test harness as well
 
1297
+  as standalone.
 
1298
+ */
 
1299
+
 
1300
+class Sysout
 
1301
+{
 
1302
+    private static TestDialog dialog;
 
1303
+
 
1304
+    public static void createDialogWithInstructions( String[] instructions )
 
1305
+    {
 
1306
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
1307
+        dialog.printInstructions( instructions );
 
1308
+        dialog.setVisible(true);
 
1309
+        println( "Any messages for the tester will display here." );
 
1310
+    }
 
1311
+
 
1312
+    public static void createDialog( )
 
1313
+    {
 
1314
+        dialog = new TestDialog( new Frame(), "Instructions" );
 
1315
+        String[] defInstr = { "Instructions will appear here. ", "" } ;
 
1316
+        dialog.printInstructions( defInstr );
 
1317
+        dialog.setVisible(true);
 
1318
+        println( "Any messages for the tester will display here." );
 
1319
+    }
 
1320
+
 
1321
+
 
1322
+    public static void printInstructions( String[] instructions )
 
1323
+    {
 
1324
+        dialog.printInstructions( instructions );
 
1325
+    }
 
1326
+
 
1327
+
 
1328
+    public static void println( String messageIn )
 
1329
+    {
 
1330
+        dialog.displayMessage( messageIn );
 
1331
+    }
 
1332
+
 
1333
+}// Sysout  class
 
1334
+
 
1335
+/**
 
1336
+  This is part of the standard test machinery.  It provides a place for the
 
1337
+   test instructions to be displayed, and a place for interactive messages
 
1338
+   to the user to be displayed.
 
1339
+  To have the test instructions displayed, see Sysout.
 
1340
+  To have a message to the user be displayed, see Sysout.
 
1341
+  Do not call anything in this dialog directly.
 
1342
+  */
 
1343
+class TestDialog extends Dialog implements ActionListener
 
1344
+{
 
1345
+
 
1346
+    TextArea instructionsText;
 
1347
+    TextArea messageText;
 
1348
+    int maxStringLength = 80;
 
1349
+    Panel  buttonP = new Panel();
 
1350
+    Button passB = new Button( "pass" );
 
1351
+    Button failB = new Button( "fail" );
 
1352
+
 
1353
+    //DO NOT call this directly, go through Sysout
 
1354
+    public TestDialog( Frame frame, String name )
 
1355
+    {
 
1356
+        super( frame, name );
 
1357
+        int scrollBoth = TextArea.SCROLLBARS_BOTH;
 
1358
+        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
 
1359
+        add( "North", instructionsText );
 
1360
+
 
1361
+        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
 
1362
+        add("Center", messageText);
 
1363
+
 
1364
+        passB = new Button( "pass" );
 
1365
+        passB.setActionCommand( "pass" );
 
1366
+        passB.addActionListener( this );
 
1367
+        buttonP.add( "East", passB );
 
1368
+
 
1369
+        failB = new Button( "fail" );
 
1370
+        failB.setActionCommand( "fail" );
 
1371
+        failB.addActionListener( this );
 
1372
+        buttonP.add( "West", failB );
 
1373
+
 
1374
+        add( "South", buttonP );
 
1375
+        pack();
 
1376
+
 
1377
+        setVisible(true);
 
1378
+    }// TestDialog()
 
1379
+
 
1380
+    //DO NOT call this directly, go through Sysout
 
1381
+    public void printInstructions( String[] instructions )
 
1382
+    {
 
1383
+        //Clear out any current instructions
 
1384
+        instructionsText.setText( "" );
 
1385
+
 
1386
+        //Go down array of instruction strings
 
1387
+
 
1388
+        String printStr, remainingStr;
 
1389
+        for( int i=0; i < instructions.length; i++ )
 
1390
+        {
 
1391
+            //chop up each into pieces maxSringLength long
 
1392
+            remainingStr = instructions[ i ];
 
1393
+            while( remainingStr.length() > 0 )
 
1394
+            {
 
1395
+                //if longer than max then chop off first max chars to print
 
1396
+                if( remainingStr.length() >= maxStringLength )
 
1397
+                {
 
1398
+                    //Try to chop on a word boundary
 
1399
+                    int posOfSpace = remainingStr.
 
1400
+                        lastIndexOf( ' ', maxStringLength - 1 );
 
1401
+
 
1402
+                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
 
1403
+
 
1404
+                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
 
1405
+                    remainingStr = remainingStr.substring( posOfSpace + 1 );
 
1406
+                }
 
1407
+                //else just print
 
1408
+                else
 
1409
+                {
 
1410
+                    printStr = remainingStr;
 
1411
+                    remainingStr = "";
 
1412
+                }
 
1413
+
 
1414
+                instructionsText.append( printStr + "\n" );
 
1415
+
 
1416
+            }// while
 
1417
+
 
1418
+        }// for
 
1419
+
 
1420
+    }//printInstructions()
 
1421
+
 
1422
+    //DO NOT call this directly, go through Sysout
 
1423
+    public void displayMessage( String messageIn )
 
1424
+    {
 
1425
+        messageText.append( messageIn + "\n" );
 
1426
+        System.out.println(messageIn);
 
1427
+    }
 
1428
+
 
1429
+    //catch presses of the passed and failed buttons.
 
1430
+    //simply call the standard pass() or fail() static methods of
 
1431
+    //ManualMainTest
 
1432
+    public void actionPerformed( ActionEvent e )
 
1433
+    {
 
1434
+        if( e.getActionCommand() == "pass" )
 
1435
+        {
 
1436
+            Winkey.pass();
 
1437
+        }
 
1438
+        else
 
1439
+        {
 
1440
+            Winkey.fail();
 
1441
+        }
 
1442
+    }
 
1443
+
 
1444
+}// TestDialog  class
 
1445
exporting patch:
 
1446
<fdopen>