From 92bc328cd9eeb2218721fa6caa20f873d5ac5cf3 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 23 Jul 2018 11:19:54 +0100 Subject: [PATCH] JAL-3049 corrected code and unit tests --- .classpath | 1 + src/jalview/gui/FeatureSettings.java | 4 ++-- test/jalview/gui/FeatureSettingsTest.java | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.classpath b/.classpath index fe6fbcc..aba05fb 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,7 @@ + diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 0e18d91..37258e4 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -1371,9 +1371,9 @@ public class FeatureSettings extends JPanel { return null; } - if (fcol.isSimpleColour() && withHint) + if (fcol.isSimpleColour()) { - return BASE_TOOLTIP; + return withHint ? BASE_TOOLTIP : null; } String description = fcol.getDescription(); description = description.replaceAll("<", "<"); diff --git a/test/jalview/gui/FeatureSettingsTest.java b/test/jalview/gui/FeatureSettingsTest.java index bf905fb..321adf6 100644 --- a/test/jalview/gui/FeatureSettingsTest.java +++ b/test/jalview/gui/FeatureSettingsTest.java @@ -197,20 +197,23 @@ public class FeatureSettingsTest @Test(groups = "Functional") public void testGetColorTooltip() throws IOException { - assertNull(FeatureSettings.getColorTooltip(null,false)); + 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,false), simpleTooltip); + 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), + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Label"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), "By Label
" + simpleTooltip + "
"); /* @@ -219,11 +222,16 @@ public class FeatureSettingsTest fc = new FeatureColour(Color.red, Color.blue, 2f, 10f); fc.setBelowThreshold(true); fc.setThreshold(4f); - assertEquals(FeatureSettings.getColorTooltip(fc,false), + 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), + assertEquals(FeatureSettings.getColorTooltip(fc, false), + "By Score (> 4.0)"); + assertEquals(FeatureSettings.getColorTooltip(fc, true), "By Score (> 4.0)
" + simpleTooltip + "
"); } -- 1.7.10.2