Clover icon

Coverage Report

  1. Project Clover database Fri Dec 6 2024 13:47:14 GMT
  2. Package jalview.gui

File SequenceRendererTest.java

 

Code metrics

0
19
3
1
90
54
3
0.16
6.33
3
1

Classes

Class Line # Actions
SequenceRendererTest 41 19 3
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.gui;
22   
23    import static org.testng.Assert.assertEquals;
24   
25    import jalview.bin.Jalview;
26    import jalview.datamodel.Alignment;
27    import jalview.datamodel.AlignmentI;
28    import jalview.datamodel.Sequence;
29    import jalview.datamodel.SequenceGroup;
30    import jalview.datamodel.SequenceI;
31    import jalview.renderer.ResidueShader;
32    import jalview.renderer.ResidueShaderI;
33    import jalview.schemes.ZappoColourScheme;
34   
35    import java.awt.Color;
36   
37    import org.testng.annotations.BeforeClass;
38    import org.testng.annotations.BeforeMethod;
39    import org.testng.annotations.Test;
40   
 
41    public class SequenceRendererTest
42    {
43    AlignmentI al;
44   
45    AlignViewport av;
46   
47    SequenceI seq1;
48   
 
49  1 toggle @BeforeClass(alwaysRun = true)
50    public static void setUpBeforeClass() throws Exception
51    {
52  1 Jalview.main(
53    new String[]
54    { "--nonews", "--props", "test/jalview/testProps.jvprops" });
55    }
56   
 
57  1 toggle @BeforeMethod(alwaysRun = true)
58    public void setUp()
59    {
60  1 seq1 = new Sequence("Seq1", "ABCEEEABCABC");
61  1 SequenceI seq2 = new Sequence("Seq2", "ABCABCABCABC");
62  1 SequenceI seq3 = new Sequence("Seq3", "ABCABCABCABC");
63  1 SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3 };
64  1 al = new Alignment(seqs);
65  1 al.setDataset(null);
66  1 av = new AlignViewport(al);
67    }
68   
 
69  1 toggle @Test(groups = "Functional")
70    public void testGetResidueColour_WithGroup()
71    {
72  1 SequenceRenderer sr = new SequenceRenderer(av);
73  1 SequenceGroup sg = new SequenceGroup();
74  1 sg.addSequence(seq1, false);
75  1 sg.setStartRes(3);
76  1 sg.setEndRes(5);
77   
78  1 ResidueShaderI rs = new ResidueShader();
79  1 rs.setColourScheme(new ZappoColourScheme());
80  1 sg.setGroupColourScheme(rs);
81   
82  1 av.getAlignment().addGroup(sg);
83   
84    // outside group residues are white
85  1 assertEquals(Color.white, sr.getResidueColour(seq1, 1, null));
86   
87    // within group use Zappo scheme - E = red
88  1 assertEquals(Color.red, sr.getResidueColour(seq1, 3, null));
89    }
90    }