1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertNull; |
24 |
|
import static org.testng.AssertJUnit.assertEquals; |
25 |
|
|
26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.List; |
28 |
|
|
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (74) |
Complexity: 3 |
Complexity Density: 0.04 |
|
31 |
|
public class HiddenColumnsCursorTest |
32 |
|
{ |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
34 |
1 |
@Test(groups = { "Functional" })... |
35 |
|
public void testConstructor() |
36 |
|
{ |
37 |
1 |
HiddenColumnsCursor cursor = new HiddenColumnsCursor(); |
38 |
1 |
assertNull(cursor.findRegionForColumn(0, false)); |
39 |
|
|
40 |
1 |
List<int[]> hlist = new ArrayList<>(); |
41 |
1 |
cursor = new HiddenColumnsCursor(hlist); |
42 |
1 |
assertNull(cursor.findRegionForColumn(0, false)); |
43 |
|
|
44 |
1 |
cursor = new HiddenColumnsCursor(hlist, 3, 12); |
45 |
1 |
assertNull(cursor.findRegionForColumn(0, false)); |
46 |
|
|
47 |
1 |
hlist.add(new int[] { 3, 7 }); |
48 |
1 |
hlist.add(new int[] { 15, 25 }); |
49 |
1 |
cursor = new HiddenColumnsCursor(hlist); |
50 |
1 |
HiddenCursorPosition p = cursor.findRegionForColumn(8, false); |
51 |
1 |
assertEquals(1, p.getRegionIndex()); |
52 |
|
|
53 |
1 |
cursor = new HiddenColumnsCursor(hlist, 1, 5); |
54 |
1 |
p = cursor.findRegionForColumn(8, false); |
55 |
1 |
assertEquals(1, p.getRegionIndex()); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
61 |
1 |
@Test(groups = { "Functional" })... |
62 |
|
public void testFindRegionForColumn() |
63 |
|
{ |
64 |
1 |
HiddenColumnsCursor cursor = new HiddenColumnsCursor(); |
65 |
|
|
66 |
1 |
HiddenCursorPosition pos = cursor.findRegionForColumn(20, false); |
67 |
1 |
assertNull(pos); |
68 |
|
|
69 |
1 |
List<int[]> hidden = new ArrayList<>(); |
70 |
1 |
hidden.add(new int[] { 53, 76 }); |
71 |
1 |
hidden.add(new int[] { 104, 125 }); |
72 |
|
|
73 |
1 |
cursor = new HiddenColumnsCursor(hidden); |
74 |
|
|
75 |
1 |
int regionIndex = cursor.findRegionForColumn(126, false) |
76 |
|
.getRegionIndex(); |
77 |
1 |
assertEquals(2, regionIndex); |
78 |
|
|
79 |
1 |
regionIndex = cursor.findRegionForColumn(125, false).getRegionIndex(); |
80 |
1 |
assertEquals(1, regionIndex); |
81 |
|
|
82 |
1 |
regionIndex = cursor.findRegionForColumn(108, false).getRegionIndex(); |
83 |
1 |
assertEquals(1, regionIndex); |
84 |
|
|
85 |
1 |
regionIndex = cursor.findRegionForColumn(104, false).getRegionIndex(); |
86 |
1 |
assertEquals(1, regionIndex); |
87 |
|
|
88 |
1 |
regionIndex = cursor.findRegionForColumn(103, false).getRegionIndex(); |
89 |
1 |
assertEquals(1, regionIndex); |
90 |
|
|
91 |
1 |
regionIndex = cursor.findRegionForColumn(77, false).getRegionIndex(); |
92 |
1 |
assertEquals(1, regionIndex); |
93 |
|
|
94 |
1 |
regionIndex = cursor.findRegionForColumn(76, false).getRegionIndex(); |
95 |
1 |
assertEquals(0, regionIndex); |
96 |
|
|
97 |
1 |
regionIndex = cursor.findRegionForColumn(53, false).getRegionIndex(); |
98 |
1 |
assertEquals(0, regionIndex); |
99 |
|
|
100 |
1 |
regionIndex = cursor.findRegionForColumn(52, false).getRegionIndex(); |
101 |
1 |
assertEquals(0, regionIndex); |
102 |
|
|
103 |
1 |
regionIndex = cursor.findRegionForColumn(0, false).getRegionIndex(); |
104 |
1 |
assertEquals(0, regionIndex); |
105 |
|
|
106 |
1 |
hidden.add(new int[] { 138, 155 }); |
107 |
|
|
108 |
1 |
cursor = new HiddenColumnsCursor(hidden); |
109 |
|
|
110 |
1 |
regionIndex = cursor.findRegionForColumn(160, false).getRegionIndex(); |
111 |
1 |
assertEquals(3, regionIndex); |
112 |
|
|
113 |
1 |
regionIndex = cursor.findRegionForColumn(100, false).getRegionIndex(); |
114 |
1 |
assertEquals(1, regionIndex); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
120 |
1 |
@Test(groups = { "Functional" })... |
121 |
|
public void testFindRegionForColumn_Visible() |
122 |
|
{ |
123 |
1 |
HiddenColumnsCursor cursor = new HiddenColumnsCursor(); |
124 |
|
|
125 |
1 |
HiddenCursorPosition pos = cursor.findRegionForColumn(20, true); |
126 |
1 |
assertNull(pos); |
127 |
|
|
128 |
1 |
List<int[]> hidden = new ArrayList<>(); |
129 |
1 |
hidden.add(new int[] { 53, 76 }); |
130 |
1 |
hidden.add(new int[] { 104, 125 }); |
131 |
|
|
132 |
1 |
cursor = new HiddenColumnsCursor(hidden); |
133 |
|
|
134 |
1 |
int offset = cursor.findRegionForColumn(80, true).getHiddenSoFar(); |
135 |
1 |
assertEquals(46, offset); |
136 |
|
|
137 |
1 |
offset = cursor.findRegionForColumn(79, true).getHiddenSoFar(); |
138 |
1 |
assertEquals(24, offset); |
139 |
|
|
140 |
1 |
offset = cursor.findRegionForColumn(53, true).getHiddenSoFar(); |
141 |
1 |
assertEquals(24, offset); |
142 |
|
|
143 |
1 |
offset = cursor.findRegionForColumn(52, true).getHiddenSoFar(); |
144 |
1 |
assertEquals(0, offset); |
145 |
|
|
146 |
1 |
offset = cursor.findRegionForColumn(10, true).getHiddenSoFar(); |
147 |
1 |
assertEquals(0, offset); |
148 |
|
|
149 |
1 |
offset = cursor.findRegionForColumn(0, true).getHiddenSoFar(); |
150 |
1 |
assertEquals(0, offset); |
151 |
|
|
152 |
1 |
offset = cursor.findRegionForColumn(79, true).getHiddenSoFar(); |
153 |
1 |
assertEquals(24, offset); |
154 |
|
|
155 |
1 |
offset = cursor.findRegionForColumn(80, true).getHiddenSoFar(); |
156 |
1 |
assertEquals(46, offset); |
157 |
|
} |
158 |
|
} |