From: Tania Bento <tbento@redhat.com>
To: mauve-patches@sources.redhat.com
Subject: New JLabel test
Date: Thu, 09 Nov 2006 19:15:00 -0000 [thread overview]
Message-ID: <1163099715.29838.68.camel@toothpaste.toronto.redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 211 bytes --]
Hey,
This patch adds some tests for javax.swing.JLabel's constructors.
Cheers,
Tania
2006-11-09 Tania Bento <tbento@redhat.com>
* gnu/testlet/javax/swing/JLabel/constructor.java: Added new
tests.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 9022 bytes --]
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 <kennke@aicas.com>
+// 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);
}
}
reply other threads:[~2006-11-09 19:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1163099715.29838.68.camel@toothpaste.toronto.redhat.com \
--to=tbento@redhat.com \
--cc=mauve-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).