JAL-2876 test threshold for Colour by Label
[jalview.git] / test / jalview / schemes / FeatureColourTest.java
index 7a72c15..ed7adb8 100644 (file)
@@ -340,4 +340,33 @@ public class FeatureColourTest
     fc = FeatureColour.parseJalviewFeatureColour(descriptor);
     assertTrue(fc.isGraduatedColour());
   }
+
+  @Test(groups = { "Functional" })
+  public void testGetColor_colourByLabel_withThreshold()
+  {
+    FeatureColour fc = new FeatureColour();
+    fc.setColourByLabel(true);
+    SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 1f,
+            null);
+    fc.setThreshold(0);
+    Color expected = ColorUtils.createColourFromName("desc");
+    assertEquals(expected, fc.getColor(sf));
+
+    // score (1f) is above threshold
+    fc.setAboveThreshold(true);
+    assertEquals(expected, fc.getColor(sf));
+
+    // score is not above threshold
+    fc.setThreshold(2f);
+    assertNull(fc.getColor(sf));
+
+    // score is not below threshold
+    fc.setThreshold(0f);
+    fc.setBelowThreshold(true);
+    assertNull(fc.getColor(sf));
+
+    // score is below threshold
+    fc.setThreshold(3f);
+    assertEquals(expected, fc.getColor(sf));
+  }
 }