1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import org.testng.Assert; |
24 |
|
import org.testng.annotations.Test; |
25 |
|
|
26 |
|
import jalview.bin.Cache; |
27 |
|
import jalview.util.imagemaker.BitmapImageSizing; |
28 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (48) |
Complexity: 1 |
Complexity Density: 0.02 |
|
29 |
|
public class ImageMakerTest |
30 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (47) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
31 |
1 |
@Test(groups = { "Functional" })... |
32 |
|
public void testParseScaleWidthHeightStrings() |
33 |
|
{ |
34 |
1 |
Cache.setPropsAreReadOnly(true); |
35 |
1 |
Cache.loadProperties("test/jalview/bin/testProps.jvprops"); |
36 |
|
|
37 |
1 |
Cache.removeProperty(BitmapImageSizing.BITMAP_SCALE); |
38 |
1 |
Cache.removeProperty(BitmapImageSizing.BITMAP_HEIGHT); |
39 |
1 |
Cache.removeProperty(BitmapImageSizing.BITMAP_WIDTH); |
40 |
|
|
41 |
1 |
BitmapImageSizing bis = null; |
42 |
|
|
43 |
|
|
44 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings("1.2", "3", "4"); |
45 |
1 |
Assert.assertEquals(bis.scale(), 1.2f, |
46 |
|
"scale not parsed and set to value given"); |
47 |
1 |
Assert.assertEquals(bis.width(), 3, |
48 |
|
"width not parsed and set to value given"); |
49 |
1 |
Assert.assertEquals(bis.height(), 4, |
50 |
|
"height not parsed and set to value given"); |
51 |
|
|
52 |
|
|
53 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings("1.2", null, null); |
54 |
1 |
Assert.assertEquals(bis.scale(), 1.2f, |
55 |
|
"scale not parsed and set to value given"); |
56 |
1 |
Assert.assertEquals(bis.width(), 0, "width not parsed and set to 0"); |
57 |
1 |
Assert.assertEquals(bis.height(), 0, "height not parsed and set to 0"); |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings(null, "1", null); |
62 |
1 |
Assert.assertEquals(bis.scale(), 0f, "scale not parsed and set to 0f"); |
63 |
1 |
Assert.assertEquals(bis.width(), 1, |
64 |
|
"width not parsed and set to value given"); |
65 |
1 |
Assert.assertEquals(bis.height(), 0, "height not parsed and set to 0"); |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings(null, null, null); |
70 |
1 |
Assert.assertEquals(bis.scale(), 0f, |
71 |
|
"scale not parsed and set to undefined default 0f"); |
72 |
1 |
Assert.assertEquals(bis.width(), 0, |
73 |
|
"width not parsed and set to undefined default 0"); |
74 |
1 |
Assert.assertEquals(bis.height(), 0, |
75 |
|
"height not parsed and set to undefined default 0"); |
76 |
|
|
77 |
1 |
Cache.setProperty(BitmapImageSizing.BITMAP_HEIGHT, "1"); |
78 |
|
|
79 |
1 |
Assert.assertEquals(bis.scale(), 0f, |
80 |
|
"scale not parsed and set to undefined default 0f"); |
81 |
1 |
Assert.assertEquals(bis.width(), 0, |
82 |
|
"width not parsed and set to undefined default 0"); |
83 |
1 |
Assert.assertEquals(bis.height(), 1, |
84 |
|
"height not parsed and set to default 1"); |
85 |
|
|
86 |
1 |
Cache.setProperty(BitmapImageSizing.BITMAP_SCALE, "3.4"); |
87 |
1 |
Cache.setProperty(BitmapImageSizing.BITMAP_WIDTH, "2"); |
88 |
|
|
89 |
1 |
Assert.assertEquals(bis.scale(), 3.4f, |
90 |
|
"scale not parsed and set to undefined default 3.2f"); |
91 |
1 |
Assert.assertEquals(bis.width(), 2, |
92 |
|
"width not parsed and set to undefined default 2"); |
93 |
1 |
Assert.assertEquals(bis.height(), 1, |
94 |
|
"height not parsed and set to default 1"); |
95 |
|
|
96 |
|
|
97 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings("1.2", "3", "4"); |
98 |
1 |
Assert.assertEquals(bis.scale(), 1.2f, |
99 |
|
"scale not parsed and set to value given"); |
100 |
1 |
Assert.assertEquals(bis.width(), 3, |
101 |
|
"width not parsed and set to value given"); |
102 |
1 |
Assert.assertEquals(bis.height(), 4, |
103 |
|
"height not parsed and set to value given"); |
104 |
|
|
105 |
|
|
106 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings("1.2", null, null); |
107 |
1 |
Assert.assertEquals(bis.scale(), 1.2f, |
108 |
|
"scale not parsed and set to value given"); |
109 |
1 |
Assert.assertEquals(bis.width(), 0, |
110 |
|
"width not parsed and set to undefined 0"); |
111 |
1 |
Assert.assertEquals(bis.height(), 0, |
112 |
|
"height not parsed and set to undefined 0"); |
113 |
|
|
114 |
|
|
115 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings(null, null, "5"); |
116 |
1 |
Assert.assertEquals(bis.scale(), 0f, |
117 |
|
"scale not parsed and set to undefined 0f"); |
118 |
1 |
Assert.assertEquals(bis.width(), 0, |
119 |
|
"width not parsed and set to undefined 0"); |
120 |
1 |
Assert.assertEquals(bis.height(), 5, |
121 |
|
"height not parsed and set to value given"); |
122 |
|
|
123 |
|
|
124 |
1 |
bis = ImageMaker.parseScaleWidthHeightStrings(null, null, null); |
125 |
1 |
Assert.assertEquals(bis.scale(), 3.4f, |
126 |
|
"scale not parsed and set to undefined default 3.4f"); |
127 |
1 |
Assert.assertEquals(bis.width(), 2, |
128 |
|
"width not parsed and set to undefined default 2"); |
129 |
1 |
Assert.assertEquals(bis.height(), 1, |
130 |
|
"height not parsed and set to default 1"); |
131 |
|
} |
132 |
|
} |