From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2626 invoked by alias); 23 Aug 2005 13:55:51 -0000 Mailing-List: contact mauve-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sources.redhat.com Received: (qmail 2144 invoked by uid 22791); 23 Aug 2005 13:55:16 -0000 Received: from outmail128175.authsmtp.net (HELO squirrel.dmpriest.net.uk) (62.13.128.175) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 23 Aug 2005 13:55:16 +0000 Received: from [192.168.1.4] (host81-130-208-103.in-addr.btopenworld.com [81.130.208.103]) (authenticated bits=0) by squirrel.dmpriest.net.uk (8.13.3/8.13.3/Kp) with ESMTP id j7NDtCnn031729 for ; Tue, 23 Aug 2005 14:55:13 +0100 (BST) (envelope-from david.gilbert@object-refinery.com) Message-ID: <430B38D7.9010005@object-refinery.com> Date: Tue, 23 Aug 2005 13:55:00 -0000 From: David Gilbert User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050728) MIME-Version: 1.0 To: mauve-discuss@sources.redhat.com Subject: FYI: new tests for UIManager Content-Type: multipart/mixed; boundary="------------020604080309000204080602" X-Server-Quench: 877e9af3-13dd-11da-a87f-001185d377ca X-Authentic-SMTP: 61633132333134.squirrel.dmpriest.net.uk:1.38/Kp X-Powered-By: AuthSMTP - http://www.authsmtp.com - Authenticated SMTP Mail Relay X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-SW-Source: 2005-q3/txt/msg00009.txt.bz2 This is a multi-part message in MIME format. --------------020604080309000204080602 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 978 I committed this patch to add new tests for some of the methods in javax.swing.UIManager: 2005-08-23 David Gilbert * 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 --------------020604080309000204080602 Content-Type: text/plain; name="diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff.txt" Content-length: 25101 2005-08-23 David Gilbert 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 + +// 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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 + +// 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 (null 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; + } +} --------------020604080309000204080602--