diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2010-12-22 16:14:47 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:48:04 -0300 |
commit | 2734efb6b704c53bab64168be49ce06d6b5a03da (patch) | |
tree | b6f0464f4f23357199177609a21ea744e3d8cbaa | |
parent | d3b630e1682c89ee427964d81c32219c14863b1d (diff) |
Moved list_signal_test to pysidetest library.
This isolate the test case, and avoid other problems with X during the
buildbot compilation.
Reviewer: Lauro Moura <lauro.neto@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r-- | tests/pysidetest/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/pysidetest/list_signal_test.py | 23 | ||||
-rw-r--r-- | tests/pysidetest/testobject.h | 3 | ||||
-rw-r--r-- | tests/signals/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/signals/list_signal_test.py | 35 |
5 files changed, 27 insertions, 36 deletions
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 4a4c27aa0..b3215bc78 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -76,4 +76,5 @@ PYSIDE_TEST(homonymoussignalandmethod_test.py) PYSIDE_TEST(delegatecreateseditor_test.py) PYSIDE_TEST(modelview_test.py) PYSIDE_TEST(version_test.py) +PYSIDE_TEST(list_signal_test.py) diff --git a/tests/pysidetest/list_signal_test.py b/tests/pysidetest/list_signal_test.py new file mode 100644 index 000000000..36d3c21d2 --- /dev/null +++ b/tests/pysidetest/list_signal_test.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import unittest +from testbinding import TestObject +from PySide.QtCore import QObject + +class ListConnectionTest(unittest.TestCase): + + def childrenChanged(self, children): + self._child = children[0] + + def testConnection(self): + o = TestObject(0) + c = QObject() + c.setObjectName("child") + self._child = None + o.childrenChanged.connect(self.childrenChanged) + o.addChild(c) + self.assertEquals(self._child.objectName(), "child") + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/pysidetest/testobject.h b/tests/pysidetest/testobject.h index 901235931..d88287045 100644 --- a/tests/pysidetest/testobject.h +++ b/tests/pysidetest/testobject.h @@ -14,6 +14,7 @@ public: 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; } + void addChild(QObject* c) { m_children.append(c); emit childrenChanged(m_children); } void emitIdValueSignal(); void emitStaticMethodDoubleSignal(); @@ -22,9 +23,11 @@ signals: void idValue(int newValue); void justASignal(); void staticMethodDouble(); + void childrenChanged(const QList<QObject*>); private: int m_idValue; + QList<QObject*> m_children; }; #endif // TESTOBJECT_H diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index cad84f1a0..c9ef33e83 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -6,7 +6,6 @@ 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(leaking_signal_test.py) PYSIDE_TEST(multiple_connections_gui_test.py) PYSIDE_TEST(multiple_connections_test.py) diff --git a/tests/signals/list_signal_test.py b/tests/signals/list_signal_test.py deleted file mode 100644 index c65eb114f..000000000 --- a/tests/signals/list_signal_test.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -import unittest - -from PySide.QtCore import * -from PySide.QtGui import * - -class ListConnectionTest(unittest.TestCase): - - def modifyScene(self): - self.scene.addLine(0, 0, 10, 10) - - def sceneChanged(self, rects): - # Qt isn't so cute and sends this signal with empty lists and null rects sometimes. - if len(rects) > 0 and not rects[0].isNull(): - self.rects = rects - QApplication.quit() - - def testConnection(self): - app = QApplication([]) - - self.scene = QGraphicsScene() - QTimer.singleShot(0, self.modifyScene) - self.scene.changed.connect(self.sceneChanged) - - app.exec_() - self.assertEquals(len(self.rects), 1) - self.assertEquals(self.rects[0].x(), 0) - self.assertEquals(self.rects[0].y(), 0) - self.assertEquals(self.rects[0].width(), 10) - self.assertEquals(self.rects[0].height(), 10) - -if __name__ == '__main__': - unittest.main() - |