Added tests for inkscape and sodipodi namespace declarations and attributes

This commit is contained in:
JSCHILL1 2009-04-18 23:50:40 -05:00
parent f6387b1f22
commit 72363ec24b
4 changed files with 47 additions and 11 deletions

View file

@ -50,7 +50,7 @@
# - Convert all colors to #RRGGBB format # - Convert all colors to #RRGGBB format
# - Reduce #RRGGBB format to #RGB format when possible # - Reduce #RRGGBB format to #RGB format when possible
# - rework command-line argument processing so that options are configurable # - rework command-line argument processing so that options are configurable
https://bugs.edge.launchpad.net/ubuntu/+source/human-icon-theme/+bug/361667/ # https://bugs.edge.launchpad.net/ubuntu/+source/human-icon-theme/+bug/361667/
# Some notes to not forget: # Some notes to not forget:
# - removing unreferenced IDs loses some semantic information # - removing unreferenced IDs loses some semantic information

View file

@ -153,13 +153,47 @@ class RemoveDuplicateRadialGradientStops(unittest.TestCase):
self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3, self.assertEquals(len(grad[0].getElementsByTagNameNS(SVGNS, 'stop')), 3,
'Duplicate radial gradient stops not removed' ) 'Duplicate radial gradient stops not removed' )
# These tests will fail at present class NoSodipodiNamespaceDecl(unittest.TestCase):
#class NoInkscapeAttributes(unittest.TestCase): def runTest(self):
# def runTest(self): attrs = scour.scourXmlFile('unittests/sodipodi.svg').documentElement.attributes
# self.assertNotEquals(walkTree(scour.scourXmlFile('unittests/inkscape.svg').documentElement, for i in range(len(attrs)):
# lambda e: for a in e.attributes: a.namespaceURI self.assertNotEquals(attrs.item(i).nodeValue,
# False, 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd',
# 'Found Inkscape attributes') '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' )
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -1,5 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" <svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:foo="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="0.46" version="1.0"> inkscape:version="0.46" version="1.0">
<inkscape:perspective inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective3104"/> <inkscape:perspective inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective3104"/>
<rect width="300" height="200" fill="green" inkscape:collect="always"/> <rect width="300" height="200" fill="green" inkscape:collect="always" foo:bar="1"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 489 B

Before After
Before After

View file

@ -1,5 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:version="0.32"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:foo="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:version="0.32">
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10"/> <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10"/>
<rect width="300" height="200" fill="green" /> <rect width="300" height="200" fill="green" sodipodi:bar="1" foo:baz="1"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 485 B

Before After
Before After