Use QtTest and QTimer.singleShot() to check the font dialog
This commit is contained in:
parent
d46af0835a
commit
c3c41902cf
|
@ -2,10 +2,13 @@
|
|||
import threading
|
||||
import time
|
||||
|
||||
from main import TestBase
|
||||
from PyQt4 import QtCore, QtGui, QtTest
|
||||
|
||||
from bmconfigparser import config
|
||||
from bitmessageqt import settings
|
||||
|
||||
from .main import TestBase
|
||||
|
||||
|
||||
class TestSettings(TestBase):
|
||||
"""A test case for the "Settings" dialog"""
|
||||
|
@ -41,13 +44,34 @@ class TestSettings(TestBase):
|
|||
self.assertIs(font_setting, None)
|
||||
style_control = self.dialog.comboBoxStyle
|
||||
self.assertEqual(style_control.currentText(), 'GTK+')
|
||||
|
||||
def call_font_dialog():
|
||||
"""A function to get the open font dialog and accept it"""
|
||||
font_dialog = QtGui.QApplication.activeModalWidget()
|
||||
self.assertTrue(isinstance(font_dialog, QtGui.QFontDialog))
|
||||
selected_font = font_dialog.currentFont()
|
||||
self.assertEqual(
|
||||
config.safeGet('bitmessagesettings', 'font'), '{},{}'.format(
|
||||
selected_font.family(), selected_font.pointSize()))
|
||||
|
||||
font_dialog.accept()
|
||||
self.dialog.accept()
|
||||
self.assertEqual(
|
||||
config.safeGet('bitmessagesettings', 'windowstyle'),
|
||||
style_control.currentText())
|
||||
|
||||
def click_font_button():
|
||||
"""Use QtTest to click the button"""
|
||||
QtTest.QTest.mouseClick(
|
||||
self.dialog.buttonFont, QtCore.Qt.LeftButton)
|
||||
|
||||
style_count = style_control.count()
|
||||
self.assertGreater(style_count, 1)
|
||||
for i in range(style_count):
|
||||
if i != style_control.currentIndex():
|
||||
style_control.setCurrentIndex(i)
|
||||
break
|
||||
self.dialog.accept()
|
||||
self.assertEqual(
|
||||
config.safeGet('bitmessagesettings', 'windowstyle'),
|
||||
style_control.currentText())
|
||||
|
||||
QtCore.QTimer.singleShot(30, click_font_button)
|
||||
QtCore.QTimer.singleShot(60, call_font_dialog)
|
||||
time.sleep(2)
|
||||
|
|
Reference in New Issue
Block a user