summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2011-08-09 15:28:06 -0300
committerLauro Neto <lauro.neto@openbossa.org>2011-08-10 14:03:59 -0300
commitd64e0a5567ef1a087f2e98508b4a7d63394ab5a8 (patch)
tree6e273e672f2458a50e0f2db69dc9a5d2ed9a5575
parentca1c387257a755348654d46fe19a08cd10401c8a (diff)
downloadpyside-d64e0a5567ef1a087f2e98508b4a7d63394ab5a8.tar.gz
pyside-d64e0a5567ef1a087f2e98508b4a7d63394ab5a8.tar.xz
pyside-d64e0a5567ef1a087f2e98508b4a7d63394ab5a8.zip
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 940f8c4..807463d 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 6911334..1130750 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 e2c0fc1..e37bca8 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 0000000..c2cdd12
--- /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 88cbf03..5077f6b 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">