TestGui.py
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 import FreeCAD,FreeCADGui
00032
00033 import TestApp
00034
00035
00036
00037
00038 class TestCmd:
00039 """Opens a Qt dialog with all inserted unit tests"""
00040 def Activated(self):
00041 import QtUnitGui
00042 QtUnitGui.addTest("TestApp.All")
00043 QtUnitGui.setTest("TestApp.All")
00044 QtUnitGui.addTest("BaseTests")
00045 QtUnitGui.addTest("Document")
00046 QtUnitGui.addTest("UnicodeTests")
00047 QtUnitGui.addTest("MeshTestsApp")
00048 QtUnitGui.addTest("TestSketcherApp")
00049 QtUnitGui.addTest("TestPartApp")
00050 QtUnitGui.addTest("TestPartDesignApp")
00051 QtUnitGui.addTest("Workbench")
00052 QtUnitGui.addTest("Menu")
00053 QtUnitGui.addTest("Menu.MenuDeleteCases")
00054 QtUnitGui.addTest("Menu.MenuCreateCases")
00055
00056 def GetResources(self):
00057 return {'MenuText': 'Self-test...', 'ToolTip': 'Runs a self-test to check if the application works properly'}
00058
00059 class TestAllCmd:
00060 "Test all commando object"
00061 def Activated(self):
00062 import QtUnitGui
00063 QtUnitGui.addTest("TestApp.All")
00064 QtUnitGui.setTest("TestApp.All")
00065
00066 def GetResources(self):
00067 return {'Pixmap' : 'Std_Tool1', 'MenuText': 'Test all', 'ToolTip': 'Runs all tests at once (can take very long!)'}
00068
00069 class TestDocCmd:
00070 "Document test commando object"
00071 def Activated(self):
00072 import QtUnitGui
00073 QtUnitGui.addTest("Document")
00074 QtUnitGui.setTest("Document")
00075
00076 def GetResources(self):
00077 return {'Pixmap' : 'Std_Tool1',
00078 'MenuText': 'Test Document',
00079 'ToolTip' : 'Test the document (creation, save, load and destruction)'}
00080
00081 class TestBaseCmd:
00082 "Base test commando object"
00083 def Activated(self):
00084 import QtUnitGui
00085 QtUnitGui.addTest("BaseTests")
00086 QtUnitGui.setTest("BaseTests")
00087
00088 def GetResources(self):
00089 return {
00090 'Pixmap' : 'Std_Tool1',
00091 'MenuText': 'Test base',
00092 'ToolTip' : 'Test the basic functions of FreeCAD'
00093 }
00094
00095 class TestAllTextCmd:
00096 "Test all commando object"
00097 def Activated(self):
00098 import unittest, TestApp
00099 unittest.TextTestRunner().run(unittest.defaultTestLoader.loadTestsFromName("TestApp.All"))
00100
00101 def GetResources(self):
00102 return {'Pixmap' : 'Std_Tool1',
00103 'MenuText': 'Test all',
00104 'ToolTip' : 'Runs all tests at once (can take very long!)'
00105 }
00106
00107 class TestDocTextCmd:
00108 "Document test commando object"
00109 def Activated(self):
00110 TestApp.TestText("Document")
00111
00112 def GetResources(self):
00113 return {'Pixmap' : 'Std_Tool1',
00114 'MenuText': 'Test Document',
00115 'ToolTip' : 'Test the document (creation, save, load and destruction)'}
00116
00117 class TestBaseTextCmd:
00118 "Base test commando object"
00119 def Activated(self):
00120 TestApp.TestText("BaseTests")
00121
00122 def GetResources(self):
00123 return {'Pixmap' : 'Std_Tool1',
00124 'MenuText': 'Test base',
00125 'ToolTip' : 'Test the basic functions of FreeCAD'}
00126
00127 class TestWorkbenchCmd:
00128 "Workbench test"
00129 def Activated(self):
00130 i=0
00131 while (i<20):
00132 FreeCADGui.activateWorkbench("MeshWorkbench")
00133 FreeCADGui.updateGui()
00134 FreeCADGui.activateWorkbench("NoneWorkbench")
00135 FreeCADGui.updateGui()
00136 FreeCADGui.activateWorkbench("PartWorkbench")
00137 FreeCADGui.updateGui()
00138 print i
00139 i=i+1
00140 FreeCADGui.activateWorkbench("TestWorkbench")
00141
00142 def GetResources(self):
00143 return {'Pixmap' : 'Std_Tool1',
00144 'MenuText': 'Test workbench',
00145 'ToolTip' : 'Test the switching of workbenches in FreeCAD'}
00146
00147 class TestCreateMenuCmd:
00148 "Base test commando object"
00149 def Activated(self):
00150 TestApp.TestText("Menu.MenuCreateCases")
00151
00152 def GetResources(self):
00153 return {'Pixmap' : 'Std_Tool1',
00154 'MenuText': 'Add menu',
00155 'ToolTip' : 'Test the menu stuff of FreeCAD'}
00156
00157 class TestDeleteMenuCmd:
00158 "Base test commando object"
00159 def Activated(self):
00160 TestApp.TestText("Menu.MenuDeleteCases")
00161
00162 def GetResources(self):
00163 return {'Pixmap' : 'Std_Tool1',
00164 'MenuText': 'Remove menu',
00165 'ToolTip' : 'Test the menu stuff of FreeCAD'}
00166
00167 class TestInsertFeatureCmd:
00168 "Base test commando object"
00169 def Activated(self):
00170 if FreeCAD.activeDocument() != None:
00171 FreeCAD.activeDocument().addObject("App::FeatureTest")
00172 else:
00173 FreeCAD.PrintMessage("No active document.\n")
00174
00175 def GetResources(self):
00176 return {'Pixmap' : 'Std_Tool1',
00177 'MenuText': 'Insert a TestFeauture',
00178 'ToolTip' : 'Insert a TestFeature in the active Document'}
00179
00180
00181
00182
00183 FreeCADGui.addCommand('Test_Test' ,TestCmd())
00184 FreeCADGui.addCommand('Test_TestAllText' ,TestAllTextCmd())
00185 FreeCADGui.addCommand('Test_TestDocText' ,TestDocTextCmd())
00186 FreeCADGui.addCommand('Test_TestBaseText',TestBaseTextCmd())
00187 FreeCADGui.addCommand('Test_TestAll' ,TestAllCmd())
00188 FreeCADGui.addCommand('Test_TestDoc' ,TestDocCmd())
00189 FreeCADGui.addCommand('Test_TestBase' ,TestBaseCmd())
00190 FreeCADGui.addCommand('Test_TestWork' ,TestWorkbenchCmd())
00191 FreeCADGui.addCommand('Test_TestCreateMenu' ,TestCreateMenuCmd())
00192 FreeCADGui.addCommand('Test_TestDeleteMenu' ,TestDeleteMenuCmd())
00193 FreeCADGui.addCommand('Test_InsertFeature' ,TestInsertFeatureCmd())
00194