diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-03-14 10:44:23 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-03-14 10:44:23 +0000 |
commit | 4c131bd42f52e394b4c6220a3af179cb4539bf40 (patch) | |
tree | a5abb4df2edda095317f825c276e863b8a1d081b /test | |
parent | 28b4b3d4de6106f807de5836683c82c453d58b9e (diff) | |
download | xmlgraphics-fop-4c131bd42f52e394b4c6220a3af179cb4539bf40.tar.gz xmlgraphics-fop-4c131bd42f52e394b4c6220a3af179cb4539bf40.zip |
FOP-2357: When an SVG image has transparency and a PDF profile is used that disallows it, ignore it and issue a warning rather than throw an error
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1577477 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
4 files changed, 47 insertions, 5 deletions
diff --git a/test/java/org/apache/fop/events/EventChecker.java b/test/java/org/apache/fop/events/EventChecker.java index 3f0eef6bb..506658467 100644 --- a/test/java/org/apache/fop/events/EventChecker.java +++ b/test/java/org/apache/fop/events/EventChecker.java @@ -27,7 +27,7 @@ import static org.junit.Assert.fail; /** * Class that checks that an expected event is produced, and only this one. */ -class EventChecker implements EventListener { +public class EventChecker implements EventListener { private final String expectedEventID; @@ -35,7 +35,7 @@ class EventChecker implements EventListener { private boolean eventReceived; - EventChecker(String expectedEventID, Map<String, Object> expectedParams) { + public EventChecker(String expectedEventID, Map<String, Object> expectedParams) { this.expectedEventID = expectedEventID; this.expectedParams = expectedParams; } @@ -51,9 +51,9 @@ class EventChecker implements EventListener { } } - void end() { + public void end() { if (!eventReceived) { - fail("Did not received expected event: " + expectedEventID); + fail("Did not receive expected event: " + expectedEventID); } } } diff --git a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java index 6aad0320e..b2b77e842 100644 --- a/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java +++ b/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java @@ -21,6 +21,8 @@ package org.apache.fop.render.pdf; import java.io.File; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import org.junit.Test; import org.xml.sax.SAXException; @@ -28,7 +30,10 @@ import org.xml.sax.SAXException; import static org.junit.Assert.fail; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.events.EventChecker; +import org.apache.fop.pdf.PDFAMode; import org.apache.fop.pdf.PDFConformanceException; +import org.apache.fop.svg.SVGEventProducer; /** * Tests PDF/A-1 functionality. @@ -108,4 +113,17 @@ public class PDFAConformanceTestCase extends BasePDFTest { } } + @Test + public void svgTransparency() throws Exception { + Map<String, Object> params = new HashMap<String, Object>(); + params.put("pdfProfile", PDFAMode.PDFA_1B); + EventChecker eventChecker = new EventChecker(SVGEventProducer.class.getName() + + ".transparencyIgnored", params); + FOUserAgent ua = getUserAgent(); + ua.getEventBroadcaster().addEventListener(eventChecker); + File foFile = new File(foBaseDir, "svg-transparency.fo"); + convertFO(foFile, ua, dumpPDF); + eventChecker.end(); + } + } diff --git a/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java b/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java index efef464bd..e7e47e7ba 100644 --- a/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java +++ b/test/java/org/apache/fop/svg/PDFTextPainterTestCase.java @@ -36,7 +36,7 @@ public class PDFTextPainterTestCase extends NativeTextPainterTest { private static class OperatorCheckingPDFGraphics2D extends PDFGraphics2D { OperatorCheckingPDFGraphics2D(FontInfo fontInfo, final OperatorValidator validator) { - super(false, fontInfo, new PDFDocument("test"), null, null, null, 0); + super(false, fontInfo, new PDFDocument("test"), null, null, null, 0, null); this.currentStream = new StringWriter() { @Override diff --git a/test/xml/pdf-a/svg-transparency.fo b/test/xml/pdf-a/svg-transparency.fo new file mode 100644 index 000000000..922416fbc --- /dev/null +++ b/test/xml/pdf-a/svg-transparency.fo @@ -0,0 +1,24 @@ +<?xml version="1.0"?> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator"> + <fo:layout-master-set> + <fo:simple-page-master master-name="page" + page-height="420pt" page-width="620pt" margin="10pt"> + <fo:region-body display-align="center"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="page"> + <fo:flow flow-name="xsl-region-body" text-align="center"> + <fo:block font-size="20pt">RGB Circles</fo:block> + <fo:block><fo:instream-foreign-object> + <svg xmlns="http://www.w3.org/2000/svg" width="300" height="286.6"> + <g style="fill-opacity:0.7; stroke:black; stroke-width:3" + transform="translate(0, 286.6) scale(1, -1) translate(100, 100)"> + <circle cx="50" cy="86.6" r="80" style="fill:red;"/> + <circle cx="0" cy="0" r="80" style="fill:green;"/> + <circle cx="100" cy="0" r="80" style="fill:blue;"/> + </g> + </svg> + </fo:instream-foreign-object></fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root> |