JAL-3423 testNG fix for revised tooltip html format
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 26 Aug 2019 18:42:31 +0000 (13:42 -0500)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 26 Aug 2019 18:42:31 +0000 (13:42 -0500)
src/jalview/gui/JvSwingUtils.java
test/jalview/gui/JvSwingUtilsTest.java
test/jalview/gui/PopupMenuTest.java

index c1c8c82..b25b2c8 100644 (file)
@@ -56,6 +56,8 @@ import javax.swing.border.TitledBorder;
  */
 public final class JvSwingUtils
 {
+  public static final String HTML_PREFIX = "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">";
+
   /**
    * wrap a bare html safe string to around 60 characters per line using a CSS
    * style class specifying word-wrap and break-word
@@ -97,7 +99,7 @@ public final class JvSwingUtils
     }
     // BH 2018,2019
     return (enclose
-            ? "<html><div style=\"width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;\">"
+            ? HTML_PREFIX
             + ttext
                     + "</div></html>"
             : ttext);
index 61c5c9b..5a8fba7 100644 (file)
@@ -113,9 +113,8 @@ public class JvSwingUtilsTest
   public void testWrapTooltip_longText()
   {
     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>",
+    String expected = JvSwingUtils.HTML_PREFIX + tip + " </div></html>";
+    assertEquals(expected,
             JvSwingUtils.wrapTooltip(true, tip));
     assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip));
   }
index e42c34c..e9b6e54 100644 (file)
@@ -199,9 +199,8 @@ public class PopupMenuTest
     // String expected = "<html><style> p.ttip {width: 350; text-align: justify;
     // word-wrap: break-word;}</style><p class=\"ttip\">"
     // + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
-    String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
-            + "<div class=\"ttip\">" + s
-            + "<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>";
+    String expected = JvSwingUtils.HTML_PREFIX + s
+            + "<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
     assertEquals(expected, menu.getToolTipText());
   }
 
@@ -226,8 +225,8 @@ public class PopupMenuTest
     // String expected = "<html><style> p.ttip {width: 350; text-align: justify;
     // word-wrap: break-word;}</style><p class=\"ttip\">"
     // + s + "<br/>Jmol/secondary structure<br/>PDB/Temp</p></html>";
-    String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>"
-            + "<div class=\"ttip\">Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>";
+    String expected = JvSwingUtils.HTML_PREFIX
+            + "Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp</div></html>";
     assertEquals(expected, menu.getToolTipText());
   }