FileDocCategorySizeDatePackage
TestSheetText.javaAPI DocApache Poi 3.0.13384Mon Jan 01 18:55:40 GMT 2007org.apache.poi.hslf.usermodel

TestSheetText

public class TestSheetText extends TestCase
Tests that SlideShow returns Sheets which have the right text in them
author
Nick Burch (nick at torchbox dot com)

Fields Summary
private SlideShow
ss
Constructors Summary
public TestSheetText()

		String dirname = System.getProperty("HSLF.testdata.path");
		String filename = dirname + "/basic_test_ppt_file.ppt";
		HSLFSlideShow hss = new HSLFSlideShow(filename);
		ss = new SlideShow(hss);
    
Methods Summary
public voidtestSheetOne()

		Sheet slideOne = ss.getSlides()[0];

		String[] expectText = new String[] {"This is a test title","This is a test subtitle\nThis is on page 1"};
		assertEquals(expectText.length, slideOne.getTextRuns().length);
		for(int i=0; i<expectText.length; i++) {
			assertEquals(expectText[i], slideOne.getTextRuns()[i].getText());
		}
    
public voidtestSheetTwo()

		Sheet slideTwo = ss.getSlides()[1];
		String[] expectText = new String[] {"This is the title on page 2","This is page two\nIt has several blocks of text\nNone of them have formatting"};
		assertEquals(expectText.length, slideTwo.getTextRuns().length);
		for(int i=0; i<expectText.length; i++) {
			assertEquals(expectText[i], slideTwo.getTextRuns()[i].getText());
		}
	
public voidtestWithShortTextPropData()
Check we can still get the text from a file where the TextProps don't have enough data. (Make sure we don't screw up / throw an exception etc)

		String dirname = System.getProperty("HSLF.testdata.path");
		String filename = dirname + "/iisd_report.ppt";
		HSLFSlideShow hss = new HSLFSlideShow(filename);
		SlideShow sss = new SlideShow(hss);
		
		// Should come out with 10 slides, no notes
		assertEquals(10, sss.getSlides().length);
		assertEquals(0, sss.getNotes().length);
		
		// Check text on first slide
		Slide s = sss.getSlides()[0];
		String exp = 
			"Realizing the Development Dividend:\n" +
			"Community Capacity Building and CDM.\n" +
			"Can they co-exist?\n\n" +
			"Gay Harley\n" +
			"Clean Development Alliance\n" +
			"COP 11 \u2013 MOP 1\n" + // special long hyphon
			"December 5, 2005\n";

		assertEquals(1, s.getTextRuns().length);
		assertEquals(exp, s.getTextRuns()[0].getText());