Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.gui

File SequenceRendererTest.java

 

Code metrics

0
19
3
1
89
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    AlignViewport av;
45   
46    SequenceI seq1;
47   
 
48  1 toggle @BeforeClass(alwaysRun = true)
49    public static void setUpBeforeClass() throws Exception
50    {
51  1 Jalview.main(
52    new String[]
53    { "-nonews", "-props", "test/jalview/testProps.jvprops" });
54    }
55   
 
56  1 toggle @BeforeMethod(alwaysRun = true)
57    public void setUp()
58    {
59  1 seq1 = new Sequence("Seq1", "ABCEEEABCABC");
60  1 SequenceI seq2 = new Sequence("Seq2", "ABCABCABCABC");
61  1 SequenceI seq3 = new Sequence("Seq3", "ABCABCABCABC");
62  1 SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3 };
63  1 al = new Alignment(seqs);
64  1 al.setDataset(null);
65  1 av = new AlignViewport(al);
66    }
67   
 
68  1 toggle @Test(groups = "Functional")
69    public void testGetResidueColour_WithGroup()
70    {
71  1 SequenceRenderer sr = new SequenceRenderer(av);
72  1 SequenceGroup sg = new SequenceGroup();
73  1 sg.addSequence(seq1, false);
74  1 sg.setStartRes(3);
75  1 sg.setEndRes(5);
76   
77  1 ResidueShaderI rs = new ResidueShader();
78  1 rs.setColourScheme(new ZappoColourScheme());
79  1 sg.setGroupColourScheme(rs);
80   
81  1 av.getAlignment().addGroup(sg);
82   
83    // outside group residues are white
84  1 assertEquals(Color.white, sr.getResidueColour(seq1, 1, null));
85   
86    // within group use Zappo scheme - E = red
87  1 assertEquals(Color.red, sr.getResidueColour(seq1, 3, null));
88    }
89    }