[FOray-commit] SF.net SVN: foray: [10214] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-09-25 17:46:13
|
Revision: 10214
http://foray.svn.sourceforge.net/foray/?rev=10214&view=rev
Author: victormote
Date: 2007-09-25 10:46:16 -0700 (Tue, 25 Sep 2007)
Log Message:
-----------
Add test for line centering.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
Added Paths:
-----------
trunk/foray/resource/test/fo/block-003.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-17 15:35:13 UTC (rev 10213)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-09-25 17:46:16 UTC (rev 10214)
@@ -34,6 +34,7 @@
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
import org.foray.area.PageCollection;
+import org.foray.area.TextArea;
import org.foray.core.FOrayException;
/**
@@ -215,4 +216,63 @@
assertEquals(testString, documentContent);
}
+ /**
+ * Test of fo/block-003.fo.
+ * @throws FOrayException For errors creating the FO Tree or Area Tree.
+ */
+ public void testBlock003() throws FOrayException {
+ final AreaTreeCreator creator = AreaTreeCreator.getInstance();
+ final AreaTree areaTree = creator.buildAreaTree(
+ "fo/block-003.fo");
+ final NormalFlowRA firstNormalFlowArea = this.getFirstNormalFlowArea(
+ areaTree);
+
+ /* Test location and dimensions of the block area. */
+ AreaNode node = firstNormalFlowArea.getChildAt(0);
+ assertTrue(node instanceof NormalBlockArea);
+ final NormalBlockArea blockArea = (NormalBlockArea) node;
+ /* 1 inch left margin. */
+ assertEquals(72000, blockArea.crOriginX());
+ /* 10 inches from bottom (11 inches high, 1 inch top margin). */
+ assertEquals(720000, blockArea.crOriginY());
+ /* Page is 8.5 inches wide, with 2 inches total margin.
+ * 6.5 * 72,000 = 468,000. */
+ assertEquals(468000, blockArea.crIpd());
+
+ /* Test location and dimensions of the line area. */
+ node = blockArea.getChildAt(0);
+ assertTrue(node instanceof LineArea);
+ final LineArea lineArea = (LineArea) node;
+ /* x same as the parent block. */
+ assertEquals(72000, lineArea.crOriginX());
+ /* y adjusted for half-leading = 12,000 * .2 * .5 = 1200. */
+ assertEquals(718800, lineArea.crOriginY());
+ /* ipd same as parent block. */
+ assertEquals(468000, lineArea.crIpd());
+
+ /* Test location and dimensions of the text area. The key thing we are
+ * testing here is that IT IS CENTERED. */
+ node = lineArea.getChildAt(0);
+ assertTrue(node instanceof TextArea);
+ final TextArea textArea = (TextArea) node;
+
+ /* The text is "Test of Centering". From the Helvetica AFM file, the
+ * widths are as follows: T(611) + e(556) + s(500) + t(278) + space(278)
+ * + o(556) + f(278) + space(278) + C(722) + e(556) + n(556) + t(278)
+ * + e(556) + r(333) + i(222) + n(556) + g(556) = 7,670. If these are
+ * scaled to 12 points, the millipoints used are 7670 * 12 = 92,040. */
+ assertEquals(92040, textArea.crIpd());
+
+ /* The x value of the text area content rectangle should be at the x
+ * location of the parent line area + 1/2 of the unused area in the
+ * line. Total line area ipd = 468,000. Unused line area ipd =
+ * 468,000 - 92,040 = 375,960. One half of the unused line area ipd =
+ * 187,980. x = 72,000 + 187,980 = 259,980. */
+ assertEquals(259980, textArea.crOriginX());
+
+ /* The y value of the text area content rectangle should be the same as
+ * the parent line area. */
+ assertEquals(718800, textArea.crOriginY());
+ }
+
}
Added: trunk/foray/resource/test/fo/block-003.fo
===================================================================
--- trunk/foray/resource/test/fo/block-003.fo (rev 0)
+++ trunk/foray/resource/test/fo/block-003.fo 2007-09-25 17:46:16 UTC (rev 10214)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+This fo tests basic centering of content on a line.
+-->
+
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<fo:layout-master-set>
+ <fo:simple-page-master
+ master-name="simple"
+ page-height="11in"
+ page-width="8.5in"
+ margin-top="1in"
+ margin-bottom="1in"
+ margin-left="1in"
+ margin-right="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+</fo:layout-master-set>
+
+<fo:page-sequence master-reference="simple">
+<fo:flow flow-name="xsl-region-body">
+
+<fo:block font-family="sans-serif" font-size="12pt" text-align="center">Test of
+Centering</fo:block>
+
+</fo:flow>
+</fo:page-sequence>
+</fo:root>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|