From: Nick Burch Date: Mon, 27 Mar 2006 21:42:13 +0000 (+0000) Subject: Add more tests to ensure the IDs are still correct after writing out and reading... X-Git-Tag: REL_3_0_ALPHA3~138 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=590e69ce42766c184fb5402634da9ec1f0a32bf6;p=poi.git Add more tests to ensure the IDs are still correct after writing out and reading back in again git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@389292 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java index 3dab026ecb..ded6519b1b 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java @@ -110,6 +110,7 @@ public class TestSlides extends TestCase { assertEquals(258, s3._getSheetNumber()); assertEquals(3, s3.getSlideNumber()); + //serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); ppt.write(out); @@ -117,6 +118,18 @@ public class TestSlides extends TestCase { ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 3); + + // Check IDs are still right + s1 = ppt.getSlides()[0]; + assertEquals(256, s1._getSheetNumber()); + assertEquals(3, s1._getSheetRefId()); + s2 = ppt.getSlides()[1]; + assertEquals(257, s2._getSheetNumber()); + assertEquals(4, s2._getSheetRefId()); + s3 = ppt.getSlides()[2];; + assertTrue(ppt.getSlides().length == 3); + assertEquals(258, s3._getSheetNumber()); + assertEquals(5, s3._getSheetRefId()); } /** @@ -127,16 +140,44 @@ public class TestSlides extends TestCase { SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/basic_test_ppt_file.ppt")); assertTrue(ppt.getSlides().length == 2); - ppt.createSlide(); + + // First slide is 256 / 4 + Slide s1 = ppt.getSlides()[0]; + assertEquals(256, s1._getSheetNumber()); + assertEquals(4, s1._getSheetRefId()); + + // Last slide is 257 / 6 + Slide s2 = ppt.getSlides()[1]; + assertEquals(257, s2._getSheetNumber()); + assertEquals(6, s2._getSheetRefId()); + + // Add another slide, goes in at the end + Slide s3 = ppt.createSlide(); assertTrue(ppt.getSlides().length == 3); + assertEquals(258, s3._getSheetNumber()); + assertEquals(8, s3._getSheetRefId()); - //serialize and read again + + // Serialize and read again ByteArrayOutputStream out = new ByteArrayOutputStream(); ppt.write(out); out.close(); ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); assertTrue(ppt.getSlides().length == 3); + + + // Check IDs are still right + s1 = ppt.getSlides()[0]; + assertEquals(256, s1._getSheetNumber()); + assertEquals(4, s1._getSheetRefId()); + s2 = ppt.getSlides()[1]; + assertEquals(257, s2._getSheetNumber()); + assertEquals(6, s2._getSheetRefId()); + s3 = ppt.getSlides()[2];; + assertTrue(ppt.getSlides().length == 3); + assertEquals(258, s3._getSheetNumber()); + assertEquals(8, s3._getSheetRefId()); } }