diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-09-26 11:27:35 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-09-26 11:27:35 +0000 |
commit | 79f8cbdb1e9a5a8f46e23f032b62566c1f458017 (patch) | |
tree | 0018129d25685e6c25602f8135c102945c4aacff /test | |
parent | c26b503a94a02b11b1c8f0f94c9d1269aba6f742 (diff) | |
download | xmlgraphics-fop-79f8cbdb1e9a5a8f46e23f032b62566c1f458017.tar.gz xmlgraphics-fop-79f8cbdb1e9a5a8f46e23f032b62566c1f458017.zip |
Merged revisions 693433,693462,693720,693742,693781,693784,693841,695491,695500,695776,696365,697140,697152,698280,698322,698670 via svnmerge from
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r693433 | acumiskey | 2008-09-09 12:00:58 +0100 (Tue, 09 Sep 2008) | 1 line
Make PFM string parsing a little more robust
........
r693462 | acumiskey | 2008-09-09 14:35:13 +0100 (Tue, 09 Sep 2008) | 1 line
This is a better fix which will cater for the case where the first character encountered is the EOF (-1) character. EOF test now only occurs when loop is exit so this should execute more efficiently.
........
r693720 | jeremias | 2008-09-10 08:46:23 +0100 (Wed, 10 Sep 2008) | 1 line
Some older TTF fonts have shorter OS/2 tables. This fixes potential EOFExceptions.
........
r693742 | jeremias | 2008-09-10 10:00:16 +0100 (Wed, 10 Sep 2008) | 3 lines
Bugzilla #45616:
Fix for table handling in RTF output, so the output works with OpenOffice and AbiWord, too.
Submitted by: Pavel Kysilka <goldenfish.at.linuxsoft.cz>
........
r693781 | jeremias | 2008-09-10 11:52:45 +0100 (Wed, 10 Sep 2008) | 3 lines
Bugzilla #45734:
Fix for PFMReader after bug #43089 (r567078) changed the behavior of PFMFile. Fixes baseline problems when Type 1 fonts are used in conjunction with XML font metric files.
Submitted by: J. Frantzius <jfrantzius.at.web.de>
........
r693784 | jeremias | 2008-09-10 11:59:27 +0100 (Wed, 10 Sep 2008) | 1 line
Credits where credits are due. I only noticed afterwards that there was a patch attached to the issue.
........
r693841 | adelmelle | 2008-09-10 14:24:00 +0100 (Wed, 10 Sep 2008) | 1 line
Minor fix: avoid attempts at converting a default namespace declaration as a FO property, if the parser reports it as a regular attribute
........
r695491 | jeremias | 2008-09-15 16:06:28 +0100 (Mon, 15 Sep 2008) | 1 line
PDF Output: Made sure the XMP Metadata stream is never compressed.
........
r695500 | jeremias | 2008-09-15 16:15:44 +0100 (Mon, 15 Sep 2008) | 2 lines
Bugzilla #45755:
Removed ALv2 license header as this file does not have a "creativity" value and only serves as an example.
........
r695776 | maxberger | 2008-09-16 09:56:12 +0100 (Tue, 16 Sep 2008) | 4 lines
Re-enabled image loader testcases
Made sure SVG converters use SVG flavor (updated in commons)
Added new ImageLoaderTest which tests JPGs embedded in SVG
........
r696365 | jeremias | 2008-09-17 17:41:14 +0100 (Wed, 17 Sep 2008) | 3 lines
Bugzilla #45795:
PDF Output: Added support for handling 16-bit alpha channel. They are currently converted to 8 bits.
........
r697140 | jeremias | 2008-09-19 16:57:54 +0100 (Fri, 19 Sep 2008) | 1 line
Fixed stray "xml.apache.org".
........
r697152 | adelmelle | 2008-09-19 18:01:03 +0100 (Fri, 19 Sep 2008) | 1 line
Bugzilla 45842: Use FOP_OPTS environment variable in fop.bat and fop.cmd (patch submitted by Carsten Siedentop)
........
r698280 | adelmelle | 2008-09-23 19:48:34 +0100 (Tue, 23 Sep 2008) | 3 lines
Bugzilla 40798: A conditional-page-master-reference with page-position="last" is also eligible for an only page (first as well as last)
Additionally: added support for page-position="only"
........
r698322 | adelmelle | 2008-09-23 20:55:02 +0100 (Tue, 23 Sep 2008) | 1 line
Cleanup firstWhiteSpaceInSeq at end of block too...
........
r698670 | adelmelle | 2008-09-24 18:45:51 +0100 (Wed, 24 Sep 2008) | 1 line
Added two missing files from r698280
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@699279 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
4 files changed, 300 insertions, 7 deletions
diff --git a/test/java/org/apache/fop/StandardTestSuite.java b/test/java/org/apache/fop/StandardTestSuite.java index c20683912..290b29050 100644 --- a/test/java/org/apache/fop/StandardTestSuite.java +++ b/test/java/org/apache/fop/StandardTestSuite.java @@ -23,6 +23,8 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.apache.fop.fonts.TrueTypeAnsiTestCase; +import org.apache.fop.image.loader.batik.ImageLoaderTestCase; +import org.apache.fop.image.loader.batik.ImagePreloaderTestCase; import org.apache.fop.render.pdf.PDFAConformanceTestCase; import org.apache.fop.render.pdf.PDFCMapTestCase; import org.apache.fop.render.pdf.PDFEncodingTestCase; @@ -50,6 +52,8 @@ public class StandardTestSuite { suite.addTest(new TestSuite(PDFsRGBSettingsTestCase.class)); suite.addTest(new TestSuite(TrueTypeAnsiTestCase.class)); suite.addTest(RichTextFormatTestSuite.suite()); + suite.addTest(new TestSuite(ImageLoaderTestCase.class)); + suite.addTest(new TestSuite(ImagePreloaderTestCase.class)); //$JUnit-END$ return suite; } diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index 457aa91d4..97bfb4d5c 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -19,21 +19,23 @@ package org.apache.fop.image.loader.batik; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; import java.io.File; import junit.framework.TestCase; +import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.FopFactory; import org.apache.xmlgraphics.image.loader.Image; import org.apache.xmlgraphics.image.loader.ImageFlavor; import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.xmlgraphics.image.loader.ImageManager; +import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor; import org.apache.xmlgraphics.image.loader.impl.ImageRendered; import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.writer.ImageWriterUtil; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.FopFactory; - /** * Tests for bundled ImageLoader implementations. */ @@ -59,10 +61,10 @@ public class ImageLoaderTestCase extends TestCase { ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); - Image img = manager.getImage(info, ImageFlavor.XML_DOM, + Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, userAgent.getImageSessionContext()); assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); + assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); ImageXMLDOM imgDom = (ImageXMLDOM)img; assertNotNull(imgDom.getDocument()); assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); @@ -101,10 +103,10 @@ public class ImageLoaderTestCase extends TestCase { ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); assertNotNull("ImageInfo must not be null", info); - Image img = manager.getImage(info, ImageFlavor.XML_DOM, + Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, userAgent.getImageSessionContext()); assertNotNull("Image must not be null", img); - assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); + assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); ImageXMLDOM imgDom = (ImageXMLDOM)img; assertNotNull(imgDom.getDocument()); assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); @@ -160,4 +162,58 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(612000, info.getSize().getHeightMpt()); } + public void testSVGWithReferences() throws Exception { + String uri = "test/resources/fop/svg/images.svg"; + FopFactory ff = FopFactory.newInstance(); + FOUserAgent userAgent = ff.newFOUserAgent(); + + ImageManager manager = ff.getImageManager(); + ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); + assertNotNull("ImageInfo must not be null", info); + + Image img = manager.getImage(info, XMLNamespaceEnabledImageFlavor.SVG_DOM, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(XMLNamespaceEnabledImageFlavor.SVG_DOM, img.getFlavor()); + ImageXMLDOM imgDom = (ImageXMLDOM)img; + assertNotNull(imgDom.getDocument()); + assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); + info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(400000, info.getSize().getWidthMpt()); + assertEquals(400000, info.getSize().getHeightMpt()); + assertEquals(400, info.getSize().getWidthPx()); + assertEquals(400, info.getSize().getHeightPx()); + + img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); + ImageRendered imgRed = (ImageRendered)img; + RenderedImage renImg = imgRed.getRenderedImage(); + assertNotNull(renImg); + if (DEBUG_TARGET_DIR != null) { + ImageWriterUtil.saveAsPNG(renImg, + (int)userAgent.getTargetResolution(), + new File(DEBUG_TARGET_DIR, "images.svg.png")); + } + assertEquals(400, renImg.getWidth()); + assertEquals(400, renImg.getHeight()); + info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(400000, info.getSize().getWidthMpt()); + assertEquals(400000, info.getSize().getHeightMpt()); + Raster raster = renImg.getData(); + // This pixel is white + int[] pixel1 = raster.getPixel(1, 1, (int[] )null); + // This pixel is from the embedded JPG and is not white + int[] pixel80 = raster.getPixel(80, 80, (int[]) null); + assertEquals(pixel1.length, pixel80.length); + boolean same = true; + for (int i = 0; i < pixel1.length; i++) { + same &= (pixel1[i] == pixel80[i]); + } + assertFalse("Embedding JPG into SVG failed", same); + } + + + } diff --git a/test/layoutengine/standard-testcases/page-position_last_bug40798.xml b/test/layoutengine/standard-testcases/page-position_last_bug40798.xml new file mode 100644 index 000000000..3292b42b1 --- /dev/null +++ b/test/layoutengine/standard-testcases/page-position_last_bug40798.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks for the use of a 'last' conditional-page-master-reference + for a first/only page (see: https://issues.apache.org/bugzilla/show_bug.cgi?id=40798) + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" + font-family="Times" font-size="20pt"> + + <fo:layout-master-set> + <fo:simple-page-master master-name="only-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="only-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="first-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="first-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="last-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="last-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="rest-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="rest-region" extent="10mm"/> + </fo:simple-page-master> + + <fo:page-sequence-master master-name="whatever"> + <fo:repeatable-page-master-alternatives maximum-repeats="1"> + <fo:conditional-page-master-reference master-reference="only-page-layout" + page-position="last"/> + <fo:conditional-page-master-reference master-reference="first-page-layout" + page-position="first"/> + </fo:repeatable-page-master-alternatives> + <fo:repeatable-page-master-alternatives maximum-repeats="no-limit"> + <fo:conditional-page-master-reference master-reference="last-page-layout" + page-position="last"/> + <fo:conditional-page-master-reference master-reference="rest-page-layout" + page-position="rest"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + + </fo:layout-master-set> + + <fo:page-sequence master-reference="whatever"> + <fo:static-content flow-name="first-region"> + <fo:block id="header.first.1" text-align="center">first</fo:block> + </fo:static-content> + <fo:static-content flow-name="only-region"> + <fo:block id="header.only.1" text-align="center">only</fo:block> + </fo:static-content> + <fo:flow flow-name="frame-body"> + <fo:block>This is the only page</fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="whatever"> + <fo:static-content flow-name="only-region"> + <fo:block id="header.only.2" text-align="center">only</fo:block> + </fo:static-content> + <fo:static-content flow-name="first-region"> + <fo:block id="header.first.2" text-align="center">first</fo:block> + </fo:static-content> + <fo:static-content flow-name="last-region"> + <fo:block id="header.last.2" text-align="center">last</fo:block> + </fo:static-content> + <fo:static-content flow-name="rest-region"> + <fo:block id="header.rest.2" text-align="center">rest</fo:block> + </fo:static-content> + <fo:flow flow-name="frame-body"> + <fo:block>This is the first page</fo:block> + <fo:block break-before="page">This is a middle page</fo:block> + <fo:block break-before="page">This is a middle page</fo:block> + <fo:block break-before="page">This is the last page</fo:block> + </fo:flow> + </fo:page-sequence> + + </fo:root> + </fo> + <checks> + <eval expected="header.only.1" xpath="(/areaTree/pageSequence[1]//regionBefore)[1]/block[1]/@prod-id" /> + <eval expected="header.first.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[1]/block[1]/@prod-id" /> + <eval expected="header.rest.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[2]/block[1]/@prod-id" /> + <eval expected="header.rest.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[3]/block[1]/@prod-id" /> + <eval expected="header.last.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[4]/block[1]/@prod-id" /> + </checks> +</testcase> diff --git a/test/layoutengine/standard-testcases/page-position_only.xml b/test/layoutengine/standard-testcases/page-position_only.xml new file mode 100644 index 000000000..bcf05db2c --- /dev/null +++ b/test/layoutengine/standard-testcases/page-position_only.xml @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> +<!-- $Id$ --> +<testcase> + <info> + <p> + This test checks for the use of an 'only' conditional-page-master-reference (XSL 1.1) + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" + font-family="Times" font-size="20pt"> + + <fo:layout-master-set> + <fo:simple-page-master master-name="only-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="only-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="first-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="first-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="last-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="last-region" extent="10mm"/> + </fo:simple-page-master> + <fo:simple-page-master master-name="rest-page-layout" + page-height="297mm" page-width="210mm" + margin-top="15mm" margin-bottom="15mm" + margin-left="15mm" margin-right="15mm"> + <fo:region-body region-name="frame-body" margin-top="10mm"/> + <fo:region-before region-name="rest-region" extent="10mm"/> + </fo:simple-page-master> + + <fo:page-sequence-master master-name="whatever"> + <fo:repeatable-page-master-alternatives maximum-repeats="no-limit"> + <fo:conditional-page-master-reference master-reference="only-page-layout" + page-position="only"/> + <fo:conditional-page-master-reference master-reference="first-page-layout" + page-position="first"/> + <fo:conditional-page-master-reference master-reference="last-page-layout" + page-position="last"/> + <fo:conditional-page-master-reference master-reference="rest-page-layout" + page-position="rest"/> + </fo:repeatable-page-master-alternatives> + </fo:page-sequence-master> + + </fo:layout-master-set> + + <fo:page-sequence master-reference="whatever"> + <fo:static-content flow-name="first-region"> + <fo:block id="header.first.1" text-align="center">first</fo:block> + </fo:static-content> + <fo:static-content flow-name="only-region"> + <fo:block id="header.only.1" text-align="center">only</fo:block> + </fo:static-content> + <fo:flow flow-name="frame-body"> + <fo:block>This is the only page</fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="whatever"> + <fo:static-content flow-name="only-region"> + <fo:block id="header.only.2" text-align="center">only</fo:block> + </fo:static-content> + <fo:static-content flow-name="first-region"> + <fo:block id="header.first.2" text-align="center">first</fo:block> + </fo:static-content> + <fo:static-content flow-name="last-region"> + <fo:block id="header.last.2" text-align="center">last</fo:block> + </fo:static-content> + <fo:static-content flow-name="rest-region"> + <fo:block id="header.rest.2" text-align="center">rest</fo:block> + </fo:static-content> + <fo:flow flow-name="frame-body"> + <fo:block>This is the first page</fo:block> + <fo:block break-before="page">This is a middle page</fo:block> + <fo:block break-before="page">This is a middle page</fo:block> + <fo:block break-before="page">This is the last page</fo:block> + </fo:flow> + </fo:page-sequence> + + </fo:root> + </fo> + <checks> + <eval expected="header.only.1" xpath="(/areaTree/pageSequence[1]//regionBefore)[1]/block[1]/@prod-id" /> + <eval expected="header.first.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[1]/block[1]/@prod-id" /> + <eval expected="header.rest.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[2]/block[1]/@prod-id" /> + <eval expected="header.rest.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[3]/block[1]/@prod-id" /> + <eval expected="header.last.2" xpath="(/areaTree/pageSequence[2]//regionBefore)[4]/block[1]/@prod-id" /> + </checks> +</testcase> |