1 2 17 18 package org.apache.poi.hssf.record; 19 20 import java.util.Iterator ; 21 import java.util.Map ; 22 import junit.framework.TestCase; 23 import org.apache.poi.hssf.util.HSSFColor; 24 25 30 public class TestPaletteRecord extends TestCase 31 { 32 public TestPaletteRecord(String name) 33 { 34 super(name); 35 } 36 37 40 public void testDefaultPalette() 41 { 42 PaletteRecord palette = new PaletteRecord(PaletteRecord.sid); 43 44 Map colors = HSSFColor.getIndexHash(); 46 Iterator indexes = colors.keySet().iterator(); 47 while (indexes.hasNext()) 48 { 49 Integer index = (Integer ) indexes.next(); 50 HSSFColor c = (HSSFColor) colors.get(index); 51 short[] rgbTriplet = c.getTriplet(); 52 byte[] paletteTriplet = palette.getColor(index.shortValue()); 53 String msg = "Expected HSSFColor constant to match PaletteRecord at index 0x" 54 + Integer.toHexString(c.getIndex()); 55 assertEquals(msg, rgbTriplet[0], paletteTriplet[0] & 0xff); 56 assertEquals(msg, rgbTriplet[1], paletteTriplet[1] & 0xff); 57 assertEquals(msg, rgbTriplet[2], paletteTriplet[2] & 0xff); 58 } 59 } 60 } 61 | Popular Tags |