aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlen Stampoultzis <glens@apache.org>2005-05-01 22:05:37 +0000
committerGlen Stampoultzis <glens@apache.org>2005-05-01 22:05:37 +0000
commitf5dd7d86f5c67d21b1024838864f26c37a14dd79 (patch)
tree3d282b8414d8c94ad6e46e1d49b21b2ff9da5f48 /src
parentf1382ee5ebcef196f771e11a0a7847e611950779 (diff)
downloadpoi-f5dd7d86f5c67d21b1024838864f26c37a14dd79.tar.gz
poi-f5dd7d86f5c67d21b1024838864f26c37a14dd79.zip
Moving to head
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java66
-rw-r--r--src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java59
2 files changed, 125 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java
new file mode 100644
index 0000000000..3fbd933e7e
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingManager2.java
@@ -0,0 +1,66 @@
+package org.apache.poi.hssf.model;
+
+import junit.framework.TestCase;
+import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherDgRecord;
+
+public class TestDrawingManager2 extends TestCase
+{
+ private DrawingManager2 drawingManager2;
+ private EscherDggRecord dgg;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ dgg = new EscherDggRecord();
+ dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[0] );
+ drawingManager2 = new DrawingManager2( dgg );
+ }
+
+ public void testCreateDgRecord() throws Exception
+ {
+ EscherDgRecord dgRecord1 = drawingManager2.createDgRecord();
+ assertEquals( 1, dgRecord1.getDrawingGroupId() );
+ assertEquals( -1, dgRecord1.getLastMSOSPID() );
+
+ EscherDgRecord dgRecord2 = drawingManager2.createDgRecord();
+ assertEquals( 2, dgRecord2.getDrawingGroupId() );
+ assertEquals( -1, dgRecord2.getLastMSOSPID() );
+
+ assertEquals( 2, dgg.getDrawingsSaved( ) );
+ assertEquals( 2, dgg.getFileIdClusters().length );
+ assertEquals( 3, dgg.getNumIdClusters() );
+ assertEquals( 0, dgg.getNumShapesSaved() );
+ }
+
+ public void testAllocateShapeId() throws Exception
+ {
+ EscherDgRecord dgRecord1 = drawingManager2.createDgRecord();
+ EscherDgRecord dgRecord2 = drawingManager2.createDgRecord();
+
+ assertEquals( 1024, drawingManager2.allocateShapeId( (short)1 ) );
+ assertEquals( 1024, dgRecord1.getLastMSOSPID() );
+ assertEquals( 1025, dgg.getShapeIdMax() );
+ assertEquals( 1025, drawingManager2.allocateShapeId( (short)1 ) );
+ assertEquals( 1025, dgRecord1.getLastMSOSPID() );
+ assertEquals( 1026, dgg.getShapeIdMax() );
+ assertEquals( 1026, drawingManager2.allocateShapeId( (short)1 ) );
+ assertEquals( 1026, dgRecord1.getLastMSOSPID() );
+ assertEquals( 1027, dgg.getShapeIdMax() );
+ assertEquals( 2048, drawingManager2.allocateShapeId( (short)2 ) );
+ assertEquals( 2048, dgRecord2.getLastMSOSPID() );
+ assertEquals( 2049, dgg.getShapeIdMax() );
+
+ for (int i = 0; i < 1021; i++)
+ {
+ drawingManager2.allocateShapeId( (short)1 );
+ assertEquals( 2049, dgg.getShapeIdMax() );
+ }
+ assertEquals( 3072, drawingManager2.allocateShapeId( (short) 1 ) );
+ assertEquals( 3073, dgg.getShapeIdMax() );
+
+ assertEquals( 2, dgg.getDrawingsSaved() );
+ assertEquals( 4, dgg.getNumIdClusters() );
+ assertEquals( 1026, dgg.getNumShapesSaved() );
+ }
+} \ No newline at end of file
diff --git a/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java b/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java
new file mode 100644
index 0000000000..6d841e669c
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java
@@ -0,0 +1,59 @@
+/* ====================================================================
+ Copyright 2003-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.aggregates;
+
+import junit.framework.TestCase;
+import org.apache.poi.hssf.record.ColumnInfoRecord;
+
+/**
+ * @author Glen Stampoultzis
+ */
+public class TestColumnInfoRecordsAggregate extends TestCase
+{
+ ColumnInfoRecordsAggregate columnInfoRecordsAggregate;
+
+ public void testGetRecordSize() throws Exception
+ {
+ columnInfoRecordsAggregate = new ColumnInfoRecordsAggregate();
+ columnInfoRecordsAggregate.insertColumn( createColumn( (short)1, (short)3 ));
+ columnInfoRecordsAggregate.insertColumn( createColumn( (short)4, (short)7 ));
+ columnInfoRecordsAggregate.insertColumn( createColumn( (short)8, (short)8 ));
+// columnInfoRecordsAggregate.setColumn( (short)2, new Short( (short)200 ), new Integer( 1 ), new Boolean( true ), null);
+ columnInfoRecordsAggregate.groupColumnRange( (short)2, (short)5, true );
+ System.out.println( "columnInfoRecordsAggregate = " + columnInfoRecordsAggregate.getNumColumns() );
+
+ assertEquals(columnInfoRecordsAggregate.getRecordSize(), columnInfoRecordsAggregate.serialize().length);
+
+ columnInfoRecordsAggregate = new ColumnInfoRecordsAggregate();
+ columnInfoRecordsAggregate.groupColumnRange( (short)3, (short)6, true );
+
+ assertEquals(columnInfoRecordsAggregate.getRecordSize(), serializedSize());
+ }
+
+ private int serializedSize()
+ {
+ return columnInfoRecordsAggregate.serialize(0, new byte[columnInfoRecordsAggregate.getRecordSize()]);
+ }
+
+ private ColumnInfoRecord createColumn( short firstCol, short lastCol )
+ {
+ ColumnInfoRecord columnInfoRecord = new ColumnInfoRecord( );
+ columnInfoRecord.setFirstColumn(firstCol);
+ columnInfoRecord.setLastColumn(lastCol);
+ return columnInfoRecord;
+ }
+} \ No newline at end of file