/*
* 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 7154177
@summary An invisible owner frame should never become visible
@author anthony.petrov@oracle.com: area=awt.toplevel
@library ../../regtesthelpers
@build Util
@run main InvisibleOwner
*/
public class InvisibleOwner {
private static volatile boolean invisibleOwnerClicked = false;
private static volatile boolean backgroundClicked = false;
// A background frame to compare a pixel color against
backgroundClicked= true;
}
});
helperFrame.setVisible(true);
// An owner frame that should stay invisible
invisibleOwnerClicked = true;
}
});
// An owned window
window.setVisible(true);
// Clicking the owned window shouldn't make its owner visible
// Assume the location and size are applied to the frame as expected.
// This should work fine on the Mac. We can't call getLocationOnScreen()
// since from Java perspective the frame is invisible anyway.
// 1. Check the color at the center of the owner frame
if (c == null) {
throw new RuntimeException("Robot.getPixelColor() failed");
}
throw new RuntimeException("The invisible frame has become visible");
}
throw new RuntimeException("The background helper frame has been covered by something unexpected");
}
// 2. Try to click it
// Cleanup
// Final checks
if (invisibleOwnerClicked) {
throw new RuntimeException("An invisible owner frame got clicked. Looks like it became visible.");
}
if (!backgroundClicked) {
throw new RuntimeException("The background helper frame hasn't been clciked");
}
}
}