From 25a0f44907be03658ca748acf4d7d719333525c4 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 14 Aug 2005 17:52:43 +0000 Subject: [PATCH] Update tests to track updates in StyleTextPropAtom git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353764 13f79535-47bb-0310-9956-ffa450edef68 --- .../hslf/record/TestStyleTextPropAtom.java | 112 +++++++++--------- 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java index fbe4840942..2ffc7e3422 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestStyleTextPropAtom.java @@ -23,6 +23,7 @@ import org.apache.poi.hslf.record.StyleTextPropAtom.*; import junit.framework.TestCase; import java.io.ByteArrayOutputStream; +import java.util.LinkedList; /** * Tests that StyleTextPropAtom works properly @@ -38,6 +39,7 @@ public class TestStyleTextPropAtom extends TestCase { 0x04, 00, 00, 00, 00, 0x05, 0x10, 00, 00, 00, 00, 00, 0x04, 00, 0xFF-256, 0x33, 00, 0xFE-256 }; + private int data_a_text_len = 54; private byte[] data_b = new byte[] { 0, 0, 0xA1-256, 0x0F, 0x2E, 0, 0, 0, 0x53, 0, 0, 0, 0, 0, 0, 0, @@ -47,6 +49,7 @@ public class TestStyleTextPropAtom extends TestCase { 0, 05, 0x19, 0, 0, 0, 0, 0, 04, 0, 0xFF-256, 0x33, 0, 0xFE-256 }; + private int data_b_text_len = 83; public void testRecordType() throws Exception { StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); @@ -55,82 +58,77 @@ public class TestStyleTextPropAtom extends TestCase { assertEquals(4001l, stpb.getRecordType()); } - public void testCharacterGroups() throws Exception { + + public void testCharacterStyleCounts() throws Exception { StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); - assertEquals(3, stpa.getCharacterStyles().length); - assertEquals(3, stpb.getCharacterStyles().length); + // Set for the appropriate text sizes + stpa.setParentTextSize(data_a_text_len); + stpb.setParentTextSize(data_b_text_len); + + // In both cases, we should only have 1 paragraph styling + assertEquals(1, stpa.getParagraphStyles().size()); + assertEquals(1, stpb.getParagraphStyles().size()); } - public void testCharacterLengths() throws Exception { + public void testParagraphStyleCounts() throws Exception { StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); - // 54 chars, 21 + 17 (+ 16) - assertEquals(54, stpa.getParagraphStyleCharactersCoveredLength() ); - CharacterStyle[] csa = stpa.getCharacterStyles(); - assertEquals(21, csa[0].getCharactersCoveredLength() ); - assertEquals(17, csa[1].getCharactersCoveredLength() ); - assertEquals(0, csa[2].getCharactersCoveredLength() ); - - // 83 chars, 30 + 28 (+ 25) - assertEquals(83, stpb.getParagraphStyleCharactersCoveredLength() ); - CharacterStyle[] csb = stpb.getCharacterStyles(); - assertEquals(30, csb[0].getCharactersCoveredLength() ); - assertEquals(28, csb[1].getCharactersCoveredLength() ); - assertEquals(0, csb[2].getCharactersCoveredLength() ); + // Set for the appropriate text sizes + stpa.setParentTextSize(data_a_text_len); + stpb.setParentTextSize(data_b_text_len); + + // In both cases, we should have three different character stylings + assertEquals(3, stpa.getCharacterStyles().size()); + assertEquals(3, stpb.getCharacterStyles().size()); } - public void testCharacterProps() throws Exception { + + public void testCharacterStyleLengths() throws Exception { StyleTextPropAtom stpa = new StyleTextPropAtom(data_a,0,data_a.length); StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length); - // Set A has no styles - CharacterStyle[] csa = stpa.getCharacterStyles(); - for(int i=0; i