FilenameFilterTest.java revision 0:37a05a11f281
1139749Simp/* 2182159Snyan * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 3119822Simp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4119822Simp * 5119822Simp * This code is free software; you can redistribute it and/or modify it 6119822Simp * under the terms of the GNU General Public License version 2 only, as 7119822Simp * published by the Free Software Foundation. 8119822Simp * 9119822Simp * This code is distributed in the hope that it will be useful, but WITHOUT 10119822Simp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11119822Simp * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12119822Simp * version 2 for more details (a copy is included in the LICENSE file that 13119822Simp * accompanied this code). 14119822Simp * 15119822Simp * You should have received a copy of the GNU General Public License version 16119822Simp * 2 along with this work; if not, write to the Free Software Foundation, 17119822Simp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18119822Simp * 19119822Simp * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20119822Simp * CA 95054 USA or visit www.sun.com if you need additional information or 21119822Simp * have any questions. 22119822Simp */ 23119822Simp 24119822Simp/* 25119822Simp test 26119822Simp @bug 6448069 27119822Simp @summary namefilter is not called for file dialog on windows 28119822Simp @author oleg.sukhodolsky: area= awt.filedialog 29119822Simp @run applet FilenameFilterTest.html 30119822Simp*/ 31119822Simp 32119822Simp/** 33119822Simp * FilenameFilterTest.java 34119822Simp * 35119822Simp * summary: namefilter is not called for file dialog on windows 36119822Simp */ 37119822Simp 38119822Simpimport java.applet.Applet; 39119822Simpimport java.awt.*; 40129276Snyan 41129276Snyanimport java.io.File; 42127215Smarcelimport java.io.FilenameFilter; 43182159Snyan 44182159Snyanimport test.java.awt.regtesthelpers.Util; 45182159Snyan 46182159Snyanpublic class FilenameFilterTest extends Applet 47182159Snyan{ 48182159Snyan //Declare things used in the test, like buttons and labels here 49182159Snyan volatile boolean filter_was_called = false; 50182159Snyan FileDialog fd; 51182159Snyan 52182159Snyan public void init() 53182159Snyan { 54182159Snyan // Set up the environment -- set the layout manager, add 55182159Snyan // buttons, etc. 56182159Snyan 57182159Snyan setLayout (new BorderLayout ()); 58182159Snyan 59182159Snyan }//End init() 60182159Snyan 61182159Snyan public void start () 62182159Snyan { 63119822Simp //Get things going. Request focus, set size, et cetera 64119866Smarcel setSize (200,200); 65119866Smarcel setVisible(true); 66119866Smarcel validate(); 67182159Snyan 68182159Snyan EventQueue.invokeLater(new Runnable() { 69182159Snyan public void run() { 70182159Snyan fd = new FileDialog(new Frame(""), "hello world", FileDialog.LOAD); 71119866Smarcel fd.setFilenameFilter(new FilenameFilter() { 72119866Smarcel public boolean accept(File dir, String name) { 73119866Smarcel filter_was_called = true; 74119822Simp System.out.println(Thread.currentThread() + " name = " + name ); 75119822Simp return true; 76168281Smarcel } 77182159Snyan }); 78119822Simp fd.setDirectory(System.getProperty("test.src")); 79168281Smarcel fd.setVisible(true); 80168281Smarcel } 81168281Smarcel }); 82168281Smarcel Util.waitForIdle(null); 83127215Smarcel if (fd == null) { 84168281Smarcel throw new RuntimeException("fd is null (very unexpected thing :("); 85127215Smarcel } 86127215Smarcel fd.dispose(); 87119822Simp if (!filter_was_called) { 88129276Snyan throw new RuntimeException("Filter was not called"); 89129276Snyan } 90182159Snyan }// start() 91119822Simp 92182159Snyan}// class FilenameFilterTest 93182159Snyan