Unit test for abs-to-rel path data conversion.

This commit is contained in:
JSCHILL1 2009-04-27 10:03:39 -05:00
parent f196f82115
commit ec4e7b3594
3 changed files with 10 additions and 2 deletions

View file

@ -404,7 +404,6 @@ class CollapseSinglyReferencedGradients(unittest.TestCase):
class InheritGradientUnitsUponCollapsing(unittest.TestCase): class InheritGradientUnitsUponCollapsing(unittest.TestCase):
def runTest(self): def runTest(self):
doc = scour.scourXmlFile('unittests/collapse-gradients.svg') doc = scour.scourXmlFile('unittests/collapse-gradients.svg')
# print doc.toprettyxml(' ')
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'radialGradient')[0].getAttribute('gradientUnits'), self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'radialGradient')[0].getAttribute('gradientUnits'),
'userSpaceOnUse', 'userSpaceOnUse',
'gradientUnits not properly inherited when collapsing gradients' ) 'gradientUnits not properly inherited when collapsing gradients' )
@ -436,5 +435,14 @@ class RemoveDelimiterBeforeNegativeCoordsInPath(unittest.TestCase):
self.assertEquals(path[4], '-', self.assertEquals(path[4], '-',
'Delimiters not removed before negative coordinates in path data' ) 'Delimiters not removed before negative coordinates in path data' )
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(path[1][1][0], -20.0,
'Absolute V value not converted to relative v value')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View file

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<path d="M 385.88362,201.47812 v-20 l100,-50 h20 C 505.43501,223.44223 659.42238,164.82405 714.32160,-0.0015300000 C 649.90356,227.13187 497.48814,312.46353 371.30643,277.40123 C 245.12472,242.33893 157.17674,250.88268 121.69357,12.440270 C 211.69357,149.44027 323.87473,190.08578 385.88362,201.47812 z " fill="blue"/> <path d="M 385.88362,201.47812 V181.47812 l100,-50 h20 C 505.43501,223.44223 659.42238,164.82405 714.32160,-0.0015300000 C 649.90356,227.13187 497.48814,312.46353 371.30643,277.40123 C 245.12472,242.33893 157.17674,250.88268 121.69357,12.440270 C 211.69357,149.44027 323.87473,190.08578 385.88362,201.47812 z " fill="blue"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 372 B

After

Width:  |  Height:  |  Size: 378 B

Before After
Before After