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 2006/04/19 13:41:27 UTC
svn commit: r395219 -
/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
Author: nick
Date: Wed Apr 19 04:41:27 2006
New Revision: 395219
URL: http://svn.apache.org/viewcvs?rev=395219&view=rev
Log:
Updated test from Yegor, to also test creating text boxes with properties
Modified:
jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
Modified: jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=395219&r1=395218&r2=395219&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ jakarta/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Wed Apr 19 04:41:27 2006
@@ -120,51 +120,47 @@
/**
* Verify that we can add TextBox shapes to a slide
- * @throws Exception
+ * and set some of the style attributes
*/
public void testTextBoxWrite() throws Exception {
ppt = new SlideShow();
Slide sl = ppt.createSlide();
+ RichTextRun rt;
+ String val = "Hello, World!";
+
+ // Create a new textbox, and give it lots of properties
TextBox txtbox = new TextBox();
- txtbox.setText("Hello, World!");
+ txtbox.setText(val);
txtbox.setFontSize(42);
txtbox.setBold(true);
txtbox.setItalic(true);
-
+ txtbox.setUnderline(false);
sl.addShape(txtbox);
- txtbox = new TextBox();
- txtbox.setText("Plain text in default font");
- sl.addShape(txtbox);
+ // Check it before save
+ rt = txtbox.getRichTextRuns()[0];
+ assertEquals(val, rt.getText());
+ assertEquals(42, rt.getFontSize());
+ assertTrue(rt.isBold());
+ assertTrue(rt.isItalic());
+ assertFalse(rt.isUnderlined());
- assertEquals(sl.getShapes().length, 2);
-
- //serialize and read again
+ // Serialize and read again
ByteArrayOutputStream out = new ByteArrayOutputStream();
ppt.write(out);
out.close();
ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));
- sl = ppt.getSlides()[0];
- assertEquals(sl.getShapes().length, 2);
- Shape[] sh = sl.getShapes();
- for (int i = 0; i < sh.length; i++) {
- assertTrue(sh[i] instanceof TextBox);
- txtbox = (TextBox)sh[i];
- String text = txtbox.getText();
- assertNotNull(text);
-
- assertEquals(txtbox.getRichTextRuns().length, 1);
- RichTextRun rt = txtbox.getRichTextRuns()[0];
-
- if (text.equals("Hello, World!")){
- assertEquals(42, rt.getFontSize());
- assertTrue(rt.isBold());
- assertTrue(rt.isItalic());
- }
- }
- }
+ txtbox = (TextBox)sl.getShapes()[0];
+ rt = txtbox.getRichTextRuns()[0];
+ // Check after save
+ assertEquals(val, rt.getText());
+ assertEquals(42, rt.getFontSize());
+ assertTrue(rt.isBold());
+ assertTrue(rt.isItalic());
+ assertFalse(rt.isUnderlined());
+ }
}
---------------------------------------------------------------------
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/