aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ddf
diff options
context:
space:
mode:
authorGlen Stampoultzis <glens@apache.org>2004-04-19 10:55:45 +0000
committerGlen Stampoultzis <glens@apache.org>2004-04-19 10:55:45 +0000
commit11dc64a9605fc821666069d4b387362ec358956f (patch)
treec67422c7e19e60fdfa1282b5d91932cf188b60c1 /src/testcases/org/apache/poi/ddf
parent7081acbc742cb155dd851336248adf4ce8cdd2a4 (diff)
downloadpoi-11dc64a9605fc821666069d4b387362ec358956f.tar.gz
poi-11dc64a9605fc821666069d4b387362ec358956f.zip
Some tests were checkin to the wrong source tree
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353550 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ddf')
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java104
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java127
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java30
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java90
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java108
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java74
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java115
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java79
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java106
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java157
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java59
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java79
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java90
-rw-r--r--src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java90
-rw-r--r--src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java123
15 files changed, 1431 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java b/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java
new file mode 100644
index 0000000000..044438ccda
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherBSERecord.java
@@ -0,0 +1,104 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+import java.io.IOException;
+
+public class TestEscherBSERecord extends TestCase
+{
+ public void testFillFields() throws Exception
+ {
+ String data = "01 00 00 00 24 00 00 00 05 05 01 02 03 04 " +
+ " 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 01 00 00 00 " +
+ " 00 00 02 00 00 00 03 00 00 00 04 05 06 07";
+ EscherBSERecord r = new EscherBSERecord();
+ int bytesWritten = r.fillFields( HexRead.readFromString( data ), 0, new DefaultEscherRecordFactory() );
+ assertEquals( 44, bytesWritten );
+ assertEquals( (short) 0x0001, r.getOptions() );
+ assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeWin32() );
+ assertEquals( EscherBSERecord.BT_JPEG, r.getBlipTypeMacOS() );
+ assertEquals( "[01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]", HexDump.toHex( r.getUid() ) );
+ assertEquals( (short) 1, r.getTag() );
+ assertEquals( 2, r.getRef() );
+ assertEquals( 3, r.getOffset() );
+ assertEquals( (byte) 4, r.getUsage() );
+ assertEquals( (byte) 5, r.getName() );
+ assertEquals( (byte) 6, r.getUnused2() );
+ assertEquals( (byte) 7, r.getUnused3() );
+ assertEquals( 0, r.getRemainingData().length );
+ }
+
+ public void testSerialize() throws Exception
+ {
+ EscherBSERecord r = createRecord();
+
+ byte[] data = new byte[8 + 36];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 44, bytesWritten );
+ assertEquals( "[01, 00, 00, 00, 24, 00, 00, 00, 05, 05, 01, 02, 03, 04, " +
+ "05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, 01, 00, 00, 00, " +
+ "00, 00, 02, 00, 00, 00, 03, 00, 00, 00, 04, 05, 06, 07, ]",
+ HexDump.toHex( data ) );
+
+ }
+
+ private EscherBSERecord createRecord() throws IOException
+ {
+ EscherBSERecord r = new EscherBSERecord();
+ r.setOptions( (short) 0x0001 );
+ r.setBlipTypeWin32( EscherBSERecord.BT_JPEG );
+ r.setBlipTypeMacOS( EscherBSERecord.BT_JPEG );
+ r.setUid( HexRead.readFromString( "01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00" ) );
+ r.setTag( (short) 1 );
+ r.setRef( 2 );
+ r.setOffset( 3 );
+ r.setUsage( (byte) 4 );
+ r.setName( (byte) 5 );
+ r.setUnused2( (byte) 6 );
+ r.setUnused3( (byte) 7 );
+ r.setRemainingData( new byte[0] );
+ return r;
+
+ }
+
+ public void testToString() throws Exception
+ {
+ EscherBSERecord record = createRecord();
+ String nl = System.getProperty("line.separator");
+ assertEquals( "org.apache.poi.ddf.EscherBSERecord:" + nl +
+ " RecordId: 0xF007" + nl +
+ " Options: 0x0001" + nl +
+ " BlipTypeWin32: 5" + nl +
+ " BlipTypeMacOS: 5" + nl +
+ " SUID: [01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 00, ]" + nl +
+ " Tag: 1" + nl +
+ " Size: 0" + nl +
+ " Ref: 2" + nl +
+ " Offset: 3" + nl +
+ " Usage: 4" + nl +
+ " Name: 5" + nl +
+ " Unused2: 6" + nl +
+ " Unused3: 7" + nl +
+ " Extra Data:" + nl, record.toString() );
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java
new file mode 100644
index 0000000000..8b82135c41
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java
@@ -0,0 +1,127 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherBlipRecord extends TestCase
+{
+ private String dataStr;
+ private byte[] data;
+
+ protected void setUp() throws Exception
+ {
+ dataStr = "2C 15 18 F0 34 00 00 00 01 01 01 01 01 01 01 01 " +
+ "01 01 01 01 01 01 01 01 06 00 00 00 03 00 00 00 " +
+ "01 00 00 00 04 00 00 00 02 00 00 00 0A 00 00 00 " +
+ "0B 00 00 00 05 00 00 00 08 07 01 02";
+ data = HexRead.readFromString(dataStr);
+ }
+
+ public void testSerialize() throws Exception
+ {
+ EscherBlipRecord r = new EscherBlipRecord();
+ r.setBoundaryLeft(1);
+ r.setBoundaryHeight(2);
+ r.setBoundaryTop(3);
+ r.setBoundaryWidth(4);
+ r.setCacheOfSavedSize(5);
+ r.setCacheOfSize(6);
+ r.setFilter((byte)7);
+ r.setCompressionFlag((byte)8);
+ r.setSecondaryUID(new byte[] { (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01,
+ (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01,
+ (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01,
+ (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, });
+ r.setWidth(10);
+ r.setHeight(11);
+ r.setRecordId(EscherBlipRecord.RECORD_ID_START);
+ r.setOptions((short)5420);
+ r.setData(new byte[] { (byte)0x01, (byte)0x02 } );
+
+ byte[] buf = new byte[r.getRecordSize()];
+ r.serialize(0, buf, new NullEscherSerializationListener() );
+
+ assertEquals("[2C, 15, 18, F0, 26, 00, 00, 00, " +
+ "01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, " +
+ "06, 00, 00, 00, " + // field_2_cacheOfSize
+ "03, 00, 00, 00, " + // field_3_boundaryTop
+ "01, 00, 00, 00, " + // field_4_boundaryLeft
+ "04, 00, 00, 00, " + // field_5_boundaryWidth
+ "02, 00, 00, 00, " + // field_6_boundaryHeight
+ "0A, 00, 00, 00, " + // field_7_x
+ "0B, 00, 00, 00, " + // field_8_y
+ "05, 00, 00, 00, " + // field_9_cacheOfSavedSize
+ "08, " + // field_10_compressionFlag
+ "07, " + // field_11_filter
+ "01, 02, ]", // field_12_data
+ HexDump.toHex(buf));
+ assertEquals(60, r.getRecordSize() );
+
+ }
+
+ public void testFillFields() throws Exception
+ {
+ EscherBlipRecord r = new EscherBlipRecord();
+ r.fillFields( data, 0, new DefaultEscherRecordFactory());
+
+ assertEquals( EscherBlipRecord.RECORD_ID_START, r.getRecordId() );
+ assertEquals( 1, r.getBoundaryLeft() );
+ assertEquals( 2, r.getBoundaryHeight() );
+ assertEquals( 3, r.getBoundaryTop() );
+ assertEquals( 4, r.getBoundaryWidth() );
+ assertEquals( 5, r.getCacheOfSavedSize() );
+ assertEquals( 6, r.getCacheOfSize() );
+ assertEquals( 7, r.getFilter() );
+ assertEquals( 8, r.getCompressionFlag() );
+ assertEquals( "[01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]", HexDump.toHex(r.getSecondaryUID() ) );
+ assertEquals( 10, r.getWidth() );
+ assertEquals( 11, r.getHeight() );
+ assertEquals( (short)5420, r.getOptions() );
+ assertEquals( "[01, 02, ]", HexDump.toHex( r.getData() ) );
+ }
+
+ public void testToString() throws Exception
+ {
+ EscherBlipRecord r = new EscherBlipRecord();
+ r.fillFields( data, 0, new DefaultEscherRecordFactory() );
+
+ String nl = System.getProperty("line.separator");
+
+ assertEquals( "org.apache.poi.ddf.EscherBlipRecord:" + nl +
+ " RecordId: 0xF018" + nl +
+ " Options: 0x152C" + nl +
+ " Secondary UID: [01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, ]" + nl +
+ " CacheOfSize: 6" + nl +
+ " BoundaryTop: 3" + nl +
+ " BoundaryLeft: 1" + nl +
+ " BoundaryWidth: 4" + nl +
+ " BoundaryHeight: 2" + nl +
+ " X: 10" + nl +
+ " Y: 11" + nl +
+ " CacheOfSavedSize: 5" + nl +
+ " CompressionFlag: 8" + nl +
+ " Filter: 7" + nl +
+ " Data:" + nl +
+ "00000000 01 02 .." + nl
+ , r.toString() );
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java b/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java
new file mode 100644
index 0000000000..473e03cc62
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherBoolProperty.java
@@ -0,0 +1,30 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+
+public class TestEscherBoolProperty extends TestCase
+{
+ public void testToString() throws Exception
+ {
+ EscherBoolProperty p = new EscherBoolProperty((short)1, 1);
+ assertEquals("propNum: 1, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)", p.toString());
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java
new file mode 100644
index 0000000000..bca9f1926f
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherChildAnchorRecord.java
@@ -0,0 +1,90 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherChildAnchorRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherChildAnchorRecord r = createRecord();
+
+ byte[] data = new byte[8 + 16];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 24, bytesWritten );
+ assertEquals( "[01, 00, " +
+ "0F, F0, " +
+ "10, 00, 00, 00, " +
+ "01, 00, 00, 00, " +
+ "02, 00, 00, 00, " +
+ "03, 00, 00, 00, " +
+ "04, 00, 00, 00, ]", HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "01 00 " +
+ "0F F0 " +
+ "10 00 00 00 " +
+ "01 00 00 00 " +
+ "02 00 00 00 " +
+ "03 00 00 00 " +
+ "04 00 00 00 ";
+
+ byte[] data = HexRead.readFromString( hexData );
+ EscherChildAnchorRecord r = new EscherChildAnchorRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 24, bytesWritten );
+ assertEquals( 1, r.getDx1() );
+ assertEquals( 2, r.getDy1() );
+ assertEquals( 3, r.getDx2() );
+ assertEquals( 4, r.getDy2() );
+ assertEquals( (short) 0x0001, r.getOptions() );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty( "line.separator" );
+
+ String expected = "org.apache.poi.ddf.EscherChildAnchorRecord:" + nl +
+ " RecordId: 0xF00F" + nl +
+ " Options: 0x0001" + nl +
+ " X1: 1" + nl +
+ " Y1: 2" + nl +
+ " X2: 3" + nl +
+ " Y2: 4" + nl;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherChildAnchorRecord createRecord()
+ {
+ EscherChildAnchorRecord r = new EscherChildAnchorRecord();
+ r.setRecordId( EscherChildAnchorRecord.RECORD_ID );
+ r.setOptions( (short) 0x0001 );
+ r.setDx1( 1 );
+ r.setDy1( 2 );
+ r.setDx2( 3 );
+ r.setDy2( 4 );
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java
new file mode 100644
index 0000000000..b9709a5b2b
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherClientAnchorRecord.java
@@ -0,0 +1,108 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherClientAnchorRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherClientAnchorRecord r = createRecord();
+
+ byte[] data = new byte[8 + 18 + 2];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 28, bytesWritten );
+ assertEquals( "[01, 00, " +
+ "10, F0, " +
+ "14, 00, 00, 00, " +
+ "4D, 00, 37, 00, 21, 00, 58, 00, " +
+ "0B, 00, 2C, 00, 16, 00, 63, 00, " +
+ "42, 00, " +
+ "FF, DD, ]", HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "01 00 " +
+ "10 F0 " +
+ "14 00 00 00 " +
+ "4D 00 37 00 21 00 58 00 " +
+ "0B 00 2C 00 16 00 63 00 " +
+ "42 00 " +
+ "FF DD";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherClientAnchorRecord r = new EscherClientAnchorRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 28, bytesWritten );
+ assertEquals( (short) 55, r.getCol1() );
+ assertEquals( (short) 44, r.getCol2() );
+ assertEquals( (short) 33, r.getDx1() );
+ assertEquals( (short) 22, r.getDx2() );
+ assertEquals( (short) 11, r.getDy1() );
+ assertEquals( (short) 66, r.getDy2() );
+ assertEquals( (short) 77, r.getFlag() );
+ assertEquals( (short) 88, r.getRow1() );
+ assertEquals( (short) 99, r.getRow2() );
+ assertEquals( (short) 0x0001, r.getOptions() );
+ assertEquals( (byte) 0xFF, r.getRemainingData()[0] );
+ assertEquals( (byte) 0xDD, r.getRemainingData()[1] );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherClientAnchorRecord:" + nl +
+ " RecordId: 0xF010" + nl +
+ " Options: 0x0001" + nl +
+ " Flag: 77" + nl +
+ " Col1: 55" + nl +
+ " DX1: 33" + nl +
+ " Row1: 88" + nl +
+ " DY1: 11" + nl +
+ " Col2: 44" + nl +
+ " DX2: 22" + nl +
+ " Row2: 99" + nl +
+ " DY2: 66" + nl +
+ " Extra Data:" + nl +
+ "00000000 FF DD .." + nl;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherClientAnchorRecord createRecord()
+ {
+ EscherClientAnchorRecord r = new EscherClientAnchorRecord();
+ r.setCol1( (short) 55 );
+ r.setCol2( (short) 44 );
+ r.setDx1( (short) 33 );
+ r.setDx2( (short) 22 );
+ r.setDy1( (short) 11 );
+ r.setDy2( (short) 66 );
+ r.setFlag( (short) 77 );
+ r.setRow1( (short) 88 );
+ r.setRow2( (short) 99 );
+ r.setOptions( (short) 0x0001 );
+ r.setRemainingData( new byte[]{(byte) 0xFF, (byte) 0xDD} );
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java
new file mode 100644
index 0000000000..b33a790fd2
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherClientDataRecord.java
@@ -0,0 +1,74 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherClientDataRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherClientDataRecord r = createRecord();
+
+ byte[] data = new byte[8];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 8, bytesWritten );
+ assertEquals( "[02, 00, " +
+ "11, F0, " +
+ "00, 00, 00, 00, ]",
+ HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "02 00 " +
+ "11 F0 " +
+ "00 00 00 00 ";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherClientDataRecord r = new EscherClientDataRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 8, bytesWritten );
+ assertEquals( (short)0xF011, r.getRecordId() );
+ assertEquals( "[]", HexDump.toHex(r.getRemainingData()) );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherClientDataRecord:" + nl +
+ " RecordId: 0xF011" + nl +
+ " Options: 0x0002" + nl +
+ " Extra Data:" + nl +
+ "" ;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherClientDataRecord createRecord()
+ {
+ EscherClientDataRecord r = new EscherClientDataRecord();
+ r.setOptions( (short) 0x0002 );
+ r.setRecordId( EscherClientDataRecord.RECORD_ID );
+ r.setRemainingData( new byte[] {} );
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java
new file mode 100644
index 0000000000..c85ece1ccc
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java
@@ -0,0 +1,115 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.HexDump;
+
+public class TestEscherContainerRecord extends TestCase
+{
+ public void testFillFields() throws Exception
+ {
+ EscherRecordFactory f = new DefaultEscherRecordFactory();
+ byte[] data = HexRead.readFromString( "0F 02 11 F1 00 00 00 00" );
+ EscherRecord r = f.createRecord( data, 0 );
+ r.fillFields( data, 0, f );
+ assertTrue( r instanceof EscherContainerRecord );
+ assertEquals( (short) 0x020F, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+
+ data = HexRead.readFromString( "0F 02 11 F1 08 00 00 00" +
+ " 02 00 22 F2 00 00 00 00" );
+ r = f.createRecord( data, 0 );
+ r.fillFields( data, 0, f );
+ EscherRecord c = r.getChild( 0 );
+ assertFalse( c instanceof EscherContainerRecord );
+ assertEquals( (short) 0x0002, c.getOptions() );
+ assertEquals( (short) 0xF222, c.getRecordId() );
+ }
+
+ public void testSerialize() throws Exception
+ {
+ UnknownEscherRecord r = new UnknownEscherRecord();
+ r.setOptions( (short) 0x123F );
+ r.setRecordId( (short) 0xF112 );
+ byte[] data = new byte[8];
+ r.serialize( 0, data, new NullEscherSerializationListener() );
+
+ assertEquals( "[3F, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+
+ EscherRecord childRecord = new UnknownEscherRecord();
+ childRecord.setOptions( (short) 0x9999 );
+ childRecord.setRecordId( (short) 0xFF01 );
+ r.addChildRecord( childRecord );
+ data = new byte[16];
+ r.serialize( 0, data, new NullEscherSerializationListener() );
+
+ assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+
+ }
+
+ public void testToString() throws Exception
+ {
+ EscherContainerRecord r = new EscherContainerRecord();
+ r.setRecordId( EscherContainerRecord.SP_CONTAINER );
+ r.setOptions( (short) 0x000F );
+ String nl = System.getProperty( "line.separator" );
+ assertEquals( "org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
+ " isContainer: true" + nl +
+ " options: 0x000F" + nl +
+ " recordId: 0xF004" + nl +
+ " numchildren: 0" + nl
+ , r.toString() );
+
+ EscherOptRecord r2 = new EscherOptRecord();
+ r2.setOptions( (short) 0x9876 );
+ r2.setRecordId( EscherOptRecord.RECORD_ID );
+
+ r.addChildRecord( r2 );
+ String expected = "org.apache.poi.ddf.EscherContainerRecord (SpContainer):" + nl +
+ " isContainer: true" + nl +
+ " options: 0x000F" + nl +
+ " recordId: 0xF004" + nl +
+ " numchildren: 1" + nl +
+ " children: " + nl +
+ "org.apache.poi.ddf.EscherOptRecord:" + nl +
+ " isContainer: false" + nl +
+ " options: 0x0003" + nl +
+ " recordId: 0xF00B" + nl +
+ " numchildren: 0" + nl +
+ " properties:" + nl;
+ assertEquals( expected, r.toString() );
+
+ }
+
+ public void testGetRecordSize() throws Exception
+ {
+ EscherContainerRecord r = new EscherContainerRecord();
+ r.addChildRecord(new EscherRecord()
+ {
+ public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory ) { return 0; }
+ public int serialize( int offset, byte[] data, EscherSerializationListener listener ) { return 0; }
+ public int getRecordSize() { return 10; }
+ public String getRecordName() { return ""; }
+ } );
+
+ assertEquals(18, r.getRecordSize());
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java
new file mode 100644
index 0000000000..58a65e302f
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherDgRecord.java
@@ -0,0 +1,79 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherDgRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherDgRecord r = createRecord();
+
+ byte[] data = new byte[16];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 16, bytesWritten );
+ assertEquals( "[10, 00, " +
+ "08, F0, " +
+ "08, 00, 00, 00, " +
+ "02, 00, 00, 00, " + // num shapes in drawing
+ "01, 04, 00, 00, ]", // The last MSOSPID given to an SP in this DG
+ HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "10 00 " +
+ "08 F0 " +
+ "08 00 00 00 " +
+ "02 00 00 00 " +
+ "01 04 00 00 ";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherDgRecord r = new EscherDgRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 16, bytesWritten );
+ assertEquals( 2, r.getNumShapes() );
+ assertEquals( 1025, r.getLastMSOSPID() );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherDgRecord:" + nl +
+ " RecordId: 0xF008" + nl +
+ " Options: 0x0010" + nl +
+ " NumShapes: 2" + nl +
+ " LastMSOSPID: 1025" + nl;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherDgRecord createRecord()
+ {
+ EscherDgRecord r = new EscherDgRecord();
+ r.setOptions( (short) 0x0010 );
+ r.setRecordId( EscherDgRecord.RECORD_ID );
+ r.setNumShapes(2);
+ r.setLastMSOSPID(1025);
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java
new file mode 100644
index 0000000000..259f8c387d
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherDggRecord.java
@@ -0,0 +1,106 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherDggRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ 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 void testFillFields() throws Exception
+ {
+ 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 void testToString() throws Exception
+ {
+ 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() );
+ }
+
+ private EscherDggRecord createRecord()
+ {
+ 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 void testGetRecordSize() throws Exception
+ {
+ EscherDggRecord r = new EscherDggRecord();
+ r.setFileIdClusters(new EscherDggRecord.FileIdCluster[] { new EscherDggRecord.FileIdCluster(0,0) } );
+ assertEquals(32,r.getRecordSize());
+
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java
new file mode 100644
index 0000000000..8795de77ad
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherOptRecord.java
@@ -0,0 +1,157 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.HexDump;
+
+import java.io.IOException;
+
+public class TestEscherOptRecord extends TestCase
+{
+
+ public void testFillFields() throws Exception
+ {
+ checkFillFieldsSimple();
+ checkFillFieldsComplex();
+ }
+
+ private void checkFillFieldsComplex() throws IOException
+ {
+ String dataStr = "33 00 " +
+ "0B F0 " +
+ "14 00 00 00 " +
+ "BF 00 01 00 00 00 " +
+ "01 80 02 00 00 00 " +
+ "BF 00 01 00 00 00 " +
+ "01 02";
+
+ EscherOptRecord r = new EscherOptRecord();
+ r.fillFields( HexRead.readFromString( dataStr ), new DefaultEscherRecordFactory() );
+ assertEquals( (short) 0x0033, r.getOptions() );
+ assertEquals( (short) 0xF00B, r.getRecordId() );
+ assertEquals( 3, r.getEscherProperties().size() );
+ EscherBoolProperty prop1 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
+ EscherComplexProperty prop2 = new EscherComplexProperty( (short) 1, false, new byte[] { 0x01, 0x02 } );
+ EscherBoolProperty prop3 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
+ assertEquals( prop1, r.getEscherProperty( 0 ) );
+ assertEquals( prop2, r.getEscherProperty( 1 ) );
+ assertEquals( prop3, r.getEscherProperty( 2 ) );
+
+ }
+
+ private void checkFillFieldsSimple()
+ throws IOException
+ {
+ String dataStr = "33 00 " + // options
+ "0B F0 " + // recordid
+ "12 00 00 00 " + // remaining bytes
+ "BF 00 08 00 08 00 " +
+ "81 01 09 00 00 08 " +
+ "C0 01 40 00 00 08";
+
+ EscherOptRecord r = new EscherOptRecord();
+ r.fillFields( HexRead.readFromString( dataStr ), new DefaultEscherRecordFactory() );
+ assertEquals( (short) 0x0033, r.getOptions() );
+ assertEquals( (short) 0xF00B, r.getRecordId() );
+ assertEquals( 3, r.getEscherProperties().size() );
+ EscherBoolProperty prop1 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296 );
+ EscherRGBProperty prop2 = new EscherRGBProperty( EscherProperties.FILL__FILLCOLOR, 0x08000009 );
+ EscherRGBProperty prop3 = new EscherRGBProperty( EscherProperties.LINESTYLE__COLOR, 0x08000040 );
+ assertEquals( prop1, r.getEscherProperty( 0 ) );
+ assertEquals( prop2, r.getEscherProperty( 1 ) );
+ assertEquals( prop3, r.getEscherProperty( 2 ) );
+ }
+
+ public void testSerialize() throws Exception
+ {
+ checkSerializeSimple();
+ checkSerializeComplex();
+ }
+
+ private void checkSerializeComplex()
+ {
+ //Complex escher record
+ EscherOptRecord r = new EscherOptRecord();
+ r.setOptions( (short) 0x0033 );
+ r.setRecordId( (short) 0xF00B );
+ EscherBoolProperty prop1 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
+ EscherComplexProperty prop2 = new EscherComplexProperty( (short) 1, false, new byte[] { 0x01, 0x02 } );
+ EscherBoolProperty prop3 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
+ r.addEscherProperty( prop1 );
+ r.addEscherProperty( prop2 );
+ r.addEscherProperty( prop3 );
+
+ byte[] data = new byte[28];
+ int bytesWritten = r.serialize(0, data, new NullEscherSerializationListener() );
+ assertEquals( 28, bytesWritten );
+ String dataStr = "[33, 00, " +
+ "0B, F0, " +
+ "14, 00, 00, 00, " +
+ "BF, 00, 01, 00, 00, 00, " +
+ "01, 80, 02, 00, 00, 00, " +
+ "BF, 00, 01, 00, 00, 00, " +
+ "01, 02, ]";
+ assertEquals( dataStr, HexDump.toHex(data) );
+
+ }
+
+ private void checkSerializeSimple()
+ {
+ EscherOptRecord r = new EscherOptRecord();
+ r.setOptions( (short) 0x0033 );
+ r.setRecordId( (short) 0xF00B );
+ EscherBoolProperty prop1 = new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 1 );
+ EscherRGBProperty prop2 = new EscherRGBProperty( EscherProperties.FILL__FILLCOLOR, 0x08000009 );
+ EscherRGBProperty prop3 = new EscherRGBProperty( EscherProperties.LINESTYLE__COLOR, 0x08000040 );
+ r.addEscherProperty( prop1 );
+ r.addEscherProperty( prop2 );
+ r.addEscherProperty( prop3 );
+
+ byte[] data = new byte[26];
+ int bytesWritten = r.serialize(0, data, new NullEscherSerializationListener() );
+ String dataStr = "[33, 00, " +
+ "0B, F0, " +
+ "12, 00, 00, 00, " +
+ "BF, 00, 01, 00, 00, 00, " +
+ "81, 01, 09, 00, 00, 08, " +
+ "C0, 01, 40, 00, 00, 08, ]";
+ assertEquals( dataStr, HexDump.toHex(data) );
+ assertEquals( 26, bytesWritten );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+ EscherOptRecord r = new EscherOptRecord();
+ r.setOptions((short)0x000F);
+ r.setRecordId(EscherOptRecord.RECORD_ID);
+ EscherProperty prop1 = new EscherBoolProperty((short)1, 1);
+ r.addEscherProperty(prop1);
+ String expected = "org.apache.poi.ddf.EscherOptRecord:" + nl +
+ " isContainer: true" + nl +
+ " options: 0x0013" + nl +
+ " recordId: 0x" + HexDump.toHex(EscherOptRecord.RECORD_ID) + nl +
+ " numchildren: 0" + nl +
+ " properties:" + nl +
+ " propNum: 1, propName: unknown, complex: false, blipId: false, value: 1 (0x00000001)" + nl;
+ assertEquals( expected, r.toString());
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java b/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java
new file mode 100644
index 0000000000..d24b3f39b7
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherPropertyFactory.java
@@ -0,0 +1,59 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+
+import java.util.List;
+
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.HexDump;
+
+/**
+ * @author Glen Stampoultzis (glens @ superlinksoftware.com)
+ */
+public class TestEscherPropertyFactory extends TestCase
+{
+ public void testCreateProperties() throws Exception
+ {
+ String dataStr = "41 C1 " + // propid, complex ind
+ "03 00 00 00 " + // size of complex property
+ "01 00 " + // propid, complex ind
+ "00 00 00 00 " + // value
+ "41 C1 " + // propid, complex ind
+ "03 00 00 00 " + // size of complex property
+ "01 02 03 " +
+ "01 02 03 "
+ ;
+ byte[] data = HexRead.readFromString( dataStr );
+ EscherPropertyFactory f = new EscherPropertyFactory();
+ List props = f.createProperties( data, 0, (short)3 );
+ EscherComplexProperty p1 = (EscherComplexProperty) props.get( 0 );
+ assertEquals( (short)0xC141, p1.getId() );
+ assertEquals( "[01, 02, 03, ]", HexDump.toHex( p1.getComplexData() ) );
+
+ EscherComplexProperty p3 = (EscherComplexProperty) props.get( 2 );
+ assertEquals( (short)0xC141, p3.getId() );
+ assertEquals( "[01, 02, 03, ]", HexDump.toHex( p3.getComplexData() ) );
+
+
+ }
+
+
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java
new file mode 100644
index 0000000000..43a00ee5ea
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherSpRecord.java
@@ -0,0 +1,79 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherSpRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherSpRecord r = createRecord();
+
+ byte[] data = new byte[16];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 16, bytesWritten );
+ assertEquals( "[02, 00, " +
+ "0A, F0, " +
+ "08, 00, 00, 00, " +
+ "00, 04, 00, 00, " +
+ "05, 00, 00, 00, ]",
+ HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "02 00 " +
+ "0A F0 " +
+ "08 00 00 00 " +
+ "00 04 00 00 " +
+ "05 00 00 00 ";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherSpRecord r = new EscherSpRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 16, bytesWritten );
+ assertEquals( 0x0400, r.getShapeId() );
+ assertEquals( 0x05, r.getFlags() );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherSpRecord:" + nl +
+ " RecordId: 0xF00A" + nl +
+ " Options: 0x0002" + nl +
+ " ShapeId: 1024" + nl +
+ " Flags: GROUP|PATRIARCH (0x00000005)" + nl;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherSpRecord createRecord()
+ {
+ EscherSpRecord r = new EscherSpRecord();
+ r.setOptions( (short) 0x0002 );
+ r.setRecordId( EscherSpRecord.RECORD_ID );
+ r.setShapeId(0x0400);
+ r.setFlags(0x05);
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java
new file mode 100644
index 0000000000..778cd456a6
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherSpgrRecord.java
@@ -0,0 +1,90 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherSpgrRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherSpgrRecord r = createRecord();
+
+ byte[] data = new byte[24];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 24, bytesWritten );
+ assertEquals( "[10, 00, " +
+ "09, F0, " +
+ "10, 00, 00, 00, " +
+ "01, 00, 00, 00, " + // x
+ "02, 00, 00, 00, " + // y
+ "03, 00, 00, 00, " + // width
+ "04, 00, 00, 00, ]", // height
+ HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "10 00 " +
+ "09 F0 " +
+ "10 00 00 00 " +
+ "01 00 00 00 " +
+ "02 00 00 00 " +
+ "03 00 00 00 " +
+ "04 00 00 00 ";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherSpgrRecord r = new EscherSpgrRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 24, bytesWritten );
+ assertEquals( 1, r.getRectX1() );
+ assertEquals( 2, r.getRectY1() );
+ assertEquals( 3, r.getRectX2() );
+ assertEquals( 4, r.getRectY2() );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherSpgrRecord:" + nl +
+ " RecordId: 0xF009" + nl +
+ " Options: 0x0010" + nl +
+ " RectX: 1" + nl +
+ " RectY: 2" + nl +
+ " RectWidth: 3" + nl +
+ " RectHeight: 4" + nl;
+ ;
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherSpgrRecord createRecord()
+ {
+ EscherSpgrRecord r = new EscherSpgrRecord();
+ r.setOptions( (short) 0x0010 );
+ r.setRecordId( EscherSpgrRecord.RECORD_ID );
+ r.setRectX1(1);
+ r.setRectY1(2);
+ r.setRectX2(3);
+ r.setRectY2(4);
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java b/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java
new file mode 100644
index 0000000000..58bd63b1d5
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestEscherSplitMenuColorsRecord.java
@@ -0,0 +1,90 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+
+public class TestEscherSplitMenuColorsRecord extends TestCase
+{
+ public void testSerialize() throws Exception
+ {
+ EscherSplitMenuColorsRecord r = createRecord();
+
+ byte[] data = new byte[24];
+ int bytesWritten = r.serialize( 0, data, new NullEscherSerializationListener() );
+ assertEquals( 24, bytesWritten );
+ assertEquals( "[40, 00, " +
+ "1E, F1, " +
+ "10, 00, 00, 00, " +
+ "02, 04, 00, 00, " +
+ "02, 00, 00, 00, " +
+ "02, 00, 00, 00, " +
+ "01, 00, 00, 00, ]",
+ HexDump.toHex( data ) );
+ }
+
+ public void testFillFields() throws Exception
+ {
+ String hexData = "40 00 " +
+ "1E F1 " +
+ "10 00 00 00 " +
+ "02 04 00 00 " +
+ "02 00 00 00 " +
+ "02 00 00 00 " +
+ "01 00 00 00 ";
+ byte[] data = HexRead.readFromString( hexData );
+ EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
+ int bytesWritten = r.fillFields( data, new DefaultEscherRecordFactory() );
+
+ assertEquals( 24, bytesWritten );
+ assertEquals( 0x0402, r.getColor1() );
+ assertEquals( 0x02, r.getColor2() );
+ assertEquals( 0x02, r.getColor3() );
+ assertEquals( 0x01, r.getColor4() );
+ }
+
+ public void testToString() throws Exception
+ {
+ String nl = System.getProperty("line.separator");
+
+ String expected = "org.apache.poi.ddf.EscherSplitMenuColorsRecord:" + nl +
+ " RecordId: 0xF11E" + nl +
+ " Options: 0x0040" + nl +
+ " Color1: 0x00000402" + nl +
+ " Color2: 0x00000002" + nl +
+ " Color3: 0x00000002" + nl +
+ " Color4: 0x00000001" + nl +
+ "";
+ assertEquals( expected, createRecord().toString() );
+ }
+
+ private EscherSplitMenuColorsRecord createRecord()
+ {
+ EscherSplitMenuColorsRecord r = new EscherSplitMenuColorsRecord();
+ r.setOptions( (short) 0x0040 );
+ r.setRecordId( EscherSplitMenuColorsRecord.RECORD_ID );
+ r.setColor1( 0x402 );
+ r.setColor2( 0x2 );
+ r.setColor3( 0x2 );
+ r.setColor4( 0x1 );
+ return r;
+ }
+
+}
diff --git a/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java b/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java
new file mode 100644
index 0000000000..32232aea11
--- /dev/null
+++ b/src/testcases/org/apache/poi/ddf/TestUnknownEscherRecord.java
@@ -0,0 +1,123 @@
+
+/* ====================================================================
+ Copyright 2002-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.ddf;
+
+import junit.framework.TestCase;
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.HexDump;
+
+public class TestUnknownEscherRecord extends TestCase
+{
+ public void testFillFields() throws Exception
+ {
+ String testData =
+ "0F 02 " + // options
+ "11 F1 " + // record id
+ "00 00 00 00"; // remaining bytes
+
+ UnknownEscherRecord r = new UnknownEscherRecord();
+ EscherRecordFactory factory = new DefaultEscherRecordFactory();
+ r.fillFields( HexRead.readFromString( testData ), factory );
+
+ assertEquals( 0x020F, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+ assertTrue( r.isContainerRecord() );
+ assertEquals( 8, r.getRecordSize() );
+ assertEquals( 0, r.getChildRecords().size() );
+ assertEquals( 0, r.getData().length );
+
+ testData =
+ "00 02 " + // options
+ "11 F1 " + // record id
+ "04 00 00 00 " + // remaining bytes
+ "01 02 03 04";
+
+ r = new UnknownEscherRecord();
+ r.fillFields( HexRead.readFromString( testData ), factory );
+
+ assertEquals( 0x0200, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+ assertEquals( 12, r.getRecordSize() );
+ assertFalse( r.isContainerRecord() );
+ assertEquals( 0, r.getChildRecords().size() );
+ assertEquals( 4, r.getData().length );
+ assertEquals( 1, r.getData()[0] );
+ assertEquals( 2, r.getData()[1] );
+ assertEquals( 3, r.getData()[2] );
+ assertEquals( 4, r.getData()[3] );
+
+ testData =
+ "0F 02 " + // options
+ "11 F1 " + // record id
+ "08 00 00 00 " + // remaining bytes
+ "00 02 " + // options
+ "FF FF " + // record id
+ "00 00 00 00"; // remaining bytes
+
+ r = new UnknownEscherRecord();
+ r.fillFields( HexRead.readFromString( testData ), factory );
+
+ assertEquals( 0x020F, r.getOptions() );
+ assertEquals( (short) 0xF111, r.getRecordId() );
+ assertEquals( 8, r.getRecordSize() );
+ assertTrue( r.isContainerRecord() );
+ assertEquals( 1, r.getChildRecords().size() );
+ assertEquals( (short) 0xFFFF, r.getChild( 0 ).getRecordId() );
+
+ }
+
+ public void testSerialize() throws Exception
+ {
+ UnknownEscherRecord r = new UnknownEscherRecord();
+ r.setOptions( (short) 0x1234 );
+ r.setRecordId( (short) 0xF112 );
+ byte[] data = new byte[8];
+ r.serialize( 0, data, new NullEscherSerializationListener() );
+
+ assertEquals( "[34, 12, 12, F1, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+
+ EscherRecord childRecord = new UnknownEscherRecord();
+ childRecord.setOptions( (short) 0x9999 );
+ childRecord.setRecordId( (short) 0xFF01 );
+ r.addChildRecord( childRecord );
+ r.setOptions( (short) 0x123F );
+ data = new byte[16];
+ r.serialize( 0, data, new NullEscherSerializationListener() );
+
+ assertEquals( "[3F, 12, 12, F1, 08, 00, 00, 00, 99, 99, 01, FF, 00, 00, 00, 00, ]", HexDump.toHex( data ) );
+ }
+
+ public void testToString() throws Exception
+ {
+ UnknownEscherRecord r = new UnknownEscherRecord();
+ r.setOptions( (short) 0x1234 );
+ r.setRecordId( (short) 0xF112 );
+ byte[] data = new byte[8];
+ r.serialize( 0, data, new NullEscherSerializationListener() );
+
+ String nl = System.getProperty("line.separator");
+ assertEquals( "org.apache.poi.ddf.UnknownEscherRecord:" + nl +
+ " isContainer: false" + nl +
+ " options: 0x1234" + nl +
+ " recordId: 0xF112" + nl +
+ " numchildren: 0" + nl
+ , r.toString() );
+ }
+
+
+}