aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2016-01-18 13:47:43 +0000
committerSimon Steiner <ssteiner@apache.org>2016-01-18 13:47:43 +0000
commit5415b5105bebd35052a0ebb3bd101d40893986ef (patch)
tree13c049c3c3b6d594b8b060c5ce1c246d7789a810 /test
parent58fba2eb411a57bd075d6fa55e14eb2b622f0dc4 (diff)
downloadxmlgraphics-fop-5415b5105bebd35052a0ebb3bd101d40893986ef.tar.gz
xmlgraphics-fop-5415b5105bebd35052a0ebb3bd101d40893986ef.zip
FOP-2309: Support PCL Color thanks to James Burton
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1725271 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java b/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java
new file mode 100644
index 000000000..65ac6ef0b
--- /dev/null
+++ b/test/java/org/apache/fop/render/pcl/PCLPainterTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * 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$ */
+package org.apache.fop.render.pcl;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+import javax.xml.transform.stream.StreamResult;
+
+import org.junit.Test;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.render.intermediate.IFContext;
+import org.apache.fop.render.intermediate.IFException;
+
+import junit.framework.Assert;
+
+public class PCLPainterTestCase {
+ private FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent();
+
+ @Test
+ public void testFillRect() throws IFException {
+ Rectangle size = new Rectangle(1, 1);
+ PCLPageDefinition pclPageDef = new PCLPageDefinition("", 0, new Dimension(), size, true);
+ PCLDocumentHandler documentHandler = new PCLDocumentHandler(new IFContext(ua));
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ documentHandler.setResult(new StreamResult(output));
+ documentHandler.startDocument();
+ PCLPainter pclPainter = new PCLPainter(documentHandler, pclPageDef);
+ pclPainter.fillRect(size, Color.RED);
+ Assert.assertTrue(output.toString().contains("*c4Q\u001B*c0.01h0.01V\u001B*c32G\u001B*c4P"));
+ output.reset();
+
+ pclPainter.getPCLUtil().setColorEnabled(true);
+ pclPainter.fillRect(size, Color.RED);
+ Assert.assertFalse(output.toString().contains("*c4P"));
+ Assert.assertTrue(output.toString().contains("*v255a0b0c0I\u001B*v0S\u001B*c0.01h0.01V\u001B*c0P"));
+ }
+
+}