6997102: Test case has hard code, so that applet thread threw exception

Reviewed-by: alexp
This commit is contained in:
Pavel Porvatov 2011-02-18 20:09:35 +03:00
parent 5ddedf5391
commit e70749d90d
2 changed files with 17 additions and 4 deletions
jdk/test/javax/swing/JFileChooser/6798062

@ -1,6 +1,8 @@
<html>
<body>
<applet code="bug6798062.class" width=400 height=300></applet>
The test is suitable only for Windows
1. Create a link
2. Copy path to the link into TextField
3. Run the Windows Task Manager. Select the Processes tab and find the java process

@ -28,6 +28,7 @@
@run applet/manual=done bug6798062.html
*/
import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder;
import javax.swing.*;
@ -68,13 +69,23 @@ public class bug6798062 extends JApplet {
add(initialize());
}
private JPanel initialize() {
File file = new File("c:/");
private JComponent initialize() {
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
return new JLabel("The test is suitable only for Windows");
}
String tempDir = System.getProperty("java.io.tmpdir");
if (tempDir.length() == 0) { // 'java.io.tmpdir' isn't guaranteed to be defined
tempDir = System.getProperty("user.home");
}
System.out.println("Temp directory: " + tempDir);
try {
folder = ShellFolder.getShellFolder(file);
folder = ShellFolder.getShellFolder(new File(tempDir));
} catch (FileNotFoundException e) {
fail("Directory " + file.getPath() + " not found");
fail("Directory " + tempDir + " not found");
}
slider.setMajorTickSpacing(10);