From ee1603d97a5f00f6e5d0ec26ebe9132438501c84 Mon Sep 17 00:00:00 2001 From: James Procter Date: Sun, 1 Oct 2023 17:06:47 +0100 Subject: [PATCH] JAL-244 attempt to fix broken test - still needs to be fixed! --- test/jalview/gui/AlignmentPanelTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/jalview/gui/AlignmentPanelTest.java b/test/jalview/gui/AlignmentPanelTest.java index 37b8582..0e2bf54 100644 --- a/test/jalview/gui/AlignmentPanelTest.java +++ b/test/jalview/gui/AlignmentPanelTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; +import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; @@ -219,13 +220,20 @@ public class AlignmentPanelTest av.setShowAnnotation(false); av.setIdWidth(18); + FontMetrics fmfor = new Container() + .getFontMetrics(new Font(af.viewport.font.getName(), + Font.ITALIC, af.viewport.font.getSize())); + /* * note 4 pixels 'padding' are added to the longest seq name/annotation label */ Dimension d = af.alignPanel.calculateIdWidth(2000); + // Assumption ID_WIDTH_PADDING == 4 + int expwidth = 3 + fmfor.stringWidth("Conservation"); + assertEquals(d.width, 166); // 4 + pixel width of "Q93Z60_ARATH/1-118" assertEquals(d.height, 12); // fixed value (not used?) - assertEquals(av.getIdWidth(), 18); // not changed by this method + assertEquals(av.getIdWidth(), expwidth); // not changed by this method /* * make the longest sequence name longer @@ -244,11 +252,10 @@ public class AlignmentPanelTest */ AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[0]; aa.label = "THIS IS A VERY LONG LABEL INDEED"; - FontMetrics fmfor = af.alignPanel - .getFontMetrics(af.alignPanel.getAlabels().getFont()); - // Assumption ID_WIDTH_PADDING == 4 - int expwidth = 4 + fmfor.stringWidth(aa.label); d = af.alignPanel.calculateIdWidth(2000); + // Assumption ID_WIDTH_PADDING == 3 + expwidth = 3 + fmfor.stringWidth(aa.label); + assertEquals(d.width, expwidth); // 228 == ID_WIDTH_PADDING + pixel width of // "THIS IS A VERY LONG LABEL INDEED" assertEquals(d.height, 12); -- 1.7.10.2