Created unit test for signals.
Test for types inside of namespace
Test for types defined by typedef.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
4ebad6745f
commit
1155542ecc
4 changed files with 173 additions and 0 deletions
|
|
@ -23,6 +23,9 @@ qt4_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
|
||||||
|
|
||||||
set(testbinding_SRC
|
set(testbinding_SRC
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testobject_wrapper.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testobject_wrapper.cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_wrapper.cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobjectwithnamespace_wrapper.cpp
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp2_testobjectwithoutnamespace_wrapper.cpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testview_wrapper.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testview_wrapper.cpp
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
|
||||||
)
|
)
|
||||||
|
|
@ -75,6 +78,7 @@ PYSIDE_TEST(delegatecreateseditor_test.py)
|
||||||
PYSIDE_TEST(homonymoussignalandmethod_test.py)
|
PYSIDE_TEST(homonymoussignalandmethod_test.py)
|
||||||
PYSIDE_TEST(list_signal_test.py)
|
PYSIDE_TEST(list_signal_test.py)
|
||||||
PYSIDE_TEST(modelview_test.py)
|
PYSIDE_TEST(modelview_test.py)
|
||||||
|
PYSIDE_TEST(signalandnamespace_test.py)
|
||||||
PYSIDE_TEST(signalwithdefaultvalue_test.py)
|
PYSIDE_TEST(signalwithdefaultvalue_test.py)
|
||||||
PYSIDE_TEST(signalemissionfrompython_test.py)
|
PYSIDE_TEST(signalemissionfrompython_test.py)
|
||||||
PYSIDE_TEST(version_test.py)
|
PYSIDE_TEST(version_test.py)
|
||||||
|
|
|
||||||
92
tests/pysidetest/signalandnamespace_test.py
Normal file
92
tests/pysidetest/signalandnamespace_test.py
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from testbinding import PySideCPP, TestObjectWithoutNamespace
|
||||||
|
|
||||||
|
class ModelViewTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def callback(self, o):
|
||||||
|
self._called = o
|
||||||
|
|
||||||
|
def testWithoutNamespace(self):
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignal.connect(self.callback)
|
||||||
|
o.emitSignal.emit(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignal.connect(self.callback)
|
||||||
|
o.callSignal(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
def testWithNamespace(self):
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignalWithNamespace.connect(self.callback)
|
||||||
|
o.emitSignalWithNamespace.emit(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignalWithNamespace.connect(self.callback)
|
||||||
|
o.callSignalWithNamespace(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
|
||||||
|
def testWithoutNamespace1(self):
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignal.connect(self.callback)
|
||||||
|
o.emitSignal.emit(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignal.connect(self.callback)
|
||||||
|
o.callSignal(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
def testWithNamespace1(self):
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignalWithNamespace.connect(self.callback)
|
||||||
|
o.emitSignalWithNamespace.emit(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignalWithNamespace.connect(self.callback)
|
||||||
|
o.callSignalWithNamespace(o)
|
||||||
|
self.assert_(o == self._called)
|
||||||
|
|
||||||
|
def testTypedfWithouNamespace(self):
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignalWithTypedef.connect(self.callback)
|
||||||
|
o.emitSignalWithTypedef.emit(10)
|
||||||
|
self.assertEqual(10, self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = PySideCPP.TestObjectWithNamespace(None)
|
||||||
|
o.emitSignalWithTypedef.connect(self.callback)
|
||||||
|
o.callSignalWithTypedef(10)
|
||||||
|
self.assertEqual(10, self._called)
|
||||||
|
|
||||||
|
def testTypedefWithNamespace(self):
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignalWithTypedef.connect(self.callback)
|
||||||
|
o.emitSignalWithTypedef.emit(10)
|
||||||
|
self.assertEqual(10, self._called)
|
||||||
|
|
||||||
|
self._called = None
|
||||||
|
o = TestObjectWithoutNamespace(None)
|
||||||
|
o.emitSignalWithTypedef.connect(self.callback)
|
||||||
|
o.callSignalWithTypedef(10)
|
||||||
|
self.assertEqual(10, self._called)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define TESTOBJECT_H
|
#define TESTOBJECT_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMetaType>
|
||||||
#ifdef pysidetest_EXPORTS
|
#ifdef pysidetest_EXPORTS
|
||||||
#define PYSIDE_EXPORTS 1
|
#define PYSIDE_EXPORTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -34,5 +35,55 @@ private:
|
||||||
QList<QObject*> m_children;
|
QList<QObject*> m_children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef int PySideInt;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PySideCPP {
|
||||||
|
|
||||||
|
class PYSIDE_API TestObjectWithNamespace : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TestObjectWithNamespace(QObject* parent) : QObject(parent) {}
|
||||||
|
QString name() { return "TestObjectWithNamespace"; }
|
||||||
|
|
||||||
|
void callSignal(TestObjectWithNamespace* obj) { emitSignal(obj); }
|
||||||
|
void callSignalWithNamespace(TestObjectWithNamespace* obj) { emitSignalWithNamespace(obj); }
|
||||||
|
void callSignalWithTypedef(int val) { emitSignalWithTypedef(val); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void emitSignal(TestObjectWithNamespace* obj);
|
||||||
|
void emitSignalWithNamespace(PySideCPP::TestObjectWithNamespace* obj);
|
||||||
|
void emitSignalWithTypedef(PySideInt val);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace PySideCPP
|
||||||
|
|
||||||
|
namespace PySideCPP2 {
|
||||||
|
|
||||||
|
typedef long PySideLong;
|
||||||
|
|
||||||
|
class PYSIDE_API TestObjectWithoutNamespace : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TestObjectWithoutNamespace(QObject* parent) : QObject(parent) {}
|
||||||
|
QString name() { return "TestObjectWithoutNamespace"; }
|
||||||
|
|
||||||
|
void callSignal(TestObjectWithoutNamespace* obj) { emitSignal(obj); }
|
||||||
|
void callSignalWithNamespace(TestObjectWithoutNamespace* obj) { emitSignalWithNamespace(obj); }
|
||||||
|
void callSignalWithTypedef(long val) { emitSignalWithTypedef(val); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void emitSignal(TestObjectWithoutNamespace* obj);
|
||||||
|
void emitSignalWithNamespace(PySideCPP2::TestObjectWithoutNamespace* obj);
|
||||||
|
void emitSignalWithTypedef(PySideLong val);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace PySideCPP2
|
||||||
|
|
||||||
#endif // TESTOBJECT_H
|
#endif // TESTOBJECT_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,32 @@
|
||||||
<load-typesystem name="typesystem_core.xml" generate="no" />
|
<load-typesystem name="typesystem_core.xml" generate="no" />
|
||||||
<load-typesystem name="typesystem_gui.xml" generate="no"/>
|
<load-typesystem name="typesystem_gui.xml" generate="no"/>
|
||||||
<object-type name="TestObject" />
|
<object-type name="TestObject" />
|
||||||
|
|
||||||
|
<inject-code>
|
||||||
|
qRegisterMetaType<PySideInt>("PySideInt");
|
||||||
|
qRegisterMetaType<PySideCPP2::PySideLong>("PySideLong");
|
||||||
|
</inject-code>
|
||||||
|
|
||||||
|
<namespace-type name="PySideCPP">
|
||||||
|
<object-type name="TestObjectWithNamespace" >
|
||||||
|
<modify-function signature="emitSignal(PySideCPP::TestObjectWithNamespace*)">
|
||||||
|
<modify-argument index="1">
|
||||||
|
<replace-type modified-type="TestObjectWithNamespace*"/>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
</object-type>
|
||||||
|
</namespace-type>
|
||||||
|
|
||||||
|
<namespace-type name="PySideCPP2" generate="no">
|
||||||
|
<object-type name="TestObjectWithoutNamespace" >
|
||||||
|
<modify-function signature="emitSignalWithNamespace(PySideCPP2::TestObjectWithoutNamespace*)">
|
||||||
|
<modify-argument index="1">
|
||||||
|
<replace-type modified-type="PySideCPP2::TestObjectWithoutNamespace*"/>
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
</object-type>
|
||||||
|
</namespace-type>
|
||||||
|
|
||||||
<object-type name="TestView" >
|
<object-type name="TestView" >
|
||||||
<modify-function signature="TestView(QAbstractListModel*,QObject*)">
|
<modify-function signature="TestView(QAbstractListModel*,QObject*)">
|
||||||
<modify-argument index="1">
|
<modify-argument index="1">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue