Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Modal/SupportedTest/SupportedTest.java
38828 views
/*1* Copyright (c) 2007, 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@bug 652063526@summary Test that modality and modal exclusion types are handled27correctly according Toolkit.isModalityTypeSupported() and28Toolkit.isModalExclusionTypeSupported() methods29@author artem.ananiev: area=awt.modal30@run main SupportedTest31*/3233import java.awt.*;3435public class SupportedTest36{37public static void main(String[] args)38{39boolean passed = true;40Toolkit tk = Toolkit.getDefaultToolkit();4142// check for modality types4344Frame f = new Frame("F");45for (Dialog.ModalityType mt : Dialog.ModalityType.values())46{47if (!tk.isModalityTypeSupported(mt))48{49Dialog d = new Dialog(f, "D", mt);50if (!d.getModalityType().equals(Dialog.ModalityType.MODELESS))51{52System.err.println("Error: modality type " + mt + " is not supported\n" +53"but a dialog with this modality type can be created");54passed = false;55}56}57}5859// check for modal exclusion types60for (Dialog.ModalExclusionType et : Dialog.ModalExclusionType.values())61{62if (!tk.isModalExclusionTypeSupported(et))63{64Frame g = new Frame("G");65g.setModalExclusionType(et);66if (!g.getModalExclusionType().equals(Dialog.ModalExclusionType.NO_EXCLUDE))67{68System.err.println("Error: modal exclusion type " + et + "is not supported\n" +69"but a window with this modal exclusion type can be created");70passed = false;71}72}73}7475if (!passed)76{77throw new RuntimeException("Test FAILED: some of modality types and/or modal exclusion types are handled incorrectly");78}79}80}818283