harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495924 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/JFileChooser.java test/api/java/common/javax/swing/JFileChooserTest.java
Date Sat, 13 Jan 2007 16:56:42 GMT
Author: hindessm
Date: Sat Jan 13 08:56:42 2007
New Revision: 495924

URL: http://svn.apache.org/viewvc?view=rev&rev=495924
Log:
Applying patch from "[#HARMONY-2582] [classlib][swing]
javax.swing.JFileChooser(File, null) throws unspecified NPE while RI does
not".

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JFileChooser.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFileChooserTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JFileChooser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JFileChooser.java?view=diff&rev=495924&r1=495923&r2=495924
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JFileChooser.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/JFileChooser.java
Sat Jan 13 08:56:42 2007
@@ -164,11 +164,11 @@
     }
 
     public JFileChooser(final String currentDirectoryPath) {
-        this(currentDirectoryPath, FileSystemView.getFileSystemView());
+        this(currentDirectoryPath, null);
     }
 
     public JFileChooser(final File currentDirectory) {
-        this(currentDirectory, FileSystemView.getFileSystemView());
+        this(currentDirectory, null);
     }
 
     public JFileChooser(final FileSystemView fsv) {
@@ -596,7 +596,7 @@
     }
 
     protected void setup(final FileSystemView view) {
-        setFileSystemView(view);
+        setFileSystemView(view != null ? view : FileSystemView.getFileSystemView());
         updateUI();
         if (isAcceptAllFileFilterUsed()) {
             addChoosableFileFilter(getAcceptAllFileFilter());

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFileChooserTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFileChooserTest.java?view=diff&rev=495924&r1=495923&r2=495924
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFileChooserTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JFileChooserTest.java
Sat Jan 13 08:56:42 2007
@@ -102,9 +102,52 @@
         }
     }
 
+    public void testJFileChooser_FSV() throws Exception {
+        File testDir = new File("testDir");
+        testDir.deleteOnExit();
+        testDir.mkdir();
+        chooser = new JFileChooser();
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((File) null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir.getAbsolutePath());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((String) null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((FileSystemView) null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir, FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir, null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((File) null, FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((File) null, null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir.getAbsolutePath(), FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser(testDir.getAbsolutePath(), null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((String) null, FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser = new JFileChooser((String) null, null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        testDir.delete();
+    }
+
     //TODO
     public void testSetup() throws Exception {
+        chooser = new JFileChooser();
         assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser.setup(FileSystemView.getFileSystemView());
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+        chooser.setup(null);
+        assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+
         final File defaultDir = new File("testDir");
         defaultDir.deleteOnExit();
         try {
@@ -124,6 +167,12 @@
             assertEquals(view, chooser.getFileSystemView());
             assertEquals(FileSystemView.getFileSystemView().getDefaultDirectory(), chooser
                     .getCurrentDirectory());
+            chooser.setup(FileSystemView.getFileSystemView());
+            assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
+            chooser.setup(view);
+            assertEquals(view, chooser.getFileSystemView());
+            chooser.setup(null);
+            assertEquals(FileSystemView.getFileSystemView(), chooser.getFileSystemView());
         } catch (Throwable t) {
             defaultDir.delete();
             fail("Detected problem " + t.getMessage());



Mime
View raw message