FileDocCategorySizeDatePackage
TestDrawingManager.javaAPI DocApache Poi 3.0.14270Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.model

TestDrawingManager

public class TestDrawingManager extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestAllocateShapeId()

        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 0 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
        DrawingManager dm = new DrawingManager( dgg );

        EscherDgRecord dg = dm.createDgRecord();
        int shapeId = dm.allocateShapeId( dg.getDrawingGroupId() );
        assertEquals( 1024, shapeId );
        assertEquals( 1025, dgg.getShapeIdMax() );
        assertEquals( 1, dgg.getDrawingsSaved() );
        assertEquals( 1, dgg.getFileIdClusters()[0].getDrawingGroupId() );
        assertEquals( 1, dgg.getFileIdClusters()[0].getNumShapeIdsUsed() );
        assertEquals( 1024, dg.getLastMSOSPID() );
        assertEquals( 1, dg.getNumShapes() );
    
public voidtestCreateDgRecord()

        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 0 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
        DrawingManager dm = new DrawingManager( dgg );

        EscherDgRecord dgRecord = dm.createDgRecord();
        assertEquals( -1, dgRecord.getLastMSOSPID() );
        assertEquals( 0, dgRecord.getNumShapes() );
        assertEquals( 1, dm.getDgg().getDrawingsSaved() );
        assertEquals( 1, dm.getDgg().getFileIdClusters().length );
        assertEquals( 1, dm.getDgg().getFileIdClusters()[0].getDrawingGroupId() );
        assertEquals( 0, dm.getDgg().getFileIdClusters()[0].getNumShapeIdsUsed() );
    
public voidtestDrawingGroupExists()

        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 1 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        DrawingManager dm = new DrawingManager( dgg );
        assertFalse( dm.drawingGroupExists( (short) 1 ) );
        assertTrue( dm.drawingGroupExists( (short) 2 ) );
        assertFalse( dm.drawingGroupExists( (short) 3 ) );
    
public voidtestFindFreeSPIDBlock()

        EscherDggRecord dgg = new EscherDggRecord();
        DrawingManager dm = new DrawingManager( dgg );
        dgg.setShapeIdMax( 1024 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
        dgg.setShapeIdMax( 1025 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
        dgg.setShapeIdMax( 2047 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
    
public voidtestFindNewDrawingGroupId()

        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 1 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        DrawingManager dm = new DrawingManager( dgg );
        assertEquals( 1, dm.findNewDrawingGroupId() );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 1, 10 ),
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        assertEquals( 3, dm.findNewDrawingGroupId() );