]> source.dussan.org Git - poi.git/commitdiff
Tests to go with fix for bug 39374
authorNick Burch <nick@apache.org>
Fri, 21 Apr 2006 14:06:10 +0000 (14:06 +0000)
committerNick Burch <nick@apache.org>
Fri, 21 Apr 2006 14:06:10 +0000 (14:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@395889 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java

index 6ed7b7fce4e527b5e561eaced2b000a87612de99..ed98fad0abf9c3959ccf6d422ab893715e0a9c7b 100644 (file)
@@ -122,7 +122,7 @@ public class TestShapes extends TestCase {
      * Verify that we can add TextBox shapes to a slide\r
      * and set some of the style attributes\r
      */\r
-    public void testTextBoxWrite() throws Exception {\r
+    public void testTextBoxWriteBytes() throws Exception {\r
         ppt = new SlideShow();\r
         Slide sl = ppt.createSlide();\r
         RichTextRun rt;\r
@@ -163,4 +163,49 @@ public class TestShapes extends TestCase {
         assertTrue(rt.isItalic());\r
         assertFalse(rt.isUnderlined());\r
     }\r
+\r
+    /**\r
+     * Verify that we can add TextBox shapes to a slide\r
+     * and set some of the style attributes, with a unicode string\r
+     */\r
+    public void testTextBoxWriteChars() throws Exception {\r
+        ppt = new SlideShow();\r
+        Slide sl = ppt.createSlide();\r
+        RichTextRun rt;\r
+\r
+        String val = "Hello, World! (With some \u1234 and \uffee unicode in it)";\r
+\r
+        // Create a new textbox, and give it lots of properties\r
+        TextBox txtbox = new TextBox();\r
+        txtbox.setText(val);\r
+        txtbox.setFontSize(42);\r
+        txtbox.setBold(true);\r
+        txtbox.setUnderline(false);\r
+        sl.addShape(txtbox);\r
+\r
+        // Check it before save\r
+        rt = txtbox.getRichTextRuns()[0];\r
+        assertEquals(val, rt.getText());\r
+        assertEquals(42, rt.getFontSize());\r
+        assertTrue(rt.isBold());\r
+        assertFalse(rt.isItalic());\r
+        assertFalse(rt.isUnderlined());\r
+\r
+        // Serialize and read again\r
+        ByteArrayOutputStream out = new ByteArrayOutputStream();\r
+        ppt.write(out);\r
+        out.close();\r
+\r
+        ppt = new SlideShow(new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray())));\r
+\r
+        txtbox = (TextBox)sl.getShapes()[0];\r
+        rt = txtbox.getRichTextRuns()[0];\r
+\r
+        // Check after save\r
+        assertEquals(val, rt.getText());\r
+        assertEquals(42, rt.getFontSize());\r
+        assertTrue(rt.isBold());\r
+        assertFalse(rt.isItalic());\r
+        assertFalse(rt.isUnderlined());\r
+    }\r
 }\r