]> source.dussan.org Git - poi.git/commitdiff
Add more tests to ensure the IDs are still correct after writing out and reading...
authorNick Burch <nick@apache.org>
Mon, 27 Mar 2006 21:42:13 +0000 (21:42 +0000)
committerNick Burch <nick@apache.org>
Mon, 27 Mar 2006 21:42:13 +0000 (21:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@389292 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hslf/model/TestSlides.java

index 3dab026ecb06005fb68b54b37a807a5feaf58dfa..ded6519b1ba3002c2b31eea67d2a6df47e692513 100644 (file)
@@ -110,6 +110,7 @@ public class TestSlides extends TestCase {
         assertEquals(258, s3._getSheetNumber());\r
         assertEquals(3, s3.getSlideNumber());\r
 \r
+        \r
         //serialize and read again\r
          ByteArrayOutputStream out = new ByteArrayOutputStream();\r
         ppt.write(out);\r
@@ -117,6 +118,18 @@ public class TestSlides extends TestCase {
 \r
         ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));\r
         assertTrue(ppt.getSlides().length == 3);\r
+        \r
+        // Check IDs are still right\r
+        s1 = ppt.getSlides()[0];\r
+        assertEquals(256, s1._getSheetNumber());\r
+        assertEquals(3, s1._getSheetRefId());\r
+        s2 = ppt.getSlides()[1];\r
+        assertEquals(257, s2._getSheetNumber());\r
+        assertEquals(4, s2._getSheetRefId());\r
+        s3 = ppt.getSlides()[2];;\r
+        assertTrue(ppt.getSlides().length == 3);\r
+        assertEquals(258, s3._getSheetNumber());\r
+        assertEquals(5, s3._getSheetRefId());\r
     }\r
 \r
     /**\r
@@ -127,16 +140,44 @@ public class TestSlides extends TestCase {
         SlideShow ppt = new SlideShow(new HSLFSlideShow(dirname + "/basic_test_ppt_file.ppt"));\r
         \r
         assertTrue(ppt.getSlides().length == 2);\r
-        ppt.createSlide();\r
+        \r
+        // First slide is 256 / 4\r
+        Slide s1 = ppt.getSlides()[0];\r
+        assertEquals(256, s1._getSheetNumber());\r
+        assertEquals(4, s1._getSheetRefId());\r
+        \r
+        // Last slide is 257 / 6\r
+        Slide s2 = ppt.getSlides()[1];\r
+        assertEquals(257, s2._getSheetNumber());\r
+        assertEquals(6, s2._getSheetRefId());\r
+        \r
+        // Add another slide, goes in at the end\r
+        Slide s3 = ppt.createSlide();\r
         assertTrue(ppt.getSlides().length == 3);\r
+        assertEquals(258, s3._getSheetNumber());\r
+        assertEquals(8, s3._getSheetRefId());\r
 \r
-        //serialize and read again\r
+        \r
+        // Serialize and read again\r
          ByteArrayOutputStream out = new ByteArrayOutputStream();\r
         ppt.write(out);\r
         out.close();\r
 \r
         ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));\r
         assertTrue(ppt.getSlides().length == 3);\r
+        \r
+        \r
+        // Check IDs are still right\r
+        s1 = ppt.getSlides()[0];\r
+        assertEquals(256, s1._getSheetNumber());\r
+        assertEquals(4, s1._getSheetRefId());\r
+        s2 = ppt.getSlides()[1];\r
+        assertEquals(257, s2._getSheetNumber());\r
+        assertEquals(6, s2._getSheetRefId());\r
+        s3 = ppt.getSlides()[2];;\r
+        assertTrue(ppt.getSlides().length == 3);\r
+        assertEquals(258, s3._getSheetNumber());\r
+        assertEquals(8, s3._getSheetRefId());\r
     }\r
 \r
 }\r