Workbench.py

Go to the documentation of this file.
00001 # Workbench test module  
00002 # (c) 2006 Werner Mayer
00003 #
00004 
00005 #***************************************************************************
00006 #*   (c) Werner Mayer <werner.wm.mayer@gmx.de> 2006                        *
00007 #*                                                                         *
00008 #*   This file is part of the FreeCAD CAx development system.              *
00009 #*                                                                         *
00010 #*   This program is free software; you can redistribute it and/or modify  *
00011 #*   it under the terms of the GNU Lesser General Public License (LGPL)    *
00012 #*   as published by the Free Software Foundation; either version 2 of     *
00013 #*   the License, or (at your option) any later version.                   *
00014 #*   for detail see the LICENCE text file.                                 *
00015 #*                                                                         *
00016 #*   FreeCAD is distributed in the hope that it will be useful,            *
00017 #*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018 #*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00019 #*   GNU Library General Public License for more details.                  *
00020 #*                                                                         *
00021 #*   You should have received a copy of the GNU Library General Public     *
00022 #*   License along with FreeCAD; if not, write to the Free Software        *
00023 #*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
00024 #*   USA                                                                   *
00025 #*                                                                         *
00026 #*   Werner Mayer 2006                                                     *
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())

Generated on Wed Nov 23 19:01:12 2011 for FreeCAD by  doxygen 1.6.1