From: kiramt Date: Fri, 1 Sep 2017 06:22:55 +0000 (+0100) Subject: JAL-2527 Unit test for group colouring X-Git-Tag: Release_2_10_3b1~142^2~2^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dbd4cbab0473d8ecac0432cc9ce74a552c7409d1;p=jalview.git JAL-2527 Unit test for group colouring --- diff --git a/test/jalview/renderer/OverviewResColourFinderTest.java b/test/jalview/renderer/OverviewResColourFinderTest.java index d7ce4a8..3d4ca6f 100644 --- a/test/jalview/renderer/OverviewResColourFinderTest.java +++ b/test/jalview/renderer/OverviewResColourFinderTest.java @@ -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 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 });