1 33 34 package edu.rice.cs.drjava.config; 35 36 import edu.rice.cs.drjava.DrJavaTestCase; 37 38 import java.awt.*; 39 40 43 public final class ColorOptionTest extends DrJavaTestCase { 44 45 46 public ColorOptionTest(String name) { super(name); } 47 48 public void testGetName() { 49 ColorOption io1 = new ColorOption("indent_size",null); 50 ColorOption io2 = new ColorOption("max_files",null); 51 52 assertEquals("indent_size", io1.getName()); 53 assertEquals("max_files", io2.getName()); 54 } 55 56 public void testParse() { 57 ColorOption io = new ColorOption("max_files",null); 58 59 assertEquals(Color.black, io.parse("0x000000")); 60 assertEquals(Color.green, io.parse("0x00ff00")); 61 62 try { io.parse("true"); fail(); } 63 catch (OptionParseException e) { } 64 65 try { io.parse("black"); fail(); } 66 catch (OptionParseException e) { } 67 } 68 69 70 public void testFormat() { 71 ColorOption io1 = new ColorOption("max_files",null); 72 ColorOption io2 = new ColorOption("indent_size",null); 73 74 assertEquals("#000000", io1.format(Color.black)); 75 assertEquals("#ff00ff", io2.format(Color.magenta)); 76 assertEquals("#ffffff", io1.format(Color.white)); 77 78 ColorOption c = new ColorOption("blue", Color.blue); 79 assertEquals("testFormat:", "#000000", c.format(Color.black)); 80 assertEquals("testFormat:", "#0000ff", c.format(Color.blue)); 81 assertEquals("testFormat:", "#00ff00", c.format(Color.green)); 82 assertEquals("testFormat:", "#ff0000", c.format(Color.red)); 83 } 84 } 85 | Popular Tags |