poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1204133 - /poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
Date Sun, 20 Nov 2011 06:34:32 GMT
Author: yegor
Date: Sun Nov 20 06:34:32 2011
New Revision: 1204133

URL: http://svn.apache.org/viewvc?rev=1204133&view=rev
Log:
fixed TestXSLFTextParagraph that failed when the Arial font was not available

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java?rev=1204133&r1=1204132&r2=1204133&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java
Sun Nov 20 06:34:32 2011
@@ -1,6 +1,8 @@
 package org.apache.poi.xslf.usermodel;
 
 import junit.framework.TestCase;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 import java.awt.*;
 import java.awt.geom.Rectangle2D;
@@ -15,6 +17,7 @@ import java.util.List;
  * To change this template use File | Settings | File Templates.
  */
 public class TestXSLFTextParagraph extends TestCase {
+    private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class);
 
     public void testWrappingWidth() throws Exception {
         XMLSlideShow ppt = new XMLSlideShow();
@@ -100,14 +103,33 @@ public class TestXSLFTextParagraph exten
         assertEquals(expectedWidth, p.getWrappingWidth(false));
      }
 
+    /**
+     * test breaking test into lines.
+     * This test is platform-dependent and will run only if the test fonr (Arial)
+     * is present in local graphics environment
+     */
     public void testBreakLines(){
+        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        String testFont = "Arial";
+        boolean testFontAvailable = false;
+        for(String family : env.getAvailableFontFamilyNames()) {
+            if(family.equals(testFont)) {
+                testFontAvailable = true;
+                break;
+            }
+        }
+
+        if(!testFontAvailable) {
+            _logger.log(POILogger.WARN, "the Arial font family is not available in local
graphics environment");
+        }
+
         XMLSlideShow ppt = new XMLSlideShow();
         XSLFSlide slide = ppt.createSlide();
         XSLFTextShape sh = slide.createAutoShape();
 
         XSLFTextParagraph p = sh.addNewTextParagraph();
         XSLFTextRun r = p.addNewTextRun();
-        r.setFontFamily("serif"); // this should always be available
+        r.setFontFamily("Arial"); // this should always be available
         r.setFontSize(12);
         r.setText(
                 "Paragraph formatting allows for more granular control " +
@@ -121,12 +143,12 @@ public class TestXSLFTextParagraph exten
 
         List<TextFragment> lines;
         lines = p.breakText(graphics);
-        assertEquals(3, lines.size());
+        assertEquals(4, lines.size());
 
         // descrease the shape width from 300 pt to 100 pt
         sh.setAnchor(new Rectangle(50, 50, 100, 200));
         lines = p.breakText(graphics);
-        assertEquals(10, lines.size());
+        assertEquals(12, lines.size());
 
         // descrease the shape width from 300 pt to 100 pt
         sh.setAnchor(new Rectangle(50, 50, 600, 200));
@@ -137,7 +159,7 @@ public class TestXSLFTextParagraph exten
         sh.setLeftInset(200);
         sh.setRightInset(200);
         lines = p.breakText(graphics);
-        assertEquals(4, lines.size());
+        assertEquals(5, lines.size());
 
         r.setText("Apache POI");
         lines = p.breakText(graphics);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message