diff options
| author | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
|---|---|---|
| committer | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
| commit | e7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch) | |
| tree | 9097520c54e355ded9bd0b4d6618af4e8dacdd91 /share/extensions/test | |
| parent | updated to latest trunk (diff) | |
| parent | [Bug #1695016] Xaml export misses some radialGradients. (diff) | |
| download | inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip | |
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'share/extensions/test')
| -rw-r--r-- | share/extensions/test/Makefile.am | 60 | ||||
| -rwxr-xr-x | share/extensions/test/frame_test.py | 120 | ||||
| -rwxr-xr-x | share/extensions/test/run-all-extension-tests | 27 | ||||
| -rwxr-xr-x | share/extensions/test/simpletransform.test.py | 28 | ||||
| -rw-r--r-- | share/extensions/test/svg/simpletransform.test.svg | 8 | ||||
| -rw-r--r-- | share/extensions/test/svg/single_box.svg | 62 | ||||
| -rwxr-xr-x[-rw-r--r--] | share/extensions/test/test_template.py.txt | 0 |
7 files changed, 234 insertions, 71 deletions
diff --git a/share/extensions/test/Makefile.am b/share/extensions/test/Makefile.am deleted file mode 100644 index cd1929a7f..000000000 --- a/share/extensions/test/Makefile.am +++ /dev/null @@ -1,60 +0,0 @@ - -# List of all tests to be run. -#TESTS = svgcalendar.test.py -# that is not working :-/ - -EXTRA_DIST = \ - addnodes.test.py \ - chardataeffect.test.py \ - color_randomize_test.py \ - coloreffect.test.py \ - create_test_from_template.sh \ - dots.test.py \ - draw_from_triangle.test.py \ - dxf_outlines.test.py \ - edge3d.test.py \ - embedimage.test.py \ - eqtexsvg.test.py \ - extractimage.test.py \ - extrude.test.py \ - flatten.test.py \ - foldablebox.test.py \ - fractalize.test.py \ - funcplot.test.py \ - gimp_xcf.test.py \ - grid_cartesian.test.py \ - grid_polar.test.py \ - guides_creator.test.py \ - handles.test.py \ - hpgl_output.test.py \ - inkweb-debug.js \ - inkwebeffect.test.py \ - inkwebjs-move.test.svg \ - interp_att_g.test.py \ - interp.test.py \ - lindenmayer.test.py \ - lorem_ipsum.test.py \ - markers_strokepaint.test.py \ - measure.test.py \ - minimal-blank.svg \ - motion.test.py \ - pathmodifier.test.py \ - perfectboundcover.test.py \ - perspective.test.py \ - polyhedron_3d.test.py \ - radiusrand.test.py \ - render_alphabetsoup.test.py \ - render_barcode.test.py \ - render_barcode.data \ - render_gears.test.py \ - restack.test.py \ - rtree.test.py \ - run-all-extension-tests \ - spirograph.test.py \ - straightseg.test.py \ - summersnight.test.py \ - svg_and_media_zip_output.test.py \ - svgcalendar.test.py \ - test_template.py.txt \ - triangle.test.py \ - whirl.test.py diff --git a/share/extensions/test/frame_test.py b/share/extensions/test/frame_test.py new file mode 100755 index 000000000..3d686ab25 --- /dev/null +++ b/share/extensions/test/frame_test.py @@ -0,0 +1,120 @@ +#!/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) + new_frame_style = new_frame.attrib['style'].lower() + self.assertTrue('fill-opacity:0.36' in new_frame_style + , 'Invalid fill-opacity in "' + new_frame_style + '".') + self.assertTrue('stroke:#000000' in new_frame_style + , 'Invalid stroke in "' + new_frame_style + '".') + self.assertTrue('stroke-width:10.0' in new_frame_style + , 'Invalid stroke-width in "' + new_frame_style + '".') + self.assertTrue('stroke-opacity:1.00' in new_frame_style + , 'Invalid stroke-opacity in "' + new_frame_style + '".') + self.assertTrue('fill:#ff0000' in new_frame_style + , 'Invalid fill in "' + new_frame_style + '".') + + + 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/run-all-extension-tests b/share/extensions/test/run-all-extension-tests index e7faf672a..ff739c311 100755 --- a/share/extensions/test/run-all-extension-tests +++ b/share/extensions/test/run-all-extension-tests @@ -38,20 +38,25 @@ failed_tests=$( $MKTEMP ) if coverage.py erase >/dev/null 2>/dev/null; then has_py_coverage=true cover_py_cmd=coverage.py -else - if coverage erase >/dev/null 2>/dev/null; then - has_py_coverage=true - cover_py_cmd=coverage - else - if python-coverage erase >/dev/null 2>/dev/null; then - has_py_coverage=true - cover_py_cmd=python-coverage - fi - fi + else + if coverage erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=coverage + else + if python-coverage erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=python-coverage + else + if coverage-script.py erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=coverage-script.py + fi + fi + fi fi if $has_py_coverage; then - echo -e "\nRunning tests with coverage" + echo -e "\nRunning tests with coverage (${cover_py_cmd})" fi #if $has_py_coverage; then # $cover_py_cmd -e diff --git a/share/extensions/test/simpletransform.test.py b/share/extensions/test/simpletransform.test.py new file mode 100755 index 000000000..9e5dbc3b2 --- /dev/null +++ b/share/extensions/test/simpletransform.test.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import os +import sys +import unittest + +sys.path.append('..') # this line allows to import the extension code + +import inkex +from simpletransform import * + +class ComputeBBoxTest(unittest.TestCase): + def setUp(self): + args = [ 'svg/simpletransform.test.svg' ] + self.e = inkex.Effect() + self.e.affect(args, False) + + def test_scaled_object(self): + "Object in the defs with 50,50 scaled by 0.5 when used" + bbox = computeBBox(self.e.document.xpath("//svg:g", namespaces=inkex.NSS)) + text_bbox = "{} {} {} {}".format(bbox[0], bbox[1], bbox[2], bbox[3]) + self.assertEqual(text_bbox, "0.0 25.0 0.0 25.0") + + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(ComputeBBoxTest) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/svg/simpletransform.test.svg b/share/extensions/test/svg/simpletransform.test.svg new file mode 100644 index 000000000..62876eea7 --- /dev/null +++ b/share/extensions/test/svg/simpletransform.test.svg @@ -0,0 +1,8 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100"> + <g> + <defs> + <rect width="50" height="50" id="rect"/> + </defs> + <use xlink:href="#rect" transform="scale(.5)"/> + </g> +</svg>
\ 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> diff --git a/share/extensions/test/test_template.py.txt b/share/extensions/test/test_template.py.txt index 9a570cd6a..9a570cd6a 100644..100755 --- a/share/extensions/test/test_template.py.txt +++ b/share/extensions/test/test_template.py.txt |
