diff options
Diffstat (limited to 'sources/pyside6/tests/QtGui')
34 files changed, 209 insertions, 112 deletions
diff --git a/sources/pyside6/tests/QtGui/CMakeLists.txt b/sources/pyside6/tests/QtGui/CMakeLists.txt index c5b0c473c..71a5c7eb9 100644 --- a/sources/pyside6/tests/QtGui/CMakeLists.txt +++ b/sources/pyside6/tests/QtGui/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #Keep this in alphabetical sort PYSIDE_TEST(bug_367.py) diff --git a/sources/pyside6/tests/QtGui/QtGui.pyproject b/sources/pyside6/tests/QtGui/QtGui.pyproject new file mode 100644 index 000000000..75b5e084f --- /dev/null +++ b/sources/pyside6/tests/QtGui/QtGui.pyproject @@ -0,0 +1,56 @@ +{ + "files": ["bug_1091.py", + "bug_367.py", + "bug_493.py", + "bug_606.py", + "bug_617.py", + "bug_652.py", + "bug_660.py", + "bug_716.py", + "bug_740.py", + "bug_743.py", + "bug_785.py", + "bug_991.py", + "bug_PYSIDE-344.py", + "deepcopy_test.py", + "event_filter_test.py", + "float_to_int_implicit_conversion_test.py", + "pyside_reload_test.py", + "qbrush_test.py", + "qcolor_reduce_test.py", + "qcolor_test.py", + "qcursor_test.py", + "qdatastream_gui_operators_test.py", + "qdesktopservices_test.py", + "qfont_test.py", + "qfontmetrics_test.py", + "qguiapplication_test.py", + "qicon_test.py", + "qimage_test.py", + "qimage_win_test.py", + "qitemselection_test.py", + "qkeysequence_test.py", + "qpainter_test.py", + "qpdfwriter_test.py", + "qpen_test.py", + "qpixelformat_test.py", + "qpixmap_constructor.py", + "qpixmap_test.py", + "qpixmapcache_test.py", + "qpolygonf_test.py", + "qradialgradient_test.py", + "qrasterwindow_test.py", + "qregion_test.py", + "qshortcut_test.py", + "qstandarditemmodel_test.py", + "qstring_qkeysequence_test.py", + "qstylehints_test.py", + "qtextdocument_functions.py", + "qtextdocument_undoredo_test.py", + "qtextdocumentwriter_test.py", + "qtextline_test.py", + "qtransform_test.py", + "repr_test.py", + "timed_app_and_patching_test.py", + "xpm_data.py"] +} diff --git a/sources/pyside6/tests/QtGui/bug_367.py b/sources/pyside6/tests/QtGui/bug_367.py index facf9179c..771fa5a4b 100644 --- a/sources/pyside6/tests/QtGui/bug_367.py +++ b/sources/pyside6/tests/QtGui/bug_367.py @@ -12,11 +12,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QStandardItem, QStandardItemModel -class BugTest(UsesQGuiApplication): +class BugTest(UsesQApplication): @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testCase(self): model = QStandardItemModel() diff --git a/sources/pyside6/tests/QtGui/bug_617.py b/sources/pyside6/tests/QtGui/bug_617.py index a6487768b..d90d1e754 100644 --- a/sources/pyside6/tests/QtGui/bug_617.py +++ b/sources/pyside6/tests/QtGui/bug_617.py @@ -16,12 +16,7 @@ from PySide6.QtGui import QColor class MyEvent(QEvent): def __init__(self): - if sys.pyside63_option_python_enum: - # PYSIDE-1735: Python Enum: We cannot assign arbitrary numbers. - # They must exist as constants in the type. - QEvent.__init__(self, QEvent.Type(1000)) - else: - QEvent.__init__(self, QEvent.Type(999)) + QEvent.__init__(self, QEvent.Type(999)) class Bug617(unittest.TestCase): @@ -32,8 +27,7 @@ class Bug617(unittest.TestCase): def testOutOfBounds(self): e = MyEvent() - self.assertEqual(repr(e.type()), "<Type.User: 1000>" - if sys.pyside63_option_python_enum else "PySide6.QtCore.QEvent.Type(999)") + self.assertEqual(repr(e.type()), "<Type.999: 999>") if __name__ == "__main__": diff --git a/sources/pyside6/tests/QtGui/bug_740.py b/sources/pyside6/tests/QtGui/bug_740.py index c88c48069..ece314cc8 100644 --- a/sources/pyside6/tests/QtGui/bug_740.py +++ b/sources/pyside6/tests/QtGui/bug_740.py @@ -10,12 +10,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QSize from PySide6.QtGui import QBitmap, QImage -class TestQBitmap(UsesQGuiApplication): +class TestQBitmap(UsesQApplication): def testFromDataMethod(self): dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8") bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function diff --git a/sources/pyside6/tests/QtGui/event_filter_test.py b/sources/pyside6/tests/QtGui/event_filter_test.py index c26e74926..01d8fbc02 100644 --- a/sources/pyside6/tests/QtGui/event_filter_test.py +++ b/sources/pyside6/tests/QtGui/event_filter_test.py @@ -10,7 +10,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QObject, QEvent from PySide6.QtGui import QWindow @@ -22,7 +22,7 @@ class MyFilter(QObject): return QObject.eventFilter(self, obj, event) -class EventFilter(UsesQGuiApplication): +class EventFilter(UsesQApplication): @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testRefCount(self): o = QObject() diff --git a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py index f06c6177b..ba438f8e0 100644 --- a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py +++ b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py @@ -15,10 +15,10 @@ init_test_paths(False) from PySide6.QtGui import QImage, qRgb -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class SetPixelFloat(UsesQGuiApplication): +class SetPixelFloat(UsesQApplication): '''Test case for calling setPixel with float as argument''' def setUp(self): diff --git a/sources/pyside6/tests/QtGui/qbrush_test.py b/sources/pyside6/tests/QtGui/qbrush_test.py index ca685b9b6..69262328b 100644 --- a/sources/pyside6/tests/QtGui/qbrush_test.py +++ b/sources/pyside6/tests/QtGui/qbrush_test.py @@ -13,12 +13,12 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import Qt -from PySide6.QtGui import QColor, QBrush +from PySide6.QtGui import QColor, QBrush, QConicalGradient -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class Constructor(UsesQGuiApplication): +class Constructor(UsesQApplication): '''Test case for constructor of QBrush''' def testQColor(self): @@ -30,6 +30,14 @@ class Constructor(UsesQGuiApplication): obj = QBrush(Qt.blue) self.assertEqual(obj.color(), Qt.blue) + def testGradient(self): + """Test type discovery on class hierarchies with non-virtual + destructors by specifying a polymorphic-id-expression without + polymorphic-name-function.""" + gradient = QConicalGradient() + brush = QBrush(gradient) + self.assertEqual(type(brush.gradient()), type(gradient)) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcolor_test.py b/sources/pyside6/tests/QtGui/qcolor_test.py index 336d58f8e..bbd558f10 100644 --- a/sources/pyside6/tests/QtGui/qcolor_test.py +++ b/sources/pyside6/tests/QtGui/qcolor_test.py @@ -41,7 +41,7 @@ class QColorGetTest(unittest.TestCase): def testGetCmykF(self): # not supported by colorsys for x, y in zip(self.color.getCmykF(), (170 / 255.0, 85 / 255.0, 0, 195 / 255.0, 80 / 255.0)): - self.assertTrue(x - y < 1/10000.0) + self.assertTrue(x - y < 1 / 10000.0) class QColorQRgbConstructor(unittest.TestCase): diff --git a/sources/pyside6/tests/QtGui/qcursor_test.py b/sources/pyside6/tests/QtGui/qcursor_test.py index 6a540d73e..1494fe370 100644 --- a/sources/pyside6/tests/QtGui/qcursor_test.py +++ b/sources/pyside6/tests/QtGui/qcursor_test.py @@ -15,10 +15,10 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtGui import QBitmap, QCursor, QPixmap -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class TestQCursor(UsesQGuiApplication): +class TestQCursor(UsesQApplication): def testQCursorConstructor(self): bmp = QBitmap(16, 16) cursor = QCursor(bmp, bmp, 16, 16) diff --git a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py index 5687fba87..f2c86abf7 100644 --- a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py +++ b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py @@ -13,10 +13,10 @@ init_test_paths(False) from PySide6.QtCore import QDataStream, QByteArray, QIODevice, Qt from PySide6.QtGui import QPixmap, QColor -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QPixmapQDatastream(UsesQGuiApplication): +class QPixmapQDatastream(UsesQApplication): '''QDataStream <<>> QPixmap''' def setUp(self): diff --git a/sources/pyside6/tests/QtGui/qfont_test.py b/sources/pyside6/tests/QtGui/qfont_test.py index b6eeb27f3..f81d47ec6 100644 --- a/sources/pyside6/tests/QtGui/qfont_test.py +++ b/sources/pyside6/tests/QtGui/qfont_test.py @@ -11,10 +11,10 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtGui import QFont -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QFontTest(UsesQGuiApplication): +class QFontTest(UsesQApplication): def testStringConstruction(self): """PYSIDE-1685: Test that passing str to QFont works after addding diff --git a/sources/pyside6/tests/QtGui/qfontmetrics_test.py b/sources/pyside6/tests/QtGui/qfontmetrics_test.py index 069a41f7d..98c4c8f96 100644 --- a/sources/pyside6/tests/QtGui/qfontmetrics_test.py +++ b/sources/pyside6/tests/QtGui/qfontmetrics_test.py @@ -16,10 +16,10 @@ init_test_paths(False) from PySide6.QtGui import QFont, QFontMetrics, QFontMetricsF from PySide6.QtCore import QRect, QRectF, Qt, QSize, QSizeF -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QFontMetricsTest(UsesQGuiApplication): +class QFontMetricsTest(UsesQApplication): '''Base class for QFontMetrics tests''' def setUp(self): @@ -91,8 +91,8 @@ class BoundingRectTest(QFontMetricsTest): '''QFontMetrics.boundingRect(QRect, ...) - type error''' arg = QRect(0, 0, 100, 200) self.assertRaises(TypeError, self.metrics.boundingRect, arg, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) class SizeTest(QFontMetricsTest): @@ -123,7 +123,7 @@ class SizeTest(QFontMetricsTest): 'PySide by INdT', 20, ['aaaa', 'ase']) -class QFontMetricsFTest(UsesQGuiApplication): +class QFontMetricsFTest(UsesQApplication): '''Base class for QFontMetrics tests''' def setUp(self): @@ -196,8 +196,8 @@ class FSizeTest(QFontMetricsFTest): def testTypeError(self): '''QFontMetricsF.size - type error''' self.assertRaises(TypeError, self.metrics.size, - Qt.TextExpandTabs | Qt.AlignLeft, - 'PySide by INdT', 20, ['aaaa', 'ase']) + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) class QCharTest(QFontMetricsFTest): diff --git a/sources/pyside6/tests/QtGui/qicon_test.py b/sources/pyside6/tests/QtGui/qicon_test.py index 80fc5a56b..18ef3d815 100644 --- a/sources/pyside6/tests/QtGui/qicon_test.py +++ b/sources/pyside6/tests/QtGui/qicon_test.py @@ -26,6 +26,7 @@ class QIconCtorWithNoneTest(TimedQGuiApplication): PIX_PATH = os.fspath(Path(__file__).resolve().parents[2] / "doc/tutorials/basictutorial/icons.png") + class QIconAddPixmapTest(TimedQGuiApplication): '''PYSIDE-1669: check that addPixmap works''' diff --git a/sources/pyside6/tests/QtGui/qimage_test.py b/sources/pyside6/tests/QtGui/qimage_test.py index 595f85892..5912bf318 100644 --- a/sources/pyside6/tests/QtGui/qimage_test.py +++ b/sources/pyside6/tests/QtGui/qimage_test.py @@ -13,11 +13,11 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtGui import QImage -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from xpm_data import xpm -class QImageTest(UsesQGuiApplication): +class QImageTest(UsesQApplication): '''Test case for calling setPixel with float as argument''' def testQImageStringBuffer(self): diff --git a/sources/pyside6/tests/QtGui/qimage_win_test.py b/sources/pyside6/tests/QtGui/qimage_win_test.py index 34e4d0daf..2d9cb96f1 100644 --- a/sources/pyside6/tests/QtGui/qimage_win_test.py +++ b/sources/pyside6/tests/QtGui/qimage_win_test.py @@ -14,7 +14,7 @@ init_test_paths(False) from PySide6.QtCore import Qt from PySide6.QtGui import QImage -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication def create_image(): @@ -23,7 +23,7 @@ def create_image(): return result -class QImageWinTest(UsesQGuiApplication): +class QImageWinTest(UsesQApplication): def test_to_hbitmap(self): """Test conversion to/from a Windows HBITMAP.""" diff --git a/sources/pyside6/tests/QtGui/qitemselection_test.py b/sources/pyside6/tests/QtGui/qitemselection_test.py index 52ab589f2..179bff745 100644 --- a/sources/pyside6/tests/QtGui/qitemselection_test.py +++ b/sources/pyside6/tests/QtGui/qitemselection_test.py @@ -10,12 +10,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QItemSelection from PySide6.QtGui import QStandardItemModel -class QItemSelectionTest(UsesQGuiApplication): +class QItemSelectionTest(UsesQApplication): def testLen(self): model = QStandardItemModel(2, 2) model.insertRow(0) diff --git a/sources/pyside6/tests/QtGui/qkeysequence_test.py b/sources/pyside6/tests/QtGui/qkeysequence_test.py index 03c0ea1c5..3d72fb50a 100644 --- a/sources/pyside6/tests/QtGui/qkeysequence_test.py +++ b/sources/pyside6/tests/QtGui/qkeysequence_test.py @@ -11,29 +11,25 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import Qt -from PySide6.QtGui import QKeySequence +from PySide6.QtGui import QKeySequence, qt_set_sequence_auto_mnemonic -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QKeySequenceTest(UsesQGuiApplication): +class QKeySequenceTest(UsesQApplication): def testGetItemOperator(self): # bug #774 - if sys.pyside63_option_python_enum: - # PYSIDE-1735: Remapped from Qt.Modifier to Qt.KeyboardModifier - # Note that Qt.(Keyboard)?Modifier will be no longer IntFlag. - ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R) - self.assertEqual(ks[0].keyboardModifiers(), Qt.ShiftModifier) - self.assertEqual(ks[1].keyboardModifiers(), Qt.ControlModifier) - self.assertEqual(ks[2].key(), Qt.Key_P) - self.assertEqual(ks[3].key(), Qt.Key_R) - else: - ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R) - self.assertEqual(ks[0], Qt.SHIFT) - self.assertEqual(ks[1], Qt.CTRL) - self.assertEqual(ks[2], Qt.Key_P) - self.assertEqual(ks[3], Qt.Key_R) + # PYSIDE-1735: Remapped from Qt.Modifier to Qt.KeyboardModifier + # Note that Qt.(Keyboard)?Modifier will be no longer IntFlag. + ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R) + self.assertEqual(ks[0].keyboardModifiers(), Qt.ShiftModifier) + self.assertEqual(ks[1].keyboardModifiers(), Qt.ControlModifier) + self.assertEqual(ks[2].key(), Qt.Key_P) + self.assertEqual(ks[3].key(), Qt.Key_R) + + def testAutoMnemonic(self): + qt_set_sequence_auto_mnemonic(True) if __name__ == '__main__': diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py index ffba42e99..103b91ad6 100644 --- a/sources/pyside6/tests/QtGui/qpainter_test.py +++ b/sources/pyside6/tests/QtGui/qpainter_test.py @@ -11,7 +11,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QPainter, QLinearGradient, QImage from PySide6.QtCore import QLine, QLineF, QPoint, QPointF, QRect, QRectF, Qt @@ -23,7 +23,7 @@ except ModuleNotFoundError: HAVE_NUMPY = False -class QPainterDrawText(UsesQGuiApplication): +class QPainterDrawText(UsesQApplication): def setUp(self): super(QPainterDrawText, self).setUp() self.image = QImage(32, 32, QImage.Format_ARGB32) @@ -100,7 +100,7 @@ class QPainterDrawText(UsesQGuiApplication): self.painter.drawPointsNp(x, y) -class SetBrushWithOtherArgs(UsesQGuiApplication): +class SetBrushWithOtherArgs(UsesQApplication): '''Using qpainter.setBrush with args other than QBrush''' def testSetBrushGradient(self): diff --git a/sources/pyside6/tests/QtGui/qpdfwriter_test.py b/sources/pyside6/tests/QtGui/qpdfwriter_test.py index 671f7acbf..2dca2aca2 100644 --- a/sources/pyside6/tests/QtGui/qpdfwriter_test.py +++ b/sources/pyside6/tests/QtGui/qpdfwriter_test.py @@ -10,12 +10,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QPageLayout, QPageSize, QPdfWriter, QTextDocument from PySide6.QtCore import QDir, QMarginsF, QTemporaryFile -class QPdfWriterTest(UsesQGuiApplication): +class QPdfWriterTest(UsesQApplication): def testWrite(self): temporaryFile = QTemporaryFile(QDir.tempPath() + "/pdfwriter_test_XXXXXX.pdf") diff --git a/sources/pyside6/tests/QtGui/qpen_test.py b/sources/pyside6/tests/QtGui/qpen_test.py index 9e788bdb3..7e8604606 100644 --- a/sources/pyside6/tests/QtGui/qpen_test.py +++ b/sources/pyside6/tests/QtGui/qpen_test.py @@ -10,7 +10,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtCore import Qt, QTimer from PySide6.QtGui import QPen, QPainter, QRasterWindow @@ -26,12 +26,13 @@ class Painting(QRasterWindow): with QPainter(self) as painter: painter.setPen(Qt.NoPen) self.penFromEnum = painter.pen() - painter.setPen(int(Qt.NoPen)) + intVal = Qt.NoPen.value + painter.setPen(intVal) self.penFromInteger = painter.pen() QTimer.singleShot(20, self.close) -class QPenTest(UsesQGuiApplication): +class QPenTest(UsesQApplication): def testCtorWithCreatedEnums(self): '''A simple case of QPen creation using created enums.''' diff --git a/sources/pyside6/tests/QtGui/qpixelformat_test.py b/sources/pyside6/tests/QtGui/qpixelformat_test.py index eaf94426f..869d15952 100644 --- a/sources/pyside6/tests/QtGui/qpixelformat_test.py +++ b/sources/pyside6/tests/QtGui/qpixelformat_test.py @@ -12,12 +12,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QSize, Qt from PySide6.QtGui import QColor, QImage, QPixelFormat, qPixelFormatRgba -class QPixelFormatTest(UsesQGuiApplication): +class QPixelFormatTest(UsesQApplication): def test(self): image = QImage(QSize(200, 200), QImage.Format_ARGB32) image.fill(QColor(Qt.red)) diff --git a/sources/pyside6/tests/QtGui/qpixmap_constructor.py b/sources/pyside6/tests/QtGui/qpixmap_constructor.py index afba18841..dd658af52 100644 --- a/sources/pyside6/tests/QtGui/qpixmap_constructor.py +++ b/sources/pyside6/tests/QtGui/qpixmap_constructor.py @@ -13,7 +13,7 @@ init_test_paths(False) from PySide6.QtGui import QPixmap -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication xpm = [ "27 22 206 2", @@ -248,7 +248,7 @@ xpm = [ ] -class QStringSequenceTest(UsesQGuiApplication): +class QStringSequenceTest(UsesQApplication): def testQPixmapConstructor(self): pixmap1 = QPixmap(xpm) self.assertFalse(pixmap1.isNull()) diff --git a/sources/pyside6/tests/QtGui/qpixmap_test.py b/sources/pyside6/tests/QtGui/qpixmap_test.py index d76b0a469..b80ae2ad5 100644 --- a/sources/pyside6/tests/QtGui/qpixmap_test.py +++ b/sources/pyside6/tests/QtGui/qpixmap_test.py @@ -10,12 +10,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QColor, QPixmap from PySide6.QtCore import QFile, QIODevice, QObject, QSize, Qt -class QPixmapTest(UsesQGuiApplication): +class QPixmapTest(UsesQApplication): def testQVariantConstructor(self): obj = QObject() pixmap = QPixmap() @@ -43,7 +43,7 @@ class QPixmapTest(UsesQGuiApplication): self.assertTrue(pixmap.loadFromData(data)) -class QPixmapToImage(UsesQGuiApplication): +class QPixmapToImage(UsesQApplication): def testFilledImage(self): '''QPixmap.fill + toImage + image.pixel''' diff --git a/sources/pyside6/tests/QtGui/qpixmapcache_test.py b/sources/pyside6/tests/QtGui/qpixmapcache_test.py index aa55621af..2ecb439d3 100644 --- a/sources/pyside6/tests/QtGui/qpixmapcache_test.py +++ b/sources/pyside6/tests/QtGui/qpixmapcache_test.py @@ -10,11 +10,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QPixmapCache, QPixmap -class QPixmapCacheTest(UsesQGuiApplication): +class QPixmapCacheTest(UsesQApplication): def testWithString(self): pm1 = QPixmap() diff --git a/sources/pyside6/tests/QtGui/qrasterwindow_test.py b/sources/pyside6/tests/QtGui/qrasterwindow_test.py index a2b5bcae2..4920902d5 100644 --- a/sources/pyside6/tests/QtGui/qrasterwindow_test.py +++ b/sources/pyside6/tests/QtGui/qrasterwindow_test.py @@ -12,13 +12,14 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication -from PySide6.QtCore import QEvent, QPoint, QRect, QSize, QTimer, Qt -from PySide6.QtGui import QColor, QBackingStore, QPaintDevice, QPainter, QWindow, QPaintDeviceWindow, QRasterWindow, QRegion, QStaticText +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QPoint, QRect, QSize, QTimer, Qt +from PySide6.QtGui import (QColor, QPainter, QRasterWindow, QStaticText, + QTextCursor, QTextDocument, QAbstractTextDocumentLayout) # Window using convenience class QRasterWindow -class TestRasterWindow(QRasterWindow): +class StaticTextRasterWindow(QRasterWindow): def __init__(self): super().__init__() self.text = QStaticText("QRasterWindow") @@ -30,12 +31,44 @@ class TestRasterWindow(QRasterWindow): painter.drawStaticText(QPoint(10, 10), self.text) -class QRasterWindowTest(UsesQGuiApplication): +class TextDocumentWindow(QRasterWindow): + """PYSIDE-2252, drawing with QAbstractTextDocumentLayout.PaintContext""" + + def __init__(self): + super().__init__() + self.m_document = QTextDocument() + self.m_document.setPlainText("bla bla") + + def paintEvent(self, event): + with QPainter(self) as painter: + clientRect = QRect(QPoint(0, 0), self.size()) + painter.fillRect(clientRect, QColor(Qt.white)) + ctx = QAbstractTextDocumentLayout.PaintContext() + ctx.clip = clientRect + + sel = QAbstractTextDocumentLayout.Selection() + cursor = QTextCursor(self.m_document) + cursor.movePosition(QTextCursor.Start) + cursor.movePosition(QTextCursor.NextWord, QTextCursor.KeepAnchor) + sel.cursor = cursor + sel.format.setForeground(Qt.red) + ctx.selections = [sel] + + self.m_document.documentLayout().draw(painter, ctx) + + +class QRasterWindowTest(UsesQApplication): def test(self): - rasterWindow = TestRasterWindow() + rasterWindow = StaticTextRasterWindow() rasterWindow.setFramePosition(QPoint(100, 100)) rasterWindow.resize(QSize(400, 400)) rasterWindow.show() + + rasterWindow2 = TextDocumentWindow() + rasterWindow2.setFramePosition(rasterWindow.frameGeometry().topRight() + QPoint(20, 0)) + rasterWindow2.resize(QSize(400, 400)) + rasterWindow2.show() + QTimer.singleShot(100, self.app.quit) self.app.exec() diff --git a/sources/pyside6/tests/QtGui/qregion_test.py b/sources/pyside6/tests/QtGui/qregion_test.py index 48da94889..df14fc3e0 100644 --- a/sources/pyside6/tests/QtGui/qregion_test.py +++ b/sources/pyside6/tests/QtGui/qregion_test.py @@ -12,10 +12,10 @@ init_test_paths(False) from PySide6.QtGui import QRegion from PySide6.QtCore import QPoint, QRect, QSize -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QRegionTest(UsesQGuiApplication): +class QRegionTest(UsesQApplication): def testFunctionUnit(self): r = QRegion(0, 0, 10, 10) diff --git a/sources/pyside6/tests/QtGui/qstandarditemmodel_test.py b/sources/pyside6/tests/QtGui/qstandarditemmodel_test.py index 78d55d414..55aca9113 100644 --- a/sources/pyside6/tests/QtGui/qstandarditemmodel_test.py +++ b/sources/pyside6/tests/QtGui/qstandarditemmodel_test.py @@ -14,10 +14,10 @@ init_test_paths(False) from PySide6.QtCore import QObject from PySide6.QtGui import QStandardItemModel, QStandardItem from shiboken6 import Shiboken -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication -class QStandardItemModelTest(UsesQGuiApplication): +class QStandardItemModelTest(UsesQApplication): def setUp(self): super(QStandardItemModelTest, self).setUp() @@ -43,7 +43,7 @@ class QStandardItemModelTest(UsesQGuiApplication): self.assertFalse(Shiboken.isValid(root)) -class QStandardItemModelRef(UsesQGuiApplication): +class QStandardItemModelRef(UsesQApplication): @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount") def testRefCount(self): model = QStandardItemModel(5, 5) diff --git a/sources/pyside6/tests/QtGui/qstring_qkeysequence_test.py b/sources/pyside6/tests/QtGui/qstring_qkeysequence_test.py index 29dcfb34b..f68374263 100644 --- a/sources/pyside6/tests/QtGui/qstring_qkeysequence_test.py +++ b/sources/pyside6/tests/QtGui/qstring_qkeysequence_test.py @@ -13,12 +13,12 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QAction, QKeySequence -class QStringQKeySequenceTest(UsesQGuiApplication): +class QStringQKeySequenceTest(UsesQApplication): '''Tests conversions of QString to and from QKeySequence.''' def testQStringFromQKeySequence(self): diff --git a/sources/pyside6/tests/QtGui/qstylehints_test.py b/sources/pyside6/tests/QtGui/qstylehints_test.py index d962144b6..d2b21d30d 100644 --- a/sources/pyside6/tests/QtGui/qstylehints_test.py +++ b/sources/pyside6/tests/QtGui/qstylehints_test.py @@ -12,11 +12,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from helper.usesqguiapplication import UsesQGuiApplication +from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QStyleHints -class QStyleHintsTest(UsesQGuiApplication): +class QStyleHintsTest(UsesQApplication): def test(self): styleHints = self.app.styleHints() self.assertTrue(styleHints.startDragDistance() > 0) diff --git a/sources/pyside6/tests/QtGui/qtextdocument_functions.py b/sources/pyside6/tests/QtGui/qtextdocument_functions.py index 3329b1aee..2ac72df56 100644 --- a/sources/pyside6/tests/QtGui/qtextdocument_functions.py +++ b/sources/pyside6/tests/QtGui/qtextdocument_functions.py @@ -10,7 +10,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtGui import Qt +from PySide6.QtGui import QPageRanges, Qt class QTextDocumentFunctions(unittest.TestCase): @@ -22,5 +22,16 @@ class QTextDocumentFunctions(unittest.TestCase): self.assertEqual(html, '<p>A & B</p>') +class QPageRangesTest(unittest.TestCase): + """PYSIDE-2237: Test that field QPageRanges.Range.from is properly mangled.""" + + def test(self): + pr = QPageRanges() + pr.addPage(1) + r0 = pr.toRangeList()[0] + self.assertEqual(r0.from_, 1) + self.assertEqual(r0.to, 1) + + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextline_test.py b/sources/pyside6/tests/QtGui/qtextline_test.py index ea317848f..c34a4c98a 100644 --- a/sources/pyside6/tests/QtGui/qtextline_test.py +++ b/sources/pyside6/tests/QtGui/qtextline_test.py @@ -10,11 +10,11 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtGui import QTextLayout -from helper.usesqguiapplication import UsesQGuiApplication +from PySide6.QtGui import QTextLayout, QTextOption +from helper.usesqapplication import UsesQApplication -class QTextLineTest(UsesQGuiApplication): +class QTextLineTest(UsesQApplication): def testCursorToX(self): textLayout = QTextLayout() @@ -28,6 +28,11 @@ class QTextLineTest(UsesQGuiApplication): self.assertEqual(type(x), float) self.assertEqual(type(cursorPos), int) + def testTextOption(self): + """PYSIDE-2088, large enum values causing MSVC issues.""" + v = QTextOption.IncludeTrailingSpaces | QTextOption.ShowTabsAndSpaces + self.assertEqual(v.value, 2147483649) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtransform_test.py b/sources/pyside6/tests/QtGui/qtransform_test.py index 053f07331..dc51a74e6 100644 --- a/sources/pyside6/tests/QtGui/qtransform_test.py +++ b/sources/pyside6/tests/QtGui/qtransform_test.py @@ -11,7 +11,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import QPointF -from PySide6.QtGui import QTransform, QPolygonF, QPolygonF +from PySide6.QtGui import QTransform, QPolygonF, QPolygonF, QQuaternion, QVector3D class QTransformTest(unittest.TestCase): @@ -78,6 +78,12 @@ class QTransformTest(unittest.TestCase): self.assertEqual(t1, r2) + def testQQuaternion(self): + """Test return tuples.""" + q = QQuaternion(1, 1, 1, 1) + self.assertEqual(len(q.getAxisAndAngle()), 2) + self.assertEqual(len(q.getEulerAngles()), 3) + if __name__ == "__main__": unittest.main() diff --git a/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py index c45d762b5..6e9a661ce 100644 --- a/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py +++ b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py @@ -7,13 +7,10 @@ import unittest from pathlib import Path sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) -from init_paths import init_test_paths +from init_paths import init_test_paths # noqa: E402 init_test_paths(False) from helper.timedqguiapplication import TimedQGuiApplication -from PySide6.support import deprecated -from PySide6.support.signature import importhandler -from PySide6 import QtGui class TestTimedApp(TimedQGuiApplication): @@ -23,21 +20,7 @@ class TestTimedApp(TimedQGuiApplication): # Simple test of TimedQGuiApplication self.app.exec() - -def fix_for_QtGui(QtGui): - QtGui.something = 42 - - -class TestPatchingFramework(unittest.TestCase): - """Simple test that verifies that deprecated.py works""" - - deprecated.fix_for_QtGui = fix_for_QtGui - - def test_patch_works(self): - something = "something" - self.assertFalse(hasattr(QtGui, something)) - importhandler.finish_import(QtGui) - self.assertTrue(hasattr(QtGui, something)) +# deprecated.py is no longer needed. if __name__ == '__main__': |