/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 6187066
@summary Tests the Window.autoRequestFocus property for the Window.toFront() method.
@author anton.tarasov: area=awt.focus
@library ../../regtesthelpers
@build Util
@run main AutoRequestFocusToFrontTest
*/
static boolean haveDelays;
}
}
public void init() {
// Create instructions for the user here, as well as set up
// the environment -- set the layout manager, add buttons,
// etc.
this.setLayout (new BorderLayout ());
{"This is an automatic test. Simply wait until it is done."
});
}
static void recreateGUI() {
}
modalDialog.setModal(true);
}
public void start() {
// 1. Simple Frame.
//////////////////
recreateGUI();
// 2. Ownerless Window.
//////////////////////
recreateGUI();
// 3. Ownerless Dialog.
//////////////////////
recreateGUI();
// 4.1. Owner Frame (with owned Window).
///////////////////////////////////////
recreateGUI();
// 4.2. Owned Window (with owner Frame).
///////////////////////////////////////
recreateGUI();
// 5.1. Owner Frame (with owned Dialog).
///////////////////////////////////////
recreateGUI();
// 5.2. Owned Dialog (with owner Frame).
///////////////////////////////////////
recreateGUI();
////////////////////////////////////////////////
// 6.1. Owned modal Dialog (with owner Frame).
// Focused frame is excluded from modality.
////////////////////////////////////////////////
recreateGUI();
}
// 6.2. Owner Frame (with owned modal Dialog).
// Focused frame is excluded from modality.
////////////////////////////////////////////////
recreateGUI();
}
///////////////////////////////////////////////////
// 7. Calling setVisible(true) for the shown Frame.
///////////////////////////////////////////////////
recreateGUI();
}
static class Test {
static boolean testSetVisible;
}
static void setTestSetVisible() {
testSetVisible = true;
}
/*
* @param msg notifies test stage number
* @param testButton a button of the window (owner or owned) that is to be on the top of stack order
* @param shouldFocusChange true for modal dialogs
*/
pause(100);
/////////////////////////////////////////////////////////
// Test that calling toFront() doesn't cause focus change
// when 'autoRequestFocus' is false.
/////////////////////////////////////////////////////////
public void run() {
testWindow.setAutoRequestFocus(false);
if (testSetVisible) {
setVisible(testWindow, true);
} else {
}
}
};
if (shouldFocusChange) {
if (!focusWindow.isFocused()) {
throw new TestFailedException("the window must gain focus on moving to front but it didn't!");
}
throw new TestFailedException("the window shouldn't gain focus on moving to front but it did!");
}
pause(100);
///////////////////////////////////////////////////////
// Test that the window (or its owned window) is on top.
///////////////////////////////////////////////////////
// The latest versions of Metacity (e.g. 2.16) have problems with moving a window to the front.
public void run() {
}
}, 1000, false);
if (!performed) {
// For the case when the robot failed to trigger ACTION_EVENT.
public void run() {
}
}, 1000, false);
if (!performed) {
throw new TestFailedException("the window moved to front is not on the top!");
}
}
}
/////////////////////////////////////////////////
// Test that calling toFront() focuses the window
// when 'autoRequestFocus' is true.
/////////////////////////////////////////////////
// Skip this stage for unfocusable window
if (!testWindow.isFocusableWindow()) {
return;
}
pause(100);
public void run() {
testWindow.setAutoRequestFocus(true);
if (testSetVisible) {
setVisible(testWindow, true);
} else {
}
}
}, 1000, false);
// Either the window or its owned window must be focused
throw new TestFailedException("the window should gain focus automatically but it didn't!");
}
}
}
pause(100);
}
if (visible) {
public void run() {
w.setVisible(true);
}
}, robot);
} else {
setVisible(w, true);
}
} else {
w.dispose();
}
}
if (visible) {
throw new Error("Test error: the frame couldn't be focused.");
}
}
}
}
}
w.setVisible(b);
try {
}
}
w.toFront();
}
if (haveDelays) {
}
}
}
super("Test failed: " + msg);
}
}
/****************************************************
Standard Test Machinery
DO NOT modify anything below -- it's a standard
chunk of code whose purpose is to make user
interaction uniform, and thereby make it simpler
to read and understand someone else's test.
****************************************************/
/**
This is part of the standard test machinery.
It creates a dialog (with the instructions), and is the interface
for sending text messages to the user.
To print the instructions, send an array of strings to Sysout.createDialog
WithInstructions method. Put one line of instructions per array entry.
To display a message for the tester to see, simply call Sysout.println
with the string to be displayed.
This mimics System.out.println but works within the test harness as well
as standalone.
*/
class Sysout
{
{
// dialog.setVisible(true);
println( "Any messages for the tester will display here." );
}
public static void createDialog( )
{
// dialog.setVisible(true);
println( "Any messages for the tester will display here." );
}
{
}
{
}
}// Sysout class
/**
This is part of the standard test machinery. It provides a place for the
test instructions to be displayed, and a place for interactive messages
to the user to be displayed.
To have the test instructions displayed, see Sysout.
To have a message to the user be displayed, see Sysout.
Do not call anything in this dialog directly.
*/
{
//DO NOT call this directly, go through Sysout
{
pack();
// setVisible(true);
}// TestDialog()
//DO NOT call this directly, go through Sysout
{
//Clear out any current instructions
//Go down array of instruction strings
{
//chop up each into pieces maxSringLength long
remainingStr = instructions[ i ];
{
//if longer than max then chop off first max chars to print
{
//Try to chop on a word boundary
int posOfSpace = remainingStr.
}
//else just print
else
{
remainingStr = "";
}
}// while
}// for
}//printInstructions()
//DO NOT call this directly, go through Sysout
{
}
}// TestDialog class