You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 20:15:01 UTC
svn commit: r777204 [18/21] - in /poi/trunk/src/scratchpad:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/
src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/
src/org/apac...
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExControl.java Thu May 21 18:12:22 2009
@@ -1,127 +1,124 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link org.apache.poi.hslf.record.ExControl} works properly
- *
- * @author Yegor Kozlov
- */
-public class TestExControl extends TestCase {
-
- // From a real file (embedded SWF control)
- /*
- <ExControl info="15" type="4078" size="218" offset="76" header="0F 00 EE 0F DA 00 00 00 ">
- <ExControlAtom info="0" type="4091" size="4" offset="84" header="00 00 FB 0F 04 00 00 00 ">
- 00 01 00 00
- </ExControlAtom>
- <ExOleObjAtom info="1" type="4035" size="24" offset="96" header="01 00 C3 0F 18 00 00 00 ">
- 01 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 00 96 13 00
- </ExOleObjAtom>
- <CString info="16" type="4026" size="44" offset="128" header="10 00 BA 0F 2C 00 00 00 ">
- 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
- 00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
- </CString>
- <CString info="32" type="4026" size="62" offset="180" header="20 00 BA 0F 3E 00 00 00 ">
- 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00 6C 00 61 00 73
- 00 68 00 2E 00 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00
- 6C 00 61 00 73 00 68 00 2E 00 39 00
- </CString>
- <CString info="48" type="4026" size="44" offset="250" header="30 00 BA 0F 2C 00 00 00 ">
- 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
- 00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
- </CString>
- </ExControl>
- */
- private byte[] data = new byte[] {
- 0x0F, 0x00, (byte)0xEE, 0x0F, (byte)0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFB, 0x0F, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00,
- 0x10, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00,
- 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68,
- 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, (byte)0xBA,
- 0x0F, 0x3E, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00,
- 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x53, 0x00, 0x68,
- 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00,
- 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x39, 0x00, 0x30, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00,
- 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20,
- 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00,
- 0x65, 0x00, 0x63, 0x00, 0x74, 0x00
- };
-
- public void testRead() throws Exception {
- ExControl record = new ExControl(data, 0, data.length);
- assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
-
- assertNotNull(record.getExControlAtom());
- assertEquals(256, record.getExControlAtom().getSlideId());
-
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- assertNotNull(oleObj);
- assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
- assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
-
- assertEquals("Shockwave Flash Object", record.getMenuName());
- assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
- assertEquals("Shockwave Flash Object", record.getClipboardName());
- }
-
- public void testWrite() throws Exception {
- ExControl record = new ExControl(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- ExControl record = new ExControl();
- ExControlAtom ctrl = record.getExControlAtom();
- ctrl.setSlideId(256);
-
- ExOleObjAtom oleObj = record.getExOleObjAtom();
- oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
- oleObj.setObjID(1);
- oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
- oleObj.setObjStgDataRef(2);
- oleObj.setOptions(1283584);
-
- record.setMenuName("Shockwave Flash Object");
- record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
- record.setClipboardName("Shockwave Flash Object");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertEquals(data.length, b.length);
- assertTrue(Arrays.equals(data, b));
- }
-
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link org.apache.poi.hslf.record.ExControl} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExControl extends TestCase {
+
+ // From a real file (embedded SWF control)
+ /*
+ <ExControl info="15" type="4078" size="218" offset="76" header="0F 00 EE 0F DA 00 00 00 ">
+ <ExControlAtom info="0" type="4091" size="4" offset="84" header="00 00 FB 0F 04 00 00 00 ">
+ 00 01 00 00
+ </ExControlAtom>
+ <ExOleObjAtom info="1" type="4035" size="24" offset="96" header="01 00 C3 0F 18 00 00 00 ">
+ 01 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 00 96 13 00
+ </ExOleObjAtom>
+ <CString info="16" type="4026" size="44" offset="128" header="10 00 BA 0F 2C 00 00 00 ">
+ 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
+ 00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
+ </CString>
+ <CString info="32" type="4026" size="62" offset="180" header="20 00 BA 0F 3E 00 00 00 ">
+ 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00 6C 00 61 00 73
+ 00 68 00 2E 00 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 46 00
+ 6C 00 61 00 73 00 68 00 2E 00 39 00
+ </CString>
+ <CString info="48" type="4026" size="44" offset="250" header="30 00 BA 0F 2C 00 00 00 ">
+ 53 00 68 00 6F 00 63 00 6B 00 77 00 61 00 76 00 65 00 20 00 46 00 6C 00 61
+ 00 73 00 68 00 20 00 4F 00 62 00 6A 00 65 00 63 00 74 00
+ </CString>
+ </ExControl>
+ */
+ private byte[] data = new byte[] {
+ 0x0F, 0x00, (byte)0xEE, 0x0F, (byte)0xDA, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0xFB, 0x0F, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00,
+ 0x10, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00,
+ 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68,
+ 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00, 0x65, 0x00, 0x63, 0x00, 0x74, 0x00, 0x20, 0x00, (byte)0xBA,
+ 0x0F, 0x3E, 0x00, 0x00, 0x00, 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00,
+ 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x53, 0x00, 0x68,
+ 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x46, 0x00, 0x6C, 0x00,
+ 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x2E, 0x00, 0x39, 0x00, 0x30, 0x00, (byte)0xBA, 0x0F, 0x2C, 0x00, 0x00, 0x00,
+ 0x53, 0x00, 0x68, 0x00, 0x6F, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x65, 0x00, 0x20,
+ 0x00, 0x46, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x20, 0x00, 0x4F, 0x00, 0x62, 0x00, 0x6A, 0x00,
+ 0x65, 0x00, 0x63, 0x00, 0x74, 0x00
+ };
+
+ public void testRead() throws Exception {
+ ExControl record = new ExControl(data, 0, data.length);
+ assertEquals(RecordTypes.ExControl.typeID, record.getRecordType());
+
+ assertNotNull(record.getExControlAtom());
+ assertEquals(256, record.getExControlAtom().getSlideId());
+
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ assertNotNull(oleObj);
+ assertEquals(oleObj.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ assertEquals(oleObj.getType(), ExOleObjAtom.TYPE_CONTROL);
+ assertEquals(oleObj.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+
+ assertEquals("Shockwave Flash Object", record.getMenuName());
+ assertEquals("ShockwaveFlash.ShockwaveFlash.9", record.getProgId());
+ assertEquals("Shockwave Flash Object", record.getClipboardName());
+ }
+
+ public void testWrite() throws Exception {
+ ExControl record = new ExControl(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ ExControl record = new ExControl();
+ ExControlAtom ctrl = record.getExControlAtom();
+ ctrl.setSlideId(256);
+
+ ExOleObjAtom oleObj = record.getExOleObjAtom();
+ oleObj.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ oleObj.setType(ExOleObjAtom.TYPE_CONTROL);
+ oleObj.setObjID(1);
+ oleObj.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+ oleObj.setObjStgDataRef(2);
+ oleObj.setOptions(1283584);
+
+ record.setMenuName("Shockwave Flash Object");
+ record.setProgId("ShockwaveFlash.ShockwaveFlash.9");
+ record.setClipboardName("Shockwave Flash Object");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertEquals(data.length, b.length);
+ assertTrue(Arrays.equals(data, b));
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExMediaAtom.java Thu May 21 18:12:22 2009
@@ -1,91 +1,91 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
- */
-public final class TestExMediaAtom extends TestCase {
- // From a real file
- private static final byte[] data = {
- 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- public void testRead() {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
-
- assertEquals(1, record.getObjectId());
- assertFalse(record.getFlag(ExMediaAtom.fLoop));
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
- assertFalse(record.getFlag(ExMediaAtom.fRewind));
- }
-
- public void testWrite() throws Exception {
- ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
- assertEquals(0, ref.getMask()); //
-
- ExMediaAtom record = new ExMediaAtom();
- record.setObjectId(1);
- record.setFlag(HeadersFootersAtom.fHasDate, false);
- record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- record.setFlag(HeadersFootersAtom.fHasFooter, false);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testFlags() {
- ExMediaAtom record = new ExMediaAtom();
-
- //in a new record all the bits are 0
- for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
-
- record.setFlag(ExMediaAtom.fLoop, true);
- assertTrue(record.getFlag(ExMediaAtom.fLoop));
-
- record.setFlag(ExMediaAtom.fNarration, true);
- assertTrue(record.getFlag(ExMediaAtom.fNarration));
-
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
-
- record.setFlag(ExMediaAtom.fNarration, false);
- assertFalse(record.getFlag(ExMediaAtom.fNarration));
-
- }
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link org.apache.poi.hslf.record.HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExMediaAtom extends TestCase {
+ // From a real file
+ private static final byte[] data = {
+ 0x00, 0x00, (byte)0x04, 0x10, 0x08, 0x00, 0x00, 00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ public void testRead() {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ assertEquals(RecordTypes.ExMediaAtom.typeID, record.getRecordType());
+
+ assertEquals(1, record.getObjectId());
+ assertFalse(record.getFlag(ExMediaAtom.fLoop));
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
+ assertFalse(record.getFlag(ExMediaAtom.fRewind));
+ }
+
+ public void testWrite() throws Exception {
+ ExMediaAtom record = new ExMediaAtom(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ ExMediaAtom ref = new ExMediaAtom(data, 0, data.length);
+ assertEquals(0, ref.getMask()); //
+
+ ExMediaAtom record = new ExMediaAtom();
+ record.setObjectId(1);
+ record.setFlag(HeadersFootersAtom.fHasDate, false);
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ record.setFlag(HeadersFootersAtom.fHasFooter, false);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testFlags() {
+ ExMediaAtom record = new ExMediaAtom();
+
+ //in a new record all the bits are 0
+ for(int i = 0; i < 3; i++) assertFalse(record.getFlag(1 << i));
+
+ record.setFlag(ExMediaAtom.fLoop, true);
+ assertTrue(record.getFlag(ExMediaAtom.fLoop));
+
+ record.setFlag(ExMediaAtom.fNarration, true);
+ assertTrue(record.getFlag(ExMediaAtom.fNarration));
+
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
+
+ record.setFlag(ExMediaAtom.fNarration, false);
+ assertFalse(record.getFlag(ExMediaAtom.fNarration));
+
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjAtom.java Thu May 21 18:12:22 2009
@@ -1,73 +1,72 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link ExOleObjAtom} works properly
- *
- * @author Yegor Kozlov
- */
-public final class TestExOleObjAtom extends TestCase {
- // From a real file (embedded SWF control)
- private byte[] data = {
- 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00 };
-
- public void testRead() {
- ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
- assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
-
- assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);
- assertEquals(record.getObjID(), 1);
- assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
- assertEquals(record.getObjStgDataRef(), 2);
- assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
- }
-
- public void testWrite() throws Exception {
- ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- ExOleObjAtom record = new ExOleObjAtom();
- record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
- record.setType(ExOleObjAtom.TYPE_CONTROL);
- record.setObjID(1);
- record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
- record.setObjStgDataRef(2);
- record.setOptions(1283584);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link ExOleObjAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExOleObjAtom extends TestCase {
+ // From a real file (embedded SWF control)
+ private byte[] data = {
+ 0x01, 0x00, (byte)0xC3, 0x0F, 0x18, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, (byte)0x96, 0x13, 0x00 };
+
+ public void testRead() {
+ ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+ assertEquals(RecordTypes.ExOleObjAtom.typeID, record.getRecordType());
+
+ assertEquals(record.getDrawAspect(), ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ assertEquals(record.getType(), ExOleObjAtom.TYPE_CONTROL);
+ assertEquals(record.getObjID(), 1);
+ assertEquals(record.getSubType(), ExOleObjAtom.SUBTYPE_DEFAULT);
+ assertEquals(record.getObjStgDataRef(), 2);
+ assertEquals(record.getOptions(), 1283584); //ther meaning is unknown
+ }
+
+ public void testWrite() throws Exception {
+ ExOleObjAtom record = new ExOleObjAtom(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ ExOleObjAtom record = new ExOleObjAtom();
+ record.setDrawAspect(ExOleObjAtom.DRAW_ASPECT_VISIBLE);
+ record.setType(ExOleObjAtom.TYPE_CONTROL);
+ record.setObjID(1);
+ record.setSubType(ExOleObjAtom.SUBTYPE_DEFAULT);
+ record.setObjStgDataRef(2);
+ record.setOptions(1283584);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExOleObjStg.java Thu May 21 18:12:22 2009
@@ -1,144 +1,141 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
-
-/**
- * Tests that {@link ExOleObjStg} works properly
- *
- * @author Yegor Kozlov
- */
-public class TestExOleObjStg extends TestCase {
-
- // From a real file (embedded SWF control)
- /*
- <ExOleObjStg info="16" type="4113" size="347" offset="4322" header="10 00 11 10 5B 01 00 00 ">
- 00 0E 00 00 78 9C BB 70 5E F0 C1 C2 8D 52 0F 19 D0 80 1D 03 33 C3 BF FF 9C
- 0C 6C 48 62 8C 40 CC 04 E3 08 30 30 B0 40 C5 FE FD FF FF 1F 24 C4 0C C4 FF
- 47 C1 90 02 41 0C F9 40 58 C2 A0 C0 E0 CA 90 07 A4 8B 18 2A D1 93 02 5E 20
- C6 C0 0A 8F 73 50 5A C8 BB 5D 73 29 77 DD 79 C1 69 3B 5C 5C 83 43 50 D5 06
- BC 48 2F 2B 66 38 C9 C8 0E 64 3B 30 42 C4 9C 81 B6 83 EC 4D 05 93 C5 24 D9
- 0D 02 42 0C 4C 8C C8 FE 21 56 9F 02 23 C9 56 E1 04 E4 D8 4F 4D 40 89 FD A0
- BC FB 17 4B BA F8 07 C5 A3 60 78 03 7A E6 FF 09 67 59 1B 41 F9 9F 95 61 34
- FF 53 13 50 62 3F 4C 1F AC 1C 18 CD F7 23 0B C0 DA 74 A0 B6 1B A8 3D 37 1A
- F7 23 0B A4 87 A6 85 0A 00 1B 64 6F 38 21 98 03 DA C2 E7 60 90 01 92 69 0C
- 39 0C 65 0C 05 40 32 11 58 2F A4 02 6B 07 3D 60 19 5D 0E 14 27 4E 05 1F 90
- 0C 67 C8 04 96 ED 29 C0 72 BE 1C C8 E3 06 E3 FF FF 39 18 B8 80 2C 0F A0 5C
- 3A 43 06 58 2D A8 A7 E1 C3 10 02 97 87 B8 02 E6 1A 60 77 83 21 18 A8 12 64
- 8A 23 D0 B6 1C B8 59 C8 AA 90 F5 F0 62 94 75 DC C0 DE 0A 37 5C 1D 33 54 35
- 88 97 08 35 91 83 81 07 EC 27 10 BF 18 E8 9B E1 0F 00 BD 65 3D D4
- </ExOleObjStg>
- */
- private byte[] data = new byte[] {
- 0x10, 0x00, 0x11, 0x10, 0x5B, 0x01, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x78, (byte)0x9C, (byte)0xBB, 0x70,
- 0x5E, (byte)0xF0, (byte)0xC1, (byte)0xC2, (byte)0x8D, 0x52, 0x0F, 0x19, (byte)0xD0, (byte)0x80, 0x1D, 0x03,
- 0x33, (byte)0xC3, (byte)0xBF, (byte)0xFF, (byte)0x9C, 0x0C, 0x6C, 0x48, 0x62, (byte)0x8C, 0x40, (byte)0xCC,
- 0x04, (byte)0xE3, 0x08, 0x30, 0x30, (byte)0xB0, 0x40, (byte)0xC5, (byte)0xFE, (byte)0xFD, (byte)0xFF, (byte)0xFF,
- 0x1F, 0x24, (byte)0xC4, (byte)0x0C, (byte)0xC4, (byte)0xFF, 0x47, (byte)0xC1, (byte)0x90, 0x02, 0x41, 0x0C,
- (byte)0xF9, 0x40, 0x58, (byte)0xC2, (byte)0xA0, (byte)0xC0, (byte)0xE0, (byte)0xCA, (byte)0x90, 0x07, (byte)0xA4,
- (byte)0x8B, 0x18, 0x2A, (byte)0xD1, (byte)0x93, 0x02, 0x5E, 0x20, (byte)0xC6, (byte)0xC0, 0x0A, (byte)0x8F,
- 0x73, 0x50, 0x5A, (byte)0xC8, (byte)0xBB, 0x5D, 0x73, 0x29, 0x77, (byte)0xDD, 0x79, (byte)0xC1, 0x69, 0x3B,
- 0x5C, 0x5C, (byte)0x83, 0x43, 0x50, (byte)0xD5, 0x06, (byte)0xBC, 0x48, 0x2F, 0x2B, 0x66, 0x38, (byte)0xC9,
- (byte)0xC8, 0x0E, 0x64, 0x3B, 0x30, 0x42, (byte)0xC4, (byte)0x9C, (byte)0x81, (byte)0xB6, (byte)0x83, (byte)0xEC,
- 0x4D, 0x05, (byte)0x93, (byte)0xC5, 0x24, (byte)0xD9, 0x0D, 0x02, 0x42, 0x0C, 0x4C, (byte)0x8C, (byte)0xC8,
- (byte)0xFE, 0x21, 0x56, (byte)0x9F, 0x02, 0x23, (byte)0xC9, 0x56, (byte)0xE1, 0x04, (byte)0xE4, (byte)0xD8,
- 0x4F, 0x4D, 0x40, (byte)0x89, (byte)0xFD, (byte)0xA0, (byte)0xBC, (byte)0xFB, 0x17, 0x4B, (byte)0xBA, (byte)0xF8,
- 0x07, (byte)0xC5, (byte)0xA3, 0x60, 0x78, 0x03, 0x7A, (byte)0xE6, (byte)0xFF, 0x09, 0x67, 0x59, 0x1B, 0x41,
- (byte)0xF9, (byte)0x9F, (byte)0x95, 0x61, 0x34, (byte)0xFF, 0x53, 0x13, 0x50, 0x62, 0x3F, 0x4C, 0x1F, (byte)0xAC,
- 0x1C, 0x18, (byte)0xCD, (byte)0xF7, 0x23, 0x0B, (byte)0xC0, (byte)0xDA, 0x74, (byte)0xA0, (byte)0xB6, 0x1B,
- (byte)0xA8, 0x3D, 0x37, 0x1A, (byte)0xF7, 0x23, 0x0B, (byte)0xA4, (byte)0x87, (byte)0xA6, (byte)0x85, 0x0A,
- 0x00, 0x1B, 0x64, 0x6F, 0x38, 0x21, (byte)0x98, 0x03, (byte)0xDA, (byte)0xC2, (byte)0xE7, 0x60, (byte)0x90,
- 0x01, (byte)0x92, 0x69, 0x0C, 0x39, 0x0C, 0x65, 0x0C, 0x05, 0x40, 0x32, 0x11, 0x58, 0x2F, (byte)0xA4, 0x02,
- 0x6B, 0x07, 0x3D, 0x60, 0x19, 0x5D, 0x0E, 0x14, 0x27, 0x4E, 0x05, 0x1F, (byte)0x90, 0x0C, 0x67, (byte)0xC8,
- 0x04, (byte)0x96, (byte)0xED, 0x29, (byte)0xC0, 0x72, (byte)0xBE, 0x1C, (byte)0xC8, (byte)0xE3, 0x06, (byte)0xE3,
- (byte)0xFF, (byte)0xFF, 0x39, 0x18, (byte)0xB8, (byte)0x80, 0x2C, 0x0F, (byte)0xA0, 0x5C, 0x3A, 0x43, 0x06, 0x58,
- 0x2D, (byte)0xA8, (byte)0xA7, (byte)0xE1, (byte)0xC3, 0x10, 0x02, (byte)0x97, (byte)0x87, (byte)0xB8, 0x02,
- (byte)0xE6, 0x1A, 0x60, 0x77, (byte)0x83, 0x21, 0x18, (byte)0xA8, 0x12, 0x64, (byte)0x8A, 0x23, (byte)0xD0,
- (byte)0xB6, 0x1C, (byte)0xB8, 0x59, (byte)0xC8, (byte)0xAA, (byte)0x90, (byte)0xF5, (byte)0xF0, 0x62, (byte)0x94,
- 0x75, (byte)0xDC, (byte)0xC0, (byte)0xDE, 0x0A, 0x37, 0x5C, 0x1D, 0x33, 0x54, 0x35, (byte)0x88, (byte)0x97, 0x08,
- 0x35, (byte)0x91, (byte)0x83, (byte)0x81, 0x07, (byte)0xEC, 0x27, 0x10, (byte)0xBF, 0x18, (byte)0xE8, (byte)0x9B,
- (byte)0xE1, 0x0F, 0x00, (byte)0xBD, 0x65, 0x3D, (byte)0xD4
- };
-
- public void testRead() throws Exception {
- ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
- assertEquals(RecordTypes.ExOleObjStg.typeID, record.getRecordType());
-
- int len = record.getDataLength();
- byte[] oledata = readAll(record.getData());
- assertEquals(len, oledata.length);
-
- POIFSFileSystem fs = new POIFSFileSystem(record.getData());
- assertTrue("Constructed POIFS from ExOleObjStg data", true);
- DocumentEntry doc = (DocumentEntry)fs.getRoot().getEntry("Contents");
- assertNotNull(doc);
- assertTrue("Fetched the Contents stream containing OLE properties", true);
- }
-
- public void testWrite() throws Exception {
- ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- ExOleObjStg src = new ExOleObjStg(data, 0, data.length);
- byte[] oledata = readAll(src.getData());
-
- ExOleObjStg tgt = new ExOleObjStg();
- tgt.setData(oledata);
-
-
- assertEquals(src.getDataLength(), tgt.getDataLength());
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- tgt.writeOut(out);
- byte[] b = out.toByteArray();
-
- assertEquals(data.length, b.length);
- assertTrue(Arrays.equals(data, b));
- }
-
- private byte[] readAll(InputStream is) throws IOException {
- int pos;
- byte[] chunk = new byte[1024];
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- while((pos = is.read(chunk)) > 0){
- out.write(chunk, 0, pos);
- }
- return out.toByteArray();
-
- }
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.poifs.filesystem.DirectoryNode;
+import org.apache.poi.poifs.filesystem.DocumentEntry;
+
+/**
+ * Tests that {@link ExOleObjStg} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExOleObjStg extends TestCase {
+
+ // From a real file (embedded SWF control)
+ /*
+ <ExOleObjStg info="16" type="4113" size="347" offset="4322" header="10 00 11 10 5B 01 00 00 ">
+ 00 0E 00 00 78 9C BB 70 5E F0 C1 C2 8D 52 0F 19 D0 80 1D 03 33 C3 BF FF 9C
+ 0C 6C 48 62 8C 40 CC 04 E3 08 30 30 B0 40 C5 FE FD FF FF 1F 24 C4 0C C4 FF
+ 47 C1 90 02 41 0C F9 40 58 C2 A0 C0 E0 CA 90 07 A4 8B 18 2A D1 93 02 5E 20
+ C6 C0 0A 8F 73 50 5A C8 BB 5D 73 29 77 DD 79 C1 69 3B 5C 5C 83 43 50 D5 06
+ BC 48 2F 2B 66 38 C9 C8 0E 64 3B 30 42 C4 9C 81 B6 83 EC 4D 05 93 C5 24 D9
+ 0D 02 42 0C 4C 8C C8 FE 21 56 9F 02 23 C9 56 E1 04 E4 D8 4F 4D 40 89 FD A0
+ BC FB 17 4B BA F8 07 C5 A3 60 78 03 7A E6 FF 09 67 59 1B 41 F9 9F 95 61 34
+ FF 53 13 50 62 3F 4C 1F AC 1C 18 CD F7 23 0B C0 DA 74 A0 B6 1B A8 3D 37 1A
+ F7 23 0B A4 87 A6 85 0A 00 1B 64 6F 38 21 98 03 DA C2 E7 60 90 01 92 69 0C
+ 39 0C 65 0C 05 40 32 11 58 2F A4 02 6B 07 3D 60 19 5D 0E 14 27 4E 05 1F 90
+ 0C 67 C8 04 96 ED 29 C0 72 BE 1C C8 E3 06 E3 FF FF 39 18 B8 80 2C 0F A0 5C
+ 3A 43 06 58 2D A8 A7 E1 C3 10 02 97 87 B8 02 E6 1A 60 77 83 21 18 A8 12 64
+ 8A 23 D0 B6 1C B8 59 C8 AA 90 F5 F0 62 94 75 DC C0 DE 0A 37 5C 1D 33 54 35
+ 88 97 08 35 91 83 81 07 EC 27 10 BF 18 E8 9B E1 0F 00 BD 65 3D D4
+ </ExOleObjStg>
+ */
+ private byte[] data = new byte[] {
+ 0x10, 0x00, 0x11, 0x10, 0x5B, 0x01, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x78, (byte)0x9C, (byte)0xBB, 0x70,
+ 0x5E, (byte)0xF0, (byte)0xC1, (byte)0xC2, (byte)0x8D, 0x52, 0x0F, 0x19, (byte)0xD0, (byte)0x80, 0x1D, 0x03,
+ 0x33, (byte)0xC3, (byte)0xBF, (byte)0xFF, (byte)0x9C, 0x0C, 0x6C, 0x48, 0x62, (byte)0x8C, 0x40, (byte)0xCC,
+ 0x04, (byte)0xE3, 0x08, 0x30, 0x30, (byte)0xB0, 0x40, (byte)0xC5, (byte)0xFE, (byte)0xFD, (byte)0xFF, (byte)0xFF,
+ 0x1F, 0x24, (byte)0xC4, (byte)0x0C, (byte)0xC4, (byte)0xFF, 0x47, (byte)0xC1, (byte)0x90, 0x02, 0x41, 0x0C,
+ (byte)0xF9, 0x40, 0x58, (byte)0xC2, (byte)0xA0, (byte)0xC0, (byte)0xE0, (byte)0xCA, (byte)0x90, 0x07, (byte)0xA4,
+ (byte)0x8B, 0x18, 0x2A, (byte)0xD1, (byte)0x93, 0x02, 0x5E, 0x20, (byte)0xC6, (byte)0xC0, 0x0A, (byte)0x8F,
+ 0x73, 0x50, 0x5A, (byte)0xC8, (byte)0xBB, 0x5D, 0x73, 0x29, 0x77, (byte)0xDD, 0x79, (byte)0xC1, 0x69, 0x3B,
+ 0x5C, 0x5C, (byte)0x83, 0x43, 0x50, (byte)0xD5, 0x06, (byte)0xBC, 0x48, 0x2F, 0x2B, 0x66, 0x38, (byte)0xC9,
+ (byte)0xC8, 0x0E, 0x64, 0x3B, 0x30, 0x42, (byte)0xC4, (byte)0x9C, (byte)0x81, (byte)0xB6, (byte)0x83, (byte)0xEC,
+ 0x4D, 0x05, (byte)0x93, (byte)0xC5, 0x24, (byte)0xD9, 0x0D, 0x02, 0x42, 0x0C, 0x4C, (byte)0x8C, (byte)0xC8,
+ (byte)0xFE, 0x21, 0x56, (byte)0x9F, 0x02, 0x23, (byte)0xC9, 0x56, (byte)0xE1, 0x04, (byte)0xE4, (byte)0xD8,
+ 0x4F, 0x4D, 0x40, (byte)0x89, (byte)0xFD, (byte)0xA0, (byte)0xBC, (byte)0xFB, 0x17, 0x4B, (byte)0xBA, (byte)0xF8,
+ 0x07, (byte)0xC5, (byte)0xA3, 0x60, 0x78, 0x03, 0x7A, (byte)0xE6, (byte)0xFF, 0x09, 0x67, 0x59, 0x1B, 0x41,
+ (byte)0xF9, (byte)0x9F, (byte)0x95, 0x61, 0x34, (byte)0xFF, 0x53, 0x13, 0x50, 0x62, 0x3F, 0x4C, 0x1F, (byte)0xAC,
+ 0x1C, 0x18, (byte)0xCD, (byte)0xF7, 0x23, 0x0B, (byte)0xC0, (byte)0xDA, 0x74, (byte)0xA0, (byte)0xB6, 0x1B,
+ (byte)0xA8, 0x3D, 0x37, 0x1A, (byte)0xF7, 0x23, 0x0B, (byte)0xA4, (byte)0x87, (byte)0xA6, (byte)0x85, 0x0A,
+ 0x00, 0x1B, 0x64, 0x6F, 0x38, 0x21, (byte)0x98, 0x03, (byte)0xDA, (byte)0xC2, (byte)0xE7, 0x60, (byte)0x90,
+ 0x01, (byte)0x92, 0x69, 0x0C, 0x39, 0x0C, 0x65, 0x0C, 0x05, 0x40, 0x32, 0x11, 0x58, 0x2F, (byte)0xA4, 0x02,
+ 0x6B, 0x07, 0x3D, 0x60, 0x19, 0x5D, 0x0E, 0x14, 0x27, 0x4E, 0x05, 0x1F, (byte)0x90, 0x0C, 0x67, (byte)0xC8,
+ 0x04, (byte)0x96, (byte)0xED, 0x29, (byte)0xC0, 0x72, (byte)0xBE, 0x1C, (byte)0xC8, (byte)0xE3, 0x06, (byte)0xE3,
+ (byte)0xFF, (byte)0xFF, 0x39, 0x18, (byte)0xB8, (byte)0x80, 0x2C, 0x0F, (byte)0xA0, 0x5C, 0x3A, 0x43, 0x06, 0x58,
+ 0x2D, (byte)0xA8, (byte)0xA7, (byte)0xE1, (byte)0xC3, 0x10, 0x02, (byte)0x97, (byte)0x87, (byte)0xB8, 0x02,
+ (byte)0xE6, 0x1A, 0x60, 0x77, (byte)0x83, 0x21, 0x18, (byte)0xA8, 0x12, 0x64, (byte)0x8A, 0x23, (byte)0xD0,
+ (byte)0xB6, 0x1C, (byte)0xB8, 0x59, (byte)0xC8, (byte)0xAA, (byte)0x90, (byte)0xF5, (byte)0xF0, 0x62, (byte)0x94,
+ 0x75, (byte)0xDC, (byte)0xC0, (byte)0xDE, 0x0A, 0x37, 0x5C, 0x1D, 0x33, 0x54, 0x35, (byte)0x88, (byte)0x97, 0x08,
+ 0x35, (byte)0x91, (byte)0x83, (byte)0x81, 0x07, (byte)0xEC, 0x27, 0x10, (byte)0xBF, 0x18, (byte)0xE8, (byte)0x9B,
+ (byte)0xE1, 0x0F, 0x00, (byte)0xBD, 0x65, 0x3D, (byte)0xD4
+ };
+
+ public void testRead() throws Exception {
+ ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
+ assertEquals(RecordTypes.ExOleObjStg.typeID, record.getRecordType());
+
+ int len = record.getDataLength();
+ byte[] oledata = readAll(record.getData());
+ assertEquals(len, oledata.length);
+
+ POIFSFileSystem fs = new POIFSFileSystem(record.getData());
+ assertTrue("Constructed POIFS from ExOleObjStg data", true);
+ DocumentEntry doc = (DocumentEntry)fs.getRoot().getEntry("Contents");
+ assertNotNull(doc);
+ assertTrue("Fetched the Contents stream containing OLE properties", true);
+ }
+
+ public void testWrite() throws Exception {
+ ExOleObjStg record = new ExOleObjStg(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ ExOleObjStg src = new ExOleObjStg(data, 0, data.length);
+ byte[] oledata = readAll(src.getData());
+
+ ExOleObjStg tgt = new ExOleObjStg();
+ tgt.setData(oledata);
+
+
+ assertEquals(src.getDataLength(), tgt.getDataLength());
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ tgt.writeOut(out);
+ byte[] b = out.toByteArray();
+
+ assertEquals(data.length, b.length);
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ private byte[] readAll(InputStream is) throws IOException {
+ int pos;
+ byte[] chunk = new byte[1024];
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ while((pos = is.read(chunk)) > 0){
+ out.write(chunk, 0, pos);
+ }
+ return out.toByteArray();
+
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExVideoContainer.java Thu May 21 18:12:22 2009
@@ -1,90 +1,87 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
- */
-public class TestExVideoContainer extends TestCase {
-
- // From a real file
- private byte[] data = new byte[]{
- 0x0F, 0x00, 0x05, 0x10, (byte) 0x9E, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x04, 0x10, 0x08, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, (byte)0xBA, 0x0F, (byte)0x86, 0x00, 0x00, 0x00,
- 0x44, 0x00, 0x3A, 0x00, 0x5C, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6A, 0x00, 0x65, 0x00,
- 0x63, 0x00, 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x53, 0x00, 0x63, 0x00, 0x68, 0x00, 0x75, 0x00,
- 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x41, 0x00, 0x47, 0x00, 0x5C, 0x00, 0x6D, 0x00, 0x63, 0x00,
- 0x6F, 0x00, 0x6D, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x5F, 0x00, 0x31, 0x00, 0x5F, 0x00, 0x30, 0x00,
- 0x5F, 0x00, 0x34, 0x00, 0x5C, 0x00, 0x76, 0x00, 0x69, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5C, 0x00,
- 0x64, 0x00, 0x61, 0x00, 0x74, 0x00, 0x61, 0x00, 0x5C, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
- 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00,
- 0x73, 0x00, 0x5C, 0x00, 0x63, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x2E, 0x00,
- 0x6D, 0x00, 0x70, 0x00, 0x67, 0x00};
-
-
-
-
- public void testRead() throws Exception {
- ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
- assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
-
- ExMediaAtom exMedia = record.getExMediaAtom();
- assertEquals(1, exMedia.getObjectId());
- assertNotNull(exMedia);
- assertFalse(exMedia.getFlag(ExMediaAtom.fLoop));
- assertFalse(exMedia.getFlag(ExMediaAtom.fNarration));
- assertFalse(exMedia.getFlag(ExMediaAtom.fRewind));
-
- CString path = record.getPathAtom();
- assertNotNull(exMedia);
- assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());
- }
-
- public void testWrite() throws Exception {
- ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- ExVideoContainer record = new ExVideoContainer();
- record.getExMediaAtom().setObjectId(1);
- record.getPathAtom().setText("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestExVideoContainer extends TestCase {
+
+ // From a real file
+ private byte[] data = new byte[]{
+ 0x0F, 0x00, 0x05, 0x10, (byte) 0x9E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x04, 0x10, 0x08, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, (byte)0xBA, 0x0F, (byte)0x86, 0x00, 0x00, 0x00,
+ 0x44, 0x00, 0x3A, 0x00, 0x5C, 0x00, 0x70, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x6A, 0x00, 0x65, 0x00,
+ 0x63, 0x00, 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x53, 0x00, 0x63, 0x00, 0x68, 0x00, 0x75, 0x00,
+ 0x6C, 0x00, 0x65, 0x00, 0x72, 0x00, 0x41, 0x00, 0x47, 0x00, 0x5C, 0x00, 0x6D, 0x00, 0x63, 0x00,
+ 0x6F, 0x00, 0x6D, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x5F, 0x00, 0x31, 0x00, 0x5F, 0x00, 0x30, 0x00,
+ 0x5F, 0x00, 0x34, 0x00, 0x5C, 0x00, 0x76, 0x00, 0x69, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5C, 0x00,
+ 0x64, 0x00, 0x61, 0x00, 0x74, 0x00, 0x61, 0x00, 0x5C, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
+ 0x74, 0x00, 0x73, 0x00, 0x5C, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00,
+ 0x73, 0x00, 0x5C, 0x00, 0x63, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x73, 0x00, 0x2E, 0x00,
+ 0x6D, 0x00, 0x70, 0x00, 0x67, 0x00};
+
+
+
+
+ public void testRead() throws Exception {
+ ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+ assertEquals(RecordTypes.ExVideoContainer.typeID, record.getRecordType());
+
+ ExMediaAtom exMedia = record.getExMediaAtom();
+ assertEquals(1, exMedia.getObjectId());
+ assertNotNull(exMedia);
+ assertFalse(exMedia.getFlag(ExMediaAtom.fLoop));
+ assertFalse(exMedia.getFlag(ExMediaAtom.fNarration));
+ assertFalse(exMedia.getFlag(ExMediaAtom.fRewind));
+
+ CString path = record.getPathAtom();
+ assertNotNull(exMedia);
+ assertEquals("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg", path.getText());
+ }
+
+ public void testWrite() throws Exception {
+ ExVideoContainer record = new ExVideoContainer(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ ExVideoContainer record = new ExVideoContainer();
+ record.getExMediaAtom().setObjectId(1);
+ record.getPathAtom().setText("D:\\projects\\SchulerAG\\mcom_v_1_0_4\\view\\data\\tests\\images\\cards.mpg");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestFontCollection.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -28,7 +27,7 @@
*
* @author Yegor Kozlov
*/
-public class TestFontCollection extends TestCase {
+public final class TestFontCollection extends TestCase {
// From a real file
private byte[] data = new byte[] {
0x0F, 0x00, 0xD5-256, 0x07, 0x4C, 0x00, 0x00, 0x00,
@@ -64,7 +63,7 @@
// Font collection should contain 3 fonts
Record[] child = fonts.getChildRecords();
assertEquals(child.length, 3);
-
+
// Check we get the right font name for the indicies
assertEquals("Times New Roman", fonts.getFontWithId(0));
assertEquals("Helvetica", fonts.getFontWithId(1));
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersAtom.java Thu May 21 18:12:22 2009
@@ -1,95 +1,92 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link HeadersFootersAtom} works properly
- *
- * @author Yegor Kozlov
- */
-public class TestHeadersFootersAtom extends TestCase {
- // From a real file
- private byte[] data = new byte[] {
- 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
- 0x00, 0x00, 0x23, 0x00 };
-
- public void testRead() throws Exception {
- HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
- assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
-
- assertEquals(0, record.getFormatId());
- assertEquals(0x23, record.getMask());
-
- assertTrue(record.getFlag(HeadersFootersAtom.fHasDate));
- assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
- assertFalse(record.getFlag(HeadersFootersAtom.fHasUserDate));
- assertFalse(record.getFlag(HeadersFootersAtom.fHasSlideNumber));
- assertFalse(record.getFlag(HeadersFootersAtom.fHasHeader));
- assertTrue(record.getFlag(HeadersFootersAtom.fHasFooter));
- }
-
- public void testWrite() throws Exception {
- HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testNewRecord() throws Exception {
- HeadersFootersAtom record = new HeadersFootersAtom();
- record.setFlag(HeadersFootersAtom.fHasDate, true);
- record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
- record.setFlag(HeadersFootersAtom.fHasFooter, true);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(data, b));
- }
-
- public void testFlags() throws Exception {
- HeadersFootersAtom record = new HeadersFootersAtom();
-
- //in a new record all the bits are 0
- for(int i = 0; i < 6; i++) assertFalse(record.getFlag(1 << i));
-
- record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
- assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
-
- record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
- assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
-
- record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
-
- record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
-
- }
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersAtom} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHeadersFootersAtom extends TestCase {
+ // From a real file
+ private byte[] data = new byte[] {
+ 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 00,
+ 0x00, 0x00, 0x23, 0x00 };
+
+ public void testRead() throws Exception {
+ HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+ assertEquals(RecordTypes.HeadersFootersAtom.typeID, record.getRecordType());
+
+ assertEquals(0, record.getFormatId());
+ assertEquals(0x23, record.getMask());
+
+ assertTrue(record.getFlag(HeadersFootersAtom.fHasDate));
+ assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+ assertFalse(record.getFlag(HeadersFootersAtom.fHasUserDate));
+ assertFalse(record.getFlag(HeadersFootersAtom.fHasSlideNumber));
+ assertFalse(record.getFlag(HeadersFootersAtom.fHasHeader));
+ assertTrue(record.getFlag(HeadersFootersAtom.fHasFooter));
+ }
+
+ public void testWrite() throws Exception {
+ HeadersFootersAtom record = new HeadersFootersAtom(data, 0, data.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testNewRecord() throws Exception {
+ HeadersFootersAtom record = new HeadersFootersAtom();
+ record.setFlag(HeadersFootersAtom.fHasDate, true);
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+ record.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(data, b));
+ }
+
+ public void testFlags() throws Exception {
+ HeadersFootersAtom record = new HeadersFootersAtom();
+
+ //in a new record all the bits are 0
+ for(int i = 0; i < 6; i++) assertFalse(record.getFlag(1 << i));
+
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+ assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+ assertTrue(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+ record.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ assertFalse(record.getFlag(HeadersFootersAtom.fHasTodayDate));
+
+ }
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestHeadersFootersContainer.java Thu May 21 18:12:22 2009
@@ -1,171 +1,168 @@
-
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.hslf.record;
-
-
-import junit.framework.TestCase;
-import java.io.ByteArrayOutputStream;
-import java.util.Arrays;
-
-/**
- * Tests that {@link HeadersFootersContainer} works properly
- *
- * @author Yegor Kozlov
- */
-public class TestHeadersFootersContainer extends TestCase {
- // SlideHeadersFootersContainer
- private byte[] slideData = new byte[] {
- 0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,
- 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,
- 0x20, 0x00, (byte)0xBA, 0x0F, 0x1A, 0x00, 0x00, 0x00,
- 0x4D, 0x00, 0x79, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x74,
- 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x31, 0x00
-
- };
-
- // NotesHeadersFootersContainer
- private byte[] notesData = new byte[] {
- 0x4F, 0x00, (byte)0xD9, 0x0F, 0x48, 0x00, 0x00, 0x00,
- 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x00,
- 0x10, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
- 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x48, 0x00,
- 0x65, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x00,
- 0x20, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
- 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00,
- 0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
- };
-
- public void testReadSlideHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
- assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
- assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
- assertEquals(2, record.getChildRecords().length);
-
- HeadersFootersAtom hdd = record.getHeadersFootersAtom();
- assertNotNull(hdd);
-
- CString csFooter = record.getFooterAtom();
- assertNotNull(csFooter);
- assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
-
- assertEquals("My Footer - 1", csFooter.getText());
-
- assertNull(record.getUserDateAtom());
- assertNull(record.getHeaderAtom());
- }
-
- public void testWriteSlideHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(slideData, b));
- }
-
- public void testNewSlideHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
-
- assertNotNull(record.getHeadersFootersAtom());
- assertNull(record.getUserDateAtom());
- assertNull(record.getHeaderAtom());
- assertNull(record.getFooterAtom());
-
- HeadersFootersAtom hd = record.getHeadersFootersAtom();
- hd.setFlag(HeadersFootersAtom.fHasDate, true);
- hd.setFlag(HeadersFootersAtom.fHasTodayDate, true);
- hd.setFlag(HeadersFootersAtom.fHasFooter, true);
-
- CString csFooter = record.addFooterAtom();
- assertNotNull(csFooter);
- assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
- csFooter.setText("My Footer - 1");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(slideData, b));
- }
-
- public void testReadNotesHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
- assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
- assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());
- assertEquals(3, record.getChildRecords().length);
-
- HeadersFootersAtom hdd = record.getHeadersFootersAtom();
- assertNotNull(hdd);
-
- CString csHeader = record.getHeaderAtom();
- assertNotNull(csHeader);
- assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
- assertEquals("Note Header", csHeader.getText());
-
- CString csFooter = record.getFooterAtom();
- assertNotNull(csFooter);
- assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
- assertEquals("Note Footer", csFooter.getText());
- }
-
- public void testWriteNotesHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(notesData, b));
- }
-
- public void testNewNotesHeadersFootersContainer() throws Exception {
- HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
-
- assertNotNull(record.getHeadersFootersAtom());
- assertNull(record.getUserDateAtom());
- assertNull(record.getHeaderAtom());
- assertNull(record.getFooterAtom());
-
- HeadersFootersAtom hd = record.getHeadersFootersAtom();
- hd.setFlag(HeadersFootersAtom.fHasDate, true);
- hd.setFlag(HeadersFootersAtom.fHasTodayDate, false);
- hd.setFlag(HeadersFootersAtom.fHasUserDate, true);
- hd.setFlag(HeadersFootersAtom.fHasSlideNumber, true);
- hd.setFlag(HeadersFootersAtom.fHasHeader, true);
- hd.setFlag(HeadersFootersAtom.fHasFooter, true);
-
- CString csHeader = record.addHeaderAtom();
- assertNotNull(csHeader);
- assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
- csHeader.setText("Note Header");
-
- CString csFooter = record.addFooterAtom();
- assertNotNull(csFooter);
- assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
- csFooter.setText("Note Footer");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- record.writeOut(baos);
- byte[] b = baos.toByteArray();
-
- assertTrue(Arrays.equals(notesData, b));
- }
-
-}
\ No newline at end of file
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+/**
+ * Tests that {@link HeadersFootersContainer} works properly
+ *
+ * @author Yegor Kozlov
+ */
+public final class TestHeadersFootersContainer extends TestCase {
+ // SlideHeadersFootersContainer
+ private byte[] slideData = new byte[] {
+ 0x3F, 0x00, (byte)0xD9, 0x0F, 0x2E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00,
+ 0x20, 0x00, (byte)0xBA, 0x0F, 0x1A, 0x00, 0x00, 0x00,
+ 0x4D, 0x00, 0x79, 0x00, 0x20, 0x00, 0x46, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x74,
+ 0x00, 0x65, 0x00, 0x72, 0x00, 0x20, 0x00, 0x2D, 0x00, 0x20, 0x00, 0x31, 0x00
+
+ };
+
+ // NotesHeadersFootersContainer
+ private byte[] notesData = new byte[] {
+ 0x4F, 0x00, (byte)0xD9, 0x0F, 0x48, 0x00, 0x00, 0x00,
+ 0x00, 0x00, (byte)0xDA, 0x0F, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x00,
+ 0x10, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
+ 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x48, 0x00,
+ 0x65, 0x00, 0x61, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x00,
+ 0x20, 0x00, (byte)0xBA, 0x0F, 0x16, 0x00, 0x00, 0x00,
+ 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x20, 0x00, 0x46, 0x00,
+ 0x6F, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x72, 0x00
+ };
+
+ public void testReadSlideHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+ assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+ assertEquals(HeadersFootersContainer.SlideHeadersFootersContainer, record.getOptions());
+ assertEquals(2, record.getChildRecords().length);
+
+ HeadersFootersAtom hdd = record.getHeadersFootersAtom();
+ assertNotNull(hdd);
+
+ CString csFooter = record.getFooterAtom();
+ assertNotNull(csFooter);
+ assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+
+ assertEquals("My Footer - 1", csFooter.getText());
+
+ assertNull(record.getUserDateAtom());
+ assertNull(record.getHeaderAtom());
+ }
+
+ public void testWriteSlideHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(slideData, 0, slideData.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(slideData, b));
+ }
+
+ public void testNewSlideHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.SlideHeadersFootersContainer);
+
+ assertNotNull(record.getHeadersFootersAtom());
+ assertNull(record.getUserDateAtom());
+ assertNull(record.getHeaderAtom());
+ assertNull(record.getFooterAtom());
+
+ HeadersFootersAtom hd = record.getHeadersFootersAtom();
+ hd.setFlag(HeadersFootersAtom.fHasDate, true);
+ hd.setFlag(HeadersFootersAtom.fHasTodayDate, true);
+ hd.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+ CString csFooter = record.addFooterAtom();
+ assertNotNull(csFooter);
+ assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+ csFooter.setText("My Footer - 1");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(slideData, b));
+ }
+
+ public void testReadNotesHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+ assertEquals(RecordTypes.HeadersFooters.typeID, record.getRecordType());
+ assertEquals(HeadersFootersContainer.NotesHeadersFootersContainer, record.getOptions());
+ assertEquals(3, record.getChildRecords().length);
+
+ HeadersFootersAtom hdd = record.getHeadersFootersAtom();
+ assertNotNull(hdd);
+
+ CString csHeader = record.getHeaderAtom();
+ assertNotNull(csHeader);
+ assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
+ assertEquals("Note Header", csHeader.getText());
+
+ CString csFooter = record.getFooterAtom();
+ assertNotNull(csFooter);
+ assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+ assertEquals("Note Footer", csFooter.getText());
+ }
+
+ public void testWriteNotesHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(notesData, 0, notesData.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(notesData, b));
+ }
+
+ public void testNewNotesHeadersFootersContainer() throws Exception {
+ HeadersFootersContainer record = new HeadersFootersContainer(HeadersFootersContainer.NotesHeadersFootersContainer);
+
+ assertNotNull(record.getHeadersFootersAtom());
+ assertNull(record.getUserDateAtom());
+ assertNull(record.getHeaderAtom());
+ assertNull(record.getFooterAtom());
+
+ HeadersFootersAtom hd = record.getHeadersFootersAtom();
+ hd.setFlag(HeadersFootersAtom.fHasDate, true);
+ hd.setFlag(HeadersFootersAtom.fHasTodayDate, false);
+ hd.setFlag(HeadersFootersAtom.fHasUserDate, true);
+ hd.setFlag(HeadersFootersAtom.fHasSlideNumber, true);
+ hd.setFlag(HeadersFootersAtom.fHasHeader, true);
+ hd.setFlag(HeadersFootersAtom.fHasFooter, true);
+
+ CString csHeader = record.addHeaderAtom();
+ assertNotNull(csHeader);
+ assertEquals(HeadersFootersContainer.HEADERATOM, csHeader.getOptions() >> 4);
+ csHeader.setText("Note Header");
+
+ CString csFooter = record.addFooterAtom();
+ assertNotNull(csFooter);
+ assertEquals(HeadersFootersContainer.FOOTERATOM, csFooter.getOptions() >> 4);
+ csFooter.setText("Note Footer");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ record.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertTrue(Arrays.equals(notesData, b));
+ }
+
+}
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestNotesAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.record;
@@ -29,7 +26,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestNotesAtom extends TestCase {
+public final class TestNotesAtom extends TestCase {
// From a real file
private byte[] data_a = new byte[] { 1, 0, 0xF1-256, 3, 8, 0, 0, 0,
0, 0, 0, 0x80-256, 0, 0, 0x0D, 0x30 };
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordContainer.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.record;
@@ -30,123 +27,123 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestRecordContainer extends TestCase {
+public final class TestRecordContainer extends TestCase {
private RecordContainer recordContainer;
public void testIsAnAtom() {
assertFalse( recordContainer.isAnAtom() );
}
-
+
public void testAppendChildRecord() {
// Grab records for testing with
Record r = recordContainer.getChildRecords()[0];
Record rb = recordContainer.getChildRecords()[1];
Record rc = recordContainer.getChildRecords()[2];
Record rd = recordContainer.getChildRecords()[3];
-
+
// Start with an empty set
Record[] rs = new Record[0];
recordContainer._children = rs;
recordContainer.appendChildRecord(r);
Record[] nrs = recordContainer.getChildRecords();
-
+
assertEquals(1, nrs.length);
assertEquals(r, nrs[0]);
-
+
// Now start with one with 3 entries
rs = new Record[3];
recordContainer._children = rs;
rs[0] = rb;
rs[1] = rc;
rs[2] = rd;
-
+
recordContainer.appendChildRecord(r);
nrs = recordContainer.getChildRecords();
-
+
assertEquals(4, nrs.length);
assertEquals(rb, nrs[0]);
assertEquals(rc, nrs[1]);
assertEquals(rd, nrs[2]);
assertEquals(r, nrs[3]);
}
-
+
public void testAddChildAfter() {
// Working with new StyleTextPropAtom
Record newRecord = new StyleTextPropAtom(0);
-
+
// Try to add after a mid-record
Record[] cr = recordContainer.getChildRecords();
Record after = cr[2];
Record before = cr[3];
-
+
recordContainer.addChildAfter(newRecord, after);
Record[] ncr = recordContainer.getChildRecords();
-
+
assertEquals(cr.length+1, ncr.length);
assertEquals(after, ncr[2]);
assertEquals(newRecord, ncr[3]);
assertEquals(before, ncr[4]);
-
+
// Try again at the end
recordContainer._children = cr;
after = cr[cr.length-1];
-
+
recordContainer.addChildAfter(newRecord, after);
ncr = recordContainer.getChildRecords();
-
+
assertEquals(cr.length+1, ncr.length);
assertEquals(after, ncr[cr.length-1]);
assertEquals(newRecord, ncr[cr.length]);
}
-
+
public void testAddChildBefore() {
// Working with new StyleTextPropAtom
Record newRecord = new StyleTextPropAtom(0);
-
+
// Try to add before a mid-record
Record[] cr = recordContainer.getChildRecords();
Record before = cr[2];
-
+
recordContainer.addChildBefore(newRecord, before);
Record[] ncr = recordContainer.getChildRecords();
-
+
assertEquals(cr.length+1, ncr.length);
assertEquals(newRecord, ncr[2]);
assertEquals(before, ncr[3]);
-
-
+
+
// Try again at the end
recordContainer._children = cr;
before = cr[cr.length-1];
-
+
recordContainer.addChildBefore(newRecord, before);
ncr = recordContainer.getChildRecords();
-
+
assertEquals(cr.length+1, ncr.length);
assertEquals(newRecord, ncr[cr.length-1]);
assertEquals(before, ncr[cr.length]);
-
-
+
+
// And at the start
recordContainer._children = cr;
before = cr[0];
-
+
recordContainer.addChildBefore(newRecord, before);
ncr = recordContainer.getChildRecords();
-
+
assertEquals(cr.length+1, ncr.length);
assertEquals(newRecord, ncr[0]);
assertEquals(before, ncr[1]);
}
-
+
protected void setUp() throws Exception {
super.setUp();
-
+
// Find a real RecordContainer record
String dirname = System.getProperty("HSLF.testdata.path");
String filename = dirname + "/basic_test_ppt_file.ppt";
HSLFSlideShow hss = new HSLFSlideShow(filename);
-
+
Record[] r = hss.getRecords();
for(int i=0; i<r.length; i++) {
if(r[i] instanceof RecordContainer) {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestRecordTypes.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.record;
@@ -28,7 +25,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestRecordTypes extends TestCase {
+public final class TestRecordTypes extends TestCase {
public void testPPTNameLookups() throws Exception {
assertEquals("MainMaster", RecordTypes.recordName(1016));
assertEquals("TextBytesAtom", RecordTypes.recordName(4008));
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlideAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.record;
@@ -30,10 +27,10 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSlideAtom extends TestCase {
+public final class TestSlideAtom extends TestCase {
// From a real file
private byte[] data_a = new byte[] { 1, 0, 0xEF-256, 3, 0x18, 0, 0, 0,
- 0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
+ 0, 0, 0, 0, 0x0F, 0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80-256,
0, 1, 0, 0, 7, 0, 0x0C, 0x30 };
public void testRecordType() throws Exception {
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestSlidePersistAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.record;
@@ -29,7 +26,7 @@
*
* @author Nick Burch (nick at torchbox dot com)
*/
-public class TestSlidePersistAtom extends TestCase {
+public final class TestSlidePersistAtom extends TestCase {
// From a real file
private byte[] data_a = new byte[] { 0, 0, 0xF3-256, 3, 0x14, 0, 0, 0,
4, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org