Package org.apache.batik.test.svg
Class SelfContainedSVGOnLoadTest
java.lang.Object
org.apache.batik.test.AbstractTest
org.apache.batik.test.svg.SelfContainedSVGOnLoadTest
- All Implemented Interfaces:
Test
This test takes an SVG file as an input. It processes the input SVG
(meaning it turns it into a GVT tree) and then dispatches the 'onload'
event.
The SVG input file should contain script that will position the
result of the test in the DOM using the following namespace:
xmlns:test="http://xml.apache.org/batik/test"
The result should be set in the
Sample input SVG file:
xmlns:test="http://xml.apache.org/batik/test"
The result should be set in the
result
attribute of the
<testResult> element by the script embeded in the input SVG
test file. Sample input SVG file:
<svg ... onload="runTest(evt)" xmlns:test="http://xml.apache.org/batik/test" >
<script type="text/ecmascript">
function runTest(evt) {
...; // do some test
var rootSvg = document.getDocumentElement();
var result = document.createElementNS("http://xml.apache.org/batik/test",
"testResult");
result.setAttributeNS(null, "result", "failed");
result.setAttributeNS(null, "errorCode", "org.apache.batik.css.dom.wrong.computed.value");
rootSvg.appendChild(result);
}
</script>
</svg>
- Version:
- $Id: SelfContainedSVGOnLoadTest.java 1806580 2017-08-29 12:06:44Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Entry describing the errorstatic final String
Entry describing the number of testResult elements found in the document after dispatching onload.static final String
Entry describing the result value (different from 'passed' or 'failed' found in the 'result' attribute.static final String
Error when the input file cannot be loaded into a Document object {0} = IOException messagestatic final String
The result was 'failed' but there was no 'errorCode' attribute or it was the empty stringstatic final String
There is either 0 or more than one <testResult> elements in the document after dispatching the onload event.static final String
The 'result' attribute value is neither 'passed' nor 'failed'static final String
Error while building the GVT tree or dispatching the 'onload' event.protected String
The URL for the input SVG document to be testedstatic final String
static final String
Test Constantsstatic final String
static final String
static final String
Test NamespaceFields inherited from class org.apache.batik.test.AbstractTest
id, name, parent
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default constructorSelfContainedSVGOnLoadTest
(String svgURL) -
Method Summary
Modifier and TypeMethodDescriptionprotected UserAgent
Give subclasses a chance to build their own UserAgentprotected String
resolveURL
(String url) Resolves the input string as follows.runImpl()
Run this test and produce a report.Methods inherited from class org.apache.batik.test.AbstractTest
assertEquals, assertEquals, assertNull, assertTrue, error, getId, getName, getParent, getQualifiedId, reportError, reportException, reportSuccess, run, runImplBasic, setId, setName, setParent
-
Field Details
-
ERROR_CANNOT_LOAD_SVG_DOCUMENT
Error when the input file cannot be loaded into a Document object {0} = IOException message- See Also:
-
ERROR_WHILE_PROCESSING_SVG_DOCUMENT
Error while building the GVT tree or dispatching the 'onload' event.- See Also:
-
ERROR_UNEXPECTED_NUMBER_OF_TEST_RESULT_ELEMENTS
There is either 0 or more than one <testResult> elements in the document after dispatching the onload event.- See Also:
-
ERROR_UNEXPECTED_RESULT_VALUE
The 'result' attribute value is neither 'passed' nor 'failed'- See Also:
-
ERROR_MISSING_OR_EMPTY_ERROR_CODE_ON_FAILED_TEST
The result was 'failed' but there was no 'errorCode' attribute or it was the empty string- See Also:
-
ENTRY_KEY_ERROR_DESCRIPTION
Entry describing the error- See Also:
-
ENTRY_KEY_NUMBER_OF_TEST_RESULT_ELEMENTS
Entry describing the number of testResult elements found in the document after dispatching onload.- See Also:
-
ENTRY_KEY_RESULT_VALUE
Entry describing the result value (different from 'passed' or 'failed' found in the 'result' attribute.- See Also:
-
testNS
Test Namespace- See Also:
-
TAG_TEST_RESULT
Test Constants- See Also:
-
TAG_ERROR_DESCRIPTION_ENTRY
- See Also:
-
ATTRIBUTE_RESULT
- See Also:
-
ATTRIBUTE_KEY
- See Also:
-
ATTRIBUTE_VALUE
- See Also:
-
TEST_RESULT_PASSED
- See Also:
-
TEST_RESULT_FAILED
- See Also:
-
svgURL
The URL for the input SVG document to be tested
-
-
Constructor Details
-
SelfContainedSVGOnLoadTest
- Parameters:
svgURL
- the URL string for the SVG document being tested
-
SelfContainedSVGOnLoadTest
protected SelfContainedSVGOnLoadTest()Default constructor
-
-
Method Details
-
resolveURL
Resolves the input string as follows. + First, the string is interpreted as a file description. If the file exists, then the file name is turned into a URL. + Otherwise, the string is supposed to be a URL. If it is an invalid URL, an IllegalArgumentException is thrown. -
runImpl
Run this test and produce a report. The test goes through the following steps:- load the input SVG into a Document
- build the GVT tree corresponding to the Document and dispatch the 'onload' event
- looks for one and only one <testResult> element in the Document. This is used to build the returned TestReport
- Overrides:
runImpl
in classAbstractTest
- Throws:
Exception
-
buildUserAgent
Give subclasses a chance to build their own UserAgent
-