JAL-2527 Unit test for group colouring
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 1 Sep 2017 06:22:55 +0000 (07:22 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 1 Sep 2017 06:22:55 +0000 (07:22 +0100)
test/jalview/renderer/OverviewResColourFinderTest.java

index d7ce4a8..3d4ca6f 100644 (file)
@@ -26,14 +26,17 @@ import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignViewport;
 import jalview.gui.JvOptionPane;
 import jalview.gui.Preferences;
+import jalview.schemes.ColourSchemeI;
 import jalview.schemes.UserColourScheme;
 import jalview.schemes.ZappoColourScheme;
 
 import java.awt.Color;
+import java.util.ArrayList;
 
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -46,6 +49,7 @@ public class OverviewResColourFinderTest
   {
     JvOptionPane.setInteractiveMode(false);
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
   }
 
   @Test(groups = { "Functional" })
@@ -162,10 +166,53 @@ public class OverviewResColourFinderTest
   }
 
   @Test
-  public void testGetBoxColour()
+  public void testGetResidueBoxColour_group()
   {
-    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF");
+    AlignmentI al = new Alignment(new SequenceI[] { seq });
+    
+    ColourSchemeI cs = new ZappoColourScheme();
+    ArrayList<SequenceI> seqlist = new ArrayList<>();
+    seqlist.add(seq);
+    SequenceGroup sg = new SequenceGroup(seqlist, "testgroup", cs, true,
+            true, true, 5, 9);
+    al.addGroup(sg);
+    SequenceGroup[] groups = new SequenceGroup[1];
+    groups[0] = sg;
+    
+    final AlignViewport av = new AlignViewport(al);
+    ResidueColourFinder rcf = new OverviewResColourFinder();
+    
+    // G in group specified as magenta in Zappo
+    assertEquals(Color.magenta, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 7, null));
+
+    // Residue outside group coloured white
+    assertEquals(Color.white, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 0, null));
+
+    // Gap outside group coloured lightgray
+    assertEquals(Color.lightGray, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 2, null));
 
+    rcf = new OverviewResColourFinder(true, Color.blue, Color.red);
+  
+    // G in group specified as magenta in Zappo
+    assertEquals(Color.magenta, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 7, null));
+
+    // Residue outside group coloured lightgray
+    assertEquals(Color.lightGray, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 0, null));
+
+    // Gap outside group coloured white
+    assertEquals(Color.white, rcf.getResidueColour(false,
+            av.getResidueShading(), groups, seq, 2, null));
+  }
+
+  @Test
+  public void testGetBoxColour()
+  {
     SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); // FER1_MAIZE... + a
                                                             // gap
     AlignmentI al = new Alignment(new SequenceI[] { seq });