You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ni...@apache.org on 2005/06/26 20:09:42 UTC

cvs commit: jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/usermodel TestMostRecentRecords.java

nick        2005/06/26 11:09:42

  Added:       src/scratchpad/testcases/org/apache/poi/hslf/usermodel
                        TestMostRecentRecords.java
  Log:
  Test to ensure that the code for working out the "most recent" versions
  of the key records (from PersistPtr records) is working correctly
  
  Revision  Changes    Path
  1.1                  jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestMostRecentRecords.java
  
  Index: TestMostRecentRecords.java
  ===================================================================
  
  /* ====================================================================
     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]);
  	}
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/