This is the mail archive of the mauve-discuss@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: new tests for UIManager


I committed this patch to add new tests for some of the methods in javax.swing.UIManager:

2005-08-23 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/javax/swing/UIManager/addAuxiliaryLookAndFeel.java: new file,
* gnu/testlet/javax/swing/UIManager/addPropertyChangeListener.java: new file,
* gnu/testlet/javax/swing/UIManager/getAuxiliaryLookAndFeels.java: new file,
* gnu/testlet/javax/swing/UIManager/getCrossPlatformLookAndFeelClassName.java: new file,
* gnu/testlet/javax/swing/UIManager/getDefaults.java: new file,
* gnu/testlet/javax/swing/UIManager/getLookAndFeelDefaults.java: new file,
* gnu/testlet/javax/swing/UIManager/getPropertyChangeListeners.java: new file,
* gnu/testlet/javax/swing/UIManager/removeAuxiliaryLookAndFeel.java: new file,
* gnu/testlet/javax/swing/UIManager/setLookAndFeel.java: new file,
* gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java: new file.


Regards,

Dave Gilbert
 2005-08-23  David Gilbert  <david.gilbert@object-refinery.com>
Index: gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java
diff -N gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java	23 Aug 2005 13:51:01 -0000
@@ -0,0 +1,45 @@
+// Tags: not-a-test
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import javax.swing.LookAndFeel;
+
+/**
+ * A minimal look and feel class for use in testing.
+ */
+public class MyLookAndFeel extends LookAndFeel {
+  public MyLookAndFeel() {
+  }
+  public String getDescription() {
+    return "MyLookAndFeel Description";
+  }
+  public String getID() {
+    return "MyLookAndFeel ID";
+  }
+  public String getName() {
+    return "MyLookAndFeel Name";
+  }
+  public boolean isNativeLookAndFeel() {
+    return false;
+  }
+  public boolean isSupportedLookAndFeel() {
+    return true;
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/addAuxiliaryLookAndFeel.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/addAuxiliaryLookAndFeel.java
diff -N gnu/testlet/javax/swing/UIManager/addAuxiliaryLookAndFeel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/addAuxiliaryLookAndFeel.java	23 Aug 2005 13:51:01 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+
+/**
+ * Tests the addAuxiliaryLookAndFeel() method in the {@link UIManager} class.
+ */
+public class addAuxiliaryLookAndFeel implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    LookAndFeel laf = new MyLookAndFeel();
+    harness.check(UIManager.getAuxiliaryLookAndFeels(), null);
+    UIManager.addAuxiliaryLookAndFeel(laf);
+    LookAndFeel[] auxLafs = UIManager.getAuxiliaryLookAndFeels();
+    harness.check(auxLafs.length, 1);
+    harness.check(auxLafs[0], laf);
+    UIManager.removeAuxiliaryLookAndFeel(laf);  // clean up
+    
+    // try adding a null LAF
+    boolean pass = false;
+    try
+    {
+      UIManager.addAuxiliaryLookAndFeel(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+
+}
Index: gnu/testlet/javax/swing/UIManager/addPropertyChangeListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/addPropertyChangeListener.java
diff -N gnu/testlet/javax/swing/UIManager/addPropertyChangeListener.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/addPropertyChangeListener.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,63 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.UIManager;
+
+/**
+ * Tests the addPropertyChangeListener() method in the {@link UIManager} class.
+ */
+public class addPropertyChangeListener 
+    implements Testlet, PropertyChangeListener {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    // check that there are no listeners
+    PropertyChangeListener[] listeners = UIManager.getPropertyChangeListeners();
+    harness.check(listeners.length, 0);
+    
+    // now add a listener
+    UIManager.addPropertyChangeListener(this);
+    listeners = UIManager.getPropertyChangeListeners();;
+    harness.check(listeners.length, 1);
+    harness.check(listeners[0], this);
+    
+    // try adding a null listener - it gets silently ignored
+    UIManager.addPropertyChangeListener(null);
+    harness.check(listeners.length, 1);
+  }
+
+  public void propertyChange(PropertyChangeEvent e)
+  {
+    // do nothing - there are tests elsewhere that will verify that the event
+    // is actually called
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/getAuxiliaryLookAndFeels.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getAuxiliaryLookAndFeels.java
diff -N gnu/testlet/javax/swing/UIManager/getAuxiliaryLookAndFeels.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getAuxiliaryLookAndFeels.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,52 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+
+/**
+ * Some checks for the getAuxiliaryLookAndFeels() method in the 
+ * {@link UIManager} class.
+ */
+public class getAuxiliaryLookAndFeels implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    LookAndFeel[] lafs = UIManager.getAuxiliaryLookAndFeels();
+    harness.check(lafs, null);
+   
+    LookAndFeel laf = new MyLookAndFeel();
+    UIManager.addAuxiliaryLookAndFeel(laf);
+    lafs = UIManager.getAuxiliaryLookAndFeels();
+    harness.check(lafs.length, 1);
+    harness.check(lafs[0], laf);
+    UIManager.removeAuxiliaryLookAndFeel(laf);
+  }
+  
+}
Index: gnu/testlet/javax/swing/UIManager/getCrossPlatformLookAndFeelClassName.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getCrossPlatformLookAndFeelClassName.java
diff -N gnu/testlet/javax/swing/UIManager/getCrossPlatformLookAndFeelClassName.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getCrossPlatformLookAndFeelClassName.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,45 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.UIManager;
+
+/**
+ * Tests the getCrossPlatformLookAndFeelClassName() method in the 
+ * {@link UIManager} class.
+ */
+public class getCrossPlatformLookAndFeelClassName implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    harness.check(UIManager.getCrossPlatformLookAndFeelClassName(), 
+            "javax.swing.plaf.metal.MetalLookAndFeel");
+    
+  }
+
+}
Index: gnu/testlet/javax/swing/UIManager/getDefaults.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getDefaults.java
diff -N gnu/testlet/javax/swing/UIManager/getDefaults.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getDefaults.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,57 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Tests the getDefaults() method in the {@link UIManager} class.
+ */
+public class getDefaults implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+      // here I'm checking that the same object is returned from subsequent
+      // calls - because it seems obvious that the UIDefaults are cached
+      UIDefaults d1 = UIManager.getDefaults();
+      UIDefaults d2 = UIManager.getDefaults();
+      harness.check(d1 == d2);
+    }
+    catch (UnsupportedLookAndFeelException e)
+    {
+      harness.fail(e.toString());
+    }      
+  }
+
+}
Index: gnu/testlet/javax/swing/UIManager/getLookAndFeelDefaults.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getLookAndFeelDefaults.java
diff -N gnu/testlet/javax/swing/UIManager/getLookAndFeelDefaults.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getLookAndFeelDefaults.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,58 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Tests the getLookAndFeelDefaults() method in the 
+ * {@link UIManager} class.
+ */
+public class getLookAndFeelDefaults implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+      // here I'm checking that the same object is returned from subsequent
+      // calls - because it seems obvious that the UIDefaults are cached
+      UIDefaults d1 = UIManager.getLookAndFeelDefaults();
+      UIDefaults d2 = UIManager.getLookAndFeelDefaults();
+      harness.check(d1 == d2);
+    }
+    catch (UnsupportedLookAndFeelException e)
+    {
+      harness.fail(e.toString());
+    }        
+  }
+
+}
Index: gnu/testlet/javax/swing/UIManager/getPropertyChangeListeners.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getPropertyChangeListeners.java
diff -N gnu/testlet/javax/swing/UIManager/getPropertyChangeListeners.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getPropertyChangeListeners.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,60 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.UIManager;
+
+/**
+ * Tests the getPropertyChangeListeners() method in the {@link UIManager} class.
+ */
+public class getPropertyChangeListeners
+    implements Testlet, PropertyChangeListener {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    // check that there are no listeners
+    PropertyChangeListener[] listeners = UIManager.getPropertyChangeListeners();
+    harness.check(listeners.length, 0);
+    
+    // now add a listener
+    UIManager.addPropertyChangeListener(this);
+    listeners = UIManager.getPropertyChangeListeners();;
+    harness.check(listeners.length, 1);
+    harness.check(listeners[0], this);
+    
+  }
+
+  public void propertyChange(PropertyChangeEvent e)
+  {
+    // do nothing - there are tests elsewhere that will verify that the event
+    // is actually called
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/removeAuxiliaryLookAndFeel.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/removeAuxiliaryLookAndFeel.java
diff -N gnu/testlet/javax/swing/UIManager/removeAuxiliaryLookAndFeel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/removeAuxiliaryLookAndFeel.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,112 @@
+// Tags: JDK1.4
+// Uses: MyLookAndFeel
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+
+/**
+ * Tests the removeAuxiliaryLookAndFeel() method in the {@link UIManager} class.
+ */
+public class removeAuxiliaryLookAndFeel implements Testlet {
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    test1(harness);
+    test2(harness);
+  }
+  
+  private void test1(TestHarness harness) 
+  {
+    LookAndFeel laf = new MyLookAndFeel();
+    harness.check(UIManager.getAuxiliaryLookAndFeels(), null);
+    UIManager.addAuxiliaryLookAndFeel(laf);
+    LookAndFeel[] auxLafs = UIManager.getAuxiliaryLookAndFeels();
+    harness.check(auxLafs.length, 1);
+    harness.check(auxLafs[0], laf);
+    boolean b = UIManager.removeAuxiliaryLookAndFeel(laf);  
+    harness.check(b, true);
+    harness.check(UIManager.getAuxiliaryLookAndFeels(), null);
+    
+    // try removing a null LAF
+    boolean pass = true;
+    try
+    {
+      b = UIManager.removeAuxiliaryLookAndFeel(null);
+    }
+    catch (NullPointerException e)
+    {
+      pass = false;
+    }
+    harness.check(pass);
+    harness.check(b, false);
+  }
+
+  /**
+   * Here we check that removing a LAF preserves the order of the remaining 
+   * LAFs.
+   * 
+   * @param harness
+   */
+  private void test2(TestHarness harness) 
+  {
+    harness.checkPoint("test2");
+    // first check that we are starting with 0 auxiliary LAFs
+    harness.check(UIManager.getAuxiliaryLookAndFeels(), null);
+    
+    LookAndFeel laf1 = new MyLookAndFeel();
+    LookAndFeel laf2 = new MyLookAndFeel();
+    LookAndFeel laf3 = new MyLookAndFeel();
+    LookAndFeel laf4 = new MyLookAndFeel();
+    
+    UIManager.addAuxiliaryLookAndFeel(laf1);
+    UIManager.addAuxiliaryLookAndFeel(laf2);
+    UIManager.addAuxiliaryLookAndFeel(laf3);
+    UIManager.addAuxiliaryLookAndFeel(laf4);
+    
+    UIManager.removeAuxiliaryLookAndFeel(laf2);
+    LookAndFeel[] lafs = UIManager.getAuxiliaryLookAndFeels();
+    harness.check(lafs[0], laf1);
+    harness.check(lafs[1], laf3);
+    harness.check(lafs[2], laf4);
+    
+    UIManager.removeAuxiliaryLookAndFeel(laf1);
+    lafs = UIManager.getAuxiliaryLookAndFeels();    
+    harness.check(lafs[0], laf3);
+    harness.check(lafs[1], laf4);
+
+    UIManager.removeAuxiliaryLookAndFeel(laf4);
+    lafs = UIManager.getAuxiliaryLookAndFeels();    
+    harness.check(lafs[0], laf3);
+    
+    UIManager.removeAuxiliaryLookAndFeel(laf3);
+    lafs = UIManager.getAuxiliaryLookAndFeels();    
+    harness.check(lafs, null);
+  }
+}
Index: gnu/testlet/javax/swing/UIManager/setLookAndFeel.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/setLookAndFeel.java
diff -N gnu/testlet/javax/swing/UIManager/setLookAndFeel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/setLookAndFeel.java	23 Aug 2005 13:51:03 -0000
@@ -0,0 +1,84 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.javax.swing.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+/**
+ * Some checks for the setLookAndFeel() method in the 
+ * {@link UIManager} class.
+ */
+public class setLookAndFeel
+    implements Testlet, PropertyChangeListener {
+
+  public PropertyChangeEvent lastEvent = null;
+  
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    LookAndFeel laf1 = new MyLookAndFeel();
+    try
+    {
+      UIManager.addPropertyChangeListener(this);
+      UIManager.setLookAndFeel(laf1);
+      harness.check(UIManager.getLookAndFeel(), laf1);
+      harness.check(this.lastEvent.getPropertyName(), "lookAndFeel");
+      harness.check(this.lastEvent.getSource(), UIManager.class);
+      harness.check(this.lastEvent.getNewValue(), laf1);
+    }
+    catch (UnsupportedLookAndFeelException e)
+    {
+      harness.fail(e.toString());
+    }
+   
+    try
+    {
+      UIManager.setLookAndFeel((LookAndFeel) null);
+      harness.check(UIManager.getLookAndFeel(), null);
+      harness.check(this.lastEvent.getPropertyName(), "lookAndFeel");
+      harness.check(this.lastEvent.getSource(), UIManager.class);
+      harness.check(this.lastEvent.getOldValue(), laf1);
+      harness.check(this.lastEvent.getNewValue(), null);
+    }
+    catch (UnsupportedLookAndFeelException e)
+    {
+      harness.fail(e.toString());
+    }
+        
+    UIManager.removePropertyChangeListener(this);
+  }
+  
+  public void propertyChange(PropertyChangeEvent e) 
+  {
+    this.lastEvent = e;
+  }
+}

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