[prev in list] [next in list] [prev in thread] [next in thread]
List: fop-cvs
Subject: svn commit: r1405160 - in /xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf: ./
From: vhennebert () apache ! org
Date: 2012-11-02 20:50:05
Message-ID: 20121102205005.4E3CD23889D7 () eris ! apache ! org
[Download RAW message or body]
Author: vhennebert
Date: Fri Nov 2 20:50:04 2012
New Revision: 1405160
URL: http://svn.apache.org/viewvc?rev=1405160&view=rev
Log:
Forgot to include test files in commit 1400890
Added:
xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/
xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java \
(with props) xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo \
(with props)
Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java?rev=1405160&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java \
(added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java \
Fri Nov 2 20:50:04 2012 @@ -0,0 +1,94 @@
+/*
+ * 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.accessibility.pdf;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.LinkedList;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.commons.io.output.NullOutputStream;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventListener;
+import org.apache.fop.render.pdf.PDFEventProducer;
+
+public class MissingLanguageWarningTestCase {
+
+ private Fop fop;
+
+ private MissingLanguageEventChecker eventChecker;
+
+ private static class MissingLanguageEventChecker implements EventListener {
+
+ private final String unknownLanguageEventID = \
PDFEventProducer.class.getName() + ".unknownLanguage"; +
+ private final LinkedList<String> expectedLocations = new LinkedList<String>(
+ Arrays.asList("30:37", "34:40"));
+
+ public void processEvent(Event event) {
+ if (event.getEventID().equals(unknownLanguageEventID)) {
+ assertFalse("Too many unknownLanguage events", \
expectedLocations.isEmpty()); + \
assertEquals(expectedLocations.removeFirst(), event.getParam("location")); + \
} + }
+
+ void end() {
+ assertTrue("Expected more unknownLanguage events", \
expectedLocations.isEmpty()); + }
+
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
+ FOUserAgent userAgent = fopFactory.newFOUserAgent();
+ userAgent.setAccessibility(true);
+ eventChecker = new MissingLanguageEventChecker();
+ userAgent.getEventBroadcaster().addEventListener(eventChecker);
+ fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, new \
NullOutputStream()); + }
+
+ @Test
+ public void testMissingLanguage() throws Exception {
+ Source src = new \
StreamSource(getClass().getResourceAsStream("missing-language.fo")); + \
SAXResult res = new SAXResult(fop.getDefaultHandler()); + Transformer \
transformer = TransformerFactory.newInstance().newTransformer(); + \
transformer.transform(src, res); + eventChecker.end();
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/MissingLanguageWarningTestCase.java
------------------------------------------------------------------------------
svn:keywords = Revision Id
Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo?rev=1405160&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo \
(added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo \
Fri Nov 2 20:50:04 2012 @@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page"
+ page-height="320pt" page-width="420pt" margin="10pt">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="page">
+ <fo:flow flow-name="xsl-region-body" text-align="justify" space-before="10pt">
+
+ <fo:block language="en" country="GB" space-before="inherit">This block of text \
is written in + British English. The following block is in French and \
translates as: "This block contains + French text and is tagged as \
such."</fo:block> +
+ <fo:block language="fr" country="FR" space-before="inherit">Ce block contient \
du texte en + français et est marqué comme tel.</fo:block>
+
+ <fo:block language="en" country="GB" space-before="inherit">The following \
block has no + language information, but since it contains no text no warning \
should be issued.</fo:block> +
+ <fo:block border="0.2pt solid black" space-before="inherit"> </fo:block>
+
+ <fo:block language="en" country="GB" space-before="inherit">The following \
block has no + language information and contains an image with an alt-text, \
for which a warning should be + issued.</fo:block>
+
+ <fo:block text-align="center"><fo:external-graphic
+ src="test/resources/images/fop-logo-color-24bit.png"
+ fox:alt-text="FOP logo"/></fo:block>
+
+ <fo:block space-before="inherit">This block contains no language information. \
However, only + one warning should be issued for all of its lines.</fo:block>
+
+ </fo:flow>
+ </fo:page-sequence>
+
+</fo:root>
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/accessibility/pdf/missing-language.fo
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic