Workbench.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 import FreeCAD, FreeCADGui, os, unittest
00030
00031 class WorkbenchTestCase(unittest.TestCase):
00032 def setUp(self):
00033 self.Active = FreeCADGui.activeWorkbench()
00034 FreeCAD.Console.PrintLog(FreeCADGui.activeWorkbench().name())
00035
00036 def testActivate(self):
00037 list=FreeCADGui.listWorkbenches()
00038 for i in list:
00039 FreeCADGui.activateWorkbench(i)
00040 FreeCADGui.updateGui()
00041 FreeCAD.Console.PrintLog("Active: "+FreeCADGui.activeWorkbench().name()+ " Expected: "+i+"\n")
00042 FreeCADGui.updateGui()
00043 self.failUnless(FreeCADGui.activeWorkbench().name()==i, "Test on activating workbench failed")
00044
00045 def testHandler(self):
00046 import __main__
00047 class UnitWorkbench(__main__.Workbench):
00048 MenuText = "Unittest"
00049 ToolTip = "Unittest"
00050 def Initialize(self):
00051 list = ["Test_Test"]
00052 self.appendToolbar("My Unittest",list)
00053 def GetClassName(self):
00054 return "Gui::PythonWorkbench"
00055
00056 FreeCADGui.addWorkbench(UnitWorkbench())
00057 list=FreeCADGui.listWorkbenches()
00058 self.failUnless(list.has_key("UnitWorkbench")==True, "Test on adding workbench handler failed")
00059 FreeCADGui.activateWorkbench("UnitWorkbench")
00060 FreeCADGui.updateGui()
00061 self.failUnless(FreeCADGui.activeWorkbench().name()=="UnitWorkbench", "Test on loading workbench 'Unittest' failed")
00062 FreeCADGui.removeWorkbench("UnitWorkbench")
00063 list=FreeCADGui.listWorkbenches()
00064 self.failUnless(list.has_key("UnitWorkbench")==False, "Test on removing workbench handler failed")
00065
00066 def tearDown(self):
00067 FreeCADGui.activateWorkbench(self.Active.name())
00068 FreeCAD.Console.PrintLog(self.Active.name())