From: Roman Kennke <roman.kennke@aicas.com>
To: mauve-patches <mauve-patches@sources.redhat.com>
Subject: FYI: fixed TitledBorder tests
Date: Tue, 28 Nov 2006 13:14:00 -0000 [thread overview]
Message-ID: <1164719304.6844.8.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 706 bytes --]
In the TitledBorder tests I believe we had a slight mistake. We were
treating the font height to be equal to ascent+descent, which is not
necessarily the case. In our case we really want to check for ascent
+descent except for one case (BELOW_BOTTOM) where we have to include the
line distance. The problem here is that line distance is really 0 for
many fonts, so this is a corner case that is hard to test. But I'm quite
certain that the tests are now correct and they PASS now both with Sun
and Classpath.
2006-11-28 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/border/TitledBorder/getBorderInsets.java:
Fixed test for differentiation between font ascent+descent and
height.
/Roman
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 2604 bytes --]
Index: gnu/testlet/javax/swing/border/TitledBorder/getBorderInsets.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/border/TitledBorder/getBorderInsets.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 getBorderInsets.java
--- gnu/testlet/javax/swing/border/TitledBorder/getBorderInsets.java 10 Oct 2005 08:06:08 -0000 1.1
+++ gnu/testlet/javax/swing/border/TitledBorder/getBorderInsets.java 28 Nov 2006 13:05:35 -0000
@@ -51,53 +51,53 @@
* Runs the test using the specified harness.
*
* @param harness the test harness (<code>null</code> not permitted).
*/
public void test1(TestHarness harness)
{
harness.checkPoint("(Component)");
JPanel p = new JPanel();
TitledBorder b = new TitledBorder(new EmptyBorder(1, 2, 3, 4));
p.setBorder(b);
p.setFont(b.getTitleFont());
Insets insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5, 6, 7, 8));
FontMetrics fm = p.getFontMetrics(p.getFont());
- int fontHeight = fm.getHeight();
+ int fontHeight = fm.getAscent() + fm.getDescent();
b.setTitle("XYZ");
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5 + fontHeight, 6, 7, 8));
b.setTitleFont(new Font("Dialog", Font.PLAIN, 24));
p.setFont(b.getTitleFont());
fm = p.getFontMetrics(p.getFont());
- fontHeight = fm.getHeight();
+ fontHeight = fm.getAscent() + fm.getDescent();
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5 + fontHeight, 6, 7, 8));
b.setTitlePosition(TitledBorder.ABOVE_TOP);
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5 + fontHeight + 2, 6, 7, 8));
b.setTitlePosition(TitledBorder.TOP);
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5 + fontHeight, 6, 7, 8));
b.setTitlePosition(TitledBorder.BELOW_TOP);
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5 + fontHeight + 2, 6, 7, 8));
b.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5, 6, 7 + fontHeight + 2, 8));
b.setTitlePosition(TitledBorder.BOTTOM);
insets = b.getBorderInsets(p);
harness.check(insets, new Insets(5, 6, 7 + fontHeight, 8));
b.setTitlePosition(TitledBorder.BELOW_BOTTOM);
insets = b.getBorderInsets(p);
- harness.check(insets, new Insets(5, 6, 7 + fontHeight, 8));
+ harness.check(insets, new Insets(5, 6, 7 + fm.getHeight(), 8));
}
}
reply other threads:[~2006-11-28 13:14 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=1164719304.6844.8.camel@localhost \
--to=roman.kennke@aicas.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).