This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: fixed TitledBorder tests


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

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));
   }
 
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]