FileDocCategorySizeDatePackage
TestPaletteRecord.javaAPI DocApache Poi 3.0.12366Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.record

TestPaletteRecord

public class TestPaletteRecord extends TestCase
Verifies that custom palette editing works correctly
author
Brian Sanders (bsanders at risklabs dot com)

Fields Summary
Constructors Summary
public TestPaletteRecord(String name)

        super(name);
    
Methods Summary
public voidtestDefaultPalette()
Tests that the default palette matches the constants of HSSFColor

        PaletteRecord palette = new PaletteRecord();
        
        //make sure all the HSSFColor constants match
        Map colors = HSSFColor.getIndexHash();
        Iterator indexes = colors.keySet().iterator();
        while (indexes.hasNext())
        {
            Integer index = (Integer) indexes.next();
            HSSFColor c = (HSSFColor) colors.get(index);
            short[] rgbTriplet = c.getTriplet();
            byte[] paletteTriplet = palette.getColor(index.shortValue());
            String msg = "Expected HSSFColor constant to match PaletteRecord at index 0x"
                + Integer.toHexString(c.getIndex());
            assertEquals(msg, rgbTriplet[0], paletteTriplet[0] & 0xff);
            assertEquals(msg, rgbTriplet[1], paletteTriplet[1] & 0xff);
            assertEquals(msg, rgbTriplet[2], paletteTriplet[2] & 0xff);
        }