FileDocCategorySizeDatePackage
TestEscherDggRecord.javaAPI DocApache Poi 3.0.14072Mon Jan 01 12:39:46 GMT 2007org.apache.poi.ddf

TestEscherDggRecord

public class TestEscherDggRecord extends TestCase

Fields Summary
Constructors Summary
Methods Summary
private org.apache.poi.ddf.EscherDggRecordcreateRecord()

        EscherDggRecord r = new EscherDggRecord();
        r.setOptions( (short) 0x0000 );
        r.setRecordId( EscherDggRecord.RECORD_ID );
        r.setShapeIdMax( 0x402 );
        r.setNumShapesSaved( 0x02 );
        r.setDrawingsSaved( 0x01 );
        r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] {
            new EscherDggRecord.FileIdCluster( 1, 2 )
        });
        return r;
    
public voidtestFillFields()

        String hexData = "00 00 " +
                "06 F0 " +
                "18 00 00 00 " +
                "02 04 00 00 " +
                "02 00 00 00 " +
                "02 00 00 00 " +
                "01 00 00 00 " +
                "01 00 00 00 02 00 00 00";
        byte[] data = HexRead.readFromString( hexData );
        EscherDggRecord r = new EscherDggRecord();
        int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );

        assertEquals( 32, bytesWritten );
        assertEquals( 0x402, r.getShapeIdMax() );
        assertEquals( 0x02, r.getNumIdClusters() );
        assertEquals( 0x02, r.getNumShapesSaved() );
        assertEquals( 0x01, r.getDrawingsSaved() );
        assertEquals( 1, r.getFileIdClusters().length );
        assertEquals( 0x01, r.getFileIdClusters()[0].getDrawingGroupId());
        assertEquals( 0x02, r.getFileIdClusters()[0].getNumShapeIdsUsed());
    
public voidtestGetRecordSize()

        EscherDggRecord r = new EscherDggRecord();
        r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
        assertEquals(32,r.getRecordSize());

    
public voidtestSerialize()

        EscherDggRecord r = createRecord();

        byte[] data = new byte[32];
        int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
        assertEquals( 32, bytesWritten );
        assertEquals( "[00, 00, " +
                "06, F0, " +
                "18, 00, 00, 00, " +
                "02, 04, 00, 00, " +
                "02, 00, 00, 00, " +
                "02, 00, 00, 00, " +
                "01, 00, 00, 00, " +
                "01, 00, 00, 00, 02, 00, 00, 00, ]",
                HexDump.toHex( data ) );
    
public voidtestToString()

        String nl = System.getProperty("line.separator");

        String expected = "org.apache.poi.ddf.EscherDggRecord:" + nl +
                "  RecordId: 0xF006" + nl +
                "  Options: 0x0000" + nl +
                "  ShapeIdMax: 1026" + nl +
                "  NumIdClusters: 2" + nl +
                "  NumShapesSaved: 2" + nl +
                "  DrawingsSaved: 1" + nl +
                "  DrawingGroupId1: 1" + nl +
                "  NumShapeIdsUsed1: 2" + nl;
        assertEquals( expected, createRecord().toString() );