From 7134c5969d5a335d5f4b5d2af3d0c428d67614b4 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 21 Apr 2006 14:06:10 +0000 Subject: [PATCH] Tests to go with fix for bug 39374 git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@395889 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hslf/model/TestShapes.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java index 6ed7b7fce4..ed98fad0ab 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java @@ -122,7 +122,7 @@ public class TestShapes extends TestCase { * Verify that we can add TextBox shapes to a slide * and set some of the style attributes */ - public void testTextBoxWrite() throws Exception { + public void testTextBoxWriteBytes() throws Exception { ppt = new SlideShow(); Slide sl = ppt.createSlide(); RichTextRun rt; @@ -163,4 +163,49 @@ public class TestShapes extends TestCase { assertTrue(rt.isItalic()); assertFalse(rt.isUnderlined()); } + + /** + * Verify that we can add TextBox shapes to a slide + * and set some of the style attributes, with a unicode string + */ + public void testTextBoxWriteChars() throws Exception { + ppt = new SlideShow(); + Slide sl = ppt.createSlide(); + RichTextRun rt; + + String val = "Hello, World! (With some \u1234 and \uffee unicode in it)"; + + // Create a new textbox, and give it lots of properties + TextBox txtbox = new TextBox(); + txtbox.setText(val); + txtbox.setFontSize(42); + txtbox.setBold(true); + txtbox.setUnderline(false); + sl.addShape(txtbox); + + // Check it before save + rt = txtbox.getRichTextRuns()[0]; + assertEquals(val, rt.getText()); + assertEquals(42, rt.getFontSize()); + assertTrue(rt.isBold()); + assertFalse(rt.isItalic()); + assertFalse(rt.isUnderlined()); + + // Serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ppt.write(out); + out.close(); + + ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()))); + + txtbox = (TextBox)sl.getShapes()[0]; + rt = txtbox.getRichTextRuns()[0]; + + // Check after save + assertEquals(val, rt.getText()); + assertEquals(42, rt.getFontSize()); + assertTrue(rt.isBold()); + assertFalse(rt.isItalic()); + assertFalse(rt.isUnderlined()); + } } -- 2.39.5