From: Ben Soares Date: Mon, 13 Nov 2023 19:02:34 +0000 (+0000) Subject: JAL-4059 redo these tests as TestNG asserts to add message X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c41f0715fd4f3c345c048a9ca558ee3e3364ffcd;p=jalview.git JAL-4059 redo these tests as TestNG asserts to add message --- diff --git a/test/jalview/gui/JvSwingUtilsTest.java b/test/jalview/gui/JvSwingUtilsTest.java index e6f4041..07b9738 100644 --- a/test/jalview/gui/JvSwingUtilsTest.java +++ b/test/jalview/gui/JvSwingUtilsTest.java @@ -20,8 +20,8 @@ */ package jalview.gui; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import javax.swing.JScrollBar; @@ -65,7 +65,7 @@ public class JvSwingUtilsTest * operating range is 25 - 425 (400 wide) so value 125 is a quarter of this * range */ - assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f)); + assertEquals(JvSwingUtils.getScrollValueForProportion(sb, 0.25f), 125); } /** @@ -76,19 +76,26 @@ public class JvSwingUtilsTest public void testWrapTooltip_shortText() { String tip = "hello world"; - assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); - assertEquals("" + tip + "", - JvSwingUtils.wrapTooltip(true, tip)); + assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip, + "Text was not kept the same"); + assertEquals(JvSwingUtils.wrapTooltip(true, tip), + "" + tip + "", + "Text was not simply wrapped in HTML"); tip = "012345678901234567890123456789012345678901234567890123456789"; // 60 - assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); - assertEquals("" + tip + "", - JvSwingUtils.wrapTooltip(true, tip)); + assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip, + "Text was not kept the same"); + assertEquals(JvSwingUtils.wrapTooltip(true, tip), + "" + tip + "", + "Text was not simply wrapped in HTML"); tip = "0123456789012345678901234567890123456789012345678901234567890"; // 61 - assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip))); - assertFalse(("" + tip + "") - .equals(JvSwingUtils.wrapTooltip(true, tip))); + assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip)), + "Text is the same when it should be shortened/wrapped over lines"); + assertFalse( + ("" + tip + "") + .equals(JvSwingUtils.wrapTooltip(true, tip)), + "Text is only wrapped in HTML tags when it should be wrapped over lines"); } /** @@ -100,9 +107,11 @@ public class JvSwingUtilsTest public void testWrapTooltip_multilineShortText() { String tip = "Now is the winter of our discontent
Made glorious summer by this sun of York"; - assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); - assertEquals("" + tip + "", - JvSwingUtils.wrapTooltip(true, tip)); + assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip, + "Text was not kept the same"); + assertEquals(JvSwingUtils.wrapTooltip(true, tip), + "" + tip + "", + "Text was not simply wrapped in HTML"); } /** @@ -114,9 +123,11 @@ public class JvSwingUtilsTest { String tip = "Now is the winter of our discontent made glorious summer by this sun of York"; String expected = "" - + "
" + tip + "
"; - assertEquals("" + expected + "", - JvSwingUtils.wrapTooltip(true, tip)); - assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip)); + + "
" + tip + "
"; + assertEquals(JvSwingUtils.wrapTooltip(true, tip), + "" + expected + "", + "Text was not wrapped in HTML with styling and div"); + assertEquals(JvSwingUtils.wrapTooltip(false, tip), expected, + "Text was not just styled with div"); } }