2362N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 99N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 99N/A * This code is free software; you can redistribute it and/or modify it 99N/A * under the terms of the GNU General Public License version 2 only, as 99N/A * published by the Free Software Foundation. 99N/A * This code is distributed in the hope that it will be useful, but WITHOUT 99N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 99N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 99N/A * version 2 for more details (a copy is included in the LICENSE file that 99N/A * accompanied this code). 99N/A * You should have received a copy of the GNU General Public License version 99N/A * 2 along with this work; if not, write to the Free Software Foundation, 99N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 99N/A @summary Modal Dialog block input to all frame windows not just its parent. 99N/A @author dmitry.cherepanov: area=awt.modal 99N/A * summary: The test opens and closes blocker dialog, the test verifies 99N/A * that active window is correct when the dialog is closed. 99N/A //*** Create instructions for the user here *** 99N/A " the test will be run 6 times, to start next test just close all ",
99N/A " windows of previous; the instructions are the same for all tests: ",
99N/A " 1) there are two frames (one the frames has 'show modal' button), ",
99N/A " 2) press the button to show a dialog, ",
99N/A " 3) close the dialog (an alternative scenario - activate another",
99N/A " native window before closing the dialog), ",
99N/A " 4) the frame with button should become next active window, ",
99N/A " if it's true, then the test passed, otherwise, it failed. ",
99N/A " Press 'pass' button only after all of the 6 tests are completed, ",
99N/A " the number of the currently executed test is displayed on the ",
99N/A test(
false,
true,
false);
// 3rd parameter has no affect for ownerless 99N/A test(
false,
false,
false);
// 3rd parameter has no affect for ownerless 99N/A * The ownerless parameter indicates whether the blocker dialog 99N/A * has owner. The usual parameter indicates whether the blocker 99N/A * dialog is a Java dialog (non-native dialog like file dialog). 99N/A /***************************************************** 99N/A * Standard Test Machinery Section 99N/A * DO NOT modify anything in this section -- it's a 99N/A * standard chunk of code which has all of the 99N/A * synchronisation necessary for the test harness. 99N/A * By keeping it the same in all tests, it is easier 99N/A * to read and understand someone else's test, as 99N/A * well as insuring that all tests behave correctly 99N/A * with the test harness. 99N/A * There is a section following this for test-defined 99N/A ******************************************************/ 99N/A //The test passed, so just return from main and harness will 99N/A // interepret this return as a pass 99N/A //At this point, neither test passed nor test failed has been 99N/A // called -- either would have thrown an exception and ended the 99N/A // test, so we know we have multiple threads. 99N/A //Test involves other threads, so sleep and wait for them to 99N/A // called pass() or fail() 99N/A //Timed out, so fail the test 99N/A //reset flag in case hit this code more than once for some reason (just safety) 99N/A //first check if this is executing in main thread 99N/A //Still in the main thread, so set the flag just for kicks, 99N/A // and throw a test passed exception which will be caught 99N/A // and end the test. 99N/A //pass was called from a different thread, so set the flag and interrupt 99N/A //test writer didn't specify why test failed, so give generic 99N/A //check if this called from main thread 99N/A //If main thread, fail now 'cause not sleeping 99N/A}
// class ManualMainTest 99N/A//This exception is used to exit from any level of call nesting 99N/A// when it's determined that the test has passed, and immediately 99N/A//*********** End Standard Test Machinery Section ********** 99N/A//************ Begin classes defined for the test **************** 99N/A// make listeners in a class defined here, and instantiate them in init() 99N/A/* Example of a class which may be written as part of a test 99N/Aclass NewClass implements anInterface 99N/A static int newVar = 0; 99N/A public void eventDispatched(AWTEvent e) 99N/A //Counting events to see if we get enough 99N/A if( eventCount == 20 ) 99N/A //got enough events, so pass 99N/A ManualMainTest.pass(); 99N/A else if( tries == 20 ) 99N/A //tried too many times without getting enough events so fail 99N/A ManualMainTest.fail(); 99N/A }// eventDispatched() 99N/A//************** End classes defined for the test ******************* 99N/A/**************************************************** 99N/A Standard Test Machinery 99N/A DO NOT modify anything below -- it's a standard 99N/A chunk of code whose purpose is to make user 99N/A interaction uniform, and thereby make it simpler 99N/A to read and understand someone else's test. 99N/A ****************************************************/ 99N/A This is part of the standard test machinery. 99N/A It creates a dialog (with the instructions), and is the interface 99N/A for sending text messages to the user. 99N/A To print the instructions, send an array of strings to Sysout.createDialog 99N/A WithInstructions method. Put one line of instructions per array entry. 99N/A To display a message for the tester to see, simply call Sysout.println 99N/A with the string to be displayed. 99N/A This mimics System.out.println but works within the test harness as well 99N/A println(
"Any messages for the tester will display here." );
99N/A println(
"Any messages for the tester will display here." );
99N/A This is part of the standard test machinery. It provides a place for the 99N/A test instructions to be displayed, and a place for interactive messages 99N/A to the user to be displayed. 99N/A To have the test instructions displayed, see Sysout. 99N/A To have a message to the user be displayed, see Sysout. 99N/A Do not call anything in this dialog directly. 99N/A //DO NOT call this directly, go through Sysout 99N/A //DO NOT call this directly, go through Sysout 99N/A //Clear out any current instructions 99N/A //Go down array of instruction strings 99N/A //chop up each into pieces maxSringLength long 99N/A //if longer than max then chop off first max chars to print 99N/A //Try to chop on a word boundary 99N/A }
//printInstructions() 99N/A //DO NOT call this directly, go through Sysout 99N/A //catch presses of the passed and failed buttons. 99N/A //simply call the standard pass() or fail() static methods of 99N/A}
// TestDialog class