From 6a2df2daa4e1efc5b7e6e5946c96a528ec9b7248 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 29 Jul 2010 15:02:48 -0300 Subject: Added test case for signal signature received by QObject::connectNotify(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Luciano Wolf Reviewed by Renato Araújo --- tests/signals/CMakeLists.txt | 3 ++- tests/signals/signal_signature_test.py | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/signals/signal_signature_test.py (limited to 'tests/signals') diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index e09be0e65..eda247d25 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -3,6 +3,7 @@ PYSIDE_TEST(decorators_test.py) PYSIDE_TEST(invalid_callback_test.py) PYSIDE_TEST(lambda_gui_test.py) PYSIDE_TEST(lambda_test.py) +PYSIDE_TEST(list_signal_test.py) PYSIDE_TEST(multiple_connections_gui_test.py) PYSIDE_TEST(multiple_connections_test.py) PYSIDE_TEST(pysignal_test.py) @@ -26,8 +27,8 @@ PYSIDE_TEST(signal_emission_test.py) PYSIDE_TEST(signal_func_test.py) PYSIDE_TEST(signal_manager_refcount_test.py) PYSIDE_TEST(signal_object_test.py) +PYSIDE_TEST(signal_signature_test.py) PYSIDE_TEST(signal_with_primitive_type_test.py) PYSIDE_TEST(slot_reference_count_test.py) PYSIDE_TEST(static_metaobject_test.py) PYSIDE_TEST(upstream_segfault_test.py) -PYSIDE_TEST(list_signal_test.py) diff --git a/tests/signals/signal_signature_test.py b/tests/signals/signal_signature_test.py new file mode 100644 index 000000000..785ebb806 --- /dev/null +++ b/tests/signals/signal_signature_test.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +'''Test case for signal signature received by QObject::connectNotify().''' + +import unittest +from PySide.QtCore import * +from helper import UsesQCoreApplication + +class Obj(QObject): + def __init__(self): + QObject.__init__(self) + self.signal = '' + + def connectNotify(self, signal): + self.signal = signal + +def callback(): + pass + +class TestConnectNotifyWithNewStyleSignals(UsesQCoreApplication): + '''Test case for signal signature received by QObject::connectNotify().''' + + def testOldStyle(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL('destroyed()'), receiver, SLOT('deleteLater()')) + self.assertEqual(sender.signal, SIGNAL('destroyed()')) + + def testOldStyleWithPythonCallback(self): + sender = Obj() + sender.connect(SIGNAL('destroyed()'), callback) + self.assertEqual(sender.signal, SIGNAL('destroyed()')) + + def testNewStyle(self): + sender = Obj() + sender.destroyed.connect(callback) + self.assertEqual(sender.signal, SIGNAL('destroyed(QObject*)')) + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.3