diff --git a/src/Mod/Test/BaseTests.py b/src/Mod/Test/BaseTests.py index ffc7cb364b..d7bdd0c7a4 100644 --- a/src/Mod/Test/BaseTests.py +++ b/src/Mod/Test/BaseTests.py @@ -1,5 +1,5 @@ #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2004 * +#* Copyright (c) 2004 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -10,16 +10,15 @@ #* 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 * +#* 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 * +#* License along with FreeCAD; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2004 * #***************************************************************************/ import FreeCAD, os, unittest, tempfile, math @@ -105,7 +104,7 @@ class ConsoleTestCase(unittest.TestCase): class ParameterTestCase(unittest.TestCase): def setUp(self): self.TestPar = FreeCAD.ParamGet("System parameter:Test") - + def testGroup(self): #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testGroup\n") # check on Group creation @@ -116,7 +115,7 @@ class ParameterTestCase(unittest.TestCase): self.failUnless(self.TestPar.HasGroup("44"),"A referenced group must not be deleted") Temp = 0 - #check on special conditions + # check on special conditions def testInt(self): #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testInt\n") #Temp = FreeCAD.ParamGet("System parameter:Test/44") @@ -126,7 +125,7 @@ class ParameterTestCase(unittest.TestCase): # check on Deletion self.TestPar.RemInt("44") self.failUnless(self.TestPar.GetInt("44",1) == 1,"Deletion error at Int") - + def testBool(self): #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testBool\n") @@ -263,7 +262,7 @@ class ParameterTestCase(unittest.TestCase): Temp.SetInt(str(l),4711) Temp.SetBool(str(l),1) Temp = 0 - + def testExportImport(self): # Parameter testing #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") @@ -283,7 +282,7 @@ class ParameterTestCase(unittest.TestCase): Temp.Import(TempPath) self.failUnless(Temp.GetFloat("ExTest") == 4711.4711,"ExportImport error") Temp = 0 - + def tearDown(self): #remove all TestPar = FreeCAD.ParamGet("System parameter:Test") diff --git a/src/Mod/Test/Document.py b/src/Mod/Test/Document.py index 2dacc4f23a..0f285314b6 100644 --- a/src/Mod/Test/Document.py +++ b/src/Mod/Test/Document.py @@ -1,5 +1,5 @@ #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2003 * +#* Copyright (c) 2003 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -19,7 +19,6 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2003 * #***************************************************************************/ import FreeCAD, os, unittest, tempfile @@ -1416,28 +1415,28 @@ class DocumentExpressionCases(unittest.TestCase): class DocumentObserverCases(unittest.TestCase): class Observer(): - + def __init__(self): self.signal = [] self.parameter = [] self.parameter2 = [] - + def slotCreatedDocument(self, doc): self.signal.append('DocCreated'); self.parameter.append(doc); - + def slotDeletedDocument(self, doc): self.signal.append('DocDeleted'); self.parameter.append(doc); - + def slotRelabelDocument(self, doc): self.signal.append('DocRelabled'); self.parameter.append(doc); - + def slotActivateDocument(self, doc): self.signal.append('DocActivated'); self.parameter.append(doc); - + def slotRecomputedDocument(self, doc): self.signal.append('DocRecomputed'); self.parameter.append(doc); @@ -1445,7 +1444,7 @@ class DocumentObserverCases(unittest.TestCase): def slotUndoDocument(self, doc): self.signal.append('DocUndo'); self.parameter.append(doc); - + def slotRedoDocument(self, doc): self.signal.append('DocRedo'); self.parameter.append(doc); @@ -1454,25 +1453,25 @@ class DocumentObserverCases(unittest.TestCase): self.signal.append('DocOpenTransaction'); self.parameter.append(doc); self.parameter2.append(name); - + def slotCommitTransaction(self, doc): self.signal.append('DocCommitTransaction'); self.parameter.append(doc); - + def slotAbortTransaction(self, doc): self.signal.append('DocAbortTransaction'); self.parameter.append(doc); - + def slotBeforeChangeDocument(self, doc, prop): self.signal.append('DocBeforeChange') self.parameter.append(doc) self.parameter2.append(prop) - + def slotChangedDocument(self, doc, prop): self.signal.append('DocChanged') self.parameter.append(doc) self.parameter2.append(prop) - + def slotCreatedObject(self, obj): self.signal.append('ObjCreated'); self.parameter.append(obj); @@ -1485,7 +1484,7 @@ class DocumentObserverCases(unittest.TestCase): self.signal.append('ObjChanged'); self.parameter.append(obj) self.parameter2.append(prop) - + def slotBeforeChangeObject(self, obj, prop): self.signal.append('ObjBeforeChange'); self.parameter.append(obj) @@ -1494,17 +1493,17 @@ class DocumentObserverCases(unittest.TestCase): def slotRecomputedObject(self, obj): self.signal.append('ObjRecomputed'); self.parameter.append(obj) - + def slotAppendDynamicProperty(self, obj, prop): self.signal.append('ObjAddDynProp'); self.parameter.append(obj) self.parameter2.append(prop) - + def slotRemoveDynamicProperty(self, obj, prop): self.signal.append('ObjRemoveDynProp'); self.parameter.append(obj) self.parameter2.append(prop) - + def slotChangePropertyEditor(self, obj, prop): self.signal.append('ObjChangePropEdit'); self.parameter.append(obj) @@ -1519,44 +1518,44 @@ class DocumentObserverCases(unittest.TestCase): self.signal.append('DocFinishSave') self.parameter.append(obj) self.parameter2.append(name) - + def slotBeforeAddingDynamicExtension(self, obj, extension): self.signal.append('ObjBeforeDynExt') self.parameter.append(obj) self.parameter2.append(extension) - + def slotAddedDynamicExtension(self, obj, extension): self.signal.append('ObjDynExt') self.parameter.append(obj) self.parameter2.append(extension) class GuiObserver(): - + def __init__(self): self.signal = [] self.parameter = [] self.parameter2 = [] - + def slotCreatedDocument(self, doc): self.signal.append('DocCreated'); self.parameter.append(doc); - + def slotDeletedDocument(self, doc): self.signal.append('DocDeleted'); self.parameter.append(doc); - + def slotRelabelDocument(self, doc): self.signal.append('DocRelabled'); self.parameter.append(doc); - + def slotRenameDocument(self, doc): self.signal.append('DocRenamed'); self.parameter.append(doc); - + def slotActivateDocument(self, doc): self.signal.append('DocActivated'); self.parameter.append(doc); - + def slotCreatedObject(self, obj): self.signal.append('ObjCreated'); self.parameter.append(obj); @@ -1569,15 +1568,15 @@ class DocumentObserverCases(unittest.TestCase): self.signal.append('ObjChanged'); self.parameter.append(obj) self.parameter2.append(prop) - + def slotInEdit(self, obj): self.signal.append('ObjInEdit'); - self.parameter.append(obj) - + self.parameter.append(obj) + def slotResetEdit(self, obj): self.signal.append('ObjResetEdit'); - self.parameter.append(obj) - + self.parameter.append(obj) + def setUp(self): self.Obs = self.Observer(); FreeCAD.addDocumentObserver(self.Obs); @@ -1612,7 +1611,7 @@ class DocumentObserverCases(unittest.TestCase): return # testing document level signals - self.Doc1 = FreeCAD.newDocument("Observer1"); + self.Doc1 = FreeCAD.newDocument("Observer1"); if FreeCAD.GuiUp: self.assertEqual(self.Obs.signal.pop(0), 'DocActivated') self.assertTrue(self.Obs.parameter.pop(0) is self.Doc1) @@ -1627,7 +1626,7 @@ class DocumentObserverCases(unittest.TestCase): self.assertEqual(self.Obs.signal.pop(0), 'DocRelabled') self.assertTrue(self.Obs.parameter.pop(0) is self.Doc1) self.assertTrue(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + self.Doc2 = FreeCAD.newDocument("Observer2"); if FreeCAD.GuiUp: self.assertEqual(self.Obs.signal.pop(0), 'DocActivated') @@ -1643,7 +1642,7 @@ class DocumentObserverCases(unittest.TestCase): self.assertEqual(self.Obs.signal.pop(0), 'DocRelabled') self.assertTrue(self.Obs.parameter.pop(0) is self.Doc2) self.assertTrue(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + FreeCAD.setActiveDocument('Observer1') self.assertEqual(self.Obs.signal.pop(), 'DocActivated') self.assertTrue(self.Obs.parameter.pop() is self.Doc1) @@ -1651,7 +1650,7 @@ class DocumentObserverCases(unittest.TestCase): #undo/redo is not enabled in cmd line mode by default self.Doc2.UndoMode = 1 - + # Must set Doc2 as active document before start transaction test. If not, # then a transaction will be auto created inside the active document if a # new transaction is triggered from a non active document @@ -1671,12 +1670,12 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + self.Doc2.commitTransaction() self.assertEqual(self.Obs.signal.pop(), 'DocCommitTransaction') self.assertTrue(self.Obs.parameter.pop() is self.Doc2) self.assertTrue(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + self.Doc2.openTransaction('test2') # openTransaction() now only setup pending transaction, which will only be # created when there is actual change @@ -1689,7 +1688,7 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + self.Doc2.abortTransaction() self.assertEqual(self.Obs.signal.pop(), 'DocAbortTransaction') self.assertTrue(self.Obs.parameter.pop() is self.Doc2) @@ -1697,7 +1696,7 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + self.Doc2.undo() self.assertEqual(self.Obs.signal.pop(), 'DocUndo') self.assertTrue(self.Obs.parameter.pop() is self.Doc2) @@ -1705,7 +1704,7 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + self.Doc2.redo() self.assertEqual(self.Obs.signal.pop(), 'DocRedo') self.assertTrue(self.Obs.parameter.pop() is self.Doc2) @@ -1713,7 +1712,7 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + self.Doc1.Comment = 'test comment' self.assertEqual(self.Obs.signal.pop(0), 'DocBeforeChange') self.assertTrue(self.Obs.parameter.pop(0) is self.Doc1) @@ -1721,7 +1720,7 @@ class DocumentObserverCases(unittest.TestCase): self.assertEqual(self.Obs.signal.pop(0), 'DocChanged') self.assertTrue(self.Obs.parameter.pop(0) is self.Doc1) self.assertEqual(self.Obs.parameter2.pop(0), 'Comment') - + FreeCAD.closeDocument(self.Doc2.Name) self.assertEqual(self.Obs.signal.pop(), 'DocDeleted') self.assertTrue(self.Obs.parameter.pop() is self.Doc2) @@ -1735,15 +1734,15 @@ class DocumentObserverCases(unittest.TestCase): self.assertEqual(self.Obs.signal.pop(), 'DocDeleted') self.assertEqual(self.Obs.parameter.pop(), self.Doc1) self.assertTrue(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + def testObject(self): #testing signal on object changes - + self.Doc1 = FreeCAD.newDocument("Observer1") self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + obj = self.Doc1.addObject("App::DocumentObject","obj") self.failUnless(self.Obs.signal.pop() == 'ObjCreated') self.failUnless(self.Obs.parameter.pop() is obj) @@ -1751,7 +1750,7 @@ class DocumentObserverCases(unittest.TestCase): self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + obj.Label = "myobj" self.failUnless(self.Obs.signal.pop(0) == 'ObjBeforeChange') self.failUnless(self.Obs.parameter.pop(0) is obj) @@ -1760,13 +1759,13 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.Obs.parameter.pop(0) is obj) self.failUnless(self.Obs.parameter2.pop(0) == "Label") self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + obj.enforceRecompute() obj.recompute() self.failUnless(self.Obs.signal.pop(0) == 'ObjRecomputed') self.failUnless(self.Obs.parameter.pop(0) is obj) self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + obj.enforceRecompute() self.Doc1.recompute() self.failUnless(self.Obs.signal.pop(0) == 'ObjRecomputed') @@ -1774,12 +1773,12 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.Obs.signal.pop(0) == 'DocRecomputed') self.failUnless(self.Obs.parameter.pop(0) is self.Doc1) self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + FreeCAD.ActiveDocument.removeObject(obj.Name) self.failUnless(self.Obs.signal.pop(0) == 'ObjDeleted') self.failUnless(self.Obs.parameter.pop(0) is obj) self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + pyobj = self.Doc1.addObject("App::FeaturePython","pyobj") self.Obs.signal = [] self.Obs.parameter = [] @@ -1789,19 +1788,19 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.Obs.parameter.pop() is pyobj) self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + pyobj.setEditorMode('Prop', ['ReadOnly']) self.failUnless(self.Obs.signal.pop() == 'ObjChangePropEdit') self.failUnless(self.Obs.parameter.pop() is pyobj) self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + pyobj.removeProperty('Prop') self.failUnless(self.Obs.signal.pop() == 'ObjRemoveDynProp') self.failUnless(self.Obs.parameter.pop() is pyobj) self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + pyobj.addExtension("App::GroupExtensionPython", None) self.failUnless(self.Obs.signal.pop() == 'ObjDynExt') self.failUnless(self.Obs.parameter.pop() is pyobj) @@ -1809,38 +1808,38 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.Obs.signal.pop(0) == 'ObjBeforeDynExt') self.failUnless(self.Obs.parameter.pop(0) is pyobj) self.failUnless(self.Obs.parameter2.pop(0) == 'App::GroupExtensionPython') - #a proxy property was changed, hence those events are also in the signal list + #a proxy property was changed, hence those events are also in the signal list self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + FreeCAD.closeDocument(self.Doc1.Name) self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + def testUndoDisabledDocument(self): # testing document level signals - self.Doc1 = FreeCAD.newDocument("Observer1"); + self.Doc1 = FreeCAD.newDocument("Observer1"); self.Doc1.UndoMode = 0 self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - - self.Doc1.openTransaction('test') + + self.Doc1.openTransaction('test') self.Doc1.commitTransaction() self.Doc1.undo() - self.Doc1.redo() + self.Doc1.redo() self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) - + FreeCAD.closeDocument(self.Doc1.Name) self.Obs.signal = [] self.Obs.parameter = [] self.Obs.parameter2 = [] - + def testGuiObserver(self): - + if not FreeCAD.GuiUp: return @@ -1863,7 +1862,7 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.GuiObs.signal.pop(0) == 'DocRelabled') self.failUnless(self.GuiObs.parameter.pop(0) is self.GuiDoc1) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + self.Doc1.Label = "test" self.failUnless(self.Obs.signal.pop() == 'DocRelabled') self.failUnless(self.Obs.parameter.pop() is self.Doc1) @@ -1874,7 +1873,7 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.GuiObs.signal.pop(0) == 'DocRelabled') self.failUnless(self.GuiObs.parameter.pop(0) is self.GuiDoc1) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + FreeCAD.setActiveDocument(self.Doc1.Name) self.failUnless(self.Obs.signal.pop() == 'DocActivated') self.failUnless(self.Obs.parameter.pop() is self.Doc1) @@ -1882,14 +1881,14 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.GuiObs.signal.pop() == 'DocActivated') self.failUnless(self.GuiObs.parameter.pop() is self.GuiDoc1) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + obj = self.Doc1.addObject("App::FeaturePython","obj") self.failUnless(self.Obs.signal.pop() == 'ObjCreated') self.failUnless(self.Obs.parameter.pop() is obj) #there are multiple object change signals self.Obs.signal = [] self.Obs.parameter = [] - self.Obs.parameter2 = [] + self.Obs.parameter2 = [] self.failUnless(self.GuiObs.signal.pop() == "ObjCreated") self.failUnless(self.GuiObs.parameter.pop() is obj.ViewObject) @@ -1910,21 +1909,21 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.GuiObs.parameter.pop(0) is obj.ViewObject) self.failUnless(self.GuiObs.parameter2.pop(0) == "Visibility") self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + obj.ViewObject.addProperty("App::PropertyLength","Prop","Group","test property") self.failUnless(self.Obs.signal.pop() == 'ObjAddDynProp') self.failUnless(self.Obs.parameter.pop() is obj.ViewObject) self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + obj.ViewObject.setEditorMode('Prop', ['ReadOnly']) self.failUnless(self.Obs.signal.pop() == 'ObjChangePropEdit') self.failUnless(self.Obs.parameter.pop() is obj.ViewObject) self.failUnless(self.Obs.parameter2.pop() == 'Prop') self.failUnless(not self.Obs.signal and not self.Obs.parameter and not self.Obs.parameter2) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + obj.ViewObject.removeProperty('Prop') self.failUnless(self.Obs.signal.pop() == 'ObjRemoveDynProp') self.failUnless(self.Obs.parameter.pop() is obj.ViewObject) @@ -1943,7 +1942,7 @@ class DocumentObserverCases(unittest.TestCase): self.failUnless(self.GuiObs.signal.pop(0) == 'ObjResetEdit') self.failUnless(self.GuiObs.parameter.pop(0) is obj.ViewObject) self.failUnless(not self.GuiObs.signal and not self.GuiObs.parameter and not self.GuiObs.parameter2) - + obj.ViewObject.addExtension("Gui::ViewProviderGroupExtensionPython", None) self.failUnless(self.Obs.signal.pop() == 'ObjDynExt') self.failUnless(self.Obs.parameter.pop() is obj.ViewObject) @@ -1955,7 +1954,7 @@ class DocumentObserverCases(unittest.TestCase): self.GuiObs.signal = [] self.GuiObs.parameter = [] self.GuiObs.parameter2 = [] - + vo = obj.ViewObject FreeCAD.ActiveDocument.removeObject(obj.Name) self.failUnless(self.Obs.signal.pop(0) == 'ObjDeleted') diff --git a/src/Mod/Test/Gui/AppTestGui.cpp b/src/Mod/Test/Gui/AppTestGui.cpp index 277569aef9..f8c90e45f6 100644 --- a/src/Mod/Test/Gui/AppTestGui.cpp +++ b/src/Mod/Test/Gui/AppTestGui.cpp @@ -45,7 +45,7 @@ public: add_varargs_method("addTest",&Module::addTest,"addTest"); initialize("This module is the QtUnitGui module"); // register with Python } - + virtual ~Module() {} private: diff --git a/src/Mod/Test/Gui/PreCompiled.cpp b/src/Mod/Test/Gui/PreCompiled.cpp index 8dd161cbfd..285f33c03f 100644 --- a/src/Mod/Test/Gui/PreCompiled.cpp +++ b/src/Mod/Test/Gui/PreCompiled.cpp @@ -21,4 +21,4 @@ ***************************************************************************/ -#include "PreCompiled.h" +#include "PreCompiled.h" diff --git a/src/Mod/Test/Gui/PreCompiled.h b/src/Mod/Test/Gui/PreCompiled.h index 44a04de6ad..a916e52897 100644 --- a/src/Mod/Test/Gui/PreCompiled.h +++ b/src/Mod/Test/Gui/PreCompiled.h @@ -70,4 +70,4 @@ #endif //_PreComp_ -#endif // __PRECOMPILED_GUI__ +#endif // __PRECOMPILED_GUI__ diff --git a/src/Mod/Test/Gui/UnitTestImp.cpp b/src/Mod/Test/Gui/UnitTestImp.cpp index 0855c93742..aa7f4298c5 100644 --- a/src/Mod/Test/Gui/UnitTestImp.cpp +++ b/src/Mod/Test/Gui/UnitTestImp.cpp @@ -173,7 +173,7 @@ void UnitTestDialog::on_helpButton_clicked() */ void UnitTestDialog::on_aboutButton_clicked() { - QMessageBox::information(this, tr("About FreeCAD UnitTest"), tr( + QMessageBox::information(this, tr("About FreeCAD UnitTest"), tr( "Copyright (c) Werner Mayer\n\n" "FreeCAD UnitTest is part of FreeCAD and supports writing Unit Tests for " "ones own modules.")); @@ -291,7 +291,7 @@ void UnitTestDialog::setStatusText(const QString& text) /** * Sets the progress of the progress bar whereas fraction is in between 0.0 and 1.0. - * It also sets the color of the progress bar to red if a failure or error in the unit + * It also sets the color of the progress bar to red if a failure or error in the unit * test occurred. */ void UnitTestDialog::setProgressFraction(float fraction, const QString& color) diff --git a/src/Mod/Test/Gui/qtunittest.py b/src/Mod/Test/Gui/qtunittest.py index 5dd674d114..b6412dca59 100755 --- a/src/Mod/Test/Gui/qtunittest.py +++ b/src/Mod/Test/Gui/qtunittest.py @@ -1,9 +1,5 @@ -# Qt Unit test module -# (c) 2006 Werner Mayer -# - #*************************************************************************** -#* (c) Werner Mayer 2006 * +#* Copyright (c) 2006 Werner Mayer * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -22,10 +18,10 @@ #* 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 2006 * #***************************************************************************/ +# Qt Unit test module + __author__ = "Werner Mayer (werner.wm.mayer@gmx.de)" import string @@ -161,7 +157,7 @@ class RollbackImporter: """ def __init__(self): self.previousModules = sys.modules.copy() - + def rollbackImports(self): for modname in sys.modules.keys(): if modname not in self.previousModules: diff --git a/src/Mod/Test/Init.py b/src/Mod/Test/Init.py index 1a249c7d2b..f9d3759960 100644 --- a/src/Mod/Test/Init.py +++ b/src/Mod/Test/Init.py @@ -1,8 +1,5 @@ -# FreeCAD init script of the test module -# (c) 2001 Juergen Riegel - #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2001,2002 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -22,9 +19,10 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ +# FreeCAD init script of the test module + # Base system tests FreeCAD.__unit_test__ += [ "BaseTests", "UnitTests", diff --git a/src/Mod/Test/InitGui.py b/src/Mod/Test/InitGui.py index ddee8219ea..cbb18f8588 100644 --- a/src/Mod/Test/InitGui.py +++ b/src/Mod/Test/InitGui.py @@ -1,9 +1,5 @@ -# Test gui init module -# (c) 2003 Juergen Riegel -# - #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2002,2003 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -23,10 +19,9 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ - +# Test gui init module class TestWorkbench ( Workbench ): "Test workbench object" diff --git a/src/Mod/Test/Menu.py b/src/Mod/Test/Menu.py index c37a803497..d24585a2dc 100644 --- a/src/Mod/Test/Menu.py +++ b/src/Mod/Test/Menu.py @@ -1,9 +1,5 @@ -# Menu test module -# (c) 2005 Werner Mayer -# - #*************************************************************************** -#* (c) Werner Mayer 2005 * +#* Copyright (c) 2005 Werner Mayer * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -26,6 +22,8 @@ #* Werner Mayer 2005 * #***************************************************************************/ +# Menu test module + import FreeCAD, os, unittest, FreeCADGui diff --git a/src/Mod/Test/TestApp.py b/src/Mod/Test/TestApp.py index ab09b13cb4..74f00a4619 100644 --- a/src/Mod/Test/TestApp.py +++ b/src/Mod/Test/TestApp.py @@ -1,5 +1,5 @@ #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2002 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -19,7 +19,6 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ import FreeCAD @@ -70,7 +69,7 @@ def TestText(s): r = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) retval = r.run(s) # Flushing to make sure the stream is written to the console - # before the wrapping process stops executing. Without this line + # before the wrapping process stops executing. Without this line # executing the tests from command line did not show stats # and proper tarceback in some cases. sys.stdout.flush() diff --git a/src/Mod/Test/TestGui.py b/src/Mod/Test/TestGui.py index f36a19774c..ab745a7205 100644 --- a/src/Mod/Test/TestGui.py +++ b/src/Mod/Test/TestGui.py @@ -1,10 +1,5 @@ -# FreeCAD Part module -# (c) 2001 Juergen Riegel -# -# Part design module - #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* Copyright (c) 2001,2002 Juergen Riegel * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -24,9 +19,12 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Juergen Riegel 2002 * #***************************************************************************/ +# FreeCAD Part module +# +# Part design module + # import FreeCAD modules import FreeCAD,FreeCADGui # import the App Test module diff --git a/src/Mod/Test/TestPythonSyntax.py b/src/Mod/Test/TestPythonSyntax.py index f305366898..b57cd287c6 100644 --- a/src/Mod/Test/TestPythonSyntax.py +++ b/src/Mod/Test/TestPythonSyntax.py @@ -1,3 +1,27 @@ +#*************************************************************************** +#* Copyright (c) 2018 looooo * +#* * +#* 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 * +#* * +#***************************************************************************/ + + import sys import os import ast @@ -37,7 +61,7 @@ class PythonSyntaxTestCase(unittest.TestCase): self.whitelist += ["automotive_design.py"] self.whitelist += ["ifc2x3.py"] self.whitelist += ["ifc4.py"] - + def testAll(self): mod_dir = os.path.join(App.getHomePath(), "Mod") diff --git a/src/Mod/Test/UnicodeTests.py b/src/Mod/Test/UnicodeTests.py index b20ad99991..6d505d057c 100644 --- a/src/Mod/Test/UnicodeTests.py +++ b/src/Mod/Test/UnicodeTests.py @@ -1,5 +1,26 @@ # -*- coding: utf-8 -*- -# (c) Juergen Riegel (juergen.riegel@web.de) 2007 LGPL +#*************************************************************************** +#* Copyright (c) 2007 Juergen Riegel * +#* * +#* 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 * +#* * +#***************************************************************************/ # Open and edit only in UTF-8 !!!!!! @@ -29,9 +50,9 @@ class DocumentSaveRestoreCases(unittest.TestCase): self.Doc = FreeCAD.newDocument("SaveRestoreTests") L1 = self.Doc.addObject("App::FeatureTest","Label_1") L1.Label = u"हिन्दी" - self.TempPath = tempfile.gettempdir() + self.TempPath = tempfile.gettempdir() FreeCAD.Console.PrintLog( ' Using temp path: ' + self.TempPath + '\n') - + def testSaveAndRestore(self): # saving and restoring SaveName = self.TempPath + os.sep + "UnicodeTest.FCStd" @@ -41,10 +62,10 @@ class DocumentSaveRestoreCases(unittest.TestCase): self.failUnless(self.Doc.Label_1.Label == u"हिन्दी") FreeCAD.closeDocument("UnicodeTest") FreeCAD.newDocument("SaveRestoreTests") - - + + def tearDown(self): #closing doc FreeCAD.closeDocument("SaveRestoreTests") - + diff --git a/src/Mod/Test/UnitTests.py b/src/Mod/Test/UnitTests.py index 48b1b9ef75..5b896da80f 100644 --- a/src/Mod/Test/UnitTests.py +++ b/src/Mod/Test/UnitTests.py @@ -1,4 +1,26 @@ -# (c) Juergen Riegel (juergen.riegel@web.de) 20010 LGPL +# -*- coding: utf-8 -*- +#*************************************************************************** +#* Copyright (c) 2010 Juergen Riegel * +#* * +#* 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 * +#* * +#***************************************************************************/ import FreeCAD import unittest diff --git a/src/Mod/Test/Workbench.py b/src/Mod/Test/Workbench.py index 2e7a40c2c5..bd5d1723e4 100755 --- a/src/Mod/Test/Workbench.py +++ b/src/Mod/Test/Workbench.py @@ -1,9 +1,5 @@ -# Workbench test module -# (c) 2006 Werner Mayer -# - #*************************************************************************** -#* (c) Werner Mayer 2006 * +#* Copyright (c) 2006 Werner Mayer * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -23,9 +19,10 @@ #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * -#* Werner Mayer 2006 * #***************************************************************************/ +# Workbench test module + import FreeCAD, FreeCADGui, os, unittest class WorkbenchTestCase(unittest.TestCase): diff --git a/src/Mod/Test/test.dox b/src/Mod/Test/test.dox index 3acfd21a30..cdc546a174 100644 --- a/src/Mod/Test/test.dox +++ b/src/Mod/Test/test.dox @@ -1,5 +1,8 @@ /** \defgroup TEST Test - * \ingroup CWORKBENCHES + * \ingroup CWORKBENCHES * \brief Test framework of FreeCAD + +See \ref src/Mod/Draft/draft.dox for example on how to populate a .dox file. + */ diff --git a/src/Mod/Test/testPathArray.py b/src/Mod/Test/testPathArray.py index dabd0c1352..327748e45c 100644 --- a/src/Mod/Test/testPathArray.py +++ b/src/Mod/Test/testPathArray.py @@ -1,9 +1,31 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +#*************************************************************************** +#* Copyright (c) 2013 WandererFan * +#* * +#* 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 * +#* * +#***************************************************************************/ -# tester for Draft makePathArray - shapes on a path - without subelements (see testPathArraySel.py) +# Tester for Draft makePathArray - shapes on a path - without subelements (see testPathArraySel.py) # Usage: in FC gui, select a "shape" document object (sphere, box, etc) (!!select in -# tree, not document view!!), then a "wire" document object (Wire, Circle, Rectangle, +# tree, not document view!!), then a "wire" document object (Wire, Circle, Rectangle, # DWire, etc) then run this macro. import FreeCAD @@ -16,7 +38,7 @@ items = 4 # count centretrans = FreeCAD.Vector(0,0,0) # no translation #centretrans = FreeCAD.Vector(-5,-5,0) # translation orient = True # align to curve -#orient = False # don't align to curve +#orient = False # don't align to curve s = FreeCADGui.Selection.getSelection() print("testPathArray: Objects in selection: ", len(s)) @@ -24,12 +46,9 @@ print("First object in selection is a: ", s[0].Shape.ShapeType) print("Second object in selection is a: ", s[1].Shape.ShapeType) base = s[0] path = s[1] -pathsubs = [] +pathsubs = [] -#o = Draft.makePathArray(base,path,items) # test with defaults -o = Draft.makePathArray(base,path,items,centretrans,orient,pathsubs) # test with non-defaults +#o = Draft.makePathArray(base,path,items) # test with defaults +o = Draft.makePathArray(base,path,items,centretrans,orient,pathsubs) # test with non-defaults print("testPathArray ended") - - - diff --git a/src/Mod/Test/testPathArraySel.py b/src/Mod/Test/testPathArraySel.py index b6a27975f4..9cfbd572be 100644 --- a/src/Mod/Test/testPathArraySel.py +++ b/src/Mod/Test/testPathArraySel.py @@ -1,7 +1,29 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +#*************************************************************************** +#* Copyright (c) 2013 WandererFan * +#* * +#* 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 * +#* * +#***************************************************************************/ -# tester for Draft makePathArray - shapes on a path - with selected subobjects +# Tester for Draft makePathArray - shapes on a path - with selected subobjects # Usage: in FC gui, select a "shape" document object (sphere, box, etc) (!select in # tree, not document view!!), then select edges from the "wire" object. diff --git a/src/Mod/Test/testmakeWireString.py b/src/Mod/Test/testmakeWireString.py index 717bccccbb..325d4a2447 100644 --- a/src/Mod/Test/testmakeWireString.py +++ b/src/Mod/Test/testmakeWireString.py @@ -1,5 +1,28 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# *************************************************************************** +# * Copyright (c) 2013 WandererFan * +# * * +# * 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. * +# * * +# * 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 Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library 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 * +# * * +# *************************************************************************** + # tester for Part.makeWireString @@ -9,38 +32,38 @@ import PartDesign print("testWire started") -# test strings -# if string contains funky characters, it has to be declared as Unicode or it +# test strings +# if string contains funky characters, it has to be declared as Unicode or it # turns into the default encoding (usually utf8). FT2 doesn't do utf8. #String = 'Wide WMA_' # wide glyphs for tracking #String = 'Big' -#String = u'ecAnO' # UCS-2 w/ only ASCII -#String = u'ucs2uéçÄñØ' # UCS-2 -#String = 'utf8!uéçÄñØ' # UTF-8 +#String = u'ecAnO' # UCS-2 w/ only ASCII +#String = u'ucs2uéçÄñØ' # UCS-2 +#String = 'utf8!uéçÄñØ' # UTF-8 #String = 'abcdefghijklmnopqrstuvwxyz0123456789' #String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' -#String = 'Big Daddy' # white space -#String = 'AVWAIXA.V' # kerning -String = 'FreeCAD' # ASCII +#String = 'Big Daddy' # white space +#String = 'AVWAIXA.V' # kerning +String = 'FreeCAD' # ASCII -#FontPath = '/usr/share/fonts/truetype/msttcorefonts/' -#FontName = 'Times_New_Roman_Italic.ttf' +#FontPath = '/usr/share/fonts/truetype/msttcorefonts/' +#FontName = 'Times_New_Roman_Italic.ttf' FontPath = '/usr/share/fonts/truetype/msttcorefonts/' -FontName = 'Arial.ttf' -#FontName = 'NOTArial.ttf' # font file not found error -#FontPath = '/usr/share/fonts/truetype/msttcorefonts/' -#FontName = 'ariali.ttf' #symlink to ttf -#FontPath = '/usr/share/fonts/truetype/' +FontName = 'Arial.ttf' +#FontName = 'NOTArial.ttf' # font file not found error +#FontPath = '/usr/share/fonts/truetype/msttcorefonts/' +#FontName = 'ariali.ttf' # symlink to ttf +#FontPath = '/usr/share/fonts/truetype/' #FontName = 'Peterbuilt.ttf' # overlapping script font -#FontPath = '/usr/share/fonts/truetype/' +#FontPath = '/usr/share/fonts/truetype/' #FontName = 'dyspepsia.ttf' # overlapping script font # :) Height = 2000 # out string height FCunits Track = 0 # intercharacter spacing - + print("testWire.py input String contains ", len(String), " characters.") - -s = Part.makeWireString(String,FontPath,FontName,Height,Track) + +s = Part.makeWireString(String,FontPath,FontName,Height,Track) print("returned from makeWireString") print("testWire.py output contains ", len(s), " WireChars.") @@ -48,5 +71,5 @@ print("testWire.py output contains ", len(s), " WireChars.") for char in s: for contour in char: Part.show(contour) - + print("testWire ended.")