aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2011-08-09 15:28:06 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:42 -0300
commit5e08e864e7378b87b18bf885a73ac5f4d0cac93a (patch)
treedbde08cb1fcdfd98e91d85e0b69772ed6ffaf096
parent44e1d257ec00d03a1dd4feeb4a0b8f2f2739df84 (diff)
Added test for signal with typedef
Reviewer: Renato Filho <renato.filho@openbossa.org> Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--tests/pysidetest/CMakeLists.txt3
-rw-r--r--tests/pysidetest/testobject.cpp6
-rw-r--r--tests/pysidetest/testobject.h14
-rw-r--r--tests/pysidetest/typedef_signal_test.py27
-rw-r--r--tests/pysidetest/typesystem_pysidetest.xml2
5 files changed, 51 insertions, 1 deletions
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt
index 940f8c49c..807463dc9 100644
--- a/tests/pysidetest/CMakeLists.txt
+++ b/tests/pysidetest/CMakeLists.txt
@@ -23,6 +23,7 @@ qt4_wrap_cpp(pysidetest_MOC_SRC ${pysidetest_MOC_HEADERS})
set(testbinding_SRC
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testobject_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/intvalue_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
@@ -84,4 +85,4 @@ PYSIDE_TEST(signalandnamespace_test.py)
PYSIDE_TEST(signalwithdefaultvalue_test.py)
PYSIDE_TEST(signalemissionfrompython_test.py)
PYSIDE_TEST(version_test.py)
-
+PYSIDE_TEST(typedef_signal_test.py)
diff --git a/tests/pysidetest/testobject.cpp b/tests/pysidetest/testobject.cpp
index 6911334ff..113075047 100644
--- a/tests/pysidetest/testobject.cpp
+++ b/tests/pysidetest/testobject.cpp
@@ -24,3 +24,9 @@ TestObject::emitSignalWithDefaultValue_bool()
emit signalWithDefaultValue(true);
}
+void
+TestObject::emitSignalWithTypedefValue(int value)
+{
+ emit signalWithTypedefValue(TypedefValue(value));
+}
+
diff --git a/tests/pysidetest/testobject.h b/tests/pysidetest/testobject.h
index e2c0fc114..e37bca8de 100644
--- a/tests/pysidetest/testobject.h
+++ b/tests/pysidetest/testobject.h
@@ -10,6 +10,17 @@
#endif
#include "pysidemacros.h"
+class IntValue
+{
+public:
+
+ IntValue(int val): value(val){};
+ IntValue() : value(0) {};
+ int value;
+};
+
+typedef IntValue TypedefValue;
+
class PYSIDE_API TestObject : public QObject
{
Q_OBJECT
@@ -28,12 +39,15 @@ public:
void emitSignalWithDefaultValue_void();
void emitSignalWithDefaultValue_bool();
+ void emitSignalWithTypedefValue(int value);
+
signals:
void idValue(int newValue);
void justASignal();
void staticMethodDouble();
void childrenChanged(const QList<QObject*>&);
void signalWithDefaultValue(bool value = false);
+ void signalWithTypedefValue(TypedefValue value);
private:
int m_idValue;
diff --git a/tests/pysidetest/typedef_signal_test.py b/tests/pysidetest/typedef_signal_test.py
new file mode 100644
index 000000000..c2cdd1216
--- /dev/null
+++ b/tests/pysidetest/typedef_signal_test.py
@@ -0,0 +1,27 @@
+
+import unittest
+
+from PySide.QtCore import QObject
+from testbinding import TestObject
+
+class Receiver(QObject):
+
+ def __init__(self):
+ QObject.__init__(self)
+ self.received = None
+
+ def slot(self, value):
+ self.received = value
+
+class TypedefSignal(unittest.TestCase):
+
+ def testTypedef(self):
+ obj = TestObject(0)
+ receiver = Receiver()
+
+ obj.signalWithTypedefValue.connect(receiver.slot)
+ obj.emitSignalWithTypedefValue(2)
+ self.assertEqual(receiver.received.value, 2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/pysidetest/typesystem_pysidetest.xml b/tests/pysidetest/typesystem_pysidetest.xml
index 88cbf03af..5077f6b26 100644
--- a/tests/pysidetest/typesystem_pysidetest.xml
+++ b/tests/pysidetest/typesystem_pysidetest.xml
@@ -2,6 +2,8 @@
<typesystem package="testbinding">
<load-typesystem name="typesystem_core.xml" generate="no" />
<load-typesystem name="typesystem_gui.xml" generate="no"/>
+ <value-type name="IntValue"/>
+ <primitive-type name="TypedefValue"/>
<object-type name="TestObject" />
<inject-code position="end">