1 |
|
package jalview.io; |
2 |
|
|
3 |
|
import org.testng.Assert; |
4 |
|
import org.testng.annotations.DataProvider; |
5 |
|
import org.testng.annotations.Test; |
6 |
|
|
7 |
|
import jalview.bin.Cache; |
8 |
|
import jalview.gui.AlignFrame; |
9 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.5 |
|
10 |
|
public class JalviewFileChooserTest |
11 |
|
{ |
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
4-
|
|
12 |
0 |
@Test(groups = { "Functional" }, dataProvider = "propertiesAndFormats")... |
13 |
|
public void checkDefaultSaveFormat(String DEFAULT_SAVE_FILE_FORMAT, |
14 |
|
String ALWAYS_USE_DEFAULT_SAVE_FORMAT, |
15 |
|
FileFormat alignmentCurrentFormat, |
16 |
|
FileFormat alignFrameLastSavedFormat, |
17 |
|
String expectedDefaultFormatName) |
18 |
|
{ |
19 |
0 |
String alignmentCurrentFormatName = alignmentCurrentFormat == null |
20 |
|
? null |
21 |
|
: alignmentCurrentFormat.getName(); |
22 |
|
|
23 |
0 |
AlignFrame.setLastAlignmentSavedFormat(alignFrameLastSavedFormat); |
24 |
|
|
25 |
0 |
setOrRemoveProperty(JalviewFileChooser.DEFAULT_SAVE_FORMAT_PROPERTY, |
26 |
|
DEFAULT_SAVE_FILE_FORMAT); |
27 |
0 |
setOrRemoveProperty( |
28 |
|
JalviewFileChooser.ALWAYS_USE_DEFAULT_SAVED_FORMAT_PROPERTY, |
29 |
|
ALWAYS_USE_DEFAULT_SAVE_FORMAT); |
30 |
|
|
31 |
0 |
String defaultFormat = JalviewFileChooser |
32 |
|
.defaultSaveFileFormat(alignmentCurrentFormatName); |
33 |
|
|
34 |
0 |
Assert.assertEquals(defaultFormat, expectedDefaultFormatName, |
35 |
|
"The calculated default format did not match the expected default format."); |
36 |
|
} |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
38 |
0 |
@DataProvider(name = "propertiesAndFormats")... |
39 |
|
public Object[][] propertiesAndFormats() |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
0 |
return new Object[][] { |
47 |
|
|
48 |
|
|
49 |
|
{ null, null, null, null, FileFormat.Fasta.getName() }, |
50 |
|
{ null, null, FileFormat.BLC, null, FileFormat.BLC.getName() }, |
51 |
|
{ null, null, FileFormat.BLC, FileFormat.PIR, |
52 |
|
FileFormat.BLC.getName() }, |
53 |
|
{ null, null, null, FileFormat.PIR, FileFormat.Fasta.getName() }, |
54 |
|
|
55 |
|
{ "Stockholm", null, null, null, FileFormat.Stockholm.getName() }, |
56 |
|
{ "Stockholm", null, FileFormat.BLC, null, |
57 |
|
FileFormat.BLC.getName() }, |
58 |
|
{ "Stockholm", null, FileFormat.BLC, FileFormat.PIR, |
59 |
|
FileFormat.BLC.getName() }, |
60 |
|
{ "Stockholm", null, null, FileFormat.PIR, |
61 |
|
FileFormat.Stockholm.getName() }, |
62 |
|
|
63 |
|
{ "Stockholm", "true", null, null, FileFormat.Stockholm.getName() }, |
64 |
|
{ "Stockholm", "true", FileFormat.BLC, null, |
65 |
|
FileFormat.Stockholm.getName() }, |
66 |
|
{ "Stockholm", "true", FileFormat.BLC, FileFormat.PIR, |
67 |
|
FileFormat.Stockholm.getName() }, |
68 |
|
{ "Stockholm", "true", null, FileFormat.PIR, |
69 |
|
FileFormat.Stockholm.getName() }, |
70 |
|
|
71 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, null, null, null, |
72 |
|
FileFormat.Fasta.getName() }, |
73 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, null, |
74 |
|
FileFormat.BLC, null, FileFormat.BLC.getName() }, |
75 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, null, |
76 |
|
FileFormat.BLC, FileFormat.PIR, FileFormat.BLC.getName() }, |
77 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, null, null, |
78 |
|
FileFormat.PIR, FileFormat.PIR.getName() }, |
79 |
|
|
80 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, "true", null, |
81 |
|
null, FileFormat.Fasta.getName() }, |
82 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, "true", |
83 |
|
FileFormat.BLC, null, FileFormat.BLC.getName() }, |
84 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, "true", |
85 |
|
FileFormat.BLC, FileFormat.PIR, FileFormat.PIR.getName() }, |
86 |
|
{ JalviewFileChooser.USE_LAST_SAVED_FORMAT_VALUE, "true", null, |
87 |
|
FileFormat.PIR, FileFormat.PIR.getName() }, |
88 |
|
|
89 |
|
|
90 |
|
{ "ALL_EXTENSIONS", null, null, null, "ALL_EXTENSIONS" }, |
91 |
|
{ "ALL_EXTENSIONS", null, FileFormat.BLC, null, |
92 |
|
FileFormat.BLC.getName() }, |
93 |
|
{ "ALL_EXTENSIONS", null, FileFormat.BLC, FileFormat.PIR, |
94 |
|
FileFormat.BLC.getName() }, |
95 |
|
{ "ALL_EXTENSIONS", null, null, FileFormat.PIR, "ALL_EXTENSIONS" }, |
96 |
|
|
97 |
|
{ "ALL_EXTENSIONS", "true", null, null, "ALL_EXTENSIONS" }, |
98 |
|
{ "ALL_EXTENSIONS", "true", FileFormat.BLC, null, |
99 |
|
"ALL_EXTENSIONS" }, |
100 |
|
{ "ALL_EXTENSIONS", "true", FileFormat.BLC, FileFormat.PIR, |
101 |
|
"ALL_EXTENSIONS" }, |
102 |
|
{ "ALL_EXTENSIONS", "true", null, FileFormat.PIR, |
103 |
|
"ALL_EXTENSIONS" }, |
104 |
|
|
105 |
|
|
106 |
|
}; |
107 |
|
} |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
109 |
0 |
private static void setOrRemoveProperty(String key, String value)... |
110 |
|
{ |
111 |
0 |
if (value == null) |
112 |
|
{ |
113 |
0 |
Cache.removeProperty(key); |
114 |
|
} |
115 |
|
else |
116 |
|
{ |
117 |
0 |
Cache.setProperty(key, value); |
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
|
} |