3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNull;
10 public class ColorUtilsTest
13 Color paleColour = new Color(97, 203, 111); // pale green
15 Color midColour = new Color(135, 57, 41); // mid red
17 Color darkColour = new Color(11, 30, 50); // dark blue
20 public void testDarkerThan()
22 assertEquals("Wrong darker shade", new Color(32, 69, 37),
23 ColorUtils.darkerThan(paleColour));
24 assertEquals("Wrong darker shade", new Color(45, 18, 13),
25 ColorUtils.darkerThan(midColour));
26 assertEquals("Wrong darker shade", new Color(2, 9, 16),
27 ColorUtils.darkerThan(darkColour));
28 assertNull(ColorUtils.darkerThan(null));
32 public void testBrighterThan()
34 assertEquals("Wrong brighter shade", new Color(255, 255, 255), // white
35 ColorUtils.brighterThan(paleColour));
36 assertEquals("Wrong brighter shade", new Color(255, 164, 117),
37 ColorUtils.brighterThan(midColour));
38 assertEquals("Wrong brighter shade", new Color(30, 85, 144),
39 ColorUtils.brighterThan(darkColour));
40 assertNull(ColorUtils.brighterThan(null));
44 * @see http://www.rtapo.com/notes/named_colors.html
47 public void testToTkCode()
49 assertEquals("#fffafa", ColorUtils.toTkCode(new Color(255, 250, 250))); // snow
50 assertEquals("#e6e6fa", ColorUtils.toTkCode(new Color(230, 230, 250))); // lavender
51 assertEquals("#dda0dd", ColorUtils.toTkCode(new Color(221, 160, 221))); // plum
52 assertEquals("#800080", ColorUtils.toTkCode(new Color(128, 0, 128))); // purple
53 assertEquals("#00ff00", ColorUtils.toTkCode(new Color(0, 255, 0))); // lime