diff --git a/src/bitmessageqt/tests/__init__.py b/src/bitmessageqt/tests/__init__.py index 3955a761..199438f9 100644 --- a/src/bitmessageqt/tests/__init__.py +++ b/src/bitmessageqt/tests/__init__.py @@ -1,6 +1,6 @@ """bitmessageqt tests""" -from main import TestMain +from main import TestMain, TestUISignaler from support import TestSupport -__all__ = ["TestMain", "TestSupport"] +__all__ = ["TestMain", "TestSupport", "TestUISignaler"] diff --git a/src/bitmessageqt/tests/main.py b/src/bitmessageqt/tests/main.py index d2a64f83..b3aa67fa 100644 --- a/src/bitmessageqt/tests/main.py +++ b/src/bitmessageqt/tests/main.py @@ -1,10 +1,13 @@ """Common definitions for bitmessageqt tests""" +import Queue +import sys import unittest from PyQt4 import QtCore, QtGui import bitmessageqt +import queues from tr import _translate @@ -12,11 +15,23 @@ class TestBase(unittest.TestCase): """Base class for bitmessageqt test case""" def setUp(self): - self.app = QtGui.QApplication([]) - self.window = bitmessageqt.MyForm() + self.app = ( + QtGui.QApplication.instance() + or bitmessageqt.BitmessageQtApplication(sys.argv)) + self.window = self.app.activeWindow() + if not self.window: + self.window = bitmessageqt.MyForm() + self.window.appIndicatorInit(self.app) def tearDown(self): - self.app.deleteLater() + # self.app.deleteLater() + while True: + try: + thread, exc = queues.excQueue.get(block=False) + except Queue.Empty: + return + if thread == 'tests': + self.fail('Exception in the main thread: %s' % exc) class TestMain(unittest.TestCase): @@ -28,3 +43,18 @@ class TestMain(unittest.TestCase): _translate("MainWindow", "Test"), QtCore.QString ) + + +class TestUISignaler(TestBase): + """Test case for UISignalQueue""" + + def test_updateStatusBar(self): + """Check arguments order of updateStatusBar command""" + queues.UISignalQueue.put(( + 'updateStatusBar', ( + _translate("test", "Testing updateStatusBar..."), 1) + )) + + QtCore.QTimer.singleShot(60, self.app.quit) + self.app.exec_() + # self.app.processEvents(QtCore.QEventLoop.AllEvents, 60)