File: TestGui.py

package info (click to toggle)
freecad 0.14.3702+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 162,288 kB
  • ctags: 78,057
  • sloc: cpp: 360,157; python: 199,755; xml: 7,653; fortran: 3,878; ansic: 702; lex: 204; yacc: 91; sh: 41; makefile: 18
file content (196 lines) | stat: -rw-r--r-- 8,053 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# FreeCAD Part module  
# (c) 2001 Juergen Riegel
#
# Part design module

#***************************************************************************
#*   (c) Juergen Riegel (juergen.riegel@web.de) 2002                       *
#*                                                                         *
#*   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                                                                   *
#*                                                                         *
#*   Juergen Riegel 2002                                                   *
#***************************************************************************/

# import FreeCAD modules
import FreeCAD,FreeCADGui
# import the App Test module
import TestApp               #Test as Module name not possible
import sys

#---------------------------------------------------------------------------
# define the Commands of the Test Application module
#---------------------------------------------------------------------------
class TestCmd:
    """Opens a Qt dialog with all inserted unit tests"""
    def Activated(self):
        import QtUnitGui
        QtUnitGui.addTest("TestApp.All")
        QtUnitGui.setTest("TestApp.All")
        QtUnitGui.addTest("BaseTests")
        QtUnitGui.addTest("UnitTests")
        QtUnitGui.addTest("Document")
        QtUnitGui.addTest("UnicodeTests")
        QtUnitGui.addTest("MeshTestsApp")
        QtUnitGui.addTest("TestSketcherApp")
        QtUnitGui.addTest("TestPartApp")
        QtUnitGui.addTest("TestPartDesignApp")
        QtUnitGui.addTest("Workbench")
        QtUnitGui.addTest("Menu")
        QtUnitGui.addTest("Menu.MenuDeleteCases")
        QtUnitGui.addTest("Menu.MenuCreateCases")

    def GetResources(self):
        return {'MenuText': 'Self-test...', 'ToolTip': 'Runs a self-test to check if the application works properly'}

class TestAllCmd:
    "Test all commando object"
    def Activated(self):
        import QtUnitGui
        QtUnitGui.addTest("TestApp.All")
        QtUnitGui.setTest("TestApp.All")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1', 'MenuText': 'Test all', 'ToolTip': 'Runs all tests at once (can take very long!)'}

class TestDocCmd:
    "Document test commando object"
    def Activated(self):
        import QtUnitGui
        QtUnitGui.addTest("Document")
        QtUnitGui.setTest("Document")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Test Document',
                'ToolTip' : 'Test the document (creation, save, load and destruction)'}

class TestBaseCmd:
    "Base test commando object"
    def Activated(self):
        import QtUnitGui
        QtUnitGui.addTest("BaseTests")
        QtUnitGui.setTest("BaseTests")

    def GetResources(self):
        return {
            'Pixmap'  : 'Std_Tool1',
            'MenuText': 'Test base',
            'ToolTip' : 'Test the basic functions of FreeCAD'
              }

class TestAllTextCmd:
    "Test all commando object"
    def Activated(self):
        import unittest, TestApp
        unittest.TextTestRunner(stream=sys.stdout,verbosity=2).run(unittest.defaultTestLoader.loadTestsFromName("TestApp.All"))

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1', 
                'MenuText': 'Test all', 
                'ToolTip' : 'Runs all tests at once (can take very long!)'
                }

class TestDocTextCmd:
    "Document test commando object"
    def Activated(self):
        TestApp.TestText("Document")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Test Document',
                'ToolTip' : 'Test the document (creation, save, load and destruction)'}

class TestBaseTextCmd:
    "Base test commando object"
    def Activated(self):
        TestApp.TestText("BaseTests")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Test base',
                'ToolTip' : 'Test the basic functions of FreeCAD'}

class TestWorkbenchCmd:
    "Workbench test"
    def Activated(self):
        i=0
        while (i<20):
            FreeCADGui.activateWorkbench("MeshWorkbench")
            FreeCADGui.updateGui()
            FreeCADGui.activateWorkbench("NoneWorkbench")
            FreeCADGui.updateGui()
            FreeCADGui.activateWorkbench("PartWorkbench")
            FreeCADGui.updateGui()
            print i
            i=i+1
        FreeCADGui.activateWorkbench("TestWorkbench")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Test workbench',
                'ToolTip' : 'Test the switching of workbenches in FreeCAD'}

class TestCreateMenuCmd:
    "Base test commando object"
    def Activated(self):
        TestApp.TestText("Menu.MenuCreateCases")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Add menu',
                'ToolTip' : 'Test the menu stuff of FreeCAD'}

class TestDeleteMenuCmd:
    "Base test commando object"
    def Activated(self):
        TestApp.TestText("Menu.MenuDeleteCases")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Remove menu',
                'ToolTip' : 'Test the menu stuff of FreeCAD'}

class TestInsertFeatureCmd:
    "Base test commando object"
    def Activated(self):
        if FreeCAD.activeDocument() != None:
            FreeCAD.activeDocument().addObject("App::FeatureTest")
        else:
            FreeCAD.PrintMessage("No active document.\n")

    def GetResources(self):
        return {'Pixmap'  : 'Std_Tool1',
                'MenuText': 'Insert a TestFeauture',
                'ToolTip' : 'Insert a TestFeature in the active Document'}

#---------------------------------------------------------------------------
# Adds the commands to the FreeCAD command manager
#---------------------------------------------------------------------------
FreeCADGui.addCommand('Test_Test'        ,TestCmd())
FreeCADGui.addCommand('Test_TestAllText' ,TestAllTextCmd())
FreeCADGui.addCommand('Test_TestDocText' ,TestDocTextCmd())
FreeCADGui.addCommand('Test_TestBaseText',TestBaseTextCmd())
FreeCADGui.addCommand('Test_TestAll'     ,TestAllCmd())
FreeCADGui.addCommand('Test_TestDoc'     ,TestDocCmd())
FreeCADGui.addCommand('Test_TestBase'    ,TestBaseCmd())
FreeCADGui.addCommand('Test_TestWork'    ,TestWorkbenchCmd())
FreeCADGui.addCommand('Test_TestCreateMenu'    ,TestCreateMenuCmd())
FreeCADGui.addCommand('Test_TestDeleteMenu'    ,TestDeleteMenuCmd())
FreeCADGui.addCommand('Test_InsertFeature'    ,TestInsertFeatureCmd())