diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-04-11 18:44:57 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:09 -0300 |
commit | b3a3a293635281c0e55ee016e3dab77d465d5bb3 (patch) | |
tree | ab562c7edc63d93ede30fffa8389a9c58eadc9d8 /tests/pysidetest | |
parent | b2982dccc5079395231450c21d26a2fc27c32940 (diff) |
Create unit test for bug #816.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/pysidetest')
-rw-r--r-- | tests/pysidetest/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/pysidetest/application_test.py | 23 | ||||
-rw-r--r-- | tests/pysidetest/testobject.h | 3 |
3 files changed, 27 insertions, 1 deletions
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 964d70d07..caa5019bb 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -72,7 +72,7 @@ target_link_libraries(testbinding add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest) - +PYSIDE_TEST(application_test.py) PYSIDE_TEST(decoratedslot_test.py) PYSIDE_TEST(delegatecreateseditor_test.py) PYSIDE_TEST(homonymoussignalandmethod_test.py) diff --git a/tests/pysidetest/application_test.py b/tests/pysidetest/application_test.py new file mode 100644 index 000000000..39a828379 --- /dev/null +++ b/tests/pysidetest/application_test.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +import unittest +from testbinding import TestObject +from PySide.QtGui import QApplication + +class QApplicationInstance(unittest.TestCase): + + def appDestroyed(self): + sefl.assert_(False) + + def testInstanceObject(self): + TestObject.createApp() + app1 = QApplication.instance() + app2 = QApplication.instance() + app1.setObjectName("MyApp") + self.assertEqual(app1, app2) + self.assertEqual(app2.objectName(), app1.objectName()) + app1.destroyed.connect(self.appDestroyed) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/pysidetest/testobject.h b/tests/pysidetest/testobject.h index ca662d70e..f2cdd5a2b 100644 --- a/tests/pysidetest/testobject.h +++ b/tests/pysidetest/testobject.h @@ -2,6 +2,7 @@ #define TESTOBJECT_H #include <QObject> +#include <QApplication> #include <QMetaType> #ifdef pysidetest_EXPORTS #define PYSIDE_EXPORTS 1 @@ -12,6 +13,8 @@ class PYSIDE_API TestObject : public QObject { Q_OBJECT public: + static void createApp() { int argc=0; new QApplication(argc, 0); }; + TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {} int idValue() const { return m_idValue; } static int staticMethodDouble(int value) { return value * 2; } |