diff options
| author | Richard White <rwhite8282@gmail.com> | 2016-02-27 01:18:49 +0000 |
|---|---|---|
| committer | Richard White <rwhite8282@gmail.com> | 2016-02-27 01:18:49 +0000 |
| commit | 5cf5ebf8ef5cef77e0b491f52ac37e317b06279d (patch) | |
| tree | 38b0b7445a4b16ef7b4ce4decb8b2adce40195ac /share/extensions/test | |
| parent | inkview: Drop use of obsolete getopt (diff) | |
| download | inkscape-5cf5ebf8ef5cef77e0b491f52ac37e317b06279d.tar.gz inkscape-5cf5ebf8ef5cef77e0b491f52ac37e317b06279d.zip | |
Added frame extension.
(bzr r14668.1.1)
Diffstat (limited to 'share/extensions/test')
| -rwxr-xr-x | share/extensions/test/frame_test.py | 109 | ||||
| -rw-r--r-- | share/extensions/test/svg/single_box.svg | 62 |
2 files changed, 171 insertions, 0 deletions
diff --git a/share/extensions/test/frame_test.py b/share/extensions/test/frame_test.py new file mode 100755 index 000000000..72c5b66e8 --- /dev/null +++ b/share/extensions/test/frame_test.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python + +""" +An Inkscape frame extension test class. + +Copyright (C) 2016 Richard White, rwhite8282@gmail.com + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import sys +sys.path.append('/usr/share/inkscape/extensions') +sys.path.append('..') # this line allows to import the extension code + +import unittest +import inkex +from frame import * + + +class Frame_Test(unittest.TestCase): + + + def get_frame(self, document): + return document.xpath('//svg:g[@id="layer1"]//svg:path[@inkscape:label="Frame"]' + , namespaces=inkex.NSS)[0] + + + def test_empty_no_parameters(self): + args = [ 'svg/empty-SVG.svg' ] + uut = Frame() + uut.affect( args, False ) + + + def test_single_frame(self): + args = [ + '--corner_radius=20' + , '--fill_color=-16777124' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + + + def test_single_frame_grouped(self): + args = [ + '--corner_radius=20' + , '--fill_color=-16777124' + , '--group=True' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + group = new_frame.getparent() + self.assertEqual('{http://www.w3.org/2000/svg}g', group.tag) + self.assertEqual('{http://www.w3.org/2000/svg}rect', group[0].tag) + self.assertEqual('{http://www.w3.org/2000/svg}path', group[1].tag) + self.assertEqual("Frame", group[1].xpath('@inkscape:label', namespaces=inkex.NSS)[0]) + + + def test_single_frame_clipped(self): + args = [ + '--clip=True' + , '--corner_radius=20' + , '--fill_color=-16777124' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + group = new_frame.getparent() + self.assertEqual('url(#clipPath)', group[0].get('clip-path')) + clip_path = uut.document.xpath('//svg:defs/svg:clipPath', namespaces=inkex.NSS)[0] + self.assertEqual('{http://www.w3.org/2000/svg}clipPath', clip_path.tag) + + +if __name__ == '__main__': + unittest.main()
\ No newline at end of file diff --git a/share/extensions/test/svg/single_box.svg b/share/extensions/test/svg/single_box.svg new file mode 100644 index 000000000..094233d15 --- /dev/null +++ b/share/extensions/test/svg/single_box.svg @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="New document 1"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="375" + inkscape:cy="514.28571" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="479" + inkscape:window-height="379" + inkscape:window-x="1319" + inkscape:window-y="75" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <rect + style="opacity:0.5;fill:#6900ff;fill-opacity:0.36000001;stroke:#cae8ef;stroke-width:7.19999981;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect3006" + width="237.14285" + height="305.71429" + x="285.71429" + y="406.64789" /> + </g> +</svg> |
