scour.py: Modify optimizeTransform to remove superfluous []s and ()s.
testscour.py: Add unit tests for Johan Sundström's fix for bug 722544, "SVG transform matrix() arg order is a1 b1 a2 b2 a3 b3, not a1 a2 a3 b1 b2 b3". unittests/: Edit the unit tests' support files not to have a second line with the correct transformation. This is customarily in testscour.py.
This commit is contained in:
parent
338e56f1b1
commit
ba3371e282
15 changed files with 102 additions and 29 deletions
92
testscour.py
92
testscour.py
|
|
@ -1217,12 +1217,100 @@ class RemoveDefsWithWhitespace(unittest.TestCase):
|
|||
self.assertEquals(doc.getElementsByTagName('defs').length, 0,
|
||||
'Kept defs, although it contains only whitespace or is <defs/>')
|
||||
|
||||
class TransformIdentityMatrix(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-identity.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
|
||||
'Transform containing identity matrix not removed')
|
||||
|
||||
class TransformRotate135(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-135.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(135)',
|
||||
'Rotation matrix not converted to rotate(135)')
|
||||
|
||||
class TransformRotate45(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-45.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(45)',
|
||||
'Rotation matrix not converted to rotate(45)')
|
||||
|
||||
class TransformRotate90(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-90.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(90)',
|
||||
'Rotation matrix not converted to rotate(90)')
|
||||
|
||||
class TransformRotateCCW135(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-neg-135.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(-135)',
|
||||
'Counter-clockwise rotation matrix not converted to rotate(-135)')
|
||||
|
||||
class TransformRotateCCW45(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-neg-45.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(-45)',
|
||||
'Counter-clockwise rotation matrix not converted to rotate(-45)')
|
||||
|
||||
class TransformRotateCCW90(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-rotate-neg-90.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(-90)',
|
||||
'Counter-clockwise rotation matrix not converted to rotate(-90)')
|
||||
|
||||
class TransformScale2by3(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-scale-2-3.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'scale(2 3)',
|
||||
'Scaling matrix not converted to scale(2 3)')
|
||||
|
||||
class TransformScaleMinus1(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-scale-neg-1.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'scale(-1)',
|
||||
'Scaling matrix not converted to scale(-1)')
|
||||
|
||||
class TransformTranslate(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-matrix-is-translate.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'translate(2 3)',
|
||||
'Translation matrix not converted to translate(2 3)')
|
||||
|
||||
class TransformRotation3Args(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-rotate-fold-3args.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), 'rotate(90)',
|
||||
'Optional zeroes in rotate(angle 0 0) not removed')
|
||||
|
||||
class TransformIdentityRotation(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-rotate-is-identity.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
|
||||
'Transform containing identity rotation not removed')
|
||||
|
||||
class TransformIdentitySkewX(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-skewX-is-identity.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
|
||||
'Transform containing identity X-axis skew not removed')
|
||||
|
||||
class TransformIdentitySkewY(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-skewY-is-identity.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
|
||||
'Transform containing identity Y-axis skew not removed')
|
||||
|
||||
class TransformIdentityTranslate(unittest.TestCase):
|
||||
def runTest(self):
|
||||
doc = scour.scourXmlFile('unittests/transform-translate-is-identity.svg')
|
||||
self.assertEquals(doc.getElementsByTagName('line')[0].getAttribute('transform'), '',
|
||||
'Transform containing identity translation not removed')
|
||||
|
||||
# TODO: write tests for --enable-viewboxing
|
||||
# TODO; write a test for embedding rasters
|
||||
# TODO: write a test for --disable-embed-rasters
|
||||
# TODO: write tests for --keep-editor-data
|
||||
# TODO: write tests for scouring transformations
|
||||
# progress: the unittests/transform-* files list expected before/after behaviour
|
||||
|
||||
if __name__ == '__main__':
|
||||
testcss = __import__('testcss')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue