From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23710 invoked by alias); 7 Jan 2007 20:52:52 -0000 Received: (qmail 23700 invoked by uid 22791); 7 Jan 2007 20:52:51 -0000 X-Spam-Check-By: sourceware.org Received: from kennke.org (HELO box7954.elkhouse.de) (213.9.79.54) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 07 Jan 2007 20:52:44 +0000 Received: from [217.227.162.29] (helo=[192.168.2.100]) by box7954.elkhouse.de with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.50) id 1H3fxM-0004JU-9K for mauve-patches@sources.redhat.com; Sun, 07 Jan 2007 22:53:32 +0100 Subject: FYI: New JComboBox test From: Roman Kennke To: mauve-patches Content-Type: multipart/mixed; boundary="=-gJ8gaZ1lCr0jt0SEe/pa" Date: Sun, 07 Jan 2007 20:52:00 -0000 Message-Id: <1168203152.4740.0.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2007/txt/msg00005.txt.bz2 --=-gJ8gaZ1lCr0jt0SEe/pa Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 401 I'm adding a test for GNU Classpath PR30337. This checks how the JComboBox behaves when getEditor() returns null. 2007-01-07 Roman Kennke * gnu/testlet/javax/swing/JComboBox/getEditor.java (TestComboBox): New inner class for testing. (test): Moved code to testDefault() and add testPR30337(). (testDefault): Code moved from test() to here. (testPR30337): New test. /Roman --=-gJ8gaZ1lCr0jt0SEe/pa Content-Disposition: attachment; filename=patch.diff Content-Type: text/x-patch; name=patch.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 3440 Index: gnu/testlet/javax/swing/JComboBox/getEditor.java =================================================================== RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JComboBox/getEditor.java,v retrieving revision 1.1 diff -u -1 -5 -r1.1 getEditor.java --- gnu/testlet/javax/swing/JComboBox/getEditor.java 18 Oct 2005 15:51:41 -0000 1.1 +++ gnu/testlet/javax/swing/JComboBox/getEditor.java 7 Jan 2007 20:48:32 -0000 @@ -12,55 +12,121 @@ // 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. package gnu.testlet.javax.swing.JComboBox; import gnu.testlet.TestHarness; import gnu.testlet.Testlet; import javax.swing.ComboBoxEditor; import javax.swing.JComboBox; +import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.plaf.UIResource; import javax.swing.plaf.metal.MetalComboBoxEditor; /** * Some checks for the getEditor() method in the {@link JComboBox} class. */ public class getEditor implements Testlet { /** * Runs the test using the specified harness. * * @param harness the test harness (null not permitted). */ public void test(TestHarness harness) { + testDefault(harness); + testPR30337(harness); + } + + /** + * Tests the default value. + * + * @param harness the test harness to use + */ + private void testDefault(TestHarness harness) + { // use a known look and feel try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { harness.fail("Problem setting MetalLookAndFeel"); } JComboBox c1 = new JComboBox(new Object[] {"A", "B", "C"}); ComboBoxEditor editor = c1.getEditor(); // check default value harness.check(editor instanceof MetalComboBoxEditor.UIResource); c1.setEditor(new MetalComboBoxEditor()); harness.check(!(c1.getEditor() instanceof UIResource)); + + } + + /** + * A combo box that returns null for getEditor(). This is used in the + * following test. + */ + private class TestComboBox extends JComboBox + { + public ComboBoxEditor getEditor() + { + return null; + } + } + + /** + * The Classpath PR30337 overrides getEditor() to return null and expects + * the JComboBox to not throw an NPE. + * + * @param h the test harness + */ + private void testPR30337(TestHarness h) + { + // Test with default (non-editable) combo box. No NPE is thrown. + JComboBox cb = new TestComboBox(); + JFrame f = new JFrame(); + boolean pass = true; + try + { + f.getContentPane().add(cb); + f.setVisible(true); + } + catch (NullPointerException ex) + { + pass = false; + } + h.check(pass); + + // Test with editable combo box (NPE is thrown). + cb = new TestComboBox(); + f = new JFrame(); + pass = false; + try + { + cb.setEditable(true); + f.getContentPane().add(cb); + f.setVisible(true); + } + catch (NullPointerException ex) + { + pass = true; + } + h.check(pass); + } } --=-gJ8gaZ1lCr0jt0SEe/pa--