TestGuiAvailable.java revision 1077
1077N/A/*
1077N/A * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
1077N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1077N/A *
1077N/A * This code is free software; you can redistribute it and/or modify it
1077N/A * under the terms of the GNU General Public License version 2 only, as
1077N/A * published by the Free Software Foundation.
1077N/A *
1077N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1077N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1077N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1077N/A * version 2 for more details (a copy is included in the LICENSE file that
1077N/A * accompanied this code).
1077N/A *
1077N/A * You should have received a copy of the GNU General Public License version
1077N/A * 2 along with this work; if not, write to the Free Software Foundation,
1077N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1077N/A *
1077N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
1077N/A * CA 95054 USA or visit www.sun.com if you need additional information or
1077N/A * have any questions.
1077N/A */
1077N/A
1077N/A/*
1077N/A * @test
1077N/A * @bug 6669869
1077N/A * @summary Tests GuiAvailable property in different application contexts
1077N/A * @author Sergey Malenkov
1077N/A */
1077N/A
1077N/Aimport java.awt.GraphicsEnvironment;
1077N/Aimport java.beans.Beans;
1077N/Aimport sun.awt.SunToolkit;
1077N/A
1077N/Apublic class TestGuiAvailable implements Runnable {
1077N/A public static void main(String[] args) throws InterruptedException {
1077N/A if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
1077N/A throw new Error("unexpected GuiAvailable property");
1077N/A }
1077N/A Beans.setGuiAvailable(!Beans.isGuiAvailable());
1077N/A ThreadGroup group = new ThreadGroup("$$$");
1077N/A Thread thread = new Thread(group, new TestGuiAvailable());
1077N/A thread.start();
1077N/A thread.join();
1077N/A }
1077N/A
1077N/A public void run() {
1077N/A SunToolkit.createNewAppContext();
1077N/A if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
1077N/A throw new Error("shared GuiAvailable property");
1077N/A }
1077N/A }
1077N/A}