[FOray-commit] SF.net SVN: foray: [9723] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-08 20:07:52
|
Revision: 9723
http://svn.sourceforge.net/foray/?rev=9723&view=rev
Author: victormote
Date: 2007-06-08 13:07:50 -0700 (Fri, 08 Jun 2007)
Log Message:
-----------
Add a test for inline SVG at the FOTree level.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
Added Paths:
-----------
trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
trunk/foray/resource/test/fo/graphic-001.fo
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2007-06-08 19:45:52 UTC (rev 9722)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayApp.java 2007-06-08 20:07:50 UTC (rev 9723)
@@ -32,6 +32,7 @@
import org.foray.app.area.TestBorder;
import org.foray.app.area.TestMetadata;
import org.foray.app.fo.TestFont;
+import org.foray.app.fo.TestGraphic;
import org.foray.app.fo.TestInvalidXml;
import junit.framework.Test;
@@ -53,6 +54,7 @@
/* First the FO Tree tests. */
testSuite.addTestSuite(TestInvalidXml.class);
testSuite.addTestSuite(TestFont.class);
+ testSuite.addTestSuite(TestGraphic.class);
/* Now the Area Tree tests. */
testSuite.addTestSuite(TestBorder.class);
Added: trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java (rev 0)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java 2007-06-08 20:07:50 UTC (rev 9723)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2007 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.app.fo;
+
+import org.foray.core.FOrayException;
+import org.foray.fotree.FONode;
+import org.foray.fotree.FOTreeBuilder;
+import org.foray.fotree.fo.obj.Block;
+import org.foray.fotree.fo.obj.Flow;
+import org.foray.fotree.fo.obj.InstreamForeignObject;
+import org.foray.fotree.svg.obj.SVGElement;
+
+/**
+ * Tests of various graphic capabilities at the FO Tree level.
+ */
+public class TestGraphic extends AbstractFoTreeTest {
+
+ /**
+ * Test of fo/graphic-001.fo.
+ * This file contains an fo:instream-foreign-object with a simple SVG in it.
+ * @throws FOrayException For errors creating the FO Tree.
+ */
+ public void testGraphic001() throws FOrayException {
+ final FoDocumentReader reader = FoDocumentReader.getInstance();
+ final FOTreeBuilder foTree = reader.buildFoTree(
+ "fo/graphic-001.fo");
+ final Flow flow = this.getFlow(foTree);
+
+ /* The second child should be a block ... */
+ FONode node = flow.getChildAt(1);
+ assertTrue(node instanceof Block);
+ final Block block = (Block) node;
+
+ /* ... which contains an InstreamForeignObject ... */
+ node = block.getChildAt(0);
+ assertTrue(node instanceof InstreamForeignObject);
+ final InstreamForeignObject ifo = (InstreamForeignObject) node;
+
+ /* ... which contains an SVGElement ... */
+ node = ifo.getChildAt(0);
+ assertTrue(node instanceof SVGElement);
+ final SVGElement svgElement = (SVGElement) node;
+
+ /* ... for which we can find the width and height. */
+
+ /* The pixel width is 20. At the default screen resolution of 96 dpi,
+ * the millipoints are (20 / 96) * 72000 = 15000. */
+ assertEquals(15000, svgElement.intrinsicContentWidth());
+ assertEquals(15000, svgElement.intrinsicContentHeight());
+ }
+
+}
Property changes on: trunk/foray/foray-app/src/javatest/org/foray/app/fo/TestGraphic.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/resource/test/fo/graphic-001.fo
===================================================================
--- trunk/foray/resource/test/fo/graphic-001.fo (rev 0)
+++ trunk/foray/resource/test/fo/graphic-001.fo 2007-06-08 20:07:50 UTC (rev 9723)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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>The following block contains an inline SVG wrapped in a
+fo:foreign-xml object.</fo:block>
+
+<fo:block><fo:instream-foreign-object>
+
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
+ xml:space="preserve">
+ <g style="fill:red; stroke:#000000">
+ <rect x="0" y="0" width="15" height="15"/>
+ <rect x="5" y="5" width="15" height="15"/>
+ </g>
+</svg>
+
+</fo:instream-foreign-object></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.
|