2362N/A * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/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 0N/A @summary Tests the Window.autoRequestFocus property for the Window.setVisible() method. 0N/A @author anton.tarasov: area=awt.focus 0N/A @library ../../regtesthelpers 0N/A @run main AutoRequestFocusSetVisibleTest 0N/A // Create instructions for the user here, as well as set up 0N/A // the environment -- set the layout manager, add buttons, 0N/A {
"This is an automatic test. Simply wait until it is done." 0N/A * When 'frame' is shown along with the 'ownedWindow' 0N/A * (i.e. showWithParent==true) then it can appear 0N/A * that the 'ownedWindow' is shown too early and 0N/A * it can't be focused due to its owner can't be 0N/A * yet activated. So, to avoid this race, we pospone 0N/A * a little the showing of the 'ownedWindow'. 0N/A /////////////////////////////////////////////////////// 0N/A // 1. Show Frame with owned modal Dialog without delay. 0N/A // Check that the Dialog takes focus. 0N/A /////////////////////////////////////////////////////// 0N/A ////////////////////////////////////////////////// 0N/A // 2. Show Frame, activate, auto hide, auto show. 0N/A // Check that the Frame takes focus. 0N/A ////////////////////////////////////////////////// 0N/A throw new Error(
"Test error: the frame couldn't be focused.");
0N/A //////////////////////// 0N/A // 3.1 Show Frame normal. 0N/A //////////////////////// 0N/A // 3.2. Show Frame maximized both. 0N/A ///////////////////////////////// 0N/A // 3.3. Show Frame maximized vertically. 0N/A /////////////////////////////////////// 0N/A // 3.4. Show Frame maximized horizontally. 0N/A ///////////////////////////////////////// 0N/A // 3.5. Show Frame iconified. 0N/A //////////////////////////// 0N/A // 4.3. Show modal Dialog. 0N/A ///////////////////////// 0N/A /////////////////////////////////// 0N/A // 5.1 Show Frame with owned Window. 0N/A /////////////////////////////////// 0N/A // On Windows, an owned Window will not be focused on its showing 0N/A // if the owner is not currently active. 0N/A // 5.2 Show Frame with owned Dialog. 0N/A /////////////////////////////////// 0N/A /////////////////////////////////// 0N/A // 6. Show unblocking modal Dialog. 0N/A /////////////////////////////////// 0N/A // Testing the bug of activating invisible modal Dialog (awt_Window::SetAndActivateModalBlocker). 0N/A // Having some window not excluded from modality, so that it would be blocked. 0N/A throw new Error(
"Test error: the frame couldn't be focused.");
0N/A * @param msg notifies test stage number 0N/A * @param showWindow a window to show/test (if ownedWindow == null) 0N/A * @param ownedWindow an owned window to show/test, or null if showWindow should be tested 0N/A * @param clickButton a button of the window (owner or owned) expected to be on the top of stack order 0N/A * @param shouldFocusChange true the test window should gain focus 0N/A throw new Error(
"Test error: the frame couldn't be focused.");
0N/A ////////////////////////////////////////// 0N/A // Test focus change on showing the window 0N/A ////////////////////////////////////////// 0N/A //////////////////////////////////////////// 0N/A // Test that the window was shown on the top. 0N/A // Test that it can be focused. 0N/A //////////////////////////////////////////// 0N/A * If 'showWindow' is not on the top then 0N/A * 'focusOwner' button completely overlaps 'clickButton' 0N/A * and we won't catch the action. 0N/A // In case of loosing ACTION_PERFORMED, try once more. 0N/A/**************************************************** 0N/A Standard Test Machinery 0N/A DO NOT modify anything below -- it's a standard 0N/A chunk of code whose purpose is to make user 0N/A interaction uniform, and thereby make it simpler 0N/A to read and understand someone else's test. 0N/A ****************************************************/ 0N/A This is part of the standard test machinery. 0N/A It creates a dialog (with the instructions), and is the interface 0N/A for sending text messages to the user. 0N/A To print the instructions, send an array of strings to Sysout.createDialog 0N/A WithInstructions method. Put one line of instructions per array entry. 0N/A To display a message for the tester to see, simply call Sysout.println 0N/A with the string to be displayed. 0N/A This mimics System.out.println but works within the test harness as well 0N/A// dialog.setVisible(true); 0N/A println(
"Any messages for the tester will display here." );
0N/A// dialog.setVisible(true); 0N/A println(
"Any messages for the tester will display here." );
0N/A This is part of the standard test machinery. It provides a place for the 0N/A test instructions to be displayed, and a place for interactive messages 0N/A to the user to be displayed. 0N/A To have the test instructions displayed, see Sysout. 0N/A To have a message to the user be displayed, see Sysout. 0N/A Do not call anything in this dialog directly. 0N/A //DO NOT call this directly, go through Sysout 0N/A //DO NOT call this directly, go through Sysout 0N/A //Clear out any current instructions 0N/A //Go down array of instruction strings 0N/A //chop up each into pieces maxSringLength long 0N/A //if longer than max then chop off first max chars to print 0N/A //Try to chop on a word boundary 0N/A }
//printInstructions() 0N/A //DO NOT call this directly, go through Sysout