From 32c56f877253fa8917d4f4640ed65d6e63376dac Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 5 Sep 2017 14:30:08 +0100 Subject: [PATCH] JAL-2722 unit test --- test/jalview/gui/SequenceRendererTest.java | 89 ++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 test/jalview/gui/SequenceRendererTest.java diff --git a/test/jalview/gui/SequenceRendererTest.java b/test/jalview/gui/SequenceRendererTest.java new file mode 100644 index 0000000..359377a --- /dev/null +++ b/test/jalview/gui/SequenceRendererTest.java @@ -0,0 +1,89 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ +package jalview.gui; + +import static org.testng.Assert.assertEquals; + +import jalview.bin.Jalview; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.renderer.ResidueShader; +import jalview.renderer.ResidueShaderI; +import jalview.schemes.ZappoColourScheme; + +import java.awt.Color; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class SequenceRendererTest +{ + AlignmentI al; + AlignViewport av; + + SequenceI seq1; + + @BeforeClass(alwaysRun = true) + public static void setUpBeforeClass() throws Exception + { + Jalview.main( + new String[] + { "-nonews", "-props", "test/jalview/testProps.jvprops" }); + } + + @BeforeMethod(alwaysRun = true) + public void setUp() + { + seq1 = new Sequence("Seq1", "ABCEEEABCABC"); + SequenceI seq2 = new Sequence("Seq2", "ABCABCABCABC"); + SequenceI seq3 = new Sequence("Seq3", "ABCABCABCABC"); + SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3 }; + al = new Alignment(seqs); + al.setDataset(null); + av = new AlignViewport(al); + } + + @Test(groups = "Functional") + public void testGetResidueColour_WithGroup() + { + SequenceRenderer sr = new SequenceRenderer(av); + SequenceGroup sg = new SequenceGroup(); + sg.addSequence(seq1, false); + sg.setStartRes(3); + sg.setEndRes(5); + + ResidueShaderI rs = new ResidueShader(); + rs.setColourScheme(new ZappoColourScheme()); + sg.setGroupColourScheme(rs); + + av.getAlignment().addGroup(sg); + + // outside group residues are white + assertEquals(Color.white, sr.getResidueColour(seq1, 1, null)); + + // within group use Zappo scheme - E = red + assertEquals(Color.red, sr.getResidueColour(seq1, 3, null)); + } +} -- 1.7.10.2