2
'''Test cases for connecting signals between threads'''
6
from PySide.QtCore import QThread, QObject, SIGNAL, QCoreApplication
10
class Source(QObject):
11
def __init__(self, *args):
12
QObject.__init__(self, *args)
15
self.emit(SIGNAL('source()'))
17
class Target(QObject):
18
def __init__(self, *args):
19
QObject.__init__(self, *args)
25
class ThreadJustConnects(QThread):
26
def __init__(self, source, *args):
27
QThread.__init__(self, *args)
29
self.target = Target()
34
QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)
36
while not self.target.called:
41
class BasicConnection(unittest.TestCase):
43
def testEmitOutsideThread(self):
46
app = QCoreApplication([])
48
thread = ThreadJustConnects(source)
50
QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0))
61
self.assert_(thread.target.called)
63
if __name__ == '__main__':