changeset 3725:3772a3d90b40

6997102: Test case has hard code, so that applet thread threw exception Reviewed-by: alexp
author rupashka
date Fri, 18 Feb 2011 20:09:35 +0300
parents a93bb05d00fd
children 2cc71008b6db f8fdf9bca159
files test/javax/swing/JFileChooser/6798062/bug6798062.html test/javax/swing/JFileChooser/6798062/bug6798062.java
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/javax/swing/JFileChooser/6798062/bug6798062.html	Fri Feb 18 19:21:57 2011 +0300
+++ b/test/javax/swing/JFileChooser/6798062/bug6798062.html	Fri Feb 18 20:09:35 2011 +0300
@@ -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
--- a/test/javax/swing/JFileChooser/6798062/bug6798062.java	Fri Feb 18 19:21:57 2011 +0300
+++ b/test/javax/swing/JFileChooser/6798062/bug6798062.java	Fri Feb 18 20:09:35 2011 +0300
@@ -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 @@
         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);