1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.renderer; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
|
25 |
|
import jalview.datamodel.Alignment; |
26 |
|
import jalview.datamodel.AlignmentI; |
27 |
|
import jalview.datamodel.Sequence; |
28 |
|
import jalview.datamodel.SequenceI; |
29 |
|
import jalview.gui.AlignViewport; |
30 |
|
import jalview.gui.JvOptionPane; |
31 |
|
import jalview.schemes.UserColourScheme; |
32 |
|
import jalview.schemes.ZappoColourScheme; |
33 |
|
|
34 |
|
import java.awt.Color; |
35 |
|
|
36 |
|
import org.testng.annotations.BeforeClass; |
37 |
|
import org.testng.annotations.Test; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 5 |
Complexity Density: 0.12 |
|
39 |
|
public class ResidueColourFinderTest |
40 |
|
{ |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
42 |
1 |
@BeforeClass(alwaysRun = true)... |
43 |
|
public void setUpJvOptionPane() |
44 |
|
{ |
45 |
1 |
JvOptionPane.setInteractiveMode(false); |
46 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
49 |
1 |
@Test(groups = { "Functional" })... |
50 |
|
public void testGetResidueColour_zappo() |
51 |
|
{ |
52 |
1 |
SequenceI seq = new Sequence("name", "MATVLGSPRAPAFF"); |
53 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
54 |
1 |
final AlignViewport av = new AlignViewport(al); |
55 |
1 |
ResidueColourFinder rcf = new ResidueColourFinder(); |
56 |
1 |
av.setGlobalColourScheme(new ZappoColourScheme()); |
57 |
|
|
58 |
|
|
59 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(true, |
60 |
|
av.getResidueShading(), null, seq, 0, null)); |
61 |
1 |
assertEquals(Color.green, rcf.getResidueColour(true, |
62 |
|
av.getResidueShading(), null, seq, 2, null)); |
63 |
1 |
assertEquals(Color.magenta, rcf.getResidueColour(true, |
64 |
|
av.getResidueShading(), null, seq, 5, null)); |
65 |
1 |
assertEquals(Color.orange, rcf.getResidueColour(true, |
66 |
|
av.getResidueShading(), null, seq, 12, null)); |
67 |
|
|
68 |
|
|
69 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
70 |
|
av.getResidueShading(), null, seq, 0, null)); |
71 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
72 |
|
av.getResidueShading(), null, seq, 2, null)); |
73 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
74 |
|
av.getResidueShading(), null, seq, 5, null)); |
75 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
76 |
|
av.getResidueShading(), null, seq, 12, null)); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
79 |
1 |
@Test(groups = { "Functional" })... |
80 |
|
public void testGetResidueColour_none() |
81 |
|
{ |
82 |
1 |
SequenceI seq = new Sequence("name", "MA--TVLGSPRAPAFF"); |
83 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
84 |
1 |
final AlignViewport av = new AlignViewport(al); |
85 |
1 |
ResidueColourFinder rcf = new ResidueColourFinder(); |
86 |
|
|
87 |
1 |
assertEquals(Color.white, rcf.getResidueColour(true, |
88 |
|
av.getResidueShading(), null, seq, 0, null)); |
89 |
1 |
assertEquals(Color.white, rcf.getResidueColour(true, |
90 |
|
av.getResidueShading(), null, seq, 2, null)); |
91 |
|
|
92 |
|
|
93 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
94 |
|
av.getResidueShading(), null, seq, 0, null)); |
95 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
96 |
|
av.getResidueShading(), null, seq, 2, null)); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 2 |
Complexity Density: 0.12 |
1PASS
|
|
99 |
1 |
@Test(groups = { "Functional" })... |
100 |
|
public void testGetResidueColour_userdef() |
101 |
|
{ |
102 |
1 |
SequenceI seq = new Sequence("name", "MAT--GSPRAPAFF"); |
103 |
|
|
104 |
1 |
AlignmentI al = new Alignment(new SequenceI[] { seq }); |
105 |
1 |
final AlignViewport av = new AlignViewport(al); |
106 |
1 |
ResidueColourFinder rcf = new ResidueColourFinder(); |
107 |
|
|
108 |
1 |
Color[] newColours = new Color[24]; |
109 |
25 |
for (int i = 0; i < 24; i++) |
110 |
|
{ |
111 |
24 |
newColours[i] = null; |
112 |
|
} |
113 |
|
|
114 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
1 |
assertEquals(null, rcf.getResidueColour(true, av.getResidueShading(), |
119 |
|
null, seq, 3, null)); |
120 |
|
|
121 |
1 |
newColours[23] = Color.pink; |
122 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
123 |
|
|
124 |
|
|
125 |
1 |
assertEquals(Color.pink, rcf.getResidueColour(true, |
126 |
|
av.getResidueShading(), null, seq, 3, null)); |
127 |
|
|
128 |
|
|
129 |
1 |
newColours[23] = null; |
130 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
131 |
|
av.getResidueShading(), null, seq, 3, null)); |
132 |
|
|
133 |
1 |
newColours[23] = Color.pink; |
134 |
1 |
av.setGlobalColourScheme(new UserColourScheme(newColours)); |
135 |
|
|
136 |
|
|
137 |
1 |
assertEquals(Color.white, rcf.getResidueColour(false, |
138 |
|
av.getResidueShading(), null, seq, 3, null)); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
} |