From 3b7e8a00915266c891762caef4c0e6fb0a51abc8 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 6 Dec 2015 19:59:06 +0100 Subject: [PATCH] Restore unittests from history --- testcss.py | 47 + testscour.py | 1370 +++++++++++++++++ unittests/adobe.svg | 45 + .../cascading-default-attribute-removal.svg | 23 + unittests/cdata.svg | 6 + .../collapse-gradients-gradientUnits.svg | 11 + unittests/collapse-gradients.svg | 11 + unittests/collapse-same-path-points.svg | 4 + unittests/color-formats.svg | 12 + unittests/comment-beside-xml-decl.svg | 10 + unittests/comments.svg | 6 + unittests/commonized-referenced-elements.svg | 9 + unittests/consecutive-hlines.svg | 6 + unittests/css-reference.svg | 27 + unittests/doctype.svg | 7 + unittests/dont-collapse-gradients.svg | 13 + unittests/dont-convert-short-color-names.svg | 4 + unittests/duplicate-gradient-stops-pct.svg | 12 + unittests/duplicate-gradient-stops.svg | 19 + .../duplicate-gradients-update-style.svg | 15 + unittests/empty-g.svg | 7 + unittests/empty-metadata.svg | 3 + unittests/empty-style.svg | 4 + unittests/fill-none.svg | 5 + unittests/font-styles.svg | 4 + unittests/full-metadata.svg | 22 + unittests/gradient-default-attrs.svg | 10 + unittests/group-creation.svg | 6 + unittests/group-no-creation.svg | 6 + unittests/groups-in-switch-with-id.svg | 18 + unittests/groups-in-switch.svg | 18 + unittests/groups-with-title-desc.svg | 13 + unittests/ids-to-strip.svg | 11 + unittests/important-groups-in-defs.svg | 12 + unittests/inkscape.svg | 7 + unittests/metadata-with-text.svg | 4 + .../move-common-attributes-to-grandparent.svg | 10 + .../move-common-attributes-to-parent.svg | 13 + unittests/nested-defs.svg | 14 + unittests/nested-useless-groups.svg | 9 + unittests/no-collapse-lines.svg | 8 + unittests/overflow-marker.svg | 12 + unittests/overflow-svg.svg | 9 + unittests/path-abs-to-rel.svg | 4 + unittests/path-bez-optimize.svg | 4 + unittests/path-elliptical-arc-parsing.svg | 4 + unittests/path-empty-move.svg | 5 + unittests/path-implicit-line.svg | 4 + unittests/path-line-optimize.svg | 4 + unittests/path-precision.svg | 4 + unittests/path-quad-optimize.svg | 4 + unittests/path-simple-triangle.svg | 8 + unittests/path-sn.svg | 4 + unittests/path-truncate-zeros-calc.svg | 4 + unittests/path-truncate-zeros.svg | 4 + unittests/path-use-scientific-notation.svg | 4 + unittests/path-with-caps.svg | 4 + unittests/path-with-closepath.svg | 4 + unittests/polygon-coord-neg-first.svg | 4 + unittests/polygon-coord-neg.svg | 4 + unittests/polygon-coord.svg | 4 + unittests/polygon.svg | 5 + unittests/polyline-coord-neg-first.svg | 4 + unittests/polyline-coord-neg.svg | 4 + unittests/polyline-coord.svg | 4 + unittests/protection.svg | 11 + unittests/quot-in-url.svg | 10 + unittests/redundant-svg-namespace.svg | 8 + unittests/referenced-elements-1.svg | 11 + unittests/referenced-font.svg | 17 + unittests/refs-in-defs.svg | 8 + unittests/remove-duplicate-gradients.svg | 23 + .../remove-unused-attributes-on-parent.svg | 8 + unittests/scour-lengths.svg | 5 + unittests/shorten-ids.svg | 10 + unittests/sodipodi.svg | 7 + unittests/straight-curve.svg | 4 + unittests/stroke-none.svg | 4 + unittests/stroke-nowidth.svg | 4 + unittests/stroke-transparent.svg | 4 + unittests/style-cdata.svg | 16 + unittests/style-to-attr.svg | 9 + unittests/transform-matrix-is-identity.svg | 3 + unittests/transform-matrix-is-rotate-135.svg | 4 + unittests/transform-matrix-is-rotate-225.svg | 4 + unittests/transform-matrix-is-rotate-45.svg | 4 + unittests/transform-matrix-is-rotate-90.svg | 4 + .../transform-matrix-is-rotate-neg-45.svg | 4 + .../transform-matrix-is-rotate-neg-90.svg | 4 + unittests/transform-matrix-is-scale-2-3.svg | 3 + unittests/transform-matrix-is-scale-neg-1.svg | 4 + unittests/transform-matrix-is-translate.svg | 3 + unittests/transform-rotate-fold-3args.svg | 5 + unittests/transform-rotate-is-identity.svg | 3 + .../transform-rotate-trim-range-719.5.svg | 5 + .../transform-rotate-trim-range-neg-540.0.svg | 5 + unittests/transform-skewX-is-identity.svg | 4 + unittests/transform-skewY-is-identity.svg | 4 + unittests/transform-translate-is-identity.svg | 5 + unittests/unreferenced-font.svg | 17 + unittests/unreferenced-linearGradient.svg | 6 + unittests/unreferenced-pattern.svg | 6 + unittests/unreferenced-radialGradient.svg | 6 + unittests/useless-defs.svg | 21 + unittests/utf8.svg | 5 + unittests/whitespace-defs.svg | 6 + unittests/whitespace-important.svg | 4 + unittests/whitespace-nested.svg | 4 + unittests/xml-namespace-attrs.svg | 24 + unittests/xml-ns-decl.svg | 30 + unittests/xml-well-formed.svg | 9 + 111 files changed, 2341 insertions(+) create mode 100755 testcss.py create mode 100755 testscour.py create mode 100644 unittests/adobe.svg create mode 100644 unittests/cascading-default-attribute-removal.svg create mode 100644 unittests/cdata.svg create mode 100644 unittests/collapse-gradients-gradientUnits.svg create mode 100644 unittests/collapse-gradients.svg create mode 100644 unittests/collapse-same-path-points.svg create mode 100644 unittests/color-formats.svg create mode 100644 unittests/comment-beside-xml-decl.svg create mode 100644 unittests/comments.svg create mode 100644 unittests/commonized-referenced-elements.svg create mode 100644 unittests/consecutive-hlines.svg create mode 100644 unittests/css-reference.svg create mode 100644 unittests/doctype.svg create mode 100644 unittests/dont-collapse-gradients.svg create mode 100644 unittests/dont-convert-short-color-names.svg create mode 100644 unittests/duplicate-gradient-stops-pct.svg create mode 100644 unittests/duplicate-gradient-stops.svg create mode 100644 unittests/duplicate-gradients-update-style.svg create mode 100644 unittests/empty-g.svg create mode 100644 unittests/empty-metadata.svg create mode 100644 unittests/empty-style.svg create mode 100644 unittests/fill-none.svg create mode 100644 unittests/font-styles.svg create mode 100644 unittests/full-metadata.svg create mode 100644 unittests/gradient-default-attrs.svg create mode 100644 unittests/group-creation.svg create mode 100644 unittests/group-no-creation.svg create mode 100644 unittests/groups-in-switch-with-id.svg create mode 100644 unittests/groups-in-switch.svg create mode 100644 unittests/groups-with-title-desc.svg create mode 100644 unittests/ids-to-strip.svg create mode 100644 unittests/important-groups-in-defs.svg create mode 100644 unittests/inkscape.svg create mode 100644 unittests/metadata-with-text.svg create mode 100644 unittests/move-common-attributes-to-grandparent.svg create mode 100644 unittests/move-common-attributes-to-parent.svg create mode 100644 unittests/nested-defs.svg create mode 100644 unittests/nested-useless-groups.svg create mode 100644 unittests/no-collapse-lines.svg create mode 100644 unittests/overflow-marker.svg create mode 100644 unittests/overflow-svg.svg create mode 100644 unittests/path-abs-to-rel.svg create mode 100644 unittests/path-bez-optimize.svg create mode 100644 unittests/path-elliptical-arc-parsing.svg create mode 100644 unittests/path-empty-move.svg create mode 100644 unittests/path-implicit-line.svg create mode 100644 unittests/path-line-optimize.svg create mode 100644 unittests/path-precision.svg create mode 100644 unittests/path-quad-optimize.svg create mode 100644 unittests/path-simple-triangle.svg create mode 100644 unittests/path-sn.svg create mode 100644 unittests/path-truncate-zeros-calc.svg create mode 100644 unittests/path-truncate-zeros.svg create mode 100644 unittests/path-use-scientific-notation.svg create mode 100644 unittests/path-with-caps.svg create mode 100644 unittests/path-with-closepath.svg create mode 100644 unittests/polygon-coord-neg-first.svg create mode 100644 unittests/polygon-coord-neg.svg create mode 100644 unittests/polygon-coord.svg create mode 100644 unittests/polygon.svg create mode 100644 unittests/polyline-coord-neg-first.svg create mode 100644 unittests/polyline-coord-neg.svg create mode 100644 unittests/polyline-coord.svg create mode 100644 unittests/protection.svg create mode 100644 unittests/quot-in-url.svg create mode 100644 unittests/redundant-svg-namespace.svg create mode 100644 unittests/referenced-elements-1.svg create mode 100644 unittests/referenced-font.svg create mode 100644 unittests/refs-in-defs.svg create mode 100644 unittests/remove-duplicate-gradients.svg create mode 100644 unittests/remove-unused-attributes-on-parent.svg create mode 100644 unittests/scour-lengths.svg create mode 100644 unittests/shorten-ids.svg create mode 100644 unittests/sodipodi.svg create mode 100644 unittests/straight-curve.svg create mode 100644 unittests/stroke-none.svg create mode 100644 unittests/stroke-nowidth.svg create mode 100644 unittests/stroke-transparent.svg create mode 100644 unittests/style-cdata.svg create mode 100644 unittests/style-to-attr.svg create mode 100644 unittests/transform-matrix-is-identity.svg create mode 100644 unittests/transform-matrix-is-rotate-135.svg create mode 100644 unittests/transform-matrix-is-rotate-225.svg create mode 100644 unittests/transform-matrix-is-rotate-45.svg create mode 100644 unittests/transform-matrix-is-rotate-90.svg create mode 100644 unittests/transform-matrix-is-rotate-neg-45.svg create mode 100644 unittests/transform-matrix-is-rotate-neg-90.svg create mode 100644 unittests/transform-matrix-is-scale-2-3.svg create mode 100644 unittests/transform-matrix-is-scale-neg-1.svg create mode 100644 unittests/transform-matrix-is-translate.svg create mode 100644 unittests/transform-rotate-fold-3args.svg create mode 100644 unittests/transform-rotate-is-identity.svg create mode 100644 unittests/transform-rotate-trim-range-719.5.svg create mode 100644 unittests/transform-rotate-trim-range-neg-540.0.svg create mode 100644 unittests/transform-skewX-is-identity.svg create mode 100644 unittests/transform-skewY-is-identity.svg create mode 100644 unittests/transform-translate-is-identity.svg create mode 100644 unittests/unreferenced-font.svg create mode 100644 unittests/unreferenced-linearGradient.svg create mode 100644 unittests/unreferenced-pattern.svg create mode 100644 unittests/unreferenced-radialGradient.svg create mode 100644 unittests/useless-defs.svg create mode 100644 unittests/utf8.svg create mode 100644 unittests/whitespace-defs.svg create mode 100644 unittests/whitespace-important.svg create mode 100644 unittests/whitespace-nested.svg create mode 100644 unittests/xml-namespace-attrs.svg create mode 100644 unittests/xml-ns-decl.svg create mode 100644 unittests/xml-well-formed.svg diff --git a/testcss.py b/testcss.py new file mode 100755 index 0000000..243ab35 --- /dev/null +++ b/testcss.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Test Harness for Scour +# +# Copyright 2010 Jeff Schiller +# +# This file is part of Scour, http://www.codedread.com/scour/ +# +# Licensed 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. + +import unittest +from yocto_css import parseCssString + +class Blank(unittest.TestCase): + def runTest(self): + r = parseCssString('') + self.assertEquals( len(r), 0, 'Blank string returned non-empty list') + self.assertEquals( type(r), type([]), 'Blank string returned non list') + +class ElementSelector(unittest.TestCase): + def runTest(self): + r = parseCssString('foo {}') + self.assertEquals( len(r), 1, 'Element selector not returned') + self.assertEquals( r[0]['selector'], 'foo', 'Selector for foo not returned') + self.assertEquals( len(r[0]['properties']), 0, 'Property list for foo not empty') + +class ElementSelectorWithProperty(unittest.TestCase): + def runTest(self): + r = parseCssString('foo { bar: baz}') + self.assertEquals( len(r), 1, 'Element selector not returned') + self.assertEquals( r[0]['selector'], 'foo', 'Selector for foo not returned') + self.assertEquals( len(r[0]['properties']), 1, 'Property list for foo did not have 1') + self.assertEquals( r[0]['properties']['bar'], 'baz', 'Property bar did not have baz value') + +if __name__ == '__main__': + unittest.main() diff --git a/testscour.py b/testscour.py new file mode 100755 index 0000000..0167875 --- /dev/null +++ b/testscour.py @@ -0,0 +1,1370 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Test Harness for Scour +# +# Copyright 2010 Jeff Schiller +# Copyright 2010 Louis Simard +# +# This file is part of Scour, http://www.codedread.com/scour/ +# +# Licensed 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. + +import unittest +import xml.dom.minidom +from svg_regex import svg_parser +from scour import scourXmlFile, scourString, parse_args, makeWellFormed + +SVGNS = 'http://www.w3.org/2000/svg' + +# I couldn't figure out how to get ElementTree to work with the following XPath +# "//*[namespace-uri()='http://example.com']" +# so I decided to use minidom and this helper function that performs a test on a given node +# and all its children +# func must return either True (if pass) or False (if fail) +def walkTree(elem, func): + if func(elem) == False: return False + for child in elem.childNodes: + if walkTree(child, func) == False: return False + return True + +class ScourOptions: + simple_colors = True + style_to_xml = True + group_collapse = True + strip_ids = False + digits = 5 + embed_rasters = True + keep_editor_data = False + strip_xml_prolog = False + indent_type = "space" + enable_viewboxing = False + shorten_ids = False + strip_comments = False + remove_metadata = False + group_create = False + +class NoInkscapeElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/sodipodi.svg').documentElement, + lambda e: e.namespaceURI != 'http://www.inkscape.org/namespaces/inkscape'), False, + 'Found Inkscape elements' ) + +class NoSodipodiElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/sodipodi.svg').documentElement, + lambda e: e.namespaceURI != 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'), False, + 'Found Sodipodi elements' ) + +class NoAdobeIllustratorElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/AdobeIllustrator/10.0/'), False, + 'Found Adobe Illustrator elements' ) +class NoAdobeGraphsElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/Graphs/1.0/'), False, + 'Found Adobe Graphs elements' ) +class NoAdobeSVGViewerElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/'), False, + 'Found Adobe SVG Viewer elements' ) +class NoAdobeVariablesElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/Variables/1.0/'), False, + 'Found Adobe Variables elements' ) +class NoAdobeSaveForWebElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/SaveForWeb/1.0/'), False, + 'Found Adobe Save For Web elements' ) +class NoAdobeExtensibilityElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/Extensibility/1.0/'), False, + 'Found Adobe Extensibility elements' ) +class NoAdobeFlowsElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/Flows/1.0/'), False, + 'Found Adobe Flows elements' ) +class NoAdobeImageReplacementElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/ImageReplacement/1.0/'), False, + 'Found Adobe Image Replacement elements' ) +class NoAdobeCustomElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/GenericCustomNamespace/1.0/'), False, + 'Found Adobe Custom elements' ) +class NoAdobeXPathElements(unittest.TestCase): + def runTest(self): + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/adobe.svg').documentElement, + lambda e: e.namespaceURI != 'http://ns.adobe.com/XPath/1.0/'), False, + 'Found Adobe XPath elements' ) + +class DoNotRemoveMetadataWithOnlyText(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/metadata-with-text.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'metadata')), 1, + 'Removed metadata element with only text child' ) + +class RemoveEmptyMetadataElement(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/empty-metadata.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'metadata')), 0, + 'Did not remove empty metadata element' ) + +class RemoveEmptyGElements(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/empty-g.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'g')), 1, + 'Did not remove empty g element' ) + +class RemoveUnreferencedPattern(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/unreferenced-pattern.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'pattern')), 0, + 'Unreferenced pattern not removed' ) + +class RemoveUnreferencedLinearGradient(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/unreferenced-linearGradient.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'linearGradient')), 0, + 'Unreferenced linearGradient not removed' ) + +class RemoveUnreferencedRadialGradient(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/unreferenced-radialGradient.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'radialradient')), 0, + 'Unreferenced radialGradient not removed' ) + +class RemoveUnreferencedElementInDefs(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/referenced-elements-1.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'rect')), 1, + 'Unreferenced rect left in defs' ) + +class DoNotRemoveChainedRefsInDefs(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/refs-in-defs.svg') + g = doc.getElementsByTagNameNS(SVGNS, 'g')[0] + self.assertEquals( g.childNodes.length >= 2, True, + 'Chained references not honored in defs' ) + +class KeepTitleInDefs(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/referenced-elements-1.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'title')), 1, + 'Title removed from in defs' ) + +class RemoveNestedDefs(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/nested-defs.svg') + allDefs = doc.getElementsByTagNameNS(SVGNS, 'defs') + self.assertEquals(len(allDefs), 1, 'More than one defs left in doc') + +class KeepUnreferencedIDsWhenEnabled(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/ids-to-strip.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'svg')[0].getAttribute('id'), 'boo', + ' ID stripped when it should be disabled' ) + +class RemoveUnreferencedIDsWhenEnabled(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/ids-to-strip.svg', + scour.parse_args(['--enable-id-stripping'])[0]) + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'svg')[0].getAttribute('id'), '', + ' ID not stripped' ) + +class RemoveUselessNestedGroups(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/nested-useless-groups.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'g')), 1, + 'Useless nested groups not removed' ) + +class DoNotRemoveUselessNestedGroups(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/nested-useless-groups.svg', + scour.parse_args(['--disable-group-collapsing'])[0]) + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'g')), 2, + 'Useless nested groups were removed despite --disable-group-collapsing' ) + +class DoNotRemoveNestedGroupsWithTitle(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/groups-with-title-desc.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'g')), 2, + 'Nested groups with title was removed' ) + +class DoNotRemoveNestedGroupsWithDesc(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/groups-with-title-desc.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'g')), 2, + 'Nested groups with desc was removed' ) + +class RemoveDuplicateLinearGradientStops(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/duplicate-gradient-stops.svg') + grad = doc.getElementsByTagNameNS(SVGNS, 'linearGradient') + self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3, + 'Duplicate linear gradient stops not removed' ) + +class RemoveDuplicateLinearGradientStopsPct(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/duplicate-gradient-stops-pct.svg') + grad = doc.getElementsByTagNameNS(SVGNS, 'linearGradient') + self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3, + 'Duplicate linear gradient stops with percentages not removed' ) + +class RemoveDuplicateRadialGradientStops(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/duplicate-gradient-stops.svg') + grad = doc.getElementsByTagNameNS(SVGNS, 'radialGradient') + self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3, + 'Duplicate radial gradient stops not removed' ) + +class NoSodipodiNamespaceDecl(unittest.TestCase): + def runTest(self): + attrs = scour.scourXmlFile('unittests/sodipodi.svg').documentElement.attributes + for i in range(len(attrs)): + self.assertNotEquals(attrs.item(i).nodeValue, + 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd', + 'Sodipodi namespace declaration found' ) + +class NoInkscapeNamespaceDecl(unittest.TestCase): + def runTest(self): + attrs = scour.scourXmlFile('unittests/inkscape.svg').documentElement.attributes + for i in range(len(attrs)): + self.assertNotEquals(attrs.item(i).nodeValue, + 'http://www.inkscape.org/namespaces/inkscape', + 'Inkscape namespace declaration found' ) + +class NoSodipodiAttributes(unittest.TestCase): + def runTest(self): + def findSodipodiAttr(elem): + attrs = elem.attributes + if attrs == None: return True + for i in range(len(attrs)): + if attrs.item(i).namespaceURI == 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd': + return False + return True + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/sodipodi.svg').documentElement, + findSodipodiAttr), False, + 'Found Sodipodi attributes' ) + +class NoInkscapeAttributes(unittest.TestCase): + def runTest(self): + def findInkscapeAttr(elem): + attrs = elem.attributes + if attrs == None: return True + for i in range(len(attrs)): + if attrs.item(i).namespaceURI == 'http://www.inkscape.org/namespaces/inkscape': + return False + return True + self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/inkscape.svg').documentElement, + findInkscapeAttr), False, + 'Found Inkscape attributes' ) + +class KeepInkscapeNamespaceDeclarationsWhenKeepEditorData(unittest.TestCase): + def runTest(self): + options = ScourOptions + options.keep_editor_data = True + attrs = scour.scourXmlFile('unittests/inkscape.svg', options).documentElement.attributes + FoundNamespace = False + for i in range(len(attrs)): + if attrs.item(i).nodeValue == 'http://www.inkscape.org/namespaces/inkscape': + FoundNamespace = True + break + self.assertEquals(True, FoundNamespace, + "Did not find Inkscape namespace declaration when using --keep-editor-data") + return False + +class KeepSodipodiNamespaceDeclarationsWhenKeepEditorData(unittest.TestCase): + def runTest(self): + options = ScourOptions + options.keep_editor_data = True + attrs = scour.scourXmlFile('unittests/sodipodi.svg', options).documentElement.attributes + FoundNamespace = False + for i in range(len(attrs)): + if attrs.item(i).nodeValue == 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd': + FoundNamespace = True + break + self.assertEquals(True, FoundNamespace, + "Did not find Sodipodi namespace declaration when using --keep-editor-data") + return False + +class KeepReferencedFonts(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/referenced-font.svg') + fonts = doc.documentElement.getElementsByTagNameNS(SVGNS,'font') + self.assertEquals(len(fonts), 1, + 'Font wrongly removed from ' ) + +class ConvertStyleToAttrs(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('style'), '', + 'style attribute not emptied' ) + +class RemoveStrokeWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '', + 'stroke attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeWidthWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '', + 'stroke-width attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeLinecapWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '', + 'stroke-linecap attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '', + 'stroke-linejoin attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '', + 'stroke-dasharray attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-transparent.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '', + 'stroke-dashoffset attribute not emptied when stroke opacity zero' ) + +class RemoveStrokeWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '', + 'stroke attribute not emptied when width zero' ) + +class RemoveStrokeOpacityWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-opacity'), '', + 'stroke-opacity attribute not emptied when width zero' ) + +class RemoveStrokeLinecapWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '', + 'stroke-linecap attribute not emptied when width zero' ) + +class RemoveStrokeLinejoinWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '', + 'stroke-linejoin attribute not emptied when width zero' ) + +class RemoveStrokeDasharrayWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '', + 'stroke-dasharray attribute not emptied when width zero' ) + +class RemoveStrokeDashoffsetWhenStrokeWidthZero(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-nowidth.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '', + 'stroke-dashoffset attribute not emptied when width zero' ) + +class RemoveStrokeWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke'), '', + 'stroke attribute not emptied when no stroke' ) + +class RemoveStrokeWidthWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-width'), '', + 'stroke-width attribute not emptied when no stroke' ) + +class RemoveStrokeOpacityWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-opacity'), '', + 'stroke-opacity attribute not emptied when no stroke' ) + +class RemoveStrokeLinecapWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linecap'), '', + 'stroke-linecap attribute not emptied when no stroke' ) + +class RemoveStrokeLinejoinWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '', + 'stroke-linejoin attribute not emptied when no stroke' ) + +class RemoveStrokeDasharrayWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '', + 'stroke-dasharray attribute not emptied when no stroke' ) + +class RemoveStrokeDashoffsetWhenStrokeNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/stroke-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '', + 'stroke-dashoffset attribute not emptied when no stroke' ) + +class RemoveFillRuleWhenFillNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/fill-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('fill-rule'), '', + 'fill-rule attribute not emptied when no fill' ) + +class RemoveFillOpacityWhenFillNone(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/fill-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('fill-opacity'), '', + 'fill-opacity attribute not emptied when no fill' ) + +class ConvertFillPropertyToAttr(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/fill-none.svg', + scour.parse_args(['--disable-simplify-colors'])[0]) + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[1].getAttribute('fill'), 'black', + 'fill property not converted to XML attribute' ) + +class ConvertFillOpacityPropertyToAttr(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/fill-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[1].getAttribute('fill-opacity'), '.5', + 'fill-opacity property not converted to XML attribute' ) + +class ConvertFillRuleOpacityPropertyToAttr(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/fill-none.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[1].getAttribute('fill-rule'), 'evenodd', + 'fill-rule property not converted to XML attribute' ) + +class CollapseSinglyReferencedGradients(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/collapse-gradients.svg') + self.assertEquals(len(doc.getElementsByTagNameNS(SVGNS, 'linearGradient')), 0, + 'Singly-referenced linear gradient not collapsed' ) + +class InheritGradientUnitsUponCollapsing(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/collapse-gradients.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'radialGradient')[0].getAttribute('gradientUnits'), + 'userSpaceOnUse', + 'gradientUnits not properly inherited when collapsing gradients' ) + +class OverrideGradientUnitsUponCollapsing(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/collapse-gradients-gradientUnits.svg') + self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'radialGradient')[0].getAttribute('gradientUnits'), '', + 'gradientUnits not properly overrode when collapsing gradients' ) + +class DoNotCollapseMultiplyReferencedGradients(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/dont-collapse-gradients.svg') + self.assertNotEquals(len(doc.getElementsByTagNameNS(SVGNS, 'linearGradient')), 0, + 'Multiply-referenced linear gradient collapsed' ) + +class RemoveTrailingZerosFromPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-truncate-zeros.svg') + path = doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d') + self.assertEquals(path[:4] == 'm300' and path[4] != '.', True, + 'Trailing zeros not removed from path data' ) + +class RemoveTrailingZerosFromPathAfterCalculation(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-truncate-zeros-calc.svg') + path = doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d') + self.assertEquals(path, 'm5.81 0h0.1', + 'Trailing zeros not removed from path data after calculation' ) + +class RemoveDelimiterBeforeNegativeCoordsInPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-truncate-zeros.svg') + path = doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d') + self.assertEquals(path[4], '-', + 'Delimiters not removed before negative coordinates in path data' ) + +class UseScientificNotationToShortenCoordsInPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-use-scientific-notation.svg') + path = doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d') + self.assertEquals(path, 'm1e4 0', + 'Not using scientific notation for path coord when representation is shorter') + +class ConvertAbsoluteToRelativePathCommands(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-abs-to-rel.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(path[1][0], 'v', + 'Absolute V command not converted to relative v command') + self.assertEquals(float(path[1][1][0]), -20.0, + 'Absolute V value not converted to relative v value') + +class RoundPathData(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-precision.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(float(path[0][1][0]), 100.0, + 'Not rounding down' ) + self.assertEquals(float(path[0][1][1]), 100.0, + 'Not rounding up' ) + +class LimitPrecisionInPathData(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-precision.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(float(path[1][1][0]), 100.01, + 'Not correctly limiting precision on path data' ) + +class RemoveEmptyLineSegmentsFromPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-line-optimize.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(path[4][0], 'z', + 'Did not remove an empty line segment from path' ) + +# Do not remove empty segments if round linecaps. +class DoNotRemoveEmptySegmentsFromPathWithRoundLineCaps(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-with-caps.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(len(path), 2, + 'Did not preserve empty segments when path had round linecaps' ) + +class ChangeLineToHorizontalLineSegmentInPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-line-optimize.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(path[1][0], 'h', + 'Did not change line to horizontal line segment in path' ) + self.assertEquals(float(path[1][1][0]), 200.0, + 'Did not calculate horizontal line segment in path correctly' ) + +class ChangeLineToVerticalLineSegmentInPath(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-line-optimize.svg') + path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d')) + self.assertEquals(path[2][0], 'v', + 'Did not change line to vertical line segment in path' ) + self.assertEquals(float(path[2][1][0]), 100.0, + 'Did not calculate vertical line segment in path correctly' ) + +class ChangeBezierToShorthandInPath(unittest.TestCase): + def runTest(self): + path = scour.scourXmlFile('unittests/path-bez-optimize.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals(path.getAttribute('d'), 'm10 100c50-50 50 50 100 0s50 50 100 0', + 'Did not change bezier curves into shorthand curve segments in path') + +class ChangeQuadToShorthandInPath(unittest.TestCase): + def runTest(self): + path = scour.scourXmlFile('unittests/path-quad-optimize.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals(path.getAttribute('d'), 'm10 100q50-50 100 0t100 0', + 'Did not change quadratic curves into shorthand curve segments in path') + +class HandleNonAsciiUtf8(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/utf8.svg') + desc = unicode(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip() + self.assertEquals( desc, u'ú', + 'Did not handle non-ASCII characters' ) + +class HandleSciNoInPathData(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/path-sn.svg') + self.assertEquals( len(doc.getElementsByTagNameNS(SVGNS, 'path')), 1, + 'Did not handle scientific notation in path data' ) + +class TranslateRGBIntoHex(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/color-formats.svg').getElementsByTagNameNS(SVGNS, 'rect')[0] + self.assertEquals( elem.getAttribute('fill'), '#0f1011', + 'Not converting rgb into hex') + +class TranslateRGBPctIntoHex(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/color-formats.svg').getElementsByTagNameNS(SVGNS, 'stop')[0] + self.assertEquals( elem.getAttribute('stop-color'), '#7f0000', + 'Not converting rgb pct into hex') + +class TranslateColorNamesIntoHex(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/color-formats.svg').getElementsByTagNameNS(SVGNS, 'rect')[0] + self.assertEquals( elem.getAttribute('stroke'), '#a9a9a9', + 'Not converting standard color names into hex') + +class TranslateExtendedColorNamesIntoHex(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/color-formats.svg').getElementsByTagNameNS(SVGNS, 'solidColor')[0] + self.assertEquals( elem.getAttribute('solid-color'), '#fafad2', + 'Not converting extended color names into hex') + +class TranslateLongHexColorIntoShortHex(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/color-formats.svg').getElementsByTagNameNS(SVGNS, 'ellipse')[0] + self.assertEquals( elem.getAttribute('fill'), '#fff', + 'Not converting long hex color into short hex') + +class DoNotConvertShortColorNames(unittest.TestCase): + def runTest(self): + elem = scour.scourXmlFile('unittests/dont-convert-short-color-names.svg').getElementsByTagNameNS(SVGNS, 'rect')[0] + self.assertEquals( 'red', elem.getAttribute('fill'), + 'Converted short color name to longer hex string') + +class AllowQuotEntitiesInUrl(unittest.TestCase): + def runTest(self): + grads = scour.scourXmlFile('unittests/quot-in-url.svg').getElementsByTagNameNS(SVGNS, 'linearGradient') + self.assertEquals( len(grads), 1, + 'Removed referenced gradient when " was in the url') + +class RemoveFontStylesFromNonTextShapes(unittest.TestCase): + def runTest(self): + r = scour.scourXmlFile('unittests/font-styles.svg').getElementsByTagNameNS(SVGNS, 'rect')[0] + self.assertEquals( r.getAttribute('font-size'), '', + 'font-size not removed from rect' ) + +class CollapseConsecutiveHLinesSegments(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/consecutive-hlines.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals( p.getAttribute('d'), 'm100 100h200v100h-200z', + 'Did not collapse consecutive hlines segments') + +class CollapseConsecutiveHLinesCoords(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/consecutive-hlines.svg').getElementsByTagNameNS(SVGNS, 'path')[1] + self.assertEquals( p.getAttribute('d'), 'm100 300h200v100h-200z', + 'Did not collapse consecutive hlines coordinates') + +class DoNotCollapseConsecutiveHLinesSegsWithDifferingSigns(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/consecutive-hlines.svg').getElementsByTagNameNS(SVGNS, 'path')[2] + self.assertEquals( p.getAttribute('d'), 'm100 500h300-100v100h-200z', + 'Collapsed consecutive hlines segments with differing signs') + +class ConvertStraightCurvesToLines(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/straight-curve.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals(p.getAttribute('d'), 'm10 10l40 40 40-40z', + 'Did not convert straight curves into lines') + +class RemoveUnnecessaryPolygonEndPoint(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polygon.svg').getElementsByTagNameNS(SVGNS, 'polygon')[0] + self.assertEquals(p.getAttribute('points'), '50 50 150 50 150 150 50 150', + 'Unnecessary polygon end point not removed' ) + +class DoNotRemovePolgonLastPoint(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polygon.svg').getElementsByTagNameNS(SVGNS, 'polygon')[1] + self.assertEquals(p.getAttribute('points'), '200 50 300 50 300 150 200 150', + 'Last point of polygon removed' ) + +class ScourPolygonCoordsSciNo(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polygon-coord.svg').getElementsByTagNameNS(SVGNS, 'polygon')[0] + self.assertEquals(p.getAttribute('points'), '1e4 50', + 'Polygon coordinates not scoured') + +class ScourPolylineCoordsSciNo(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polyline-coord.svg').getElementsByTagNameNS(SVGNS, 'polyline')[0] + self.assertEquals(p.getAttribute('points'), '1e4 50', + 'Polyline coordinates not scoured') + +class ScourPolygonNegativeCoords(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polygon-coord-neg.svg').getElementsByTagNameNS(SVGNS, 'polygon')[0] + # points="100,-100,100-100,100-100-100,-100-100,200" /> + self.assertEquals(p.getAttribute('points'), '100 -100 100 -100 100 -100 -100 -100 -100 200', + 'Negative polygon coordinates not properly parsed') + +class ScourPolylineNegativeCoords(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polyline-coord-neg.svg').getElementsByTagNameNS(SVGNS, 'polyline')[0] + self.assertEquals(p.getAttribute('points'), '100 -100 100 -100 100 -100 -100 -100 -100 200', + 'Negative polyline coordinates not properly parsed') + +class ScourPolygonNegativeCoordFirst(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polygon-coord-neg-first.svg').getElementsByTagNameNS(SVGNS, 'polygon')[0] + # points="-100,-100,100-100,100-100-100,-100-100,200" /> + self.assertEquals(p.getAttribute('points'), '-100 -100 100 -100 100 -100 -100 -100 -100 200', + 'Negative polygon coordinates not properly parsed') + +class ScourPolylineNegativeCoordFirst(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/polyline-coord-neg-first.svg').getElementsByTagNameNS(SVGNS, 'polyline')[0] + self.assertEquals(p.getAttribute('points'), '-100 -100 100 -100 100 -100 -100 -100 -100 200', + 'Negative polyline coordinates not properly parsed') + +class DoNotRemoveGroupsWithIDsInDefs(unittest.TestCase): + def runTest(self): + f = scour.scourXmlFile('unittests/important-groups-in-defs.svg') + self.assertEquals(len(f.getElementsByTagNameNS(SVGNS, 'linearGradient')), 1, + 'Group in defs with id\'ed element removed') + +class AlwaysKeepClosePathSegments(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/path-with-closepath.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals(p.getAttribute('d'), 'm10 10h100v100h-100z', + 'Path with closepath not preserved') + +class RemoveDuplicateLinearGradients(unittest.TestCase): + def runTest(self): + svgdoc = scour.scourXmlFile('unittests/remove-duplicate-gradients.svg') + lingrads = svgdoc.getElementsByTagNameNS(SVGNS, 'linearGradient') + self.assertEquals(1, lingrads.length, + 'Duplicate linear gradient not removed') + +class RereferenceForLinearGradient(unittest.TestCase): + def runTest(self): + svgdoc = scour.scourXmlFile('unittests/remove-duplicate-gradients.svg') + rects = svgdoc.getElementsByTagNameNS(SVGNS, 'rect') + self.assertEquals(rects[0].getAttribute('fill'), rects[1].getAttribute('stroke'), + 'Rect not changed after removing duplicate linear gradient') + self.assertEquals(rects[0].getAttribute('fill'), rects[4].getAttribute('fill'), + 'Rect not changed after removing duplicate linear gradient') + +class RemoveDuplicateRadialGradients(unittest.TestCase): + def runTest(self): + svgdoc = scour.scourXmlFile('unittests/remove-duplicate-gradients.svg') + radgrads = svgdoc.getElementsByTagNameNS(SVGNS, 'radialGradient') + self.assertEquals(1, radgrads.length, + 'Duplicate radial gradient not removed') + +class RereferenceForRadialGradient(unittest.TestCase): + def runTest(self): + svgdoc = scour.scourXmlFile('unittests/remove-duplicate-gradients.svg') + rects = svgdoc.getElementsByTagNameNS(SVGNS, 'rect') + self.assertEquals(rects[2].getAttribute('stroke'), rects[3].getAttribute('fill'), + 'Rect not changed after removing duplicate radial gradient') + +class CollapseSamePathPoints(unittest.TestCase): + def runTest(self): + p = scour.scourXmlFile('unittests/collapse-same-path-points.svg').getElementsByTagNameNS(SVGNS, 'path')[0]; + self.assertEquals(p.getAttribute('d'), "m100 100l100.12 100.12c14.88 4.88-15.12-5.12 0 0z", + 'Did not collapse same path points') + +class ScourUnitlessLengths(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/scour-lengths.svg') + r = doc.getElementsByTagNameNS(SVGNS, 'rect')[0]; + svg = doc.documentElement + self.assertEquals(svg.getAttribute('x'), '1', + 'Did not scour x attribute of svg element with unitless number') + self.assertEquals(r.getAttribute('x'), '123.46', + 'Did not scour x attribute of rect with unitless number') + self.assertEquals(r.getAttribute('y'), '123', + 'Did not scour y attribute of rect unitless number') + self.assertEquals(r.getAttribute('width'), '300', + 'Did not scour width attribute of rect with unitless number') + self.assertEquals(r.getAttribute('height'), '100', + 'Did not scour height attribute of rect with unitless number') + +class ScourLengthsWithUnits(unittest.TestCase): + def runTest(self): + r = scour.scourXmlFile('unittests/scour-lengths.svg').getElementsByTagNameNS(SVGNS, 'rect')[1]; + self.assertEquals(r.getAttribute('x'), '123.46px', + 'Did not scour x attribute with unit') + self.assertEquals(r.getAttribute('y'), '35ex', + 'Did not scour y attribute with unit') + self.assertEquals(r.getAttribute('width'), '300pt', + 'Did not scour width attribute with unit') + self.assertEquals(r.getAttribute('height'), '50%', + 'Did not scour height attribute with unit') + +class RemoveRedundantSvgNamespaceDeclaration(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/redundant-svg-namespace.svg').documentElement + self.assertNotEquals( doc.getAttribute('xmlns:svg'), 'http://www.w3.org/2000/svg', + 'Redundant svg namespace declaration not removed') + +class RemoveRedundantSvgNamespacePrefix(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/redundant-svg-namespace.svg').documentElement + r = doc.getElementsByTagNameNS(SVGNS, 'rect')[1] + self.assertEquals( r.tagName, 'rect', + 'Redundant svg: prefix not removed') + + +class RemoveDefaultGradX1Value(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('x1'), '', + 'x1="0" not removed') + +class RemoveDefaultGradY1Value(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('y1'), '', + 'y1="0" not removed') + +class RemoveDefaultGradX2Value(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('x2'), '', + 'x2="100%" not removed') + +class RemoveDefaultGradY2Value(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('y2'), '', + 'y2="0" not removed') + +class RemoveDefaultGradGradientUnitsValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('gradientUnits'), '', + 'gradientUnits="objectBoundingBox" not removed') + +class RemoveDefaultGradSpreadMethodValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[0] + self.assertEquals( g.getAttribute('spreadMethod'), '', + 'spreadMethod="pad" not removed') + +class RemoveDefaultGradCXValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'radialGradient')[0] + self.assertEquals( g.getAttribute('cx'), '', + 'cx="50%" not removed') + +class RemoveDefaultGradCYValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'radialGradient')[0] + self.assertEquals( g.getAttribute('cy'), '', + 'cy="50%" not removed') + +class RemoveDefaultGradRValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'radialGradient')[0] + self.assertEquals( g.getAttribute('r'), '', + 'r="50%" not removed') + +class RemoveDefaultGradFXValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'radialGradient')[0] + self.assertEquals( g.getAttribute('fx'), '', + 'fx matching cx not removed') + +class RemoveDefaultGradFYValue(unittest.TestCase): + def runTest(self): + g = scour.scourXmlFile('unittests/gradient-default-attrs.svg').getElementsByTagNameNS(SVGNS, 'radialGradient')[0] + self.assertEquals( g.getAttribute('fy'), '', + 'fy matching cy not removed') + +class CDATAInXml(unittest.TestCase): + def runTest(self): + lines = scour.scourString(open('unittests/cdata.svg').read()).splitlines() + self.assertEquals( lines[3], + " alert('pb&j');", + 'CDATA did not come out correctly') + +class WellFormedXMLLesserThanInAttrValue(unittest.TestCase): + def runTest(self): + wellformed = scour.scourString(open('unittests/xml-well-formed.svg').read()) + self.assert_( wellformed.find('unicode="<"') != -1, + "Improperly serialized < in attribute value") + +class WellFormedXMLAmpersandInAttrValue(unittest.TestCase): + def runTest(self): + wellformed = scour.scourString(open('unittests/xml-well-formed.svg').read()) + self.assert_( wellformed.find('unicode="&"') != -1, + 'Improperly serialized & in attribute value' ) + +class WellFormedXMLLesserThanInTextContent(unittest.TestCase): + def runTest(self): + wellformed = scour.scourString(open('unittests/xml-well-formed.svg').read()) + self.assert_( wellformed.find('2 < 5') != -1, + 'Improperly serialized < in text content') + +class WellFormedXMLAmpersandInTextContent(unittest.TestCase): + def runTest(self): + wellformed = scour.scourString(open('unittests/xml-well-formed.svg').read()) + self.assert_( wellformed.find('Peanut Butter & Jelly') != -1, + 'Improperly serialized & in text content') + +class WellFormedXMLNamespacePrefix(unittest.TestCase): + def runTest(self): + wellformed = scour.scourString(open('unittests/xml-well-formed.svg').read()) + self.assert_( wellformed.find('xmlns:foo=') != -1, + 'Improperly serialized namespace prefix declarations') + +class NamespaceDeclPrefixesInXMLWhenNotInDefaultNamespace(unittest.TestCase): + def runTest(self): + xmlstring = scour.scourString(open('unittests/xml-ns-decl.svg').read()) + self.assert_( xmlstring.find('xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"') != -1, + 'Improperly serialized namespace prefix declarations when not in default namespace') + +class MoveSVGElementsToDefaultNamespace(unittest.TestCase): + def runTest(self): + xmlstring = scour.scourString(open('unittests/xml-ns-decl.svg').read()) + self.assert_( xmlstring.find(' + + This is some messed-up markup + +'''.splitlines() + for i in range(4): + self.assertEquals( s[i], c[i], + 'Whitespace not preserved for line ' + str(i)) + +class DoNotPrettyPrintWhenNestedWhitespacePreserved(unittest.TestCase): + def runTest(self): + s = scour.scourString(open('unittests/whitespace-nested.svg').read()).splitlines() + c = ''' + + Use bold text + +'''.splitlines() + for i in range(4): + self.assertEquals( s[i], c[i], + 'Whitespace not preserved when nested for line ' + str(i)) + +class GetAttrPrefixRight(unittest.TestCase): + def runTest(self): + grad = scour.scourXmlFile('unittests/xml-namespace-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[1] + self.assertEquals( grad.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), '#linearGradient841', + 'Did not get xlink:href prefix right') + +class EnsurePreserveWhitespaceOnNonTextElements(unittest.TestCase): + def runTest(self): + s = scour.scourString(open('unittests/no-collapse-lines.svg').read()) + self.assertEquals( len(s.splitlines()), 6, + 'Did not properly preserve whitespace on elements even if they were not textual') + +class HandleEmptyStyleElement(unittest.TestCase): + def runTest(self): + try: + styles = scour.scourXmlFile('unittests/empty-style.svg').getElementsByTagNameNS(SVGNS, 'style') + fail = len(styles) != 1 + except AttributeError: + fail = True + self.assertEquals( fail, False, + 'Could not handle an empty style element') + +class EnsureLineEndings(unittest.TestCase): + def runTest(self): + s = scour.scourString(open('unittests/whitespace-important.svg').read()) + self.assertEquals( len(s.splitlines()), 4, + 'Did not output line ending character correctly') + +class XmlEntities(unittest.TestCase): + def runTest(self): + self.assertEquals( scour.makeWellFormed('<>&"\''), '<>&"'', + 'Incorrectly translated XML entities') + +class DoNotStripCommentsOutsideOfRoot(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/comments.svg') + self.assertEquals( doc.childNodes.length, 4, + 'Did not include all comment children outside of root') + self.assertEquals( doc.childNodes[0].nodeType, 8, 'First node not a comment') + self.assertEquals( doc.childNodes[1].nodeType, 8, 'Second node not a comment') + self.assertEquals( doc.childNodes[3].nodeType, 8, 'Fourth node not a comment') + +class DoNotStripDoctype(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/doctype.svg') + self.assertEquals( doc.childNodes.length, 3, + 'Did not include the DOCROOT') + self.assertEquals( doc.childNodes[0].nodeType, 8, 'First node not a comment') + self.assertEquals( doc.childNodes[1].nodeType, 10, 'Second node not a doctype') + self.assertEquals( doc.childNodes[2].nodeType, 1, 'Third node not the root node') + +class PathImplicitLineWithMoveCommands(unittest.TestCase): + def runTest(self): + path = scour.scourXmlFile('unittests/path-implicit-line.svg').getElementsByTagNameNS(SVGNS, 'path')[0] + self.assertEquals( path.getAttribute('d'), "m100 100v100m200-100h-200m200 100v-100", + "Implicit line segments after move not preserved") + +class RemoveMetadataOption(unittest.TestCase): + def runTest(self): + doc = scour.scourXmlFile('unittests/full-metadata.svg', + scour.parse_args(['--remove-metadata'])[0]) + self.assertEquals(doc.childNodes.length, 1, + 'Did not remove tag with --remove-metadata') + +class EnableCommentStrippingOption(unittest.TestCase): + def runTest(self): + docStr = file('unittests/comment-beside-xml-decl.svg').read() + docStr = scour.scourString(docStr, + scour.parse_args(['--enable-comment-stripping'])[0]) + self.assertEquals(docStr.find(' + + + + + + diff --git a/unittests/comments.svg b/unittests/comments.svg new file mode 100644 index 0000000..06a75f2 --- /dev/null +++ b/unittests/comments.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/commonized-referenced-elements.svg b/unittests/commonized-referenced-elements.svg new file mode 100644 index 0000000..3a152fb --- /dev/null +++ b/unittests/commonized-referenced-elements.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/unittests/consecutive-hlines.svg b/unittests/consecutive-hlines.svg new file mode 100644 index 0000000..caae623 --- /dev/null +++ b/unittests/consecutive-hlines.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/css-reference.svg b/unittests/css-reference.svg new file mode 100644 index 0000000..6330c60 --- /dev/null +++ b/unittests/css-reference.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/unittests/doctype.svg b/unittests/doctype.svg new file mode 100644 index 0000000..d19e074 --- /dev/null +++ b/unittests/doctype.svg @@ -0,0 +1,7 @@ + + + + +]> + diff --git a/unittests/dont-collapse-gradients.svg b/unittests/dont-collapse-gradients.svg new file mode 100644 index 0000000..00b58f5 --- /dev/null +++ b/unittests/dont-collapse-gradients.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/unittests/dont-convert-short-color-names.svg b/unittests/dont-convert-short-color-names.svg new file mode 100644 index 0000000..cbcece7 --- /dev/null +++ b/unittests/dont-convert-short-color-names.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/duplicate-gradient-stops-pct.svg b/unittests/duplicate-gradient-stops-pct.svg new file mode 100644 index 0000000..43c99c4 --- /dev/null +++ b/unittests/duplicate-gradient-stops-pct.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/unittests/duplicate-gradient-stops.svg b/unittests/duplicate-gradient-stops.svg new file mode 100644 index 0000000..4629bd6 --- /dev/null +++ b/unittests/duplicate-gradient-stops.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/unittests/duplicate-gradients-update-style.svg b/unittests/duplicate-gradients-update-style.svg new file mode 100644 index 0000000..c28070c --- /dev/null +++ b/unittests/duplicate-gradients-update-style.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/unittests/empty-g.svg b/unittests/empty-g.svg new file mode 100644 index 0000000..ccb7355 --- /dev/null +++ b/unittests/empty-g.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/unittests/empty-metadata.svg b/unittests/empty-metadata.svg new file mode 100644 index 0000000..ca3c31f --- /dev/null +++ b/unittests/empty-metadata.svg @@ -0,0 +1,3 @@ + + + diff --git a/unittests/empty-style.svg b/unittests/empty-style.svg new file mode 100644 index 0000000..a2d2afd --- /dev/null +++ b/unittests/empty-style.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/fill-none.svg b/unittests/fill-none.svg new file mode 100644 index 0000000..6442c90 --- /dev/null +++ b/unittests/fill-none.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/font-styles.svg b/unittests/font-styles.svg new file mode 100644 index 0000000..e4120df --- /dev/null +++ b/unittests/font-styles.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/full-metadata.svg b/unittests/full-metadata.svg new file mode 100644 index 0000000..f67e01d --- /dev/null +++ b/unittests/full-metadata.svg @@ -0,0 +1,22 @@ + + + + + + + No One + + + + + + diff --git a/unittests/gradient-default-attrs.svg b/unittests/gradient-default-attrs.svg new file mode 100644 index 0000000..36fd0e7 --- /dev/null +++ b/unittests/gradient-default-attrs.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/unittests/group-creation.svg b/unittests/group-creation.svg new file mode 100644 index 0000000..96776c0 --- /dev/null +++ b/unittests/group-creation.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/group-no-creation.svg b/unittests/group-no-creation.svg new file mode 100644 index 0000000..bea6419 --- /dev/null +++ b/unittests/group-no-creation.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/groups-in-switch-with-id.svg b/unittests/groups-in-switch-with-id.svg new file mode 100644 index 0000000..317cfcc --- /dev/null +++ b/unittests/groups-in-switch-with-id.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/unittests/groups-in-switch.svg b/unittests/groups-in-switch.svg new file mode 100644 index 0000000..96394fd --- /dev/null +++ b/unittests/groups-in-switch.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/unittests/groups-with-title-desc.svg b/unittests/groups-with-title-desc.svg new file mode 100644 index 0000000..7983dc0 --- /dev/null +++ b/unittests/groups-with-title-desc.svg @@ -0,0 +1,13 @@ + + + + Group 1 + + + + + Group 1 + + + + diff --git a/unittests/ids-to-strip.svg b/unittests/ids-to-strip.svg new file mode 100644 index 0000000..1ac59bc --- /dev/null +++ b/unittests/ids-to-strip.svg @@ -0,0 +1,11 @@ + + + + Fooey + + + + + + + diff --git a/unittests/important-groups-in-defs.svg b/unittests/important-groups-in-defs.svg new file mode 100644 index 0000000..18ba1df --- /dev/null +++ b/unittests/important-groups-in-defs.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/unittests/inkscape.svg b/unittests/inkscape.svg new file mode 100644 index 0000000..a51ad49 --- /dev/null +++ b/unittests/inkscape.svg @@ -0,0 +1,7 @@ + + + + + diff --git a/unittests/metadata-with-text.svg b/unittests/metadata-with-text.svg new file mode 100644 index 0000000..6149b68 --- /dev/null +++ b/unittests/metadata-with-text.svg @@ -0,0 +1,4 @@ + + + This is a metadata element with only text node children + diff --git a/unittests/move-common-attributes-to-grandparent.svg b/unittests/move-common-attributes-to-grandparent.svg new file mode 100644 index 0000000..4e202bd --- /dev/null +++ b/unittests/move-common-attributes-to-grandparent.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/unittests/move-common-attributes-to-parent.svg b/unittests/move-common-attributes-to-parent.svg new file mode 100644 index 0000000..f390c89 --- /dev/null +++ b/unittests/move-common-attributes-to-parent.svg @@ -0,0 +1,13 @@ + + + + + + + +Hello +World! +Goodbye +Cruel World! + + diff --git a/unittests/nested-defs.svg b/unittests/nested-defs.svg new file mode 100644 index 0000000..7091985 --- /dev/null +++ b/unittests/nested-defs.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/unittests/nested-useless-groups.svg b/unittests/nested-useless-groups.svg new file mode 100644 index 0000000..73b5f88 --- /dev/null +++ b/unittests/nested-useless-groups.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/unittests/no-collapse-lines.svg b/unittests/no-collapse-lines.svg new file mode 100644 index 0000000..85da385 --- /dev/null +++ b/unittests/no-collapse-lines.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/unittests/overflow-marker.svg b/unittests/overflow-marker.svg new file mode 100644 index 0000000..ec068d9 --- /dev/null +++ b/unittests/overflow-marker.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/unittests/overflow-svg.svg b/unittests/overflow-svg.svg new file mode 100644 index 0000000..8830a80 --- /dev/null +++ b/unittests/overflow-svg.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/unittests/path-abs-to-rel.svg b/unittests/path-abs-to-rel.svg new file mode 100644 index 0000000..c9cc803 --- /dev/null +++ b/unittests/path-abs-to-rel.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-bez-optimize.svg b/unittests/path-bez-optimize.svg new file mode 100644 index 0000000..97bfdd1 --- /dev/null +++ b/unittests/path-bez-optimize.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-elliptical-arc-parsing.svg b/unittests/path-elliptical-arc-parsing.svg new file mode 100644 index 0000000..77a8cbd --- /dev/null +++ b/unittests/path-elliptical-arc-parsing.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-empty-move.svg b/unittests/path-empty-move.svg new file mode 100644 index 0000000..d3b63d7 --- /dev/null +++ b/unittests/path-empty-move.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/path-implicit-line.svg b/unittests/path-implicit-line.svg new file mode 100644 index 0000000..a42848e --- /dev/null +++ b/unittests/path-implicit-line.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-line-optimize.svg b/unittests/path-line-optimize.svg new file mode 100644 index 0000000..13cc139 --- /dev/null +++ b/unittests/path-line-optimize.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-precision.svg b/unittests/path-precision.svg new file mode 100644 index 0000000..8e1e267 --- /dev/null +++ b/unittests/path-precision.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-quad-optimize.svg b/unittests/path-quad-optimize.svg new file mode 100644 index 0000000..bbe3bc9 --- /dev/null +++ b/unittests/path-quad-optimize.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-simple-triangle.svg b/unittests/path-simple-triangle.svg new file mode 100644 index 0000000..94ab17e --- /dev/null +++ b/unittests/path-simple-triangle.svg @@ -0,0 +1,8 @@ + + + + diff --git a/unittests/path-sn.svg b/unittests/path-sn.svg new file mode 100644 index 0000000..0b9f7d2 --- /dev/null +++ b/unittests/path-sn.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-truncate-zeros-calc.svg b/unittests/path-truncate-zeros-calc.svg new file mode 100644 index 0000000..c889fff --- /dev/null +++ b/unittests/path-truncate-zeros-calc.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-truncate-zeros.svg b/unittests/path-truncate-zeros.svg new file mode 100644 index 0000000..ad1c6d5 --- /dev/null +++ b/unittests/path-truncate-zeros.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-use-scientific-notation.svg b/unittests/path-use-scientific-notation.svg new file mode 100644 index 0000000..afbbf05 --- /dev/null +++ b/unittests/path-use-scientific-notation.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-with-caps.svg b/unittests/path-with-caps.svg new file mode 100644 index 0000000..0e7ab1a --- /dev/null +++ b/unittests/path-with-caps.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/path-with-closepath.svg b/unittests/path-with-closepath.svg new file mode 100644 index 0000000..80858ca --- /dev/null +++ b/unittests/path-with-closepath.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polygon-coord-neg-first.svg b/unittests/polygon-coord-neg-first.svg new file mode 100644 index 0000000..9f87a3e --- /dev/null +++ b/unittests/polygon-coord-neg-first.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polygon-coord-neg.svg b/unittests/polygon-coord-neg.svg new file mode 100644 index 0000000..73fe0b9 --- /dev/null +++ b/unittests/polygon-coord-neg.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polygon-coord.svg b/unittests/polygon-coord.svg new file mode 100644 index 0000000..15940d4 --- /dev/null +++ b/unittests/polygon-coord.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polygon.svg b/unittests/polygon.svg new file mode 100644 index 0000000..d927a00 --- /dev/null +++ b/unittests/polygon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/polyline-coord-neg-first.svg b/unittests/polyline-coord-neg-first.svg new file mode 100644 index 0000000..41d1981 --- /dev/null +++ b/unittests/polyline-coord-neg-first.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polyline-coord-neg.svg b/unittests/polyline-coord-neg.svg new file mode 100644 index 0000000..da82dad --- /dev/null +++ b/unittests/polyline-coord-neg.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/polyline-coord.svg b/unittests/polyline-coord.svg new file mode 100644 index 0000000..fc209ed --- /dev/null +++ b/unittests/polyline-coord.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/protection.svg b/unittests/protection.svg new file mode 100644 index 0000000..f2930f5 --- /dev/null +++ b/unittests/protection.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/unittests/quot-in-url.svg b/unittests/quot-in-url.svg new file mode 100644 index 0000000..6d82567 --- /dev/null +++ b/unittests/quot-in-url.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/unittests/redundant-svg-namespace.svg b/unittests/redundant-svg-namespace.svg new file mode 100644 index 0000000..5022693 --- /dev/null +++ b/unittests/redundant-svg-namespace.svg @@ -0,0 +1,8 @@ + + + + + Test + + + diff --git a/unittests/referenced-elements-1.svg b/unittests/referenced-elements-1.svg new file mode 100644 index 0000000..e779080 --- /dev/null +++ b/unittests/referenced-elements-1.svg @@ -0,0 +1,11 @@ + + + + Fooey + + + + + + + diff --git a/unittests/referenced-font.svg b/unittests/referenced-font.svg new file mode 100644 index 0000000..7d992ec --- /dev/null +++ b/unittests/referenced-font.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + Text + diff --git a/unittests/refs-in-defs.svg b/unittests/refs-in-defs.svg new file mode 100644 index 0000000..8636c5a --- /dev/null +++ b/unittests/refs-in-defs.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/unittests/remove-duplicate-gradients.svg b/unittests/remove-duplicate-gradients.svg new file mode 100644 index 0000000..f986bdd --- /dev/null +++ b/unittests/remove-duplicate-gradients.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/unittests/remove-unused-attributes-on-parent.svg b/unittests/remove-unused-attributes-on-parent.svg new file mode 100644 index 0000000..7f68d15 --- /dev/null +++ b/unittests/remove-unused-attributes-on-parent.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/unittests/scour-lengths.svg b/unittests/scour-lengths.svg new file mode 100644 index 0000000..f5c0d5c --- /dev/null +++ b/unittests/scour-lengths.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/shorten-ids.svg b/unittests/shorten-ids.svg new file mode 100644 index 0000000..7852c57 --- /dev/null +++ b/unittests/shorten-ids.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/unittests/sodipodi.svg b/unittests/sodipodi.svg new file mode 100644 index 0000000..935884a --- /dev/null +++ b/unittests/sodipodi.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/unittests/straight-curve.svg b/unittests/straight-curve.svg new file mode 100644 index 0000000..95cd862 --- /dev/null +++ b/unittests/straight-curve.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/stroke-none.svg b/unittests/stroke-none.svg new file mode 100644 index 0000000..4582a85 --- /dev/null +++ b/unittests/stroke-none.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/stroke-nowidth.svg b/unittests/stroke-nowidth.svg new file mode 100644 index 0000000..2ca5809 --- /dev/null +++ b/unittests/stroke-nowidth.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/stroke-transparent.svg b/unittests/stroke-transparent.svg new file mode 100644 index 0000000..4ff39a2 --- /dev/null +++ b/unittests/stroke-transparent.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/style-cdata.svg b/unittests/style-cdata.svg new file mode 100644 index 0000000..4740da9 --- /dev/null +++ b/unittests/style-cdata.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/unittests/style-to-attr.svg b/unittests/style-to-attr.svg new file mode 100644 index 0000000..3bbe3a0 --- /dev/null +++ b/unittests/style-to-attr.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/unittests/transform-matrix-is-identity.svg b/unittests/transform-matrix-is-identity.svg new file mode 100644 index 0000000..9764b28 --- /dev/null +++ b/unittests/transform-matrix-is-identity.svg @@ -0,0 +1,3 @@ + + + diff --git a/unittests/transform-matrix-is-rotate-135.svg b/unittests/transform-matrix-is-rotate-135.svg new file mode 100644 index 0000000..a0583bc --- /dev/null +++ b/unittests/transform-matrix-is-rotate-135.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-rotate-225.svg b/unittests/transform-matrix-is-rotate-225.svg new file mode 100644 index 0000000..1aa21ef --- /dev/null +++ b/unittests/transform-matrix-is-rotate-225.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-rotate-45.svg b/unittests/transform-matrix-is-rotate-45.svg new file mode 100644 index 0000000..1749d98 --- /dev/null +++ b/unittests/transform-matrix-is-rotate-45.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-rotate-90.svg b/unittests/transform-matrix-is-rotate-90.svg new file mode 100644 index 0000000..269d526 --- /dev/null +++ b/unittests/transform-matrix-is-rotate-90.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-rotate-neg-45.svg b/unittests/transform-matrix-is-rotate-neg-45.svg new file mode 100644 index 0000000..37b46e8 --- /dev/null +++ b/unittests/transform-matrix-is-rotate-neg-45.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-rotate-neg-90.svg b/unittests/transform-matrix-is-rotate-neg-90.svg new file mode 100644 index 0000000..8fbbd4f --- /dev/null +++ b/unittests/transform-matrix-is-rotate-neg-90.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-scale-2-3.svg b/unittests/transform-matrix-is-scale-2-3.svg new file mode 100644 index 0000000..7a04ce5 --- /dev/null +++ b/unittests/transform-matrix-is-scale-2-3.svg @@ -0,0 +1,3 @@ + + + diff --git a/unittests/transform-matrix-is-scale-neg-1.svg b/unittests/transform-matrix-is-scale-neg-1.svg new file mode 100644 index 0000000..d402058 --- /dev/null +++ b/unittests/transform-matrix-is-scale-neg-1.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-matrix-is-translate.svg b/unittests/transform-matrix-is-translate.svg new file mode 100644 index 0000000..0dfcd9d --- /dev/null +++ b/unittests/transform-matrix-is-translate.svg @@ -0,0 +1,3 @@ + + + diff --git a/unittests/transform-rotate-fold-3args.svg b/unittests/transform-rotate-fold-3args.svg new file mode 100644 index 0000000..0139610 --- /dev/null +++ b/unittests/transform-rotate-fold-3args.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/transform-rotate-is-identity.svg b/unittests/transform-rotate-is-identity.svg new file mode 100644 index 0000000..198ba11 --- /dev/null +++ b/unittests/transform-rotate-is-identity.svg @@ -0,0 +1,3 @@ + + + diff --git a/unittests/transform-rotate-trim-range-719.5.svg b/unittests/transform-rotate-trim-range-719.5.svg new file mode 100644 index 0000000..f0bb947 --- /dev/null +++ b/unittests/transform-rotate-trim-range-719.5.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/transform-rotate-trim-range-neg-540.0.svg b/unittests/transform-rotate-trim-range-neg-540.0.svg new file mode 100644 index 0000000..3e857f6 --- /dev/null +++ b/unittests/transform-rotate-trim-range-neg-540.0.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/transform-skewX-is-identity.svg b/unittests/transform-skewX-is-identity.svg new file mode 100644 index 0000000..b038c6e --- /dev/null +++ b/unittests/transform-skewX-is-identity.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-skewY-is-identity.svg b/unittests/transform-skewY-is-identity.svg new file mode 100644 index 0000000..27da015 --- /dev/null +++ b/unittests/transform-skewY-is-identity.svg @@ -0,0 +1,4 @@ + + + + diff --git a/unittests/transform-translate-is-identity.svg b/unittests/transform-translate-is-identity.svg new file mode 100644 index 0000000..6c62d23 --- /dev/null +++ b/unittests/transform-translate-is-identity.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/unittests/unreferenced-font.svg b/unittests/unreferenced-font.svg new file mode 100644 index 0000000..560c83f --- /dev/null +++ b/unittests/unreferenced-font.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + Text + diff --git a/unittests/unreferenced-linearGradient.svg b/unittests/unreferenced-linearGradient.svg new file mode 100644 index 0000000..f588eac --- /dev/null +++ b/unittests/unreferenced-linearGradient.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/unreferenced-pattern.svg b/unittests/unreferenced-pattern.svg new file mode 100644 index 0000000..7bcff58 --- /dev/null +++ b/unittests/unreferenced-pattern.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/unreferenced-radialGradient.svg b/unittests/unreferenced-radialGradient.svg new file mode 100644 index 0000000..bfa35c8 --- /dev/null +++ b/unittests/unreferenced-radialGradient.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/useless-defs.svg b/unittests/useless-defs.svg new file mode 100644 index 0000000..f4663ff --- /dev/null +++ b/unittests/useless-defs.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/unittests/utf8.svg b/unittests/utf8.svg new file mode 100644 index 0000000..6c77d7a --- /dev/null +++ b/unittests/utf8.svg @@ -0,0 +1,5 @@ + + + ú + diff --git a/unittests/whitespace-defs.svg b/unittests/whitespace-defs.svg new file mode 100644 index 0000000..a32fcb4 --- /dev/null +++ b/unittests/whitespace-defs.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/unittests/whitespace-important.svg b/unittests/whitespace-important.svg new file mode 100644 index 0000000..6918044 --- /dev/null +++ b/unittests/whitespace-important.svg @@ -0,0 +1,4 @@ + + + This is some messed-up markup + diff --git a/unittests/whitespace-nested.svg b/unittests/whitespace-nested.svg new file mode 100644 index 0000000..3b99356 --- /dev/null +++ b/unittests/whitespace-nested.svg @@ -0,0 +1,4 @@ + + + Use bold text + diff --git a/unittests/xml-namespace-attrs.svg b/unittests/xml-namespace-attrs.svg new file mode 100644 index 0000000..81c5fb4 --- /dev/null +++ b/unittests/xml-namespace-attrs.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/unittests/xml-ns-decl.svg b/unittests/xml-ns-decl.svg new file mode 100644 index 0000000..0f057a7 --- /dev/null +++ b/unittests/xml-ns-decl.svg @@ -0,0 +1,30 @@ + + + + + image/svg+xml + + Open Clip Art Logo + 10-01-2004 + + + Andreas Nilsson + + + + + + Jon Phillips, Tobias Jakobs + + + This is one version of the official Open Clip Art Library logo. + logo, open clip art library logo, logotype + + + + + + + + + diff --git a/unittests/xml-well-formed.svg b/unittests/xml-well-formed.svg new file mode 100644 index 0000000..705a288 --- /dev/null +++ b/unittests/xml-well-formed.svg @@ -0,0 +1,9 @@ + + + + 2 < 5 + Peanut Butter & Jelly + + + ΉTML & CSS +