Path: blob/master/test/jdk/java/awt/Modal/SupportedTest/SupportedTest.java
41153 views
/*1* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24@test25@key headful26@bug 652063527@summary Test that modality and modal exclusion types are handled28correctly according Toolkit.isModalityTypeSupported() and29Toolkit.isModalExclusionTypeSupported() methods30@author artem.ananiev: area=awt.modal31@run main SupportedTest32*/3334import java.awt.*;3536public class SupportedTest37{38public static void main(String[] args)39{40boolean passed = true;41Toolkit tk = Toolkit.getDefaultToolkit();4243// check for modality types4445Frame f = new Frame("F");46for (Dialog.ModalityType mt : Dialog.ModalityType.values())47{48if (!tk.isModalityTypeSupported(mt))49{50Dialog d = new Dialog(f, "D", mt);51if (!d.getModalityType().equals(Dialog.ModalityType.MODELESS))52{53System.err.println("Error: modality type " + mt + " is not supported\n" +54"but a dialog with this modality type can be created");55passed = false;56}57}58}5960// check for modal exclusion types61for (Dialog.ModalExclusionType et : Dialog.ModalExclusionType.values())62{63if (!tk.isModalExclusionTypeSupported(et))64{65Frame g = new Frame("G");66g.setModalExclusionType(et);67if (!g.getModalExclusionType().equals(Dialog.ModalExclusionType.NO_EXCLUDE))68{69System.err.println("Error: modal exclusion type " + et + "is not supported\n" +70"but a window with this modal exclusion type can be created");71passed = false;72}73}74}7576if (!passed)77{78throw new RuntimeException("Test FAILED: some of modality types and/or modal exclusion types are handled incorrectly");79}80}81}828384