author | anthony |
Wed, 16 Jun 2010 11:26:15 +0400 | |
changeset 5757 | 5796afaab709 |
parent 5506 | 202f599c92aa |
child 7668 | d4a77089c587 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
test |
|
26 |
@bug 6448069 |
|
27 |
@summary namefilter is not called for file dialog on windows |
|
28 |
@author oleg.sukhodolsky: area= awt.filedialog |
|
29 |
@run applet FilenameFilterTest.html |
|
30 |
*/ |
|
31 |
||
32 |
/** |
|
33 |
* FilenameFilterTest.java |
|
34 |
* |
|
35 |
* summary: namefilter is not called for file dialog on windows |
|
36 |
*/ |
|
37 |
||
38 |
import java.applet.Applet; |
|
39 |
import java.awt.*; |
|
40 |
||
41 |
import java.io.File; |
|
42 |
import java.io.FilenameFilter; |
|
43 |
||
44 |
import test.java.awt.regtesthelpers.Util; |
|
45 |
||
46 |
public class FilenameFilterTest extends Applet |
|
47 |
{ |
|
48 |
//Declare things used in the test, like buttons and labels here |
|
49 |
volatile boolean filter_was_called = false; |
|
50 |
FileDialog fd; |
|
51 |
||
52 |
public void init() |
|
53 |
{ |
|
54 |
// Set up the environment -- set the layout manager, add |
|
55 |
// buttons, etc. |
|
56 |
||
57 |
setLayout (new BorderLayout ()); |
|
58 |
||
59 |
}//End init() |
|
60 |
||
61 |
public void start () |
|
62 |
{ |
|
63 |
//Get things going. Request focus, set size, et cetera |
|
64 |
setSize (200,200); |
|
65 |
setVisible(true); |
|
66 |
validate(); |
|
67 |
||
68 |
EventQueue.invokeLater(new Runnable() { |
|
69 |
public void run() { |
|
70 |
fd = new FileDialog(new Frame(""), "hello world", FileDialog.LOAD); |
|
71 |
fd.setFilenameFilter(new FilenameFilter() { |
|
72 |
public boolean accept(File dir, String name) { |
|
73 |
filter_was_called = true; |
|
74 |
System.out.println(Thread.currentThread() + " name = " + name ); |
|
75 |
return true; |
|
76 |
} |
|
77 |
}); |
|
78 |
fd.setDirectory(System.getProperty("test.src")); |
|
79 |
fd.setVisible(true); |
|
80 |
} |
|
81 |
}); |
|
82 |
Util.waitForIdle(null); |
|
83 |
if (fd == null) { |
|
84 |
throw new RuntimeException("fd is null (very unexpected thing :("); |
|
85 |
} |
|
5757
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
86 |
//Wait a little; some native dialog implementations may take a while |
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
87 |
//to initialize and call the filter. See 6959787 for an example. |
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
88 |
try { |
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
89 |
Thread.sleep(5000); |
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
90 |
} catch (Exception ex) { |
5796afaab709
6959787: java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.html failed on 7b94
anthony
parents:
5506
diff
changeset
|
91 |
} |
2 | 92 |
fd.dispose(); |
93 |
if (!filter_was_called) { |
|
94 |
throw new RuntimeException("Filter was not called"); |
|
95 |
} |
|
96 |
}// start() |
|
97 |
||
98 |
}// class FilenameFilterTest |