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