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.util; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
|
38 |
|
import java.awt.Color; |
39 |
|
|
40 |
|
import org.junit.Test; |
41 |
|
|
42 |
|
|
43 |
|
@link |
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 93.3% |
Uncovered Elements: 1 (15) |
Complexity: 4 |
Complexity Density: 0.33 |
|
47 |
|
public class ColorConverterTest { |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void testCanDecodeHexa() { |
51 |
1 |
assertEquals(Color.white, ColorConverter.toColor("#ffffff")); |
52 |
1 |
assertEquals(Color.black, ColorConverter.toColor("#000000")); |
53 |
1 |
assertEquals(Color.red, ColorConverter.toColor("#ff0000")); |
54 |
1 |
assertEquals(new Color(128, 64, 23), ColorConverter.toColor("#804017")); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void testCanDecodeNames() { |
59 |
1 |
assertEquals(Color.white, ColorConverter.toColor("white")); |
60 |
1 |
assertEquals(Color.black, ColorConverter.toColor("Black")); |
61 |
1 |
assertEquals(Color.red, ColorConverter.toColor("RED")); |
62 |
1 |
assertEquals(Color.yellow, ColorConverter.toColor("yelLoW")); |
63 |
|
} |
64 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testFailsOnUnknownName() { |
67 |
1 |
try { |
68 |
1 |
ColorConverter.toColor("foo"); |
69 |
0 |
fail("should have failed"); |
70 |
|
} catch (IllegalArgumentException e) { |
71 |
1 |
assertEquals("Can't decode color: foo. Please provide either an #ffffff hexadecimal value or a known named color.", e.getMessage()); |
72 |
|
} |
73 |
|
} |
74 |
|
|
75 |
|
} |