mirror of https://github.com/apache/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
This commit is contained in:
parent
74d7d53fa7
commit
590e69ce42
|
@ -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();
|
||||
assertTrue(ppt.getSlides().length == 3);
|
||||
|
||||
//serialize and read again
|
||||
// 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
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue