|
2 | 2 | import threading |
3 | 3 | import time |
4 | 4 |
|
5 | | -from main import TestBase |
| 5 | +from PyQt4 import QtCore, QtGui, QtTest |
| 6 | + |
6 | 7 | from bmconfigparser import config |
7 | 8 | from bitmessageqt import settings |
8 | 9 |
|
| 10 | +from .main import TestBase |
| 11 | + |
9 | 12 |
|
10 | 13 | class TestSettings(TestBase): |
11 | 14 | """A test case for the "Settings" dialog""" |
@@ -41,13 +44,34 @@ def test_styling(self): |
41 | 44 | self.assertIs(font_setting, None) |
42 | 45 | style_control = self.dialog.comboBoxStyle |
43 | 46 | self.assertEqual(style_control.currentText(), 'GTK+') |
| 47 | + |
| 48 | + def call_font_dialog(): |
| 49 | + """A function to get the open font dialog and accept it""" |
| 50 | + font_dialog = QtGui.QApplication.activeModalWidget() |
| 51 | + self.assertTrue(isinstance(font_dialog, QtGui.QFontDialog)) |
| 52 | + selected_font = font_dialog.currentFont() |
| 53 | + self.assertEqual( |
| 54 | + config.safeGet('bitmessagesettings', 'font'), '{},{}'.format( |
| 55 | + selected_font.family(), selected_font.pointSize())) |
| 56 | + |
| 57 | + font_dialog.accept() |
| 58 | + self.dialog.accept() |
| 59 | + self.assertEqual( |
| 60 | + config.safeGet('bitmessagesettings', 'windowstyle'), |
| 61 | + style_control.currentText()) |
| 62 | + |
| 63 | + def click_font_button(): |
| 64 | + """Use QtTest to click the button""" |
| 65 | + QtTest.QTest.mouseClick( |
| 66 | + self.dialog.buttonFont, QtCore.Qt.LeftButton) |
| 67 | + |
44 | 68 | style_count = style_control.count() |
45 | 69 | self.assertGreater(style_count, 1) |
46 | 70 | for i in range(style_count): |
47 | 71 | if i != style_control.currentIndex(): |
48 | 72 | style_control.setCurrentIndex(i) |
49 | 73 | break |
50 | | - self.dialog.accept() |
51 | | - self.assertEqual( |
52 | | - config.safeGet('bitmessagesettings', 'windowstyle'), |
53 | | - style_control.currentText()) |
| 74 | + |
| 75 | + QtCore.QTimer.singleShot(30, click_font_button) |
| 76 | + QtCore.QTimer.singleShot(60, call_font_dialog) |
| 77 | + time.sleep(2) |
0 commit comments