Create unit test for bug #816.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
b2982dccc5
commit
b3a3a29363
3 changed files with 27 additions and 1 deletions
|
|
@ -72,7 +72,7 @@ target_link_libraries(testbinding
|
||||||
|
|
||||||
add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest)
|
add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest)
|
||||||
|
|
||||||
|
PYSIDE_TEST(application_test.py)
|
||||||
PYSIDE_TEST(decoratedslot_test.py)
|
PYSIDE_TEST(decoratedslot_test.py)
|
||||||
PYSIDE_TEST(delegatecreateseditor_test.py)
|
PYSIDE_TEST(delegatecreateseditor_test.py)
|
||||||
PYSIDE_TEST(homonymoussignalandmethod_test.py)
|
PYSIDE_TEST(homonymoussignalandmethod_test.py)
|
||||||
|
|
|
||||||
23
tests/pysidetest/application_test.py
Normal file
23
tests/pysidetest/application_test.py
Normal file
|
|
@ -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()
|
||||||
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define TESTOBJECT_H
|
#define TESTOBJECT_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QApplication>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#ifdef pysidetest_EXPORTS
|
#ifdef pysidetest_EXPORTS
|
||||||
#define PYSIDE_EXPORTS 1
|
#define PYSIDE_EXPORTS 1
|
||||||
|
|
@ -12,6 +13,8 @@ class PYSIDE_API TestObject : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
static void createApp() { int argc=0; new QApplication(argc, 0); };
|
||||||
|
|
||||||
TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {}
|
TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {}
|
||||||
int idValue() const { return m_idValue; }
|
int idValue() const { return m_idValue; }
|
||||||
static int staticMethodDouble(int value) { return value * 2; }
|
static int staticMethodDouble(int value) { return value * 2; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue