Add unit tests for requiring a <g> in a <switch> if the original file has one.

This commit is contained in:
Cynthia Gauthier 2010-06-16 03:49:46 -04:00
parent bb1a38a7ad
commit c3982e28df
3 changed files with 49 additions and 0 deletions

View file

@ -1062,6 +1062,19 @@ class ShortenIDsOption(unittest.TestCase):
self.assertEquals(rectTag.getAttribute('fill'), 'url(#a)',
'Did not update reference to shortened ID')
class MustKeepGInSwitch(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/groups-in-switch.svg')
self.assertEquals(doc.getElementsByTagName('g').length, 1,
'Erroneously removed a <g> in a <switch>')
class MustKeepGInSwitch2(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/groups-in-switch-with-id.svg',
scour.parse_args(['--enable-id-stripping'])[0])
self.assertEquals(doc.getElementsByTagName('g').length, 1,
'Erroneously removed a <g> in a <switch>')
# TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:example="http://www.example.com/olfactory-feedback/0.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<switch>
<foreignObject requiredExtensions="http://www.example.com/olfactory-feedback/0.1" x="0" y="0" width="1" height="1">
<example:odor xlink:href="#odor1423">
</example:odor>
</foreignObject>
<g id="dsfargeg">
<rect width="300" height="200" fill="green" />
<circle cx="200" cy="100" r="50" fill="yellow" />
</g>
</switch>
<defs>
<example:odor id="odor1423" fill="grape"/>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 608 B

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:example="http://www.example.com/olfactory-feedback/0.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<switch>
<foreignObject requiredExtensions="http://www.example.com/olfactory-feedback/0.1" x="0" y="0" width="1" height="1">
<example:odor xlink:href="#odor1423">
</example:odor>
</foreignObject>
<g>
<rect width="300" height="200" fill="green" />
<circle cx="200" cy="100" r="50" fill="yellow" />
</g>
</switch>
<defs>
<example:odor id="odor1423" fill="grape"/>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 594 B