Merge remote-tracking branch 'origin/bug/JAL-3049colourCellTooltip' into
[jalview.git] / test / jalview / gui / FeatureSettingsTest.java
index 29c3e56..5219bda 100644 (file)
@@ -13,6 +13,7 @@ import jalview.datamodel.features.FeatureMatcherSetI;
 import jalview.io.DataSourceType;
 import jalview.io.FileLoader;
 import jalview.schemes.FeatureColour;
+import jalview.schemes.FeatureColourTest;
 import jalview.util.matcher.Condition;
 
 import java.awt.Color;
@@ -188,4 +189,42 @@ public class FeatureSettingsTest
     });
     seq.addSequenceFeature(sf);
   }
+
+  /**
+   * @see FeatureColourTest#testGetDescription()
+   * @throws IOException
+   */
+  @Test(groups = "Functional")
+  public void testGetColorTooltip() throws IOException
+  {
+    assertNull(FeatureSettings.getColorTooltip(null));
+
+    /*
+     * simple colour
+     */
+    FeatureColourI fc = new FeatureColour(Color.black);
+    String simpleTooltip = "Click to edit, right-click for menu";
+    assertEquals(FeatureSettings.getColorTooltip(fc), simpleTooltip);
+
+    /*
+     * graduated colour tooltip includes description of colour
+     */
+    fc.setColourByLabel(true);
+    assertEquals(FeatureSettings.getColorTooltip(fc),
+            "<html>By Label<br>" + simpleTooltip + "</br></html>");
+
+    /*
+     * graduated colour with threshold is html-encoded
+     */
+    fc = new FeatureColour(null, Color.red, Color.blue, null, 2f, 10f);
+    fc.setBelowThreshold(true);
+    fc.setThreshold(4f);
+    assertEquals(FeatureSettings.getColorTooltip(fc),
+            "<html>By Score (&lt; 4.0)<br>" + simpleTooltip
+                    + "</br></html>");
+    fc.setAboveThreshold(true);
+    assertEquals(FeatureSettings.getColorTooltip(fc),
+            "<html>By Score (&gt; 4.0)<br>" + simpleTooltip
+                    + "</br></html>");
+  }
 }