From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30589 invoked by alias); 9 Nov 2006 19:15:31 -0000 Received: (qmail 30578 invoked by uid 22791); 9 Nov 2006 19:15:30 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 09 Nov 2006 19:15:20 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id kA9JFIKk002892 for ; Thu, 9 Nov 2006 14:15:18 -0500 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id kA9JFGJB005820 for ; Thu, 9 Nov 2006 14:15:16 -0500 Received: from toothpaste.toronto.redhat.com (toothpaste.toronto.redhat.com [172.16.14.161]) by pobox.toronto.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id kA9JFFt5021032 for ; Thu, 9 Nov 2006 14:15:15 -0500 Subject: New JLabel test From: Tania Bento To: mauve-patches@sources.redhat.com Content-Type: multipart/mixed; boundary="=-PDj54JNMyHa0a66ZpIdZ" Date: Thu, 09 Nov 2006 19:15:00 -0000 Message-Id: <1163099715.29838.68.camel@toothpaste.toronto.redhat.com> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00729.txt.bz2 --=-PDj54JNMyHa0a66ZpIdZ Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 211 Hey, This patch adds some tests for javax.swing.JLabel's constructors. Cheers, Tania 2006-11-09 Tania Bento * gnu/testlet/javax/swing/JLabel/constructor.java: Added new tests. --=-PDj54JNMyHa0a66ZpIdZ Content-Disposition: attachment; filename=patch.diff Content-Type: text/x-patch; name=patch.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 9022 Index: gnu/testlet/javax/swing/JLabel/constructor.java =================================================================== RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JLabel/constructor.java,v retrieving revision 1.2 diff -u -r1.2 constructor.java --- gnu/testlet/javax/swing/JLabel/constructor.java 18 Oct 2005 20:55:55 -0000 1.2 +++ gnu/testlet/javax/swing/JLabel/constructor.java 9 Nov 2006 18:59:17 -0000 @@ -1,6 +1,7 @@ // Tags: JDK1.2 // Copyright (C) 2005 Roman Kennke +// 2006 Red Hat // This file is part of Mauve. @@ -26,7 +27,11 @@ import java.awt.Color; import java.awt.Font; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.SwingConstants; import javax.swing.UIManager; @@ -42,6 +47,18 @@ { public void test(TestHarness harness) { + test1(harness); + testConstructor1(harness); + testConstructor2(harness); + testConstructor3(harness); + testConstructor4(harness); + testConstructor5(harness); + testConstructor6(harness); + testHorizontalAlignment(harness); + } + + public void test1(TestHarness harness) + { try { UIManager.setLookAndFeel(new MetalLookAndFeel()); @@ -62,10 +79,278 @@ harness.check(l.getBackground(), Color.yellow); harness.check(l.getAlignmentX(), 0.0F, "alignmentX"); harness.check(l.getAlignmentY(), 0.5F, "alignmentY"); - harness.check(l.getHorizontalAlignment(), SwingConstants.LEADING, - "horizontalAlignment"); harness.check(l.getVerticalAlignment(), SwingConstants.CENTER, "verticalAlignment"); + harness.check(l.getDisabledIcon(), null); + harness.check(l.getDisplayedMnemonic(), KeyEvent.VK_UNDEFINED); + harness.check(l.getDisplayedMnemonicIndex(), -1); + harness.check(l.getHorizontalTextPosition(), JLabel.TRAILING); + harness.check(l.getVerticalTextPosition(), JLabel.CENTER); + harness.check(l.getLabelFor(), null); + harness.check(l.getIconTextGap(), 4); + } + + public void testConstructor1(TestHarness harness) + { + JLabel label = new JLabel(); + harness.check(label.getIcon(), null); + harness.check(label.getText(), ""); + } + + public void testConstructor2(TestHarness harness) + { + JLabel label = new JLabel(new ImageIcon()); + harness.check(label.getIcon() != null); + harness.check(label.getText(), null); + + label = new JLabel(new ImageIcon + (new BufferedImage(16, 16, BufferedImage.TYPE_INT_BGR))); + harness.check(label.getIcon() != null); + harness.check(label.getText(), null); + + label = new JLabel((Icon) null); + harness.check(label.getIcon() == null); + harness.check(label.getText(), null); + } + + public void testConstructor3(TestHarness harness) + { + JLabel label = new JLabel(new ImageIcon(), 2); + harness.check(label.getIcon() != null); + harness.check(label.getText(), null); + harness.check(label.getHorizontalAlignment(), SwingConstants.LEFT); + + label = new JLabel((Icon) null, 2); + harness.check(label.getIcon() == null); + harness.check(label.getText(), null); + harness.check(label.getHorizontalAlignment(), SwingConstants.LEFT); + + label = new JLabel(new ImageIcon(), 0); + harness.check(label.getIcon() != null); + harness.check(label.getText(), null); + harness.check(label.getHorizontalAlignment(), SwingConstants.CENTER); + + boolean fail = false; + try + { + label = new JLabel(new ImageIcon(), -1); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + } + + public void testConstructor4(TestHarness harness) + { + JLabel label = new JLabel("This is some text."); + harness.check(label.getIcon(), null); + harness.check(label.getText(), "This is some text."); + + label = new JLabel(""); + harness.check(label.getIcon(), null); + harness.check(label.getText(), ""); + + String text = null; + label = new JLabel(text); + harness.check(label.getIcon(), null); + harness.check(label.getText(), null); + } + + public void testConstructor5(TestHarness harness) + { + JLabel label = new JLabel("This is some text.", 11); + harness.check(label.getIcon() == null); + harness.check(label.getText(), "This is some text."); + harness.check(label.getHorizontalAlignment(), SwingConstants.TRAILING); + + label = new JLabel("", 11); + harness.check(label.getIcon() == null); + harness.check(label.getText(), ""); + harness.check(label.getHorizontalAlignment(), SwingConstants.TRAILING); + + String text = null; + label = new JLabel(text, 0); + harness.check(label.getIcon() == null); + harness.check(label.getText(), null); + harness.check(label.getHorizontalAlignment(), SwingConstants.CENTER); + + boolean fail = false; + try + { + label = new JLabel("This is some text.", -2); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + } + + public void testConstructor6(TestHarness harness) + { + JLabel label = new JLabel("This is some text.", new ImageIcon(), 0); + harness.check(label.getIcon() != null); + harness.check(label.getText(), "This is some text."); + harness.check(label.getHorizontalAlignment(), SwingConstants.CENTER); + + label = new JLabel("", (Icon) null, 10); + harness.check(label.getIcon() == null); + harness.check(label.getText(), ""); + harness.check(label.getHorizontalAlignment(), SwingConstants.LEADING); + + String text = null; + label = new JLabel(text, new ImageIcon(), 11); + harness.check(label.getIcon() != null); + harness.check(label.getText(), null); + harness.check(label.getHorizontalAlignment(), SwingConstants.TRAILING); + + boolean fail = false; + try + { + label = new JLabel("This is some text.", new ImageIcon(), -4); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + } + + public void testHorizontalAlignment(TestHarness harness) + { + JLabel label = null; + + boolean fail = false; + try + { + label = new JLabel("", -1); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + + boolean pass = false; + try + { + label = new JLabel("", 0); + pass = true; + } + catch (IllegalArgumentException e) + { + // Do nothing. + } + harness.check(pass); + harness.check(label.getHorizontalAlignment(), SwingConstants.CENTER); + + fail = false; + try + { + label = new JLabel("", 1); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + + pass = false; + try + { + label = new JLabel("", 2); + pass = true; + } + catch (IllegalArgumentException e) + { + // Do nothing. + } + harness.check(pass); + harness.check(label.getHorizontalAlignment(), SwingConstants.LEFT); + + fail = false; + try + { + label = new JLabel("", 3); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + + pass = false; + try + { + label = new JLabel("", 4); + pass = true; + } + catch (IllegalArgumentException e) + { + // Do nothing. + } + harness.check(pass); + harness.check(label.getHorizontalAlignment(), SwingConstants.RIGHT); + + fail = false; + try + { + label = new JLabel("", 5); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + + fail = false; + try + { + label = new JLabel("", 7); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); + + pass = false; + try + { + label = new JLabel("", 10); + pass = true; + } + catch (IllegalArgumentException e) + { + // Do nothing. + } + harness.check(pass); + harness.check(label.getHorizontalAlignment(), SwingConstants.LEADING); + + pass = false; + try + { + label = new JLabel("", 11); + pass = true; + } + catch (IllegalArgumentException e) + { + // Do nothing. + } + harness.check(pass); + harness.check(label.getHorizontalAlignment(), SwingConstants.TRAILING); + fail = false; + try + { + label = new JLabel("", 13); + } + catch (IllegalArgumentException e) + { + fail = true; + } + harness.check(fail); } } --=-PDj54JNMyHa0a66ZpIdZ--