From efe6abb54fe3a0b170dfb10c736c24474aedf83d Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sun, 30 Jun 2013 13:55:08 -0300 Subject: [PATCH] Draft: Added test suite --- src/Mod/Draft/CMakeLists.txt | 1 + src/Mod/Draft/TestDraft.py | 72 +++++++++++++++++++++++++++++++ src/Mod/Test/TestApp.py | 1 + src/WindowsInstaller/ModDraft.wxi | 1 + 4 files changed, 75 insertions(+) create mode 100644 src/Mod/Draft/TestDraft.py diff --git a/src/Mod/Draft/CMakeLists.txt b/src/Mod/Draft/CMakeLists.txt index e380eb193b..95a21c33f8 100644 --- a/src/Mod/Draft/CMakeLists.txt +++ b/src/Mod/Draft/CMakeLists.txt @@ -17,6 +17,7 @@ SET(Draft_SRCS importAirfoilDAT.py macros.py Draft_rc.py + TestDraft.py ) SOURCE_GROUP("" FILES ${Draft_SRCS}) diff --git a/src/Mod/Draft/TestDraft.py b/src/Mod/Draft/TestDraft.py new file mode 100644 index 0000000000..0b95f16cf8 --- /dev/null +++ b/src/Mod/Draft/TestDraft.py @@ -0,0 +1,72 @@ +# Unit test for the Draft module + +#*************************************************************************** +#* (c) Yorik van Havre 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 + + + diff --git a/src/Mod/Test/TestApp.py b/src/Mod/Test/TestApp.py index 2eab8fe40d..f70253d055 100644 --- a/src/Mod/Test/TestApp.py +++ b/src/Mod/Test/TestApp.py @@ -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 diff --git a/src/WindowsInstaller/ModDraft.wxi b/src/WindowsInstaller/ModDraft.wxi index 2a212d3795..a80dd345ef 100644 --- a/src/WindowsInstaller/ModDraft.wxi +++ b/src/WindowsInstaller/ModDraft.wxi @@ -41,6 +41,7 @@ +