aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/thread_signals_test.py
blob: 1d2f75062f04f0839d0875e0a196f56abfd57b5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

''' Test case for QObject.signalsBlocked() and blockSignal()'''

import unittest
import os
from tempfile import mkstemp

from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt
from helper import UsesQCoreApplication

class MyThread(QThread):

    def run(self):
        self.emit(SIGNAL("test(const QString&)"), "INdT - PySide");

class TestThreadSignal(UsesQCoreApplication):

    __called__ = True
    def _callback(self, msg):
        self.assertEqual(msg, "INdT - PySide")
        self.__called__ = True
        self.app.quit()

    def testThread(self):
        t = MyThread()
        QObject.connect(t, SIGNAL("test(const QString&)"), self._callback);
        t.start()

        self.app.exec_()
        t.wait()
        self.assert_(self.__called__);

if __name__ == '__main__':
    unittest.main()