diff options
Diffstat (limited to 'sources/pyside6/tests')
| -rw-r--r-- | sources/pyside6/tests/QtWidgets/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | sources/pyside6/tests/QtWidgets/qfontdialog_test.py | 39 |
2 files changed, 34 insertions, 8 deletions
diff --git a/sources/pyside6/tests/QtWidgets/CMakeLists.txt b/sources/pyside6/tests/QtWidgets/CMakeLists.txt index 9bb2fad67..57d8c5c9d 100644 --- a/sources/pyside6/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside6/tests/QtWidgets/CMakeLists.txt @@ -87,8 +87,7 @@ PYSIDE_TEST(qapplication_exit_segfault_test.py) PYSIDE_TEST(pyside3069.py) PYSIDE_TEST(qdialog_test.py) PYSIDE_TEST(qdynamic_signal.py) -# TODO: This passes, but requires manual button clicking (at least on mac) -#PYSIDE_TEST(qfontdialog_test.py) +PYSIDE_TEST(qfontdialog_test.py) PYSIDE_TEST(qformlayout_test.py) PYSIDE_TEST(qgraphicsitem_test.py) PYSIDE_TEST(qgraphicsitem_isblocked_test.py) diff --git a/sources/pyside6/tests/QtWidgets/qfontdialog_test.py b/sources/pyside6/tests/QtWidgets/qfontdialog_test.py index dd4209d10..d9868a9eb 100644 --- a/sources/pyside6/tests/QtWidgets/qfontdialog_test.py +++ b/sources/pyside6/tests/QtWidgets/qfontdialog_test.py @@ -11,21 +11,48 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) +from PySide6.QtCore import QTimer from PySide6.QtGui import QFont -from PySide6.QtWidgets import QFontDialog +from PySide6.QtWidgets import QApplication, QDialog, QFontDialog from helper.timedqapplication import TimedQApplication +def is_exposed(widget): + result = False + if widget.isVisible(): + handle = widget.windowHandle() + if handle: + result = handle.isExposed() + return result + + class TestFontDialog(TimedQApplication): - def testGetFont(self): - QFontDialog.getFont() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._timer = None + + def setUp(self, timeout=100): + super().setUp(timeout) + if not self._timer: + self._timer = QTimer() + self._timer.setInterval(50) + self._timer.timeout.connect(self._timer_handler) + self._timer.start() - def testGetFontQDialog(self): - QFontDialog.getFont(QFont("FreeSans", 10)) + def _timer_handler(self): + """Periodically check for the dialog to appear and close it.""" + for widget in QApplication.topLevelWidgets(): + if isinstance(widget, QDialog) and is_exposed(widget): + widget.accept() def testGetFontQDialogQString(self): - QFontDialog.getFont(QFont("FreeSans", 10), None, "Select font") + r = QFontDialog.getFont(QFont("FreeSans", 10), None, "Select font", + QFontDialog.FontDialogOption.DontUseNativeDialog) + self.assertTrue(type(r) is tuple) + self.assertEqual(len(r), 2) + self.assertTrue(r[0]) + self.assertTrue(type(r[1]) is QFont) if __name__ == '__main__': |
