bernhard: thuban/Extensions/svgexport/test test_svgmapwriter.py, 1.11, 1.12
cvs@intevation.de
cvs at intevation.de
Sat Dec 11 03:03:49 CET 2004
Author: bernhard
Update of /thubanrepository/thuban/Extensions/svgexport/test
In directory doto:/tmp/cvs-serv29643/Extensions/svgexport/test
Modified Files:
test_svgmapwriter.py
Log Message:
* Doc/technotes/coding_guidelines.txt: easy typo fixed.
* Extensions/svgexport/test/test_svgmapwriter.py:
Removed test_drawbezier in favour of new test_drawspline3 and
test_drawspline4 within new class TestDrawSplines(TestVirtualDC).
All only to test DrawSpline.
* Extensions/svgexport/svgmapwriter.py(DrawSpline):
New implementation now really using the strange algorithm of
xfig 3.1's approximated splines and its conversion to postscript
with one twist: SVG can do quadratic beziers, so skipped translation
to cubic beziers.
(TestWithDC): Typo in comment fixed.
Index: test_svgmapwriter.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/svgexport/test/test_svgmapwriter.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- test_svgmapwriter.py 7 Dec 2004 14:00:12 -0000 1.11
+++ test_svgmapwriter.py 11 Dec 2004 02:03:47 -0000 1.12
@@ -158,25 +158,6 @@
self.assertEquals(xmlsupport.sax_eventlist(data = data),
xmlsupport.sax_eventlist(data = file.getvalue()))
- def test_drawbezier(self):
- '''Test DrawSpline (which actually draws bezier curves).'''
- data = ('<path style="stroke-linejoin:round; stroke:#ff00ff; '
- 'stroke-width:3; stroke-linecap:round; fill:none" '
- 'meta="Object:test; Label:nothing" d="M 10 10 '
- 'C 15 12 15 8.0 20 10"/>')
- file = StringIO.StringIO()
- dc = VirtualDC(file)
- dc.SetPen(self.solid_pen)
- dc.SetMeta(self.meta)
- dc.SetBrush(self.trans_brush)
- dc.DrawSpline([ Point(10, 10),
- Point(15, 12),
- Point(15, 8.0),
- Point(20, 10) ])
- #print file.getvalue()
- self.assertEquals(xmlsupport.sax_eventlist(data = data),
- xmlsupport.sax_eventlist(data = file.getvalue()))
-
def test_text(self):
'''Set drawing properties and draw a circle'''
data = ('<text x="123.321" y="1515.5151" style="font-size:12; '
@@ -201,10 +182,55 @@
self.assertEquals(xmlsupport.sax_eventlist(data = data),
xmlsupport.sax_eventlist(data = file.getvalue()))
+class TestDrawSplines(TestVirtualDC):
+ """Testing DrawSpline variations.
+ See comments in DrawSpline().
+ """
+
+ def setUp(self):
+ super(TestDrawSplines,self).setUp()
+ self.dataframe = ('<path style="stroke-linejoin:round; stroke:#ff00ff; '
+ 'stroke-width:3; stroke-linecap:round; fill:none" '
+ 'meta="Object:test; Label:nothing" d="%s"/>')
+
+ self.file = StringIO.StringIO()
+ self.dc = VirtualDC(self.file)
+ self.dc.SetPen(self.solid_pen)
+ self.dc.SetMeta(self.meta)
+ self.dc.SetBrush(self.trans_brush)
+
+ def test_drawspline3(self):
+ '''Test DrawSpline with three points in a row.'''
+
+ d=('M 10 10 L 12.55 12.55 Q 15.1 15.1 17.65 17.65\nL 20.2 20.2')
+ data=(self.dataframe % d)
+
+ self.dc.DrawSpline([ Point(10, 10),
+ Point(15.1, 15.1),
+ Point(20.2, 20.2) ])
+ #print file.getvalue()
+ self.assertEquals(xmlsupport.sax_eventlist(data = data),
+ xmlsupport.sax_eventlist(data = self.file.getvalue()))
+
+ def test_drawspline4(self):
+ '''Test DrawSpline with four points in a row.'''
+
+ d='M 0 0 L 0 1 Q 0 2 0 3\nQ 0 4 0 5\nL 0 6'
+ data=(self.dataframe % d)
+
+ self.dc.DrawSpline([ Point(0, 0),
+ Point(0, 2),
+ Point(0, 4),
+ Point(0, 6) ])
+ #print file.getvalue()
+ self.assertEquals(xmlsupport.sax_eventlist(data = data),
+ xmlsupport.sax_eventlist(data = self.file.getvalue()))
+
+
class TestWithDC(unittest.TestCase):
"""Add dc creation and self.to_destroy list to setUp() and tearDown().
- This is a baseclass for test needing a dc.
+ This is a baseclass for tests needing a dc.
"""
def setUp(self):
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)