Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 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
0.00%
 

Contributing tests

No tests hitting this source file were found.

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  0 toggle @Test(groups = "Functional")
41    public void testCalculateMarks()
42    {
43  0 String data = ">Seq/20-45\nABCDEFGHIJKLMNOPQRSTUVWXYS\n";
44  0 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(data,
45    DataSourceType.PASTE);
46  0 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  0 List<ScaleMark> marks = new ScaleRenderer().calculateMarks(av, 0, 25);
53  0 assertEquals(marks.size(), 5);
54   
55  0 assertFalse(marks.get(0).major);
56  0 assertEquals(marks.get(0).column, 4);
57  0 assertNull(marks.get(0).text);
58   
59  0 assertTrue(marks.get(1).major);
60  0 assertEquals(marks.get(1).column, 9);
61  0 assertEquals(marks.get(1).text, "10");
62   
63  0 assertFalse(marks.get(2).major);
64  0 assertEquals(marks.get(2).column, 14);
65  0 assertNull(marks.get(2).text);
66   
67  0 assertTrue(marks.get(3).major);
68  0 assertEquals(marks.get(3).column, 19);
69  0 assertEquals(marks.get(3).text, "20");
70   
71  0 assertFalse(marks.get(4).major);
72  0 assertEquals(marks.get(4).column, 24);
73  0 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  0 av.hideColumns(8, 10);
81  0 av.hideColumns(17, 19);
82  0 marks = new ScaleRenderer().calculateMarks(av, 0, 25);
83  0 assertEquals(marks.size(), 5);
84  0 assertFalse(marks.get(0).major);
85  0 assertEquals(marks.get(0).column, 4);
86  0 assertNull(marks.get(0).text);
87  0 assertTrue(marks.get(1).major);
88  0 assertEquals(marks.get(1).column, 9);
89  0 assertEquals(marks.get(1).text, "13"); // +3 hidden columns
90  0 assertFalse(marks.get(2).major);
91  0 assertEquals(marks.get(2).column, 14);
92  0 assertNull(marks.get(2).text);
93  0 assertTrue(marks.get(3).major);
94  0 assertEquals(marks.get(3).column, 19);
95  0 assertEquals(marks.get(3).text, "26"); // +6 hidden columns
96  0 assertFalse(marks.get(4).major);
97  0 assertEquals(marks.get(4).column, 24);
98  0 assertNull(marks.get(4).text);
99    }
100    }