aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMehdi Houshmand <mehdi@apache.org>2012-09-27 12:11:28 +0000
committerMehdi Houshmand <mehdi@apache.org>2012-09-27 12:11:28 +0000
commit8828aed0ed0e9bc49fe49e69892d663356e11359 (patch)
tree018b702322f2d45dc1466fff6718ff685f853759 /test
parentc9cbf7e0a418fb7735f6d4a42632b867f3dab36c (diff)
parenta1af0b2481adf1d4bdb1279972a9d4e51e381f6a (diff)
downloadxmlgraphics-fop-8828aed0ed0e9bc49fe49e69892d663356e11359.tar.gz
xmlgraphics-fop-8828aed0ed0e9bc49fe49e69892d663356e11359.zip
Merged trunk@1384277Temp_XGC_URI_Resolution
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_XGC_URI_Resolution@1390959 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java5
-rw-r--r--test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl31
-rw-r--r--test/java/org/apache/fop/accessibility/fo/table-header_scope.fo57
-rw-r--r--test/java/org/apache/fop/fo/FONodeMocks.java30
-rw-r--r--test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java112
-rw-r--r--test/pdf/accessibility/pdf/background-image_svg_repeat.pdfbin16997 -> 17081 bytes
-rw-r--r--test/pdf/accessibility/pdf/background-image_svg_single.pdfbin9872 -> 9893 bytes
-rw-r--r--test/pdf/accessibility/pdf/image_svg.pdfbin14161 -> 14203 bytes
-rw-r--r--test/pdf/accessibility/pdf/image_wmf.pdfbin247758 -> 248963 bytes
-rw-r--r--test/pdf/accessibility/pdf/text_font-embedding.pdfbin19682 -> 28436 bytes
-rw-r--r--test/pdf/accessibility/pdf/th_scope.pdfbin0 -> 15495 bytes
-rw-r--r--test/pdf/accessibility/th_scope.fo68
12 files changed, 295 insertions, 8 deletions
diff --git a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
index 6092912f9..87b970576 100644
--- a/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
+++ b/test/java/org/apache/fop/accessibility/fo/FO2StructureTreeConverterTestCase.java
@@ -91,6 +91,11 @@ public class FO2StructureTreeConverterTestCase {
testConverter("/org/apache/fop/fo/pagination/side-regions.fo");
}
+ @Test
+ public void headerTableCellMustPropagateScope() throws Exception {
+ testConverter("table-header_scope.fo");
+ }
+
private static InputStream getResource(String name) {
return FO2StructureTreeConverterTestCase.class.getResourceAsStream(name);
}
diff --git a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl b/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
index c739462e4..90d74a7c4 100644
--- a/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
+++ b/test/java/org/apache/fop/accessibility/fo/fo2StructureTree.xsl
@@ -21,7 +21,7 @@
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
xmlns:foi="http://xmlgraphics.apache.org/fop/internal">
- <xsl:output method="xml" indent="no"/>
+ <xsl:output method="xml" indent="yes"/>
<xsl:template name="copy">
<xsl:copy>
@@ -92,10 +92,37 @@
<xsl:call-template name="copy"/>
</xsl:template>
- <xsl:template match="fo:table|fo:table-header|fo:table-footer|fo:table-body|fo:table-row|fo:table-cell">
+ <xsl:template match="fo:table|fo:table-header|fo:table-footer|fo:table-body|fo:table-row">
<xsl:call-template name="copy"/>
</xsl:template>
+ <xsl:template name="get.column.header">
+ <xsl:value-of select="ancestor::fo:table/fo:table-column[
+ count(preceding-sibling::fo:table-column) = count(current()/preceding-sibling::fo:table-cell)]/@fox:header"/>
+ </xsl:template>
+
+ <xsl:template match="fo:table-cell">
+ <xsl:variable name="header"><xsl:call-template name="get.column.header"/></xsl:variable>
+ <xsl:copy>
+ <xsl:if test="$header = 'true'">
+ <xsl:attribute name="role">TH</xsl:attribute>
+ <xsl:attribute name="scope" namespace="http://xmlgraphics.apache.org/fop/internal">Row</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="fo:table-header/fo:table-cell|fo:table-header/fo:table-row/fo:table-cell">
+ <xsl:variable name="header"><xsl:call-template name="get.column.header"/></xsl:variable>
+ <xsl:copy>
+ <xsl:attribute name="role">TH</xsl:attribute>
+ <xsl:if test="$header = 'true'">
+ <xsl:attribute name="scope" namespace="http://xmlgraphics.apache.org/fop/internal">Both</xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
<!-- Formatting Objects for Lists -->
<xsl:template match="fo:list-block|fo:list-item|fo:list-item-label|fo:list-item-body">
<xsl:call-template name="copy"/>
diff --git a/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo b/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo
new file mode 100644
index 000000000..c6272d546
--- /dev/null
+++ b/test/java/org/apache/fop/accessibility/fo/table-header_scope.fo
@@ -0,0 +1,57 @@
+<?xml version="1.0" standalone="no"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
+ font-family="sans-serif">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="120pt" page-width="220pt" 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" line-height="10pt" font-size="8pt">
+ <fo:table width="100%" table-layout="fixed">
+ <fo:table-column fox:header="true" column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-header font-weight="bold">
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Table Header</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Column 1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Column 2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-header>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell id="Row1" border="1pt solid black" padding-left="1pt" font-weight="bold">
+ <fo:block>Row 1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 1.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 1.2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black" padding-left="1pt" font-weight="bold" role="TH">
+ <fo:block>Row 2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 2.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 2.2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
diff --git a/test/java/org/apache/fop/fo/FONodeMocks.java b/test/java/org/apache/fop/fo/FONodeMocks.java
index 001173179..ba969b9fa 100644
--- a/test/java/org/apache/fop/fo/FONodeMocks.java
+++ b/test/java/org/apache/fop/fo/FONodeMocks.java
@@ -19,19 +19,22 @@
package org.apache.fop.fo;
+import java.io.IOException;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import java.io.IOException;
-
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageManager;
import org.apache.xmlgraphics.image.loader.ImageSessionContext;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.fo.flow.table.ColumnNumberManager;
+import org.apache.fop.fo.flow.table.ColumnNumberManagerHolder;
/**
* A helper class for creating mocks of {@link FONode} and its descendants.
@@ -51,27 +54,36 @@ public final class FONodeMocks {
public static FONode mockFONode() {
FONode mockFONode = mock(FONode.class);
mockGetFOEventHandler(mockFONode);
+ mockGetImageManager(mockFONode.getFOEventHandler().getUserAgent());
return mockFONode;
}
- private static void mockGetFOEventHandler(FONode mockFONode) {
+ public static FOEventHandler mockGetFOEventHandler(FONode mockFONode) {
FOEventHandler mockFOEventHandler = mock(FOEventHandler.class);
mockGetUserAgent(mockFOEventHandler);
when(mockFONode.getFOEventHandler()).thenReturn(mockFOEventHandler);
+ return mockFOEventHandler;
}
- private static void mockGetUserAgent(FOEventHandler mockFOEventHandler) {
+ public static FOUserAgent mockGetUserAgent(FOEventHandler mockFOEventHandler) {
FOUserAgent mockFOUserAgent = mock(FOUserAgent.class);
- mockGetImageManager(mockFOUserAgent);
when(mockFOEventHandler.getUserAgent()).thenReturn(mockFOUserAgent);
+ return mockFOUserAgent;
}
- private static void mockGetImageManager(FOUserAgent mockFOUserAgent) {
+ public static EventBroadcaster mockGetEventBroadcaster(FOUserAgent mockFOUserAgent) {
+ EventBroadcaster mockBroadcaster = mock(EventBroadcaster.class);
+ when(mockFOUserAgent.getEventBroadcaster()).thenReturn(mockBroadcaster);
+ return mockBroadcaster;
+ }
+
+ public static ImageManager mockGetImageManager(FOUserAgent mockFOUserAgent) {
try {
ImageManager mockImageManager = mock(ImageManager.class);
when(mockImageManager.getImageInfo(anyString(), any(ImageSessionContext.class)))
.thenReturn(null);
when(mockFOUserAgent.getImageManager()).thenReturn(mockImageManager);
+ return mockImageManager;
} catch (ImageException e) {
throw new RuntimeException(e);
} catch (IOException e) {
@@ -79,4 +91,10 @@ public final class FONodeMocks {
}
}
+ public static ColumnNumberManager mockGetColumnNumberManager(ColumnNumberManagerHolder mock) {
+ ColumnNumberManager mockColumnNumberManager = mock(ColumnNumberManager.class);
+ when(mock.getColumnNumberManager()).thenReturn(mockColumnNumberManager);
+ return mockColumnNumberManager;
+ }
+
}
diff --git a/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java b/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java
new file mode 100644
index 000000000..4cc94b5e0
--- /dev/null
+++ b/test/java/org/apache/fop/fo/flow/table/HeaderColumnTestCase.java
@@ -0,0 +1,112 @@
+/*
+ * 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.fo.flow.table;
+
+import org.junit.Test;
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.helpers.AttributesImpl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.fo.ElementMappingRegistry;
+import org.apache.fop.fo.FOEventHandler;
+import org.apache.fop.fo.FONodeMocks;
+import org.apache.fop.fo.FOValidationEventProducer;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.StaticPropertyList;
+import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.util.XMLUtil;
+
+/**
+ * Tests that the fox:header property is correctly parsed and set up at the FO tree level.
+ */
+public class HeaderColumnTestCase {
+
+ @Test
+ public void testWrongValue() throws ValidationException {
+ Table parent = createTableParent();
+ EventBroadcaster mockEventBroadcaster = FONodeMocks.mockGetEventBroadcaster(
+ parent.getFOEventHandler().getUserAgent());
+ FOValidationEventProducer eventProducer = mockGetEventProducerFor(mockEventBroadcaster);
+ TableColumn column = new TableColumn(parent);
+ PropertyList propertyList = new StaticPropertyList(column, null);
+ Attributes atts = createScopeAttribute("blah");
+ propertyList.addAttributesToList(atts);
+ verify(eventProducer).invalidPropertyValue(any(), eq("fo:table-column"),
+ eq("fox:header"), eq("blah"), any(PropertyException.class), any(Locator.class));
+ }
+
+ @Test
+ public void testCorrectValue() throws Exception {
+ testCorrectValue(true);
+ testCorrectValue(false);
+ }
+
+ private void testCorrectValue(boolean expectedValue) throws Exception {
+ Table parent = createTableParent();
+ FONodeMocks.mockGetColumnNumberManager(parent);
+ TableColumn column = new TableColumn(parent, true);
+ PropertyList propertyList = new StaticPropertyList(column, null);
+ Attributes atts = createScopeAttribute(String.valueOf(expectedValue));
+ propertyList.addAttributesToList(atts);
+ column.bind(propertyList);
+ assertEquals(expectedValue, column.isHeader());
+ }
+
+ private Table createTableParent() {
+ Table parent = mock(Table.class);
+ FOEventHandler mockFOEventHandler = FONodeMocks.mockGetFOEventHandler(parent);
+ FOUserAgent mockUserAgent = mockFOEventHandler.getUserAgent();
+ mockGetElementMappingRegistry(mockUserAgent);
+ return parent;
+ }
+
+ private Attributes createScopeAttribute(String value) {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute(ExtensionElementMapping.URI, "header", "fox:header", XMLUtil.CDATA, value);
+ return atts;
+ }
+
+ private ElementMappingRegistry mockGetElementMappingRegistry(FOUserAgent mockUserAgent) {
+ ElementMappingRegistry mockRegistry = mock(ElementMappingRegistry.class);
+ when(mockRegistry.getElementMapping(anyString())).thenReturn(new ExtensionElementMapping());
+ when(mockUserAgent.getElementMappingRegistry()).thenReturn(mockRegistry);
+ return mockRegistry;
+ }
+
+ private FOValidationEventProducer mockGetEventProducerFor(EventBroadcaster mockEventBroadcaster) {
+ FOValidationEventProducer mockEventProducer = mock(FOValidationEventProducer.class);
+ when(mockEventBroadcaster.getEventProducerFor(eq(FOValidationEventProducer.class)))
+ .thenReturn(mockEventProducer);
+ return mockEventProducer;
+ }
+
+}
diff --git a/test/pdf/accessibility/pdf/background-image_svg_repeat.pdf b/test/pdf/accessibility/pdf/background-image_svg_repeat.pdf
index 41c2ee500..0921d734f 100644
--- a/test/pdf/accessibility/pdf/background-image_svg_repeat.pdf
+++ b/test/pdf/accessibility/pdf/background-image_svg_repeat.pdf
Binary files differ
diff --git a/test/pdf/accessibility/pdf/background-image_svg_single.pdf b/test/pdf/accessibility/pdf/background-image_svg_single.pdf
index 8c2dc1006..9c8af4fb6 100644
--- a/test/pdf/accessibility/pdf/background-image_svg_single.pdf
+++ b/test/pdf/accessibility/pdf/background-image_svg_single.pdf
Binary files differ
diff --git a/test/pdf/accessibility/pdf/image_svg.pdf b/test/pdf/accessibility/pdf/image_svg.pdf
index a9428fd3f..cc0a3ebba 100644
--- a/test/pdf/accessibility/pdf/image_svg.pdf
+++ b/test/pdf/accessibility/pdf/image_svg.pdf
Binary files differ
diff --git a/test/pdf/accessibility/pdf/image_wmf.pdf b/test/pdf/accessibility/pdf/image_wmf.pdf
index c15a05223..368afe60d 100644
--- a/test/pdf/accessibility/pdf/image_wmf.pdf
+++ b/test/pdf/accessibility/pdf/image_wmf.pdf
Binary files differ
diff --git a/test/pdf/accessibility/pdf/text_font-embedding.pdf b/test/pdf/accessibility/pdf/text_font-embedding.pdf
index d1e4c6e28..47ca60bdb 100644
--- a/test/pdf/accessibility/pdf/text_font-embedding.pdf
+++ b/test/pdf/accessibility/pdf/text_font-embedding.pdf
Binary files differ
diff --git a/test/pdf/accessibility/pdf/th_scope.pdf b/test/pdf/accessibility/pdf/th_scope.pdf
new file mode 100644
index 000000000..596ffb7db
--- /dev/null
+++ b/test/pdf/accessibility/pdf/th_scope.pdf
Binary files differ
diff --git a/test/pdf/accessibility/th_scope.fo b/test/pdf/accessibility/th_scope.fo
new file mode 100644
index 000000000..4e22b9160
--- /dev/null
+++ b/test/pdf/accessibility/th_scope.fo
@@ -0,0 +1,68 @@
+<?xml version="1.0" standalone="no"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
+ font-family="sans-serif">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="120pt" page-width="220pt" 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" line-height="10pt" font-size="8pt">
+ <fo:table width="100%" table-layout="fixed">
+ <fo:table-column fox:header="true" column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-column column-width="proportional-column-width(1)"/>
+ <fo:table-header font-weight="bold">
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Table Header</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Column 1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Column 2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-header>
+ <fo:table-body>
+ <fo:table-row>
+ <fo:table-cell id="Row1" border="1pt solid black" padding-left="1pt" font-weight="bold">
+ <fo:block>Row 1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 1.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 1.2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black" padding-left="1pt" font-weight="bold" role="TH">
+ <fo:block>Row 2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 2.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 2.2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <fo:table-row>
+ <fo:table-cell border="1pt solid black" padding-left="1pt" role="TD">
+ <fo:block>Non-header</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 3.1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell border="1pt solid black" padding-left="1pt">
+ <fo:block>Cell 3.2</fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ </fo:table-body>
+ </fo:table>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>