Add test case for #203

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-08-18 16:27:33 +00:00 committed by Patrick Storz
parent 09a656287d
commit f61b4d36d6
2 changed files with 31 additions and 0 deletions

View file

@ -1401,6 +1401,20 @@ class RemoveDuplicateRadialGradients(unittest.TestCase):
'Duplicate radial gradient not removed') 'Duplicate radial gradient not removed')
class RemoveDuplicateRadialGradientsEnsureMasterHasID(unittest.TestCase):
def runTest(self):
svgdoc = scourXmlFile('unittests/remove-duplicate-gradients-master-without-id.svg')
lingrads = svgdoc.getElementsByTagNameNS(SVGNS, 'linearGradient')
rect = svgdoc.getElementById('r1')
self.assertEqual(1, lingrads.length,
'Duplicate linearGradient not removed')
self.assertEqual(lingrads[0].getAttribute("id"), "g1",
"linearGradient has a proper ID")
self.assertNotEqual(rect.getAttribute("fill"), "url(#)",
"linearGradient has a proper ID")
class RereferenceForRadialGradient(unittest.TestCase): class RereferenceForRadialGradient(unittest.TestCase):
def runTest(self): def runTest(self):

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<linearGradient x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="red"/>
<stop offset="1" stop-color="blue"/>
</linearGradient>
<linearGradient id='g1' x1='0' y1='0' x2='1' y2='1'>
<stop offset='0' stop-color='red'/>
<stop offset='1' stop-color='blue'/>
</linearGradient>
<linearGradient x1='0' y1='0' x2='1' y2='1'>
<stop offset='0' stop-color='red'/>
<stop offset='1' stop-color='blue'/>
</linearGradient>
<rect id="r1" fill="url(#g1)" width="100" height="100"/>
</svg>

After

Width:  |  Height:  |  Size: 639 B