A few more unit tests for removing stroke properties

This commit is contained in:
JSCHILL1 2009-04-22 22:32:19 -05:00
parent d09903fe39
commit 64ee621aa6
3 changed files with 22 additions and 5 deletions

View file

@ -455,6 +455,7 @@ def repairStyle(node):
for uselessStyle in ['fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-linejoin', for uselessStyle in ['fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-linejoin',
'stroke-opacity', 'stroke-miterlimit', 'stroke-linecap', 'stroke-dasharray', 'stroke-opacity', 'stroke-miterlimit', 'stroke-linecap', 'stroke-dasharray',
'stroke-dashoffset', 'stroke-opacity'] : 'stroke-dashoffset', 'stroke-opacity'] :
if styleMap.has_key(uselessStyle):
del styleMap[uselessStyle] del styleMap[uselessStyle]
num += 1 num += 1
@ -490,6 +491,7 @@ def repairStyle(node):
num += 1 num += 1
elif fillOpacity == 0.0 : elif fillOpacity == 0.0 :
for uselessFillStyle in [ 'fill', 'fill-rule' ] : for uselessFillStyle in [ 'fill', 'fill-rule' ] :
if styleMap.has_key(uselessFillStyle):
del styleMap[uselessFillStyle] del styleMap[uselessFillStyle]
num += 1 num += 1

View file

@ -256,6 +256,21 @@ class RemoveStrokeLinejoinWhenStrokeTransparent(unittest.TestCase):
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '', self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-linejoin'), '',
"stroke-linejoin attribute not emptied" ) "stroke-linejoin attribute not emptied" )
class RemoveStrokeDasharrayWhenStrokeTransparent(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dasharray'), '',
"stroke-dasharray attribute not emptied" )
class RemoveStrokeDashoffsetWhenStrokeTransparent(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/stroke-linejoin.svg')
self.assertEquals(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('stroke-dashoffset'), '',
"stroke-dashoffset attribute not emptied" )
# TODO : add in duplicate tests for when the stroke-width is 0
# TODO : add in duplicate tests for when the stroke is none
#class RemoveUnreferencedFonts(unittest.TestCase): #class RemoveUnreferencedFonts(unittest.TestCase):
# def runTest(self): # def runTest(self):
# doc = scour.scourXmlFile('unittests/unreferenced-font.svg') # doc = scour.scourXmlFile('unittests/unreferenced-font.svg')

View file

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<path id="p" fill="black" style="stroke: rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 0;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" /> <path id="p" fill="black" style="stroke: rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-dasharray: none; stroke-dashoffset: 2; stroke-linejoin: miter; stroke-opacity: 0;" d="M 7.7592046,36.982095 C 7.8831049,40.873696 7.8339808,45.305308 7.8339808,49.436888 Z" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 331 B

Before After
Before After