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 |
|
|
46 |
|
|
47 |
|
@link |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 5 |
Complexity Density: 0.17 |
|
49 |
|
public class OutputFormatTest { |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void testQualityIsProperlyConvertedToOneZeroRangeAndSetsCompressionModeToExplicit() { |
53 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
54 |
1 |
final OutputFormat f = new OutputFormat(); |
55 |
1 |
f.setQuality(63); |
56 |
1 |
f.applyTo(param); |
57 |
|
|
58 |
1 |
assertEquals(0.63f, param.getCompressionQuality(), 0f); |
59 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void testCompressionTypeIsProperlyConvertedToOneZeroRangeAndSetsCompressionModeToExplicit() { |
64 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
65 |
1 |
final OutputFormat f = new OutputFormat(); |
66 |
1 |
f.setCompressionType("JPEG"); |
67 |
1 |
f.applyTo(param); |
68 |
|
|
69 |
1 |
assertEquals("JPEG", param.getCompressionType()); |
70 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
73 |
1 |
@Test... |
74 |
|
public void testProgressiveFlagIsSetProperlyWhenTrue() { |
75 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
76 |
1 |
final OutputFormat f = new OutputFormat(); |
77 |
1 |
f.setProgressive(true); |
78 |
1 |
f.applyTo(param); |
79 |
|
|
80 |
1 |
assertEquals(ImageWriteParam.MODE_DEFAULT, param.getProgressiveMode()); |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void testProgressiveFlagIsSetProperlyWhenFalse() { |
85 |
1 |
final ImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault()); |
86 |
1 |
final OutputFormat f = new OutputFormat(); |
87 |
1 |
f.setProgressive(false); |
88 |
1 |
f.applyTo(param); |
89 |
|
|
90 |
1 |
assertEquals(ImageWriteParam.MODE_DISABLED, param.getProgressiveMode()); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
public void testCompressionSettingsAreNotResetWhenBothTypeAndQualityAreApplied() { |
95 |
1 |
final ImageWriteParam param = new BMPImageWriteParam(Locale.getDefault()); |
96 |
1 |
final OutputFormat f = new OutputFormat(); |
97 |
1 |
f.setCompressionType("BI_JPEG"); |
98 |
1 |
f.setQuality(42); |
99 |
1 |
f.applyTo(param); |
100 |
|
|
101 |
1 |
assertEquals("BI_JPEG", param.getCompressionType()); |
102 |
1 |
assertEquals(0.42f, param.getCompressionQuality(), 0f); |
103 |
1 |
assertEquals(ImageWriteParam.MODE_EXPLICIT, param.getCompressionMode()); |
104 |
|
} |
105 |
|
} |