From 2030a436e6694b598f93e15c0e90bdcc0cfbd43d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 26 Jun 2005 18:09:42 +0000 Subject: [PATCH] Test to ensure that the code for working out the "most recent" versions of the key records (from PersistPtr records) is working correctly git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353730 13f79535-47bb-0310-9956-ffa450edef68 --- .../hslf/usermodel/TestMostRecentRecords.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java new file mode 100644 index 0000000000..8ef175c2a2 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java @@ -0,0 +1,99 @@ + +/* ==================================================================== + Copyright 2002-2004 Apache Software Foundation + + Licensed 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.usermodel; + + +import junit.framework.TestCase; +import org.apache.poi.hslf.*; +import org.apache.poi.hslf.record.*; + +/** + * Tests that SlideShow finds the right records as its most recent ones + * + * @author Nick Burch (nick at torchbox dot com) + */ +public class TestMostRecentRecords extends TestCase { + // HSLFSlideShow primed on the test data + private HSLFSlideShow hss; + // SlideShow primed on the test data + private SlideShow ss; + + public TestMostRecentRecords() throws Exception { + String dirname = System.getProperty("HSLF.testdata.path"); + String filename = dirname + "/basic_test_ppt_file.ppt"; + hss = new HSLFSlideShow(filename); + ss = new SlideShow(hss); + } + + public void testCount() throws Exception { + // Most recent core records + Record[] mrcr = ss.getMostRecentCoreRecords(); + + // Master sheet + master notes + 2 slides + 2 notes + document + assertEquals(7, mrcr.length); + } + + public void testRightRecordTypes() throws Exception { + // Most recent core records + Record[] mrcr = ss.getMostRecentCoreRecords(); + + // Document + assertEquals(1000, mrcr[0].getRecordType()); + // Notes of master + assertEquals(1008, mrcr[1].getRecordType()); + // Master + assertEquals(1016, mrcr[2].getRecordType()); + + // Slide + assertEquals(1006, mrcr[3].getRecordType()); + // Notes + assertEquals(1008, mrcr[4].getRecordType()); + // Slide + assertEquals(1006, mrcr[5].getRecordType()); + // Notes + assertEquals(1008, mrcr[6].getRecordType()); + } + + public void testCorrectRecords() throws Exception { + // Most recent core records + Record[] mrcr = ss.getMostRecentCoreRecords(); + + // All records + Record[] allr = hss.getRecords(); + + // Ensure they are the right (latest) version of each + + // Document - late version + assertEquals(allr[12], mrcr[0]); + // Notes of master - unchanged + assertEquals(allr[2], mrcr[1]); + // Master - unchanged + assertEquals(allr[1], mrcr[2]); + + // Slide - added at start + assertEquals(allr[3], mrcr[3]); + // Notes - added at start + assertEquals(allr[4], mrcr[4]); + // Slide - added later and then changed + assertEquals(allr[13], mrcr[5]); + // Notes - added later but not changed + assertEquals(allr[9], mrcr[6]); + } +} -- 2.39.5