1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.imaging; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
|
38 |
|
import java.util.Locale; |
39 |
|
|
40 |
|
import javax.imageio.ImageWriteParam; |
41 |
|
import javax.imageio.plugins.bmp.BMPImageWriteParam; |
42 |
|
import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
43 |
|
|
44 |
|
import org.junit.Test; |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 5 |
Complexity Density: 0.17 |
|
46 |
|
public class OutputFormatTest { |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
48 |
1 |
@Test... |
49 |
|
public void qualityIsProperlyConvertedToOneZeroRangeAndSetsCompressionModeToExplicit() throws Exception { |
50 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
51 |
1 |
final OutputFormat f = new OutputFormat(); |
52 |
1 |
f.setQuality(63); |
53 |
1 |
f.applyTo(param); |
54 |
|
|
55 |
1 |
assertEquals(0.63f, param.getCompressionQuality(), 0f); |
56 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void compressionTypeIsProperlyConvertedToOneZeroRangeAndSetsCompressionModeToExplicit() throws Exception { |
61 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
62 |
1 |
final OutputFormat f = new OutputFormat(); |
63 |
1 |
f.setCompressionType("JPEG"); |
64 |
1 |
f.applyTo(param); |
65 |
|
|
66 |
1 |
assertEquals("JPEG", param.getCompressionType()); |
67 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void progressiveFlagIsSetProperlyWhenTrue() throws Exception { |
72 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
73 |
1 |
final OutputFormat f = new OutputFormat(); |
74 |
1 |
f.setProgressive(true); |
75 |
1 |
f.applyTo(param); |
76 |
|
|
77 |
1 |
assertEquals(ImageWriteParam.MODE_DEFAULT, param.getProgressiveMode()); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
80 |
1 |
@Test... |
81 |
|
public void progressiveFlagIsSetProperlyWhenFalse() throws Exception { |
82 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
83 |
1 |
final OutputFormat f = new OutputFormat(); |
84 |
1 |
f.setProgressive(false); |
85 |
1 |
f.applyTo(param); |
86 |
|
|
87 |
1 |
assertEquals(ImageWriteParam.MODE_DISABLED, param.getProgressiveMode()); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
90 |
1 |
@Test... |
91 |
|
public void compressionSettingsAreNotResetWhenBothTypeAndQualityAreApplied() throws Exception { |
92 |
1 |
final ImageWriteParam param = new BMPImageWriteParam(Locale.getDefault()); |
93 |
1 |
final OutputFormat f = new OutputFormat(); |
94 |
1 |
f.setCompressionType("BI_JPEG"); |
95 |
1 |
f.setQuality(42); |
96 |
1 |
f.applyTo(param); |
97 |
|
|
98 |
1 |
assertEquals("BI_JPEG", param.getCompressionType()); |
99 |
1 |
assertEquals(0.42f, param.getCompressionQuality(), 0f); |
100 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
101 |
|
} |
102 |
|
} |