aboutsummaryrefslogtreecommitdiffstats
path: root/test/java/org/apache
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2012-05-25 20:02:21 +0000
committerGlenn Adams <gadams@apache.org>2012-05-25 20:02:21 +0000
commit47789800746b09c46b7369d9d8122b40531494e0 (patch)
tree71b8cec5543d08620b0bfd5ec0b768f596dc85f8 /test/java/org/apache
parentb14cfce3f812f97852d88db7b837b55b0c55c625 (diff)
downloadxmlgraphics-fop-47789800746b09c46b7369d9d8122b40531494e0.tar.gz
xmlgraphics-fop-47789800746b09c46b7369d9d8122b40531494e0.zip
Bugzilla #53294: Fix invalid PostScript file being created when font-size is 0. Submitted by Robert Meyer.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1342792 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache')
-rw-r--r--test/java/org/apache/fop/render/ps/PSPainterTestCase.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/render/ps/PSPainterTestCase.java b/test/java/org/apache/fop/render/ps/PSPainterTestCase.java
new file mode 100644
index 000000000..4e50f09c9
--- /dev/null
+++ b/test/java/org/apache/fop/render/ps/PSPainterTestCase.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+package org.apache.fop.render.ps;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.verification.VerificationMode;
+
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import org.apache.fop.render.intermediate.IFState;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+public class PSPainterTestCase {
+
+ private PSDocumentHandler docHandler;
+ private PSPainter psPainter;
+ private PSGenerator gen;
+ private IFState state;
+
+ @Before
+ public void setup() {
+ docHandler = new PSDocumentHandler();
+ gen = mock(PSGenerator.class);
+ docHandler.gen = gen;
+ state = IFState.create();
+ psPainter = new PSPainter(docHandler, state);
+ }
+
+ @Test
+ public void testNonZeroFontSize() throws IOException {
+ testFontSize(6, times(1));
+ }
+
+ @Test
+ public void testZeroFontSize() throws IOException {
+ testFontSize(0, never());
+ }
+
+ private void testFontSize(int fontSize, VerificationMode test) throws IOException {
+ state.setFontSize(fontSize);
+ try {
+ psPainter.drawText(10, 10, 2, 2, null, "Test");
+ } catch (Exception ex) {
+ //Expected
+ }
+ verify(gen, test).useColor(state.getTextColor());
+ }
+}