FileDocCategorySizeDatePackage
TestDocument.javaAPI DocApache Poi 3.0.13343Sun Mar 11 12:59:32 GMT 2007org.apache.poi.hslf.record

TestDocument

public class TestDocument extends TestCase
Tests that Document works properly (Also tests Environment while we're at it)
author
Nick Burch (nick at torchbox dot com)

Fields Summary
private HSLFSlideShow
ss
private POIFSFileSystem
pfs
Constructors Summary
public TestDocument()

		String dirname = System.getProperty("HSLF.testdata.path");
		String filename = dirname + "/basic_test_ppt_file.ppt";
		FileInputStream fis = new FileInputStream(filename);
		pfs = new POIFSFileSystem(fis);
		ss = new HSLFSlideShow(pfs);
    
Methods Summary
private org.apache.poi.hslf.record.DocumentgetDocRecord()

    	Record[] r = ss.getRecords();
    	for(int i=(r.length-1); i>=0; i--) {
    		if(r[i] instanceof Document) {
    			return (Document)r[i];
    		}
    	}
    	throw new IllegalStateException("No Document record found");
    
public voidtestChildRecords()

    	Document dr = getDocRecord();
    	assertNotNull(dr.getDocumentAtom());
    	assertTrue(dr.getDocumentAtom() instanceof DocumentAtom);
    	
    	assertNotNull(dr.getEnvironment());
    	assertTrue(dr.getEnvironment() instanceof Environment);
    	
    	assertNotNull(dr.getSlideListWithTexts());
    	assertEquals(3, dr.getSlideListWithTexts().length);
    	assertNotNull(dr.getSlideListWithTexts()[0]);
    	assertTrue(dr.getSlideListWithTexts()[0] instanceof SlideListWithText);
    	assertNotNull(dr.getSlideListWithTexts()[1]);
    	assertTrue(dr.getSlideListWithTexts()[1] instanceof SlideListWithText);
    	assertNotNull(dr.getSlideListWithTexts()[2]);
    	assertTrue(dr.getSlideListWithTexts()[2] instanceof SlideListWithText);
    
public voidtestEnvironment()

    	Document dr = getDocRecord();
    	Environment env = dr.getEnvironment();
    	
    	assertEquals(1010, env.getRecordType());
    	assertNotNull(env.getFontCollection());
    	assertTrue(env.getFontCollection() instanceof FontCollection);
    
public voidtestRecordType()

    	Document dr = getDocRecord();
    	assertEquals(1000, dr.getRecordType());