This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Some UIManager tests


This patch (committed) adds some new tests for the UIManager class:

2006-09-06 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/UIManager/getBoolean.java: New file,
   * gnu/testlet/javax/swing/UIManager/getBorder.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getColor.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getDimension.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getFont.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getIcon.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getInsets.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getInt.java: Likewise,
   * gnu/testlet/javax/swing/UIManager/getString.java: Likewise.

I have a GNU Classpath patch that fixes the failing tests.

Regards,

Dave
Index: gnu/testlet/javax/swing/UIManager/getBoolean.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getBoolean.java
diff -N gnu/testlet/javax/swing/UIManager/getBoolean.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getBoolean.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,99 @@
+/* getBoolean.java -- some checks for the getBoolean() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getBoolean implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getBoolean("ScrollBar.allowsAbsolutePositioning"), 
+            true);
+    UIManager.put("ScrollBar.allowsAbsolutePositioning", Boolean.FALSE);
+    harness.check(UIManager.getBoolean("ScrollBar.allowsAbsolutePositioning"), 
+            false);
+    UIManager.put("ScrollBar.allowsAbsolutePositioning", null);
+    harness.check(UIManager.getBoolean("ScrollBar.allowsAbsolutePositioning"), 
+            true);
+    
+    // check an item that is not a boolean - it should return false
+    harness.check(UIManager.getBoolean("ScrollBar.darkShadow"), false);
+    
+    // check an item that doesn't exist - it should return false
+    harness.check(UIManager.getBoolean("XXXXXXXXXXXXXXXXX"), false);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getBoolean(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getBoolean(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getBorder.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getBorder.java
diff -N gnu/testlet/javax/swing/UIManager/getBorder.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getBorder.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,98 @@
+/* getBorder.java -- some checks for the getBorder() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getBorder implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getBorder("Button.border") instanceof Border);
+    UIManager.put("Button.border", new EmptyBorder(1, 1, 1, 1));
+    harness.check(UIManager.getBorder("Button.border") instanceof EmptyBorder);
+    UIManager.put("Button.border", null);
+    harness.check(UIManager.getBorder("Button.border") instanceof Border);
+    
+    // check an item that is not a border - it should return null
+    harness.check(UIManager.getBorder("ScrollBar.darkShadow"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getBorder("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getBorder(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getBorder(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getColor.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getColor.java
diff -N gnu/testlet/javax/swing/UIManager/getColor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getColor.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,100 @@
+/* getColor.java -- some checks for the getColor() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getColor implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getColor("Button.background") 
+            instanceof ColorUIResource);
+    UIManager.put("Button.background", Color.red);
+    harness.check(UIManager.getColor("Button.background"), Color.red);
+    UIManager.put("Button.background", null);
+    harness.check(UIManager.getColor("Button.background") 
+            instanceof ColorUIResource);
+    
+    // check an item that is not a color - it should return null
+    harness.check(UIManager.getColor("Button.border"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getBorder("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getColor(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getColor(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getDimension.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getDimension.java
diff -N gnu/testlet/javax/swing/UIManager/getDimension.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getDimension.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,100 @@
+/* getDimension.java -- some checks for the getDimension() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Dimension;
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getDimension implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getDimension("ScrollBar.minimumThumbSize"), 
+            new Dimension(8, 8));
+    UIManager.put("ScrollBar.minimumThumbSize", new Dimension(1, 2));
+    harness.check(UIManager.getDimension("ScrollBar.minimumThumbSize"), 
+            new Dimension(1, 2));
+    UIManager.put("ScrollBar.minimumThumbSize", null);
+    harness.check(UIManager.getDimension("ScrollBar.minimumThumbSize"),
+            new Dimension(8, 8));
+    
+    // check an item that is not a dimension - it should return null
+    harness.check(UIManager.getDimension("Button.border"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getDimension("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getDimension(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getDimension(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getFont.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getFont.java
diff -N gnu/testlet/javax/swing/UIManager/getFont.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getFont.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,99 @@
+/* getFont.java -- some checks for the getFont() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Font;
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getFont implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getFont("Button.font") instanceof FontUIResource);
+    UIManager.put("Button.font", new Font("Dialog", Font.BOLD, 7));
+    harness.check(UIManager.getFont("Button.font"), new Font("Dialog", 
+            Font.BOLD, 7)); 
+    UIManager.put("Button.font", null);
+    harness.check(UIManager.getFont("Button.font") instanceof FontUIResource);
+    
+    // check an item that is not a font - it should return null
+    harness.check(UIManager.getFont("Button.border"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getFont("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getFont(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getFont(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getIcon.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getIcon.java
diff -N gnu/testlet/javax/swing/UIManager/getIcon.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getIcon.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,102 @@
+/* getIcon.java -- some checks for the getIcon() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Locale;
+
+import javax.swing.Icon;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalIconFactory;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getIcon implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getIcon("FileChooser.detailsViewIcon") 
+            instanceof Icon);
+    Icon icon = MetalIconFactory.getHorizontalSliderThumbIcon();
+    UIManager.put("FileChooser.detailsViewIcon", icon);
+    harness.check(UIManager.getIcon("FileChooser.detailsViewIcon"), icon); 
+    UIManager.put("FileChooser.detailsViewIcon", null);
+    harness.check(UIManager.getIcon("FileChooser.detailsViewIcon") 
+            instanceof Icon);
+    harness.check(UIManager.getIcon("FileChooser.detailsViewIcon") != icon);
+    
+    // check an item that is not a font - it should return null
+    harness.check(UIManager.getIcon("Button.border"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getIcon("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getIcon(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getIcon(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getInsets.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getInsets.java
diff -N gnu/testlet/javax/swing/UIManager/getInsets.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getInsets.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,100 @@
+/* getInsets.java -- some checks for the getInsets() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Insets;
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.InsetsUIResource;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getInsets implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getInsets("Button.margin") 
+            instanceof InsetsUIResource);
+    UIManager.put("Button.margin", new Insets(1, 2, 3, 4));
+    harness.check(UIManager.getInsets("Button.margin"), new Insets(1, 2, 3, 4)); 
+    UIManager.put("Button.margin", null);
+    harness.check(UIManager.getInsets("Button.margin") 
+            instanceof InsetsUIResource);
+    
+    // check an item that is not an Insets - it should return null
+    harness.check(UIManager.getInsets("Button.border"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getInsets("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getInsets(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getInsets(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getInt.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getInt.java
diff -N gnu/testlet/javax/swing/UIManager/getInt.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getInt.java	6 Sep 2006 15:26:53 -0000
@@ -0,0 +1,96 @@
+/* getInt.java -- some checks for the getInt() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getInt implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getInt("Button.textIconGap"), 4);
+    UIManager.put("Button.textIconGap", new Integer(999));
+    harness.check(UIManager.getInt("Button.textIconGap"), 999);
+    UIManager.put("Button.textIconGap", null);
+    harness.check(UIManager.getInt("Button.textIconGap"), 4);
+    
+    // check an item that is not a boolean - it should return false
+    harness.check(UIManager.getInt("ScrollBar.darkShadow"), 0);
+    
+    // check an item that doesn't exist - it should return false
+    harness.check(UIManager.getInt("XXXXXXXXXXXXXXXXX"), 0);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getInt(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getInt(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getString.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getString.java
diff -N gnu/testlet/javax/swing/UIManager/getString.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getString.java	6 Sep 2006 15:26:54 -0000
@@ -0,0 +1,99 @@
+/* getString.java -- some checks for the getString() methods in the 
+     UIManager class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class getString implements Testlet
+{
+  public void test(TestHarness harness) 
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e) 
+    {
+      e.printStackTrace();
+    }
+    test1(harness);
+    test2(harness);
+  }
+  
+  public void test1(TestHarness harness) 
+  {
+    harness.checkPoint("(Object)");
+    harness.check(UIManager.getString("OptionPane.errorSound"), 
+            "sounds/OptionPaneError.wav");
+    UIManager.put("OptionPane.errorSound", "ABC");
+    harness.check(UIManager.getString("OptionPane.errorSound"), 
+            "ABC");
+    UIManager.put("OptionPane.errorSound", null);
+    harness.check(UIManager.getString("OptionPane.errorSound"), 
+            "sounds/OptionPaneError.wav");
+    
+    // check an item that is not a String - it should return null
+    harness.check(UIManager.getString("ScrollBar.darkShadow"), null);
+    
+    // check an item that doesn't exist - it should return null
+    harness.check(UIManager.getString("XXXXXXXXXXXXXXXXX"), null);
+    
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getString(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+  
+  public void test2(TestHarness harness) 
+  {
+    harness.checkPoint("(Object, Locale)");    
+
+    // try null
+    boolean pass = false;
+    try 
+    {
+      UIManager.getString(null, Locale.getDefault());
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]