Screenshots in bitmessageqt tests #1738
|
@ -18,5 +18,5 @@ install:
|
||||||
- export PYTHONWARNINGS=all
|
- export PYTHONWARNINGS=all
|
||||||
script:
|
script:
|
||||||
- python checkdeps.py
|
- python checkdeps.py
|
||||||
- xvfb-run src/bitmessagemain.py -t
|
- python src/bitmessagemain.py -t
|
||||||
- python -bm tests
|
- python -bm tests
|
||||||
|
|
|
@ -2,3 +2,4 @@ coverage
|
||||||
python_prctl
|
python_prctl
|
||||||
psutil
|
psutil
|
||||||
pycrypto
|
pycrypto
|
||||||
|
xvfbwrapper;platform_system=="Linux"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import Queue
|
import Queue
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
@ -23,6 +24,22 @@ class TestBase(unittest.TestCase):
|
||||||
self.window = bitmessageqt.MyForm()
|
self.window = bitmessageqt.MyForm()
|
||||||
self.window.appIndicatorInit(self.app)
|
self.window.appIndicatorInit(self.app)
|
||||||
|
|
||||||
|
def take_screenshot(self, window=None):
|
||||||
|
"""Take a screenshot of the *window* or main window if not set"""
|
||||||
|
def save_screenshot():
|
||||||
|
"""Save screenshot and quit app clause"""
|
||||||
|
screenshot = QtGui.QPixmap.grabWindow(
|
||||||
|
self.app.desktop().winId())
|
||||||
|
screenshot.save(os.path.join(
|
||||||
|
bitmessageqt.state.appdata, '%s.png' % self.id()))
|
||||||
|
self.app.quit()
|
||||||
|
|
||||||
|
timer = QtCore.QTimer()
|
||||||
|
timer.timeout.connect(save_screenshot)
|
||||||
|
timer.start(200)
|
||||||
|
(window or self.window).show()
|
||||||
|
self.app.exec_()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# self.app.deleteLater()
|
# self.app.deleteLater()
|
||||||
while True:
|
while True:
|
||||||
|
@ -55,6 +72,4 @@ class TestUISignaler(TestBase):
|
||||||
_translate("test", "Testing updateStatusBar..."), 1)
|
_translate("test", "Testing updateStatusBar..."), 1)
|
||||||
))
|
))
|
||||||
|
|
||||||
QtCore.QTimer.singleShot(60, self.app.quit)
|
self.take_screenshot()
|
||||||
self.app.exec_()
|
|
||||||
# self.app.processEvents(QtCore.QEventLoop.AllEvents, 60)
|
|
||||||
|
|
|
@ -31,3 +31,5 @@ class TestSupport(TestBase):
|
||||||
ui.lineEditSubject.text(), self.SUPPORT_SUBJECT)
|
ui.lineEditSubject.text(), self.SUPPORT_SUBJECT)
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
sys.version, ui.textEditMessage.toPlainText())
|
sys.version, ui.textEditMessage.toPlainText())
|
||||||
|
|
||||||
|
self.take_screenshot()
|
||||||
|
|
|
@ -3,6 +3,7 @@ Tests for core and those that do not work outside
|
||||||
(because of import error for example)
|
(because of import error for example)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import atexit
|
||||||
import os
|
import os
|
||||||
import pickle # nosec
|
import pickle # nosec
|
||||||
import Queue
|
import Queue
|
||||||
|
@ -398,8 +399,9 @@ def run():
|
||||||
suite = loader.loadTestsFromTestCase(TestCore)
|
suite = loader.loadTestsFromTestCase(TestCore)
|
||||||
try:
|
try:
|
||||||
import bitmessageqt.tests
|
import bitmessageqt.tests
|
||||||
|
from xvfbwrapper import Xvfb
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
Xvfb = None
|
||||||
else:
|
else:
|
||||||
qt_tests = loader.loadTestsFromModule(bitmessageqt.tests)
|
qt_tests = loader.loadTestsFromModule(bitmessageqt.tests)
|
||||||
suite.addTests(qt_tests)
|
suite.addTests(qt_tests)
|
||||||
|
@ -410,4 +412,8 @@ def run():
|
||||||
|
|
||||||
sys.excepthook = keep_exc
|
sys.excepthook = keep_exc
|
||||||
|
|
||||||
|
if Xvfb:
|
||||||
|
vdisplay = Xvfb(width=1024, height=768)
|
||||||
|
vdisplay.start()
|
||||||
|
atexit.register(vdisplay.stop)
|
||||||
return unittest.TextTestRunner(verbosity=2).run(suite)
|
return unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
|
Reference in New Issue
Block a user