*/
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;
* 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);
}
/**
public void testWrapTooltip_shortText()
{
String tip = "hello world";
- assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip));
- assertEquals("<html>" + tip + "</html>",
- JvSwingUtils.wrapTooltip(true, tip));
+ assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip,
+ "Text was not kept the same");
+ assertEquals(JvSwingUtils.wrapTooltip(true, tip),
+ "<html>" + tip + "</html>",
+ "Text was not simply wrapped in HTML");
tip = "012345678901234567890123456789012345678901234567890123456789"; // 60
- assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip));
- assertEquals("<html>" + tip + "</html>",
- JvSwingUtils.wrapTooltip(true, tip));
+ assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip,
+ "Text was not kept the same");
+ assertEquals(JvSwingUtils.wrapTooltip(true, tip),
+ "<html>" + tip + "</html>",
+ "Text was not simply wrapped in HTML");
tip = "0123456789012345678901234567890123456789012345678901234567890"; // 61
- assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip)));
- assertFalse(("<html>" + tip + "</html>")
- .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(
+ ("<html>" + tip + "</html>")
+ .equals(JvSwingUtils.wrapTooltip(true, tip)),
+ "Text is only wrapped in HTML tags when it should be wrapped over lines");
}
/**
public void testWrapTooltip_multilineShortText()
{
String tip = "Now is the winter of our discontent<br>Made glorious summer by this sun of York";
- assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip));
- assertEquals("<html>" + tip + "</html>",
- JvSwingUtils.wrapTooltip(true, tip));
+ assertEquals(JvSwingUtils.wrapTooltip(false, tip), tip,
+ "Text was not kept the same");
+ assertEquals(JvSwingUtils.wrapTooltip(true, tip),
+ "<html>" + tip + "</html>",
+ "Text was not simply wrapped in HTML");
}
/**
{
String tip = "Now is the winter of our discontent made glorious summer by this sun of York";
String expected = "<style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
- + "<div class=\"ttip\">" + tip + " </div>";
- assertEquals("<html>" + expected + "</html>",
- JvSwingUtils.wrapTooltip(true, tip));
- assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip));
+ + "<div class=\"ttip\">" + tip + "</div>";
+ assertEquals(JvSwingUtils.wrapTooltip(true, tip),
+ "<html>" + expected + "</html>",
+ "Text was not wrapped in HTML with styling and div");
+ assertEquals(JvSwingUtils.wrapTooltip(false, tip), expected,
+ "Text was not just styled with div");
}
}