Adding new-style signal/slot tests.
Based on Marcelo Lira's source code.
Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>,
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
16809db86b
commit
9a8bc9c3d1
6 changed files with 254 additions and 0 deletions
47
tests/signals/ref02_test.py
Executable file
47
tests/signals/ref02_test.py
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
from PySide.QtCore import QCoreApplication, QTimeLine
|
||||
from helper import UsesQCoreApplication
|
||||
|
||||
class NativeSignalsTest(UsesQCoreApplication):
|
||||
|
||||
def setUp(self):
|
||||
UsesQCoreApplication.setUp(self)
|
||||
self.called = False
|
||||
self.timeline = QTimeLine(100)
|
||||
|
||||
def tearDown(self):
|
||||
del self.called
|
||||
del self.timeline
|
||||
UsesQCoreApplication.tearDown(self)
|
||||
|
||||
def testSignalWithIntArgument(self):
|
||||
|
||||
def valueChangedSlot(value):
|
||||
self.called = True
|
||||
self.assertEqual(type(value), float)
|
||||
self.app.quit()
|
||||
|
||||
self.timeline.valueChanged.connect(valueChangedSlot)
|
||||
self.timeline.start()
|
||||
|
||||
self.app.exec_()
|
||||
self.assert_(self.called)
|
||||
|
||||
def testSignalWithoutArguments(self):
|
||||
|
||||
def finishedSlot():
|
||||
self.called = True
|
||||
self.app.quit()
|
||||
|
||||
self.timeline.finished.connect(finishedSlot)
|
||||
self.timeline.start()
|
||||
|
||||
self.app.exec_()
|
||||
self.assert_(self.called)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue