A test for updateStatusBar command

This commit is contained in:
Dmitri Bogomolov 2020-10-09 17:55:21 +03:00
parent 695140d57d
commit caf3a3fbbc
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 35 additions and 5 deletions

View File

@ -1,6 +1,6 @@
"""bitmessageqt tests""" """bitmessageqt tests"""
from main import TestMain from main import TestMain, TestUISignaler
from support import TestSupport from support import TestSupport
__all__ = ["TestMain", "TestSupport"] __all__ = ["TestMain", "TestSupport", "TestUISignaler"]

View File

@ -1,10 +1,13 @@
"""Common definitions for bitmessageqt tests""" """Common definitions for bitmessageqt tests"""
import Queue
import sys
import unittest import unittest
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import bitmessageqt import bitmessageqt
import queues
from tr import _translate from tr import _translate
@ -12,11 +15,23 @@ class TestBase(unittest.TestCase):
"""Base class for bitmessageqt test case""" """Base class for bitmessageqt test case"""
def setUp(self): def setUp(self):
self.app = QtGui.QApplication([]) 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 = bitmessageqt.MyForm()
self.window.appIndicatorInit(self.app)
def tearDown(self): 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): class TestMain(unittest.TestCase):
@ -28,3 +43,18 @@ class TestMain(unittest.TestCase):
_translate("MainWindow", "Test"), _translate("MainWindow", "Test"),
QtCore.QString 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)