Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 10:11:34 GMT
  2. Package jalview.renderer

File ScaleRendererTest.java

 

Code metrics

0
39
1
1
100
59
1
0.03
39
1
1

Classes

Class Line # Actions
ScaleRendererTest 38 39 1
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.renderer;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertFalse;
25    import static org.testng.Assert.assertNull;
26    import static org.testng.Assert.assertTrue;
27   
28    import jalview.gui.AlignFrame;
29    import jalview.gui.AlignViewport;
30    import jalview.io.DataSourceType;
31    import jalview.io.FileLoader;
32    import jalview.renderer.ScaleRenderer.ScaleMark;
33   
34    import java.util.List;
35   
36    import org.testng.annotations.Test;
37   
 
38    public class ScaleRendererTest
39    {
 
40  1 toggle @Test(groups = "Functional")
41    public void testCalculateMarks()
42    {
43  1 String data = ">Seq/20-45\nABCDEFGHIJKLMNOPQRSTUVWXYS\n";
44  1 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(data,
45    DataSourceType.PASTE);
46  1 AlignViewport av = af.getViewport();
47   
48    /*
49    * scale has minor ticks at 5, 15, 25, major at 10 and 20
50    * (these are base 1, ScaleMark holds base 0 values)
51    */
52  1 List<ScaleMark> marks = new ScaleRenderer().calculateMarks(av, 0, 25);
53  1 assertEquals(marks.size(), 5);
54   
55  1 assertFalse(marks.get(0).major);
56  1 assertEquals(marks.get(0).column, 4);
57  1 assertNull(marks.get(0).text);
58   
59  1 assertTrue(marks.get(1).major);
60  1 assertEquals(marks.get(1).column, 9);
61  1 assertEquals(marks.get(1).text, "10");
62   
63  1 assertFalse(marks.get(2).major);
64  1 assertEquals(marks.get(2).column, 14);
65  1 assertNull(marks.get(2).text);
66   
67  1 assertTrue(marks.get(3).major);
68  1 assertEquals(marks.get(3).column, 19);
69  1 assertEquals(marks.get(3).text, "20");
70   
71  1 assertFalse(marks.get(4).major);
72  1 assertEquals(marks.get(4).column, 24);
73  1 assertNull(marks.get(4).text);
74   
75    /*
76    * now hide columns 9-11 and 18-20 (base 1)
77    * scale marks are now in the same columns as before, but
78    * with column numbering adjusted for hidden columns
79    */
80  1 av.hideColumns(8, 10);
81  1 av.hideColumns(17, 19);
82  1 marks = new ScaleRenderer().calculateMarks(av, 0, 25);
83  1 assertEquals(marks.size(), 5);
84  1 assertFalse(marks.get(0).major);
85  1 assertEquals(marks.get(0).column, 4);
86  1 assertNull(marks.get(0).text);
87  1 assertTrue(marks.get(1).major);
88  1 assertEquals(marks.get(1).column, 9);
89  1 assertEquals(marks.get(1).text, "13"); // +3 hidden columns
90  1 assertFalse(marks.get(2).major);
91  1 assertEquals(marks.get(2).column, 14);
92  1 assertNull(marks.get(2).text);
93  1 assertTrue(marks.get(3).major);
94  1 assertEquals(marks.get(3).column, 19);
95  1 assertEquals(marks.get(3).text, "26"); // +6 hidden columns
96  1 assertFalse(marks.get(4).major);
97  1 assertEquals(marks.get(4).column, 24);
98  1 assertNull(marks.get(4).text);
99    }
100    }