JAL-3746 apply copyright to tests
[jalview.git] / test / jalview / gui / AnnotationPanelTest.java
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.datamodel.AlignmentAnnotation;
26
27 import org.testng.annotations.Test;
28
29 public class AnnotationPanelTest
30 {
31
32   @Test(groups = "Functional")
33   public void testGetRowIndex()
34   {
35     assertEquals(AnnotationPanel.getRowIndex(0, null), -1);
36
37     AlignmentAnnotation[] anns = new AlignmentAnnotation[] {};
38     assertEquals(AnnotationPanel.getRowIndex(0, anns), -1);
39
40     AlignmentAnnotation ann1 = new AlignmentAnnotation(null, null, null);
41     AlignmentAnnotation ann2 = new AlignmentAnnotation(null, null, null);
42     AlignmentAnnotation ann3 = new AlignmentAnnotation(null, null, null);
43     ann1.visible = true;
44     ann2.visible = true;
45     ann3.visible = true;
46     ann1.height = 10;
47     ann2.height = 20;
48     ann3.height = 30;
49     anns = new AlignmentAnnotation[] { ann1, ann2, ann3 };
50
51     assertEquals(AnnotationPanel.getRowIndex(0, anns), 0);
52     assertEquals(AnnotationPanel.getRowIndex(9, anns), 0);
53     assertEquals(AnnotationPanel.getRowIndex(10, anns), 1);
54     assertEquals(AnnotationPanel.getRowIndex(29, anns), 1);
55     assertEquals(AnnotationPanel.getRowIndex(30, anns), 2);
56     assertEquals(AnnotationPanel.getRowIndex(59, anns), 2);
57     assertEquals(AnnotationPanel.getRowIndex(60, anns), -1);
58
59     ann2.visible = false;
60     assertEquals(AnnotationPanel.getRowIndex(0, anns), 0);
61     assertEquals(AnnotationPanel.getRowIndex(9, anns), 0);
62     assertEquals(AnnotationPanel.getRowIndex(10, anns), 2);
63     assertEquals(AnnotationPanel.getRowIndex(39, anns), 2);
64     assertEquals(AnnotationPanel.getRowIndex(40, anns), -1);
65
66     ann1.visible = false;
67     assertEquals(AnnotationPanel.getRowIndex(0, anns), 2);
68     assertEquals(AnnotationPanel.getRowIndex(29, anns), 2);
69     assertEquals(AnnotationPanel.getRowIndex(30, anns), -1);
70   }
71 }