X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fgui%2FFeatureSettingsTest.java;h=fd4bd4b7ef1fb14dece9f6453cb823aa049a0f3b;hb=f6dbc1f173fe70d90949cfb887d8cf35bb514e91;hp=29c3e56c461c48b39f2c1488489d715f7b32331f;hpb=e42eed3a0089a8a064560df4cf17a5021fd1e16a;p=jalview.git diff --git a/test/jalview/gui/FeatureSettingsTest.java b/test/jalview/gui/FeatureSettingsTest.java index 29c3e56..fd4bd4b 100644 --- a/test/jalview/gui/FeatureSettingsTest.java +++ b/test/jalview/gui/FeatureSettingsTest.java @@ -13,7 +13,9 @@ 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 jalview.viewmodel.seqfeatures.FeatureRendererModel; import java.awt.Color; import java.io.File; @@ -49,7 +51,7 @@ public class FeatureSettingsTest /* * set colour schemes for features */ - FeatureRenderer fr = af.getFeatureRenderer(); + FeatureRendererModel fr = af.getFeatureRenderer(); // type1: red fr.setColour("type1", new FeatureColour(Color.red)); @@ -188,4 +190,50 @@ public class FeatureSettingsTest }); seq.addSequenceFeature(sf); } + + /** + * @see FeatureColourTest#testGetDescription() + * @throws IOException + */ + @Test(groups = "Functional") + public void testGetColorTooltip() throws IOException + { + assertNull(FeatureSettings.getColorTooltip(null, false)); + + /* + * simple colour + */ + FeatureColourI fc = new FeatureColour(Color.black); + String simpleTooltip = "Click to edit, right-click for menu"; + assertEquals(FeatureSettings.getColorTooltip(fc, true), simpleTooltip); + assertNull(FeatureSettings.getColorTooltip(fc, false)); + + /* + * graduated colour tooltip includes description of colour + */ + fc.setColourByLabel(true); + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Label"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), + "By Label
" + simpleTooltip + "
"); + + /* + * 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, false), + "By Score (< 4.0)"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), + "By Score (< 4.0)
" + simpleTooltip + + "
"); + + fc.setAboveThreshold(true); + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Score (> 4.0)"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), + "By Score (> 4.0)
" + simpleTooltip + + "
"); + } }