Draft: Added test suite

This commit is contained in:
Yorik van Havre
2013-06-30 13:55:08 -03:00
parent e3a9355148
commit efe6abb54f
4 changed files with 75 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ SET(Draft_SRCS
importAirfoilDAT.py
macros.py
Draft_rc.py
TestDraft.py
)
SOURCE_GROUP("" FILES ${Draft_SRCS})

View File

@@ -0,0 +1,72 @@
# Unit test for the Draft module
#***************************************************************************
#* (c) Yorik van Havre <yorik@uncreated.net> 2013 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Werner Mayer 2005 *
#***************************************************************************/
import FreeCAD, os, unittest, FreeCADGui, Draft
class DraftTest(unittest.TestCase):
def setUp(self):
# setting a new document to hold the tests
if FreeCAD.ActiveDocument:
if FreeCAD.ActiveDocument.Name != "DraftTest":
FreeCAD.newDocument("DraftTest")
else:
FreeCAD.newDocument("DraftTest")
FreeCAD.setActiveDocument("DraftTest")
def testPivy(self):
# first checking if pivy is working
FreeCAD.Console.PrintLog ('Checking Pivy...\n')
from pivy import coin
c = coin.SoCube()
FreeCADGui.ActiveDocument.ActiveView.getSceneGraph().addChild(c)
self.failUnless(c,"Pivy is not working properly")
def testWire(self):
# testing the Wire tool
FreeCAD.Console.PrintLog ('Checking Draft Wire...\n')
Draft.makeWire([FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(2,2,0)])
self.failUnless(FreeCAD.ActiveDocument.getObject("DWire"),"Draft Wire failed")
def testArc(self):
# testing the Arc tool
FreeCAD.Console.PrintLog ('Checking Draft Arc...\n')
Draft.makeCircle(2, startangle=0, endangle=90)
self.failUnless(FreeCAD.ActiveDocument.getObject("Arc"),"Draft Arc failed")
def testDimension(self):
# testing the Arc tool
FreeCAD.Console.PrintLog ('Checking Draft Dimension...\n')
Draft.makeDimension(FreeCAD.Vector(0,0,0),FreeCAD.Vector(2,0,0),FreeCAD.Vector(1,-1,0))
self.failUnless(FreeCAD.ActiveDocument.getObject("Dimension"),"Draft Dimension failed")
def tearDown(self):
#closing doc
#FreeCAD.closeDocument("DraftTest")
pass

View File

@@ -51,6 +51,7 @@ def All():
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestSketcherGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestPartDesignGui") )
suite.addTest(unittest.defaultTestLoader.loadTestsFromName("TestDraft") )
return suite

View File

@@ -41,6 +41,7 @@
<File Id="DraftVecUtilsPy" Name="DraftVecUtils.py" DiskId="1" />
<File Id="DraftGeomUtilsPy" Name="DraftGeomUtils.py" DiskId="1" />
<File Id="importDWGPy" Name="importDWG.py" DiskId="1" />
<File Id="TestDraftPy" Name="TestDraft.py" DiskId="1" />
</Component>
</Directory>
</Include>