Implement the feature described in bug 598976: Create a <g> with the common attributes of a run of elements if there are 3 or more elements in the run.

This commit is contained in:
Cynthia Gauthier 2010-07-02 05:35:31 -04:00
parent 2a6cfb6b2c
commit 404c013e5f
6 changed files with 162 additions and 7 deletions

View file

@ -51,6 +51,7 @@ class ScourOptions:
shorten_ids = False
strip_comments = False
remove_metadata = False
group_create = False
class NoInkscapeElements(unittest.TestCase):
def runTest(self):
@ -1075,6 +1076,27 @@ class MustKeepGInSwitch2(unittest.TestCase):
self.assertEquals(doc.getElementsByTagName('g').length, 1,
'Erroneously removed a <g> in a <switch>')
class GroupCreation(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/group-creation.svg',
scour.parse_args(['--create-groups'])[0])
self.assertEquals(doc.getElementsByTagName('g').length, 1,
'Did not create a <g> for a run of elements having similar attributes')
class GroupCreationForInheritableAttributesOnly(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/group-creation.svg',
scour.parse_args(['--create-groups'])[0])
self.assertEquals(doc.getElementsByTagName('g').item(0).getAttribute('y'), '',
'Promoted the uninheritable attribute y to a <g>')
class GroupNoCreation(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/group-no-creation.svg',
scour.parse_args(['--create-groups'])[0])
self.assertEquals(doc.getElementsByTagName('g').length, 0,
'Created a <g> for a run of elements having dissimilar attributes')
# TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters