1
/***************************************************************************
2
* Copyright (c) 2006 Werner Mayer <werner.wm.mayer@gmx.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
29
#include "UnitTestPy.h"
30
#include "UnitTestImp.h"
31
#include "qrc_Test.cpp"
33
#include <Gui/Language/Translator.h>
34
#include <Base/Console.h>
36
class UnitTestModule : public Py::ExtensionModule<UnitTestModule>
40
UnitTestModule() : Py::ExtensionModule<UnitTestModule>("QtUnitGui")
42
TestGui::UnitTestDialogPy::init_type();
43
add_varargs_method("UnitTest",&UnitTestModule::new_UnitTest,"UnitTest");
44
add_varargs_method("setTest",&UnitTestModule::setTest,"setTest");
45
add_varargs_method("addTest",&UnitTestModule::addTest,"addTest");
46
initialize("This module is the QtUnitGui module"); // register with Python
49
virtual ~UnitTestModule() {}
52
Py::Object new_UnitTest(const Py::Tuple& args)
54
return Py::asObject(new TestGui::UnitTestDialogPy());
56
Py::Object setTest(const Py::Tuple& args)
59
if (!PyArg_ParseTuple(args.ptr(), "|s", &pstr))
60
throw Py::Exception();
62
TestGui::UnitTestDialog* dlg = TestGui::UnitTestDialog::instance();
64
dlg->setUnitTest(QString::fromLatin1(pstr));
69
Py::Object addTest(const Py::Tuple& args)
72
if (!PyArg_ParseTuple(args.ptr(), "|s", &pstr))
73
throw Py::Exception();
75
TestGui::UnitTestDialog* dlg = TestGui::UnitTestDialog::instance();
77
dlg->addUnitTest(QString::fromLatin1(pstr));
84
static PyObject* addTest(PyObject *self, PyObject *args)
87
if (!PyArg_ParseTuple(args, "|s", &pstr)) // convert args: Python->C
88
return NULL; // NULL triggers exception
90
TestGui::UnitTestDialog* dlg = TestGui::UnitTestDialog::instance();
92
dlg->addUnitTest(QString::fromLatin1(pstr));
98
static PyObject* setTest(PyObject *self, PyObject *args)
101
if (!PyArg_ParseTuple(args, "|s", &pstr)) // convert args: Python->C
102
return NULL; // NULL triggers exception
104
TestGui::UnitTestDialog* dlg = TestGui::UnitTestDialog::instance();
106
dlg->setUnitTest(QString::fromLatin1(pstr));
112
/* registration table */
113
static struct PyMethodDef TestGui_methods[] = {
114
{"addTest", addTest, 1},
115
{"setTest", setTest, 1},
116
{NULL, NULL} /* end of table marker */
119
void loadTestResource()
121
// add resources and reloads the translators
122
Q_INIT_RESOURCE(Test);
123
Gui::Translator::instance()->refresh();
128
void AppTestGuiExport initQtUnitGui()
130
// the following constructor call registers our extension module
131
// with the Python runtime system
132
(void)new UnitTestModule;
134
//if(PyType_Ready(&TestGui::UnitTestPy::Type) < 0) return;
135
//PyObject* pyModule = Py_InitModule("QtUnitGui", TestGui_methods); /* mod name, table ptr */
136
//union PyType_Object pyDlgType = {&TestGui::UnitTestPy::Type};
137
//PyModule_AddObject(pyModule, "UnitTest", pyDlgType.o);
138
Base::Console().Log("Loading GUI of Test module... done\n");
140
// add resources and reloads the translators