diff options
Diffstat (limited to 'test/java/org')
3 files changed, 95 insertions, 4 deletions
diff --git a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java b/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java index ab5c18c9e..f0e9522d9 100644 --- a/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java +++ b/test/java/org/apache/fop/render/intermediate/BorderPainterTestCase.java @@ -23,10 +23,6 @@ import java.io.IOException; import org.junit.Test; -import org.apache.fop.fo.Constants; -import org.apache.fop.traits.BorderProps; -import org.apache.fop.traits.BorderProps.Mode; - import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doThrow; @@ -36,6 +32,10 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; +import org.apache.fop.fo.Constants; +import org.apache.fop.traits.BorderProps; +import org.apache.fop.traits.BorderProps.Mode; + public class BorderPainterTestCase { private static final BorderProps BORDER_PROPS = new BorderProps(Constants.EN_SOLID, 10, 50, 50, diff --git a/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java b/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java new file mode 100644 index 000000000..5acad9837 --- /dev/null +++ b/test/java/org/apache/fop/render/pdf/PDFBorderPainterTestCase.java @@ -0,0 +1,47 @@ +package org.apache.fop.render.pdf; + +import java.awt.Color; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +import org.apache.fop.fo.Constants; +import org.apache.fop.pdf.PDFDocument; + +public class PDFBorderPainterTestCase { + + private PDFContentGenerator generator; + private ByteArrayOutputStream outStream; + private PDFGraphicsPainter borderPainter; + + @Before + public void setUp() { + outStream = new ByteArrayOutputStream(); + generator = new PDFContentGenerator(new PDFDocument("test"), outStream, null); + borderPainter = new PDFGraphicsPainter(generator); + } + + /** + * This test will fail if either of the below statements isn't true: + * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_SPACE_RATIO = 0.5f:q + * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_LENGTH_FACTOR = 4.0f. + */ + @Test + public void testDrawBorderLine() throws Exception { + borderPainter.drawBorderLine(0, 0, 40000, 1000, true, true, + Constants.EN_DASHED, Color.BLACK); + generator.flushPDFDoc(); + OutputStream outStream = new ByteArrayOutputStream(); + outStream = generator.getStream().getBufferOutputStream(); + assertTrue(((ByteArrayOutputStream) outStream).toString().contains("[4 2] 0 d 1 w")); + } + + public void tearDown() { + generator = null; + outStream= null; + } +} diff --git a/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java b/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java new file mode 100644 index 000000000..1ffe87982 --- /dev/null +++ b/test/java/org/apache/fop/render/ps/PSBorderPainterTestCase.java @@ -0,0 +1,44 @@ +package org.apache.fop.render.ps; + +import java.awt.Color; +import java.io.ByteArrayOutputStream; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +import org.apache.xmlgraphics.ps.PSGenerator; + +import org.apache.fop.fo.Constants; + +public class PSBorderPainterTestCase { + + private PSGenerator generator; + private ByteArrayOutputStream outStream; + private PSGraphicsPainter borderPainter; + + @Before + public void setUp() { + outStream = new ByteArrayOutputStream(); + generator = new PSGenerator(outStream); + borderPainter = new PSGraphicsPainter(generator); + } + + /** + * This test will fail if either of the below statements isn't true: + * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_SPACE_RATIO = 0.5f:q + * org.apache.fop.render.intermediate.BorderPainter.DASHED_BORDER_LENGTH_FACTOR = 4.0f. + */ + @Test + public void testDrawBorderLine() throws Exception { + borderPainter.drawBorderLine(0, 0, 40000, 1000, true, true, + Constants.EN_DASHED, Color.BLACK); + assertTrue(outStream.toString().contains("[4.0 2.0] 0 setdash")); + } + + public void tearDown() { + generator = null; + outStream= null; + } +} |