poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/extractor TextExtractor.java
Date Sun, 13 Nov 2005 17:01:54 GMT
nick        2005/11/13 09:01:54

  Modified:    src/scratchpad/testcases/org/apache/poi/hslf/extractor
                        TextExtractor.java
  Log:
  Test for extracting text from slide PPDrawings (to ensure bug 37451 is really fixed)
  
  Revision  Changes    Path
  1.2       +34 -18    jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TextExtractor.java
  
  Index: TextExtractor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TextExtractor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextExtractor.java	28 May 2005 05:36:00 -0000	1.1
  +++ TextExtractor.java	13 Nov 2005 17:01:54 -0000	1.2
  @@ -28,40 +28,56 @@
    * @author Nick Burch (nick at torchbox dot com)
    */
   public class TextExtractor extends TestCase {
  -	// Extractor primed on the test data
  +	// Extractor primed on the 2 page basic test data
   	private PowerPointExtractor ppe;
  +	// Extractor primed on the 1 page but text-box'd test data
  +	private PowerPointExtractor ppe2;
   
       public TextExtractor() throws Exception {
   		String dirname = System.getProperty("HSLF.testdata.path");
   		String filename = dirname + "/basic_test_ppt_file.ppt";
   		ppe = new PowerPointExtractor(filename);
  +		String filename2 = dirname + "/with_textbox.ppt";
  +		ppe2 = new PowerPointExtractor(filename2);
       }
   
       public void testReadSheetText() throws Exception {
  +    	// Basic 2 page example
   		String sheetText = ppe.getText();
   		String expectText = "This is a test title\nThis is a test subtitle\nThis is on page 1\nThis
is the title on page 2\nThis is page two\nIt has several blocks of text\nNone of them have
formatting\n";
   
  -		assertEquals(expectText.length(),sheetText.length());
  -		char[] st = sheetText.toCharArray();
  -		char[] et = expectText.toCharArray();
  -		for(int i=0; i<et.length; i++) {
  -			System.out.println(i + "\t" + et[i] + " " + st[i]);
  -			assertEquals(et[i],st[i]);
  -		}
  -		assertEquals(expectText,sheetText);
  -    }
  +		ensureTwoStringsTheSame(expectText, sheetText);
  +		
  +		
  +		// 1 page example with text boxes
  +		sheetText = ppe2.getText();
  +		expectText = "Hello, World!!!\nI am just a poor boy\nThis is Times New Roman\nPlain Text
\n"; 
   
  +		ensureTwoStringsTheSame(expectText, sheetText);
  +    }
  +    
   	public void testReadNoteText() throws Exception {
  +		// Basic 2 page example
   		String notesText = ppe.getNotes();
   		String expectText = "These are the notes for page 1\nThese are the notes on page two,
again lacking formatting\n";
   
  -		assertEquals(expectText.length(),notesText.length());
  -		char[] nt = notesText.toCharArray();
  -		char[] et = expectText.toCharArray();
  -		for(int i=0; i<et.length; i++) {
  -			System.out.println(i + "\t" + et[i] + " " + nt[i]);
  -			assertEquals(et[i],nt[i]);
  -		}
  -		assertEquals(expectText,notesText);
  +		ensureTwoStringsTheSame(expectText, notesText);
  +		
  +		// Other one doesn't have notes
  +		notesText = ppe2.getNotes();
  +		expectText = "";
  +		
  +		ensureTwoStringsTheSame(expectText, notesText);
   	}
  +	
  +    private void ensureTwoStringsTheSame(String exp, String act) throws Exception {
  +		assertEquals(exp.length(),act.length());
  +		char[] expC = exp.toCharArray();
  +		char[] actC = act.toCharArray();
  +		for(int i=0; i<expC.length; i++) {
  +			System.out.println(i + "\t" + expC[i] + " " + actC[i]);
  +			assertEquals(expC[i],actC[i]);
  +		}
  +		assertEquals(exp,act);
  +    }
   }
  
  
  

---------------------------------------------------------------------
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/


Mime
View raw message