summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/CMakeLists.txt13
-rw-r--r--tests/auto/gui/image/qicoimageformat/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.icobin0 -> 12862 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.pngbin0 -> 3911 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.icobin0 -> 16958 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.pngbin0 -> 5536 bytes
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp31
-rw-r--r--tests/auto/gui/image/qicon/CMakeLists.txt15
-rw-r--r--tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.pngbin0 -> 267 bytes
-rw-r--r--tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme8
-rw-r--r--tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.pngbin0 -> 267 bytes
-rw-r--r--tests/auto/gui/image/qicon/icons/hicolor/index.theme11
-rw-r--r--tests/auto/gui/image/qicon/icons/testtheme/index.theme2
-rw-r--r--tests/auto/gui/image/qicon/icons/themeparent/index.theme1
-rw-r--r--tests/auto/gui/image/qicon/plugin/CMakeLists.txt20
-rw-r--r--tests/auto/gui/image/qicon/plugin/main.cpp73
-rw-r--r--tests/auto/gui/image/qicon/plugin/plugin.json3
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp82
-rw-r--r--tests/auto/gui/image/qiconhighdpi/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp20
-rw-r--r--tests/auto/gui/image/qimage/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qimage/images/CGATS001Compat-v2-micro.iccbin0 -> 8464 bytes
-rw-r--r--tests/auto/gui/image/qimage/images/VideoHD.iccbin0 -> 786 bytes
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp417
-rw-r--r--tests/auto/gui/image/qimageiohandler/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp2
-rw-r--r--tests/auto/gui/image/qimagereader/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qimagereader/images/image.pbm10
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp252
-rw-r--r--tests/auto/gui/image/qimagewriter/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp2
-rw-r--r--tests/auto/gui/image/qmovie/CMakeLists.txt10
-rw-r--r--tests/auto/gui/image/qmovie/multiframe/Obj_N2_Internal_Mem.icobin0 -> 25214 bytes
-rw-r--r--tests/auto/gui/image/qmovie/tst_qmovie.cpp95
-rw-r--r--tests/auto/gui/image/qpicture/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qpicture/tst_qpicture.cpp2
-rw-r--r--tests/auto/gui/image/qpixmap/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp6
-rw-r--r--tests/auto/gui/image/qpixmapcache/CMakeLists.txt6
-rw-r--r--tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp149
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt6
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp62
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt6
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp54
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt7
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp139
-rw-r--r--tests/auto/gui/kernel/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/noqteventloop/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp2
-rw-r--r--tests/auto/gui/kernel/qaction/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qaction/tst_qaction.cpp2
-rw-r--r--tests/auto/gui/kernel/qactiongroup/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp2
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp2
-rw-r--r--tests/auto/gui/kernel/qbackingstore/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp85
-rw-r--r--tests/auto/gui/kernel/qclipboard/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qclipboard/test/BLACKLIST5
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp24
-rw-r--r--tests/auto/gui/kernel/qcursor/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qcursor/tst_qcursor.cpp2
-rw-r--r--tests/auto/gui/kernel/qdrag/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qdrag/tst_qdrag.cpp2
-rw-r--r--tests/auto/gui/kernel/qevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qevent/tst_qevent.cpp62
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp2
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp9
-rw-r--r--tests/auto/gui/kernel/qguiapplication/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp104
-rw-r--r--tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt38
-rw-r--r--tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt37
-rw-r--r--tests/auto/gui/kernel/qguieventloop/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qguimetatype/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp2
-rw-r--r--tests/auto/gui/kernel/qguitimer/CMakeLists.txt36
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp2
-rw-r--r--tests/auto/gui/kernel/qhighdpi/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp42
-rw-r--r--tests/auto/gui/kernel/qinputdevice/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp2
-rw-r--r--tests/auto/gui/kernel/qinputmethod/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp10
-rw-r--r--tests/auto/gui/kernel/qkeyevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp4
-rw-r--r--tests/auto/gui/kernel/qkeysequence/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp3
-rw-r--r--tests/auto/gui/kernel/qmouseevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp4
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp2
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp5
-rw-r--r--tests/auto/gui/kernel/qpalette/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp53
-rw-r--r--tests/auto/gui/kernel/qpixelformat/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp2
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp4
-rw-r--r--tests/auto/gui/kernel/qscreen/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qscreen/tst_qscreen.cpp2
-rw-r--r--tests/auto/gui/kernel/qshortcut/CMakeLists.txt7
-rw-r--r--tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp65
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp2
-rw-r--r--tests/auto/gui/kernel/qtouchevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp4
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST7
-rw-r--r--tests/auto/gui/kernel/qwindow/CMakeLists.txt16
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp236
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp355
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt6
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp4
-rw-r--r--tests/auto/gui/math3d/qquaternion/CMakeLists.txt6
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp4
-rw-r--r--tests/auto/gui/math3d/qvectornd/CMakeLists.txt6
-rw-r--r--tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp2
-rw-r--r--tests/auto/gui/painting/CMakeLists.txt4
-rw-r--r--tests/auto/gui/painting/qbrush/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp2
-rw-r--r--tests/auto/gui/painting/qcolor/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp4
-rw-r--r--tests/auto/gui/painting/qcolorspace/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.iccbin0 -> 8464 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.iccbin0 -> 13300 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/VideoHD.iccbin0 -> 786 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.iccbin0 -> 360 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.iccbin0 -> 63868 bytes
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp398
-rw-r--r--tests/auto/gui/painting/qcolortransform/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp10
-rw-r--r--tests/auto/gui/painting/qpagelayout/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp251
-rw-r--r--tests/auto/gui/painting/qpageranges/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp2
-rw-r--r--tests/auto/gui/painting/qpagesize/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp4
-rw-r--r--tests/auto/gui/painting/qpaintengine/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp2
-rw-r--r--tests/auto/gui/painting/qpainter/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp94
-rw-r--r--tests/auto/gui/painting/qpainter/utils/createImages/main.cpp2
-rw-r--r--tests/auto/gui/painting/qpainterpath/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp45
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp2
-rw-r--r--tests/auto/gui/painting/qpathclipper/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpathclipper/pathcompare.h2
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.cpp2
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.h2
-rw-r--r--tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp8
-rw-r--r--tests/auto/gui/painting/qpdfwriter/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp2
-rw-r--r--tests/auto/gui/painting/qpen/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp2
-rw-r--r--tests/auto/gui/painting/qpolygon/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp2
-rw-r--r--tests/auto/gui/painting/qregion/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp26
-rw-r--r--tests/auto/gui/painting/qtransform/CMakeLists.txt6
-rw-r--r--tests/auto/gui/painting/qtransform/tst_qtransform.cpp2
-rw-r--r--tests/auto/gui/platform/qx11info/CMakeLists.txt6
-rw-r--r--tests/auto/gui/platform/qx11info/tst_qx11info.cpp2
-rw-r--r--tests/auto/gui/qopengl/CMakeLists.txt6
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp2
-rw-r--r--tests/auto/gui/qopenglconfig/CMakeLists.txt6
-rw-r--r--tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp2
-rw-r--r--tests/auto/gui/qvulkan/CMakeLists.txt6
-rw-r--r--tests/auto/gui/qvulkan/tst_qvulkan.cpp18
-rw-r--r--tests/auto/gui/rhi/qrhi/CMakeLists.txt6
-rw-r--r--tests/auto/gui/rhi/qrhi/data/buildshaders.bat4
-rw-r--r--tests/auto/gui/rhi/qrhi/data/multiview.frag10
-rw-r--r--tests/auto/gui/rhi/qrhi/data/multiview.frag.qsbbin0 -> 2425 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/multiview.vert18
-rw-r--r--tests/auto/gui/rhi/qrhi/data/multiview.vert.qsbbin0 -> 3644 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer.comp2
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsbbin1239 -> 1262 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp443
-rw-r--r--tests/auto/gui/rhi/qshader/CMakeLists.txt6
-rw-r--r--tests/auto/gui/rhi/qshader/tst_qshader.cpp6
-rw-r--r--tests/auto/gui/text/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp6
-rw-r--r--tests/auto/gui/text/qcssparser/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp83
-rw-r--r--tests/auto/gui/text/qfont/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp90
-rw-r--r--tests/auto/gui/text/qfontcache/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qfontcache/tst_qfontcache.cpp2
-rw-r--r--tests/auto/gui/text/qfontdatabase/CMakeLists.txt12
-rw-r--r--tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttfbin0 -> 5664 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttfbin0 -> 5280 bytes
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp273
-rw-r--r--tests/auto/gui/text/qfontmetrics/CMakeLists.txt10
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp72
-rw-r--r--tests/auto/gui/text/qglyphrun/BLACKLIST7
-rw-r--r--tests/auto/gui/text/qglyphrun/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp14
-rw-r--r--tests/auto/gui/text/qinputcontrol/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp2
-rw-r--r--tests/auto/gui/text/qrawfont/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp24
-rw-r--r--tests/auto/gui/text/qstatictext/CMakeLists.txt8
-rw-r--r--tests/auto/gui/text/qstatictext/tst_qstatictext.cpp61
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp2
-rw-r--r--tests/auto/gui/text/qtextblock/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextblock/tst_qtextblock.cpp2
-rw-r--r--tests/auto/gui/text/qtextcursor/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp6
-rw-r--r--tests/auto/gui/text/qtextdocument/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextdocument/common.h2
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp294
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp24
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/BLACKLIST3
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp14
-rw-r--r--tests/auto/gui/text/qtextformat/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp8
-rw-r--r--tests/auto/gui/text/qtextimagehandler/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp74
-rw-r--r--tests/auto/gui/text/qtextlayout/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp29
-rw-r--r--tests/auto/gui/text/qtextlist/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextlist/tst_qtextlist.cpp4
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt14
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/data/paragraphs.md9
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md1
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/data/yaml-only.md6
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/data/yaml.md11
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp188
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt12
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md6
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/blockquotesWithLists.md14
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/example.md4
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/listItemWithBlockquote.md6
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md9
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/yaml.md11
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp395
-rw-r--r--tests/auto/gui/text/qtextobject/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextobject/tst_qtextobject.cpp2
-rw-r--r--tests/auto/gui/text/qtextodfwriter/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp2
-rw-r--r--tests/auto/gui/text/qtextpiecetable/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp136
-rw-r--r--tests/auto/gui/text/qtextscriptengine/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextscriptengine/generate/main.cpp2
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp50
-rw-r--r--tests/auto/gui/text/qtexttable/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp76
-rw-r--r--tests/auto/gui/text/qzip/.gitignore1
-rw-r--r--tests/auto/gui/text/qzip/CMakeLists.txt21
-rw-r--r--tests/auto/gui/text/qzip/testdata/symlink.zipbin289 -> 0 bytes
-rw-r--r--tests/auto/gui/text/qzip/testdata/test.zipbin286 -> 0 bytes
-rw-r--r--tests/auto/gui/text/qzip/tst_qzip.cpp116
-rw-r--r--tests/auto/gui/util/CMakeLists.txt12
-rw-r--r--tests/auto/gui/util/qdesktopservices/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp17
-rw-r--r--tests/auto/gui/util/qdoublevalidator/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp30
-rw-r--r--tests/auto/gui/util/qintvalidator/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp11
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp2
-rw-r--r--tests/auto/gui/util/qtexturefilereader/CMakeLists.txt7
-rw-r--r--tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktxbin0 -> 69 bytes
-rw-r--r--tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp15
-rw-r--r--tests/auto/gui/util/qundogroup/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qundogroup/tst_qundogroup.cpp2
-rw-r--r--tests/auto/gui/util/qundostack/CMakeLists.txt6
-rw-r--r--tests/auto/gui/util/qundostack/tst_qundostack.cpp2
278 files changed, 5983 insertions, 1025 deletions
diff --git a/tests/auto/gui/image/CMakeLists.txt b/tests/auto/gui/image/CMakeLists.txt
index 9cc6d4d2bf..c7fc6f07d3 100644
--- a/tests/auto/gui/image/CMakeLists.txt
+++ b/tests/auto/gui/image/CMakeLists.txt
@@ -12,14 +12,15 @@ add_subdirectory(qpixmap)
add_subdirectory(qimage)
add_subdirectory(qimageiohandler)
add_subdirectory(qimagewriter)
-add_subdirectory(qmovie)
-add_subdirectory(qpicture)
+if(QT_FEATURE_movie)
+ add_subdirectory(qmovie)
+endif()
+if(QT_FEATURE_picture)
+ add_subdirectory(qpicture)
+endif()
add_subdirectory(qiconhighdpi)
if(QT_FEATURE_private_tests)
add_subdirectory(qpixmapcache)
endif()
-# QTBUG-87669
-if(NOT ANDROID)
- add_subdirectory(qicon)
-endif()
+add_subdirectory(qicon)
diff --git a/tests/auto/gui/image/qicoimageformat/CMakeLists.txt b/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
index 78f0ef98ea..17ec68df4e 100644
--- a/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
+++ b/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qicoimageformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qicoimageformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico
new file mode 100644
index 0000000000..7e9cfa2414
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.ico
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png
new file mode 100644
index 0000000000..f0a19c05e3
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/masked/24bpp.png
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico
new file mode 100644
index 0000000000..a22248d76a
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.ico
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png
new file mode 100644
index 0000000000..a6ceac73fa
--- /dev/null
+++ b/tests/auto/gui/image/qicoimageformat/icons/masked/32bpp.png
Binary files differ
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index 47bfb5bca5..136f56facf 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui>
#include <QtCore>
@@ -27,6 +27,8 @@ private slots:
void pngCompression();
void write_data();
void write();
+ void icoMask_data();
+ void icoMask();
private:
QString m_IconPath;
@@ -319,6 +321,33 @@ void tst_QIcoImageFormat::write()
}
}
+void tst_QIcoImageFormat::icoMask_data()
+{
+ QTest::addColumn<QString>("inFile");
+ QTest::addColumn<QString>("outFile");
+
+ QTest::newRow("24bpp") << "masked/24bpp.ico" << "masked/24bpp.png";
+ QTest::newRow("32bpp") << "masked/32bpp.ico" << "masked/32bpp.png";
+}
+
+void tst_QIcoImageFormat::icoMask()
+{
+ QFETCH(QString, inFile);
+ QFETCH(QString, outFile);
+
+ QImage inImage;
+ QImageReader inReader(m_IconPath + QLatin1Char('/') + inFile);
+ inReader.read(&inImage);
+
+ QImage outImage;
+ QImageReader outReader(m_IconPath + QLatin1Char('/') + outFile);
+ outReader.read(&outImage);
+ outImage.setColorSpace(inImage.colorSpace());
+ outImage = outImage.convertToFormat(inImage.format());
+
+ QCOMPARE(inImage, outImage);
+}
+
QTEST_MAIN(tst_QIcoImageFormat)
#include "tst_qicoimageformat.moc"
diff --git a/tests/auto/gui/image/qicon/CMakeLists.txt b/tests/auto/gui/image/qicon/CMakeLists.txt
index c900c60d5b..93f75741c0 100644
--- a/tests/auto/gui/image/qicon/CMakeLists.txt
+++ b/tests/auto/gui/image/qicon/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qicon Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qicon LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -31,11 +37,14 @@ file(GLOB_RECURSE test_data_glob
*.svgz)
list(APPEND test_data ${test_data_glob})
+add_subdirectory(plugin)
+
qt_internal_add_test(tst_qicon
SOURCES
tst_qicon.cpp
LIBRARIES
Qt::Gui
+ TestIconPlugin
TESTDATA ${test_data}
)
@@ -56,6 +65,10 @@ set(tst_qicon_resource_files
"./icons/themeparent/index.theme"
"./icons/themeparent/scalable/actions/address-book-new.svg"
"./icons/themeparent/scalable/actions/appointment-new.svg"
+ "./icons/fallbacktheme/index.theme"
+ "./icons/fallbacktheme/16x16/edit-cut.png"
+ "./icons/hicolor/index.theme"
+ "./icons/hicolor/16x16/hicolor-icon.png"
"./second_icons/testtheme/32x32/actions/appointment-new.png"
"./styles/commonstyle/images/standardbutton-open-128.png"
"./styles/commonstyle/images/standardbutton-open-16.png"
@@ -95,3 +108,5 @@ qt_internal_extend_target(tst_qicon CONDITION TARGET Qt::Widgets
LIBRARIES
Qt::Widgets
)
+
+add_dependencies(tst_qicon TestIconPlugin)
diff --git a/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png b/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png
new file mode 100644
index 0000000000..661ef1ad03
--- /dev/null
+++ b/tests/auto/gui/image/qicon/icons/fallbacktheme/16x16/edit-cut.png
Binary files differ
diff --git a/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme b/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme
new file mode 100644
index 0000000000..809d296669
--- /dev/null
+++ b/tests/auto/gui/image/qicon/icons/fallbacktheme/index.theme
@@ -0,0 +1,8 @@
+[Icon Theme]
+Name=fallbacktheme
+
+Directories=16x16
+
+[16x16]
+Size=16
+Type=Fixed
diff --git a/tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.png b/tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.png
new file mode 100644
index 0000000000..661ef1ad03
--- /dev/null
+++ b/tests/auto/gui/image/qicon/icons/hicolor/16x16/hicolor-icon.png
Binary files differ
diff --git a/tests/auto/gui/image/qicon/icons/hicolor/index.theme b/tests/auto/gui/image/qicon/icons/hicolor/index.theme
new file mode 100644
index 0000000000..e5e5cef9b1
--- /dev/null
+++ b/tests/auto/gui/image/qicon/icons/hicolor/index.theme
@@ -0,0 +1,11 @@
+[Icon Theme]
+Name=hicolor
+
+# Provide a minimal hicolor theme, so that our hicolor fallback
+# lookup during testing will find that theme on all systems.
+
+Directories=16x16
+
+[16x16]
+Size=16
+Type=Fixed
diff --git a/tests/auto/gui/image/qicon/icons/testtheme/index.theme b/tests/auto/gui/image/qicon/icons/testtheme/index.theme
index e18736ab43..53664b14b2 100644
--- a/tests/auto/gui/image/qicon/icons/testtheme/index.theme
+++ b/tests/auto/gui/image/qicon/icons/testtheme/index.theme
@@ -1,7 +1,7 @@
[Icon Theme]
_Name=Test
_Comment=Test Theme
-Inherits=crystalsvg, themeparent
+Inherits=themeparent
Example=x-directory-normal
# KDE Specific Stuff
diff --git a/tests/auto/gui/image/qicon/icons/themeparent/index.theme b/tests/auto/gui/image/qicon/icons/themeparent/index.theme
index e536a0bf2f..96267addd6 100644
--- a/tests/auto/gui/image/qicon/icons/themeparent/index.theme
+++ b/tests/auto/gui/image/qicon/icons/themeparent/index.theme
@@ -1,7 +1,6 @@
[Icon Theme]
_Name=Test
_Comment=Test Theme
-Inherits=gnome,crystalsvg
Example=x-directory-normal
# KDE Specific Stuff
diff --git a/tests/auto/gui/image/qicon/plugin/CMakeLists.txt b/tests/auto/gui/image/qicon/plugin/CMakeLists.txt
new file mode 100644
index 0000000000..cae49b2df1
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## TestIconEngine Plugin:
+#####################################################################
+
+qt_internal_add_plugin(TestIconPlugin
+ STATIC
+ OUTPUT_NAME qtesticonplugin
+ OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
+ SKIP_INSTALL
+ PLUGIN_TYPE iconengines
+ DEFAULT_IF TRUE
+ SOURCES
+ main.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::Gui
+)
diff --git a/tests/auto/gui/image/qicon/plugin/main.cpp b/tests/auto/gui/image/qicon/plugin/main.cpp
new file mode 100644
index 0000000000..58d9807142
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/main.cpp
@@ -0,0 +1,73 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qiconengineplugin.h>
+#include <qiconengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class TestIconPlugin : public QIconEnginePlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "plugin.json")
+
+public:
+ QIconEngine *create(const QString &icon) override;
+};
+
+class TestIconEngine : public QIconEngine
+{
+public:
+ TestIconEngine(const QString &icon)
+ : m_iconName(QIcon::themeName() + "/" + icon)
+ {
+ }
+
+ ~TestIconEngine()
+ {}
+
+ QIconEngine *clone() const override
+ {
+ return new TestIconEngine(m_iconName);
+ }
+
+ QString key() const override
+ {
+ return QStringLiteral("TestIconEngine");
+ }
+
+ QString iconName() override
+ {
+ return m_iconName;
+ }
+
+ bool isNull() override
+ {
+ return m_iconName.isNull();
+ }
+
+ QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override
+ {
+ return {{16, 16}, {48, 48}, {64, 64}};
+ }
+
+ void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
+ {
+ Q_UNUSED(painter);
+ Q_UNUSED(rect);
+ Q_UNUSED(mode);
+ Q_UNUSED(state);
+ }
+
+private:
+ const QString m_iconName;
+};
+
+QIconEngine *TestIconPlugin::create(const QString &icon)
+{
+ return new TestIconEngine(icon);
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/tests/auto/gui/image/qicon/plugin/plugin.json b/tests/auto/gui/image/qicon/plugin/plugin.json
new file mode 100644
index 0000000000..96b59aa79e
--- /dev/null
+++ b/tests/auto/gui/image/qicon/plugin/plugin.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "plugintheme", "SpecialTheme" ]
+}
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index ebb0f1e9d2..d95ee66fb6 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QImageReader>
@@ -41,12 +41,16 @@ private slots:
void streamAvailableSizes();
void fromTheme();
void fromThemeCache();
+ void fromThemeConstant();
#ifndef QT_NO_WIDGETS
void task184901_badCache();
#endif
void task223279_inconsistentAddFile();
+ void themeFromPlugin_data();
+ void themeFromPlugin();
+
private:
bool haveImageFormat(QByteArray const&);
@@ -191,21 +195,21 @@ void tst_QIcon::isNull() {
// test string constructor with empty string
QIcon iconEmptyString = QIcon(QString());
QVERIFY(iconEmptyString.isNull());
- QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());;
+ QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());
// test string constructor with non-existing file
QIcon iconNoFile = QIcon("imagedoesnotexist");
- QVERIFY(!iconNoFile.isNull());
+ QVERIFY(iconNoFile.isNull());
QVERIFY(!iconNoFile.actualSize(QSize(32, 32)).isValid());
// test string constructor with non-existing file with suffix
QIcon iconNoFileSuffix = QIcon("imagedoesnotexist.png");
- QVERIFY(!iconNoFileSuffix.isNull());
+ QVERIFY(iconNoFileSuffix.isNull());
QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid());
// test string constructor with existing file but unsupported format
QIcon iconUnsupportedFormat = QIcon(m_sourceFileName);
- QVERIFY(!iconUnsupportedFormat.isNull());
+ QVERIFY(iconUnsupportedFormat.isNull());
QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid());
// test string constructor with existing file and supported format
@@ -552,6 +556,10 @@ void tst_QIcon::availableSizes()
void tst_QIcon::name()
{
+ const auto reset = qScopeGuard([]{
+ QIcon::setThemeName({});
+ QIcon::setThemeSearchPaths({});
+ });
{
// No name if icon does not come from a theme
QIcon icon(":/image.png");
@@ -629,6 +637,7 @@ void tst_QIcon::task184901_badCache()
void tst_QIcon::fromTheme()
{
+ const bool abIconFromPlatform = !QIcon::fromTheme("address-book-new").isNull();
QString firstSearchPath = QLatin1String(":/icons");
QString secondSearchPath = QLatin1String(":/second_icons");
QIcon::setThemeSearchPaths(QStringList() << firstSearchPath << secondSearchPath);
@@ -717,14 +726,44 @@ void tst_QIcon::fromTheme()
QCOMPARE(i.availableSizes(), abIcon.availableSizes());
}
+ // Setting or changing the fallback theme should invalidate earlier lookups.
+ // We can only test this if the system doesn't provide an icon, because once
+ // we got a valid icon, it will be cached, and even if we proxy to a different
+ // engine when a fallback theme is set, the cacheKey of the icon will be the
+ // same.
+ const QIcon editCut = QIcon::fromTheme("edit-cut");
+ if (editCut.isNull()) {
+ QIcon::setFallbackThemeName("fallbacktheme");
+ QVERIFY(!QIcon::fromTheme("edit-cut").isNull());
+ }
+
// Make sure setting the theme name clears the state
QIcon::setThemeName("");
abIcon = QIcon::fromTheme("address-book-new");
- QVERIFY(abIcon.isNull());
+ QCOMPARE_NE(abIcon.isNull(), abIconFromPlatform);
+
+ // Test fallback icon behavior for empty theme names.
+ // Can only reliably test this on systems that don't have a
+ // named system icon theme.
+ QIcon::setThemeName(""); // Reset user-theme
+ if (QIcon::themeName().isEmpty()) {
+ // Test icon from fallback theme even when theme name is empty
+ QIcon::setFallbackThemeName("fallbacktheme");
+ QVERIFY(!QIcon::fromTheme("edit-cut").isNull());
+
+ // Test icon from fallback path even when theme name is empty
+ fallbackIcon = QIcon::fromTheme("red");
+ QVERIFY(!fallbackIcon.isNull());
+ QVERIFY(QIcon::hasThemeIcon("red"));
+ QCOMPARE(fallbackIcon.availableSizes().size(), 1);
+ }
// Passing a full path to fromTheme is not very useful, but should work anyway
QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName);
QVERIFY(!fullPathIcon.isNull());
+
+ // Restore to system fallback theme
+ QIcon::setFallbackThemeName("");
}
static inline QString findGtkUpdateIconCache()
@@ -813,6 +852,11 @@ void tst_QIcon::fromThemeCache()
QVERIFY(QIcon::fromTheme("notexist-fallback").isNull());
}
+void tst_QIcon::fromThemeConstant()
+{
+ const QIcon icon = QIcon::fromTheme(QIcon::ThemeIcon::EditCut);
+}
+
void tst_QIcon::task223279_inconsistentAddFile()
{
QIcon icon1;
@@ -831,6 +875,32 @@ void tst_QIcon::task223279_inconsistentAddFile()
QCOMPARE(pm1.size(), pm2.size());
}
+Q_IMPORT_PLUGIN(TestIconPlugin)
+
+void tst_QIcon::themeFromPlugin_data()
+{
+ QTest::addColumn<QString>("themeName");
+
+ QTest::addRow("plugintheme") << "plugintheme";
+ QTest::addRow("specialtheme") << "specialTheme"; // deliberately not matching case
+}
+
+void tst_QIcon::themeFromPlugin()
+{
+ QFETCH(const QString, themeName);
+ auto restoreTheme = qScopeGuard([oldTheme = QIcon::themeName()]{
+ QIcon::setThemeName(oldTheme);
+ });
+
+ QIcon icon = QIcon::fromTheme("icon1");
+ QVERIFY(icon.isNull());
+
+ QIcon::setThemeName(themeName);
+
+ icon = QIcon::fromTheme("icon1");
+ QVERIFY(!icon.isNull());
+ QCOMPARE(icon.name(), themeName + "/icon1");
+}
QTEST_MAIN(tst_QIcon)
#include "tst_qicon.moc"
diff --git a/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt b/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
index 6a6717df09..f0ccb97c8a 100644
--- a/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
+++ b/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qiconhighdpi Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qiconhighdpi LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
index 829c463c6b..34f0132865 100644
--- a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
+++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qicon.h>
@@ -17,6 +17,7 @@ private slots:
void addPixmap_data();
void addPixmap();
void ninePatch();
+ void preferUpscale();
};
tst_QIconHighDpi::tst_QIconHighDpi()
@@ -211,6 +212,23 @@ void tst_QIconHighDpi::ninePatch()
}
}
+void tst_QIconHighDpi::preferUpscale()
+{
+ QIcon icon;
+
+ // manual pixmap adder for full control of devicePixelRatio
+ auto addPixmapWithDpr = [&icon](const QString &path, qreal dpr) {
+ QImage image(path);
+ image.setDevicePixelRatio(dpr);
+ icon.addPixmap(QPixmap::fromImage(image));
+ };
+
+ addPixmapWithDpr(":/icons/testtheme/22x22/actions/appointment-new.png", 1);
+ addPixmapWithDpr(":/icons/testtheme/22x22@2/actions/appointment-new.png", 2);
+
+ QCOMPARE(icon.pixmap(QSize(22, 22), 1.25f).devicePixelRatio(), 1.25f);
+}
+
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
diff --git a/tests/auto/gui/image/qimage/CMakeLists.txt b/tests/auto/gui/image/qimage/CMakeLists.txt
index ecd68ac82c..8d0842026d 100644
--- a/tests/auto/gui/image/qimage/CMakeLists.txt
+++ b/tests/auto/gui/image/qimage/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qimage Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qimage LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qimage/images/CGATS001Compat-v2-micro.icc b/tests/auto/gui/image/qimage/images/CGATS001Compat-v2-micro.icc
new file mode 100644
index 0000000000..b5a73495bf
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/CGATS001Compat-v2-micro.icc
Binary files differ
diff --git a/tests/auto/gui/image/qimage/images/VideoHD.icc b/tests/auto/gui/image/qimage/images/VideoHD.icc
new file mode 100644
index 0000000000..b96eb68136
--- /dev/null
+++ b/tests/auto/gui/image/qimage/images/VideoHD.icc
Binary files differ
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 415f016519..8086ffcc28 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -15,6 +15,7 @@
#include <stdio.h>
#include <qpainter.h>
+#include <private/qcmyk_p.h>
#include <private/qimage_p.h>
#include <private/qdrawhelper_p.h>
@@ -108,6 +109,10 @@ private slots:
void smoothScaleAlpha();
void smoothScaleFormats_data();
void smoothScaleFormats();
+ void smoothScaleNoConversion_data();
+ void smoothScaleNoConversion();
+ void smoothScale_CMYK_data();
+ void smoothScale_CMYK();
void transformed_data();
void transformed();
@@ -167,6 +172,15 @@ private slots:
void largeInplaceRgbConversion_data();
void largeInplaceRgbConversion();
+ void colorSpaceRgbConversion_data();
+ void colorSpaceRgbConversion();
+ void colorSpaceCmykConversion_data();
+ void colorSpaceCmykConversion();
+ void colorSpaceFromGrayConversion_data();
+ void colorSpaceFromGrayConversion();
+ void colorSpaceToGrayConversion_data();
+ void colorSpaceToGrayConversion();
+
void deepCopyWhenPaintingActive();
void scaled_QTBUG19157();
@@ -229,6 +243,7 @@ private slots:
void largeRasterScale();
void metadataChangeWithReadOnlyPixels();
+ void scaleIndexed();
#if defined(Q_OS_WIN)
void toWinHBITMAP_data();
@@ -236,6 +251,9 @@ private slots:
void fromMonoHBITMAP();
#endif // Q_OS_WIN
+ void tofromPremultipliedFormat_data();
+ void tofromPremultipliedFormat();
+
private:
const QString m_prefix;
};
@@ -315,7 +333,9 @@ static QLatin1String formatToString(QImage::Format format)
return QLatin1String("RGBA32FPx4");
case QImage::Format_RGBA32FPx4_Premultiplied:
return QLatin1String("RGBA32FPx4pm");
- default:
+ case QImage::Format_CMYK8888:
+ return QLatin1String("CMYK8888");
+ case QImage::NImageFormats:
break;
};
Q_UNREACHABLE();
@@ -1133,10 +1153,9 @@ void tst_QImage::rotate_data()
QTest::addColumn<QImage::Format>("format");
QTest::addColumn<int>("degrees");
- QList<int> degrees;
- degrees << 0 << 90 << 180 << 270;
+ constexpr int degrees[] = {0, 90, 180, 270};
- foreach (int d, degrees) {
+ for (int d : degrees) {
const QString dB = QString::number(d);
for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; i++) {
QImage::Format format = static_cast<QImage::Format>(i);
@@ -1502,6 +1521,8 @@ void tst_QImage::setPixelWithAlpha_data()
continue;
if (c == QImage::Format_Alpha8)
continue;
+ if (c == QImage::Format_CMYK8888)
+ continue;
QTest::newRow(qPrintable(formatToString(QImage::Format(c)))) << QImage::Format(c);
}
}
@@ -2059,6 +2080,94 @@ void tst_QImage::smoothScaleFormats()
QVERIFY(rotated.hasAlphaChannel());
}
+void tst_QImage::smoothScaleNoConversion_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addRow("Mono") << QImage::Format_Mono;
+ QTest::addRow("MonoLSB") << QImage::Format_MonoLSB;
+ QTest::addRow("Indexed8") << QImage::Format_Indexed8;
+}
+
+void tst_QImage::smoothScaleNoConversion()
+{
+ QFETCH(QImage::Format, format);
+ QImage img(128, 128, format);
+ img.fill(1);
+ img.setColorTable(QList<QRgb>() << qRgba(255,0,0,255) << qRgba(0,0,0,0));
+ img = img.scaled(QSize(48, 48), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QVERIFY(img.hasAlphaChannel());
+}
+
+void tst_QImage::smoothScale_CMYK_data()
+{
+ QTest::addColumn<int>("size");
+
+ const int sizes[] = { 2, 3, 4, 6, 7, 8, 10, 16, 20, 32, 40, 64, 100, 101, 128 };
+ for (int size : sizes)
+ QTest::addRow("%d x %d", size, size) << size;
+}
+
+void tst_QImage::smoothScale_CMYK()
+{
+ QFETCH(int, size);
+ QImage img(size, size, QImage::Format_CMYK8888);
+ QCmyk32 expected(31, 63, 127, 127);
+ img.fill(expected.toUint());
+
+ auto getCmykPixel = [](const QImage &image, int x, int y) {
+ Q_ASSERT(image.format() == QImage::Format_CMYK8888);
+ const uint *line = reinterpret_cast<const uint *>(image.scanLine(y));
+ const uint pixel = line[x];
+ return QCmyk32::fromCmyk32(pixel);
+ };
+
+ // scale x down, y down
+ QImage scaled = img.scaled(QSize(1, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QCmyk32 pixel = getCmykPixel(scaled, 0, 0);
+ QCOMPARE(pixel, expected);
+
+ // scale x down, y up
+ scaled = img.scaled(QSize(1, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ pixel = getCmykPixel(scaled, 0, y);
+ QCOMPARE(pixel, expected);
+ }
+
+ // scale x up, y down
+ scaled = img.scaled(QSize(size * 2, 1), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, 0);
+ QCOMPARE(pixel, expected);
+ }
+
+ // scale x up
+ scaled = img.scaled(QSize(size, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+
+ // scale y up
+ scaled = img.scaled(QSize(size * 2, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+
+ // scale x up, y up
+ scaled = img.scaled(QSize(size * 2, size * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ for (int y = 0; y < scaled.height(); ++y) {
+ for (int x = 0; x < scaled.width(); ++x) {
+ pixel = getCmykPixel(scaled, x, y);
+ QCOMPARE(pixel, expected);
+ }
+ }
+}
+
static int count(const QImage &img, int x, int y, int dx, int dy, QRgb pixel)
{
int i = 0;
@@ -2545,7 +2654,8 @@ void tst_QImage::rgbSwapped_data()
for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; ++i) {
if (i == QImage::Format_Alpha8
|| i == QImage::Format_Grayscale8
- || i == QImage::Format_Grayscale16) {
+ || i == QImage::Format_Grayscale16
+ || i == QImage::Format_CMYK8888) {
continue;
}
QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i);
@@ -3027,13 +3137,15 @@ void tst_QImage::inplaceRgbConversion_data()
for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) {
if (i == QImage::Format_Alpha8
|| i == QImage::Format_Grayscale8
- || i == QImage::Format_Grayscale16) {
+ || i == QImage::Format_Grayscale16
+ || i == QImage::Format_CMYK8888) {
continue;
}
for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) {
if (j == QImage::Format_Alpha8
|| j == QImage::Format_Grayscale8
- || j == QImage::Format_Grayscale16) {
+ || j == QImage::Format_Grayscale16
+ || j == QImage::Format_CMYK8888) {
continue;
}
if (i == j)
@@ -3214,6 +3326,258 @@ void tst_QImage::largeInplaceRgbConversion()
}
}
+void tst_QImage::colorSpaceRgbConversion_data()
+{
+ QTest::addColumn<QImage::Format>("fromFormat");
+ QTest::addColumn<QImage::Format>("toFormat");
+
+ // The various possible code paths for color space conversions compatible with RGB color spaces:
+ QImage::Format formats[] = {
+ QImage::Format_RGB32,
+ QImage::Format_ARGB32,
+ QImage::Format_ARGB32_Premultiplied,
+ QImage::Format_RGBX64,
+ QImage::Format_RGBA64,
+ QImage::Format_RGBA64_Premultiplied,
+ QImage::Format_RGBX32FPx4,
+ QImage::Format_RGBA32FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ for (auto fromFormat : formats) {
+ const QLatin1String formatI = formatToString(fromFormat);
+ for (auto toFormat : formats) {
+ QTest::addRow("%s -> %s", formatI.data(), formatToString(toFormat).data())
+ << fromFormat << toFormat;
+ }
+ }
+}
+
+void tst_QImage::colorSpaceRgbConversion()
+{
+ // Test that all color space conversions work
+ QFETCH(QImage::Format, fromFormat);
+ QFETCH(QImage::Format, toFormat);
+
+ bool srcGrayscale = fromFormat == QImage::Format_Grayscale8 || fromFormat == QImage::Format_Grayscale16;
+ bool dstGrayscale = toFormat == QImage::Format_Grayscale8 || toFormat == QImage::Format_Grayscale16;
+
+ QImage image(16, 16, fromFormat);
+ image.setColorSpace(QColorSpace::SRgb);
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ if (srcGrayscale || dstGrayscale)
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ else
+ image.setPixel(j, i, qRgb(j * 16, i * 16, (i + j) * 8));
+ }
+ }
+
+ QImage imageConverted = image.convertedToColorSpace(QColorSpace::DisplayP3, toFormat);
+ QCOMPARE(imageConverted.format(), toFormat);
+ QCOMPARE(imageConverted.size(), image.size());
+ if (dstGrayscale) {
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 6));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+ } else {
+ int red = 0;
+ int blue = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newRed = qRed(imageConverted.pixel(x, 5));
+ int newBlue = qBlue(imageConverted.pixel(x, 7));
+ QCOMPARE_GE(newBlue, blue);
+ QCOMPARE_GE(newRed, red);
+ blue = newBlue;
+ red = newRed;
+ }
+ }
+}
+
+
+void tst_QImage::colorSpaceCmykConversion_data()
+{
+ QTest::addColumn<QImage::Format>("toFormat");
+
+ QImage::Format formats[] = {
+ QImage::Format_RGB32,
+ QImage::Format_ARGB32,
+ QImage::Format_ARGB32_Premultiplied,
+ QImage::Format_RGBX64,
+ QImage::Format_RGBA64,
+ QImage::Format_RGBA64_Premultiplied,
+ QImage::Format_RGBX32FPx4,
+ QImage::Format_RGBA32FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ for (auto toFormat : formats)
+ QTest::addRow("CMYK8888 -> %s", formatToString(toFormat).data()) << toFormat;
+}
+
+void tst_QImage::colorSpaceCmykConversion()
+{
+ QFETCH(QImage::Format, toFormat);
+
+ bool dstGrayscale = toFormat == QImage::Format_Grayscale8 || toFormat == QImage::Format_Grayscale16;
+
+ QImage image(16, 16, QImage::Format_CMYK8888);
+ QFile iccProfile(m_prefix +"CGATS001Compat-v2-micro.icc");
+ iccProfile.open(QIODevice::ReadOnly);
+ image.setColorSpace(QColorSpace::fromIccProfile(iccProfile.readAll()));
+ QVERIFY(image.colorSpace().isValid());
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ if (dstGrayscale)
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ else
+ image.setPixel(j, i, qRgb(j * 16, i * 16, (i + j) * 8));
+ }
+ }
+
+ QImage imageConverted = image.convertedToColorSpace(QColorSpace::SRgb, toFormat);
+ QCOMPARE(imageConverted.format(), toFormat);
+ QCOMPARE(imageConverted.size(), image.size());
+ if (dstGrayscale) {
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 6));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+ } else {
+ int red = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newRed = qRed(imageConverted.pixel(x, 5));
+ QCOMPARE_GE(newRed, red);
+ red = newRed;
+ }
+ }
+}
+
+void tst_QImage::colorSpaceFromGrayConversion_data()
+{
+ QTest::addColumn<QImage::Format>("fromFormat");
+ QTest::addColumn<QColorSpace>("fromCS");
+ QTest::addColumn<QColorSpace>("toCS");
+
+ QImage::Format formats[] = {
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ QList<QColorSpace> colorSpaces = {
+ QColorSpace::SRgbLinear,
+ QColorSpace::DisplayP3,
+ QColorSpace(QPointF(0.31271, 0.32902), QColorSpace::TransferFunction::SRgb),
+ QColorSpace(QPointF(0.30, 0.33), QColorSpace::TransferFunction::Linear)
+ };
+ std::string names[] = {
+ "sRgbLinear",
+ "displayP3",
+ "graySRgb",
+ "grayOther",
+ "videoHD(A2B)"
+ };
+
+ QFile iccProfile(m_prefix + "VideoHD.icc");
+ iccProfile.open(QIODevice::ReadOnly);
+ colorSpaces.append(QColorSpace::fromIccProfile(iccProfile.readAll()));
+
+ for (auto fromFormat : formats) {
+ for (int from = 0; from < 5; ++from) {
+ for (int to = 0; to < 4; ++to) {
+ QTest::addRow("%s: %s -> %s", formatToString(fromFormat).data(), names[from].c_str(), names[to].c_str())
+ << fromFormat << colorSpaces[from] << colorSpaces[to];
+ }
+ }
+ }
+}
+
+void tst_QImage::colorSpaceFromGrayConversion()
+{
+ QFETCH(QImage::Format, fromFormat);
+ QFETCH(QColorSpace, fromCS);
+ QFETCH(QColorSpace, toCS);
+
+ QImage image(16, 16, fromFormat);
+ image.setColorSpace(fromCS);
+ QVERIFY(image.colorSpace().isValid());
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ }
+ }
+ QImage imageConverted = image.convertedToColorSpace(toCS);
+ QCOMPARE(imageConverted.format(), fromFormat);
+ QCOMPARE(imageConverted.size(), image.size());
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 3));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+}
+
+void tst_QImage::colorSpaceToGrayConversion_data()
+{
+ QTest::addColumn<QImage::Format>("fromFormat");
+
+ QImage::Format formats[] = {
+ QImage::Format_RGB32,
+ QImage::Format_ARGB32,
+ QImage::Format_ARGB32_Premultiplied,
+ QImage::Format_RGBX64,
+ QImage::Format_RGBA64,
+ QImage::Format_RGBA64_Premultiplied,
+ QImage::Format_RGBX32FPx4,
+ QImage::Format_RGBA32FPx4,
+ QImage::Format_RGBA32FPx4_Premultiplied,
+ QImage::Format_Grayscale8,
+ QImage::Format_Grayscale16,
+ };
+
+ for (auto fromFormat : formats)
+ QTest::addRow("%s -> Gray", formatToString(fromFormat).data()) << fromFormat;
+}
+
+void tst_QImage::colorSpaceToGrayConversion()
+{
+ QFETCH(QImage::Format, fromFormat);
+
+ QImage image(16, 16, fromFormat);
+ image.setColorSpace(QColorSpace::DisplayP3);
+ QVERIFY(image.colorSpace().isValid());
+
+ for (int i = 0; i < image.height(); ++i) {
+ for (int j = 0; j < image.width(); ++j) {
+ image.setPixel(j, i, qRgb((i + j) * 8, (i + j) * 8, (i + j) * 8));
+ }
+ }
+
+ QColorSpace grayColorSpace(QPointF(0.31271, 0.32902), QColorSpace::TransferFunction::SRgb);
+
+ QImage imageConverted = image.convertedToColorSpace(grayColorSpace);
+ QVERIFY(imageConverted.format() == QImage::Format_Grayscale8 || imageConverted.format() == QImage::Format_Grayscale16);
+ QCOMPARE(imageConverted.size(), image.size());
+ int gray = 0;
+ for (int x = 0; x < image.width(); ++x) {
+ int newGray = qGray(imageConverted.pixel(x, 11));
+ QCOMPARE_GE(newGray, gray);
+ gray = newGray;
+ }
+}
+
void tst_QImage::deepCopyWhenPaintingActive()
{
QImage image(64, 64, QImage::Format_ARGB32_Premultiplied);
@@ -3322,7 +3686,8 @@ void tst_QImage::invertPixelsRGB_data()
for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) {
if (i == QImage::Format_Alpha8
|| i == QImage::Format_Grayscale8
- || i == QImage::Format_Grayscale16) {
+ || i == QImage::Format_Grayscale16
+ || i == QImage::Format_CMYK8888) {
continue;
}
QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i);
@@ -3689,10 +4054,12 @@ void tst_QImage::metadataPassthrough()
QCOMPARE(alphaMask.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(alphaMask.devicePixelRatio(), a.devicePixelRatio());
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
QImage heuristicMask = a.createHeuristicMask();
QCOMPARE(heuristicMask.dotsPerMeterX(), a.dotsPerMeterX());
QCOMPARE(heuristicMask.dotsPerMeterY(), a.dotsPerMeterY());
QCOMPARE(heuristicMask.devicePixelRatio(), a.devicePixelRatio());
+#endif
QImage maskFromColor = a.createMaskFromColor(qRgb(0, 0, 0));
QCOMPARE(maskFromColor.dotsPerMeterX(), a.dotsPerMeterX());
@@ -4080,6 +4447,16 @@ void tst_QImage::metadataChangeWithReadOnlyPixels()
QCOMPARE(image.constBits(), (const uchar *)data);
}
+void tst_QImage::scaleIndexed()
+{
+ QImage image(10, 10, QImage::Format_Indexed8);
+ image.setColor(0, qRgb(0,0,0));
+ image.setColor(1, qRgb(1,1,1));
+ image.fill(1);
+ image.setDevicePixelRatio(2);
+ QImage image2 = image.scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation); // do not crash
+}
+
#if defined(Q_OS_WIN)
static inline QColor COLORREFToQColor(COLORREF cr)
@@ -4192,5 +4569,27 @@ void tst_QImage::fromMonoHBITMAP() // QTBUG-72343, corruption for mono bitmaps
#endif // Q_OS_WIN
+void tst_QImage::tofromPremultipliedFormat_data()
+{
+ QTest::addColumn<QImage::Format>("unpremul");
+ QTest::addColumn<QImage::Format>("premul");
+
+ // Test all available formats with both premultiplied and unpremultiplied versions
+ QTest::newRow("argb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgba8888") << QImage::Format_RGBA8888 << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("rgba64") << QImage::Format_RGBA64 << QImage::Format_RGBA64_Premultiplied;
+ QTest::newRow("rgba16fpx4") << QImage::Format_RGBA16FPx4 << QImage::Format_RGBA16FPx4_Premultiplied;
+ QTest::newRow("rgba32fpx4") << QImage::Format_RGBA32FPx4 << QImage::Format_RGBA32FPx4_Premultiplied;
+}
+
+void tst_QImage::tofromPremultipliedFormat()
+{
+ QFETCH(QImage::Format, unpremul);
+ QFETCH(QImage::Format, premul);
+
+ QCOMPARE(qt_toPremultipliedFormat(unpremul), premul);
+ QCOMPARE(qt_toUnpremultipliedFormat(premul), unpremul);
+}
+
QTEST_GUILESS_MAIN(tst_QImage)
#include "tst_qimage.moc"
diff --git a/tests/auto/gui/image/qimageiohandler/CMakeLists.txt b/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
index ccf6c617a9..9fbd9c9b9f 100644
--- a/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
+++ b/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qimageiohandler Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qimageiohandler LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qimageiohandler
SOURCES
tst_qimageiohandler.cpp
diff --git a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
index fd0e61b1ba..bd325e185c 100644
--- a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
+++ b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/image/qimagereader/CMakeLists.txt b/tests/auto/gui/image/qimagereader/CMakeLists.txt
index 0c19b33797..2a14ca3c9c 100644
--- a/tests/auto/gui/image/qimagereader/CMakeLists.txt
+++ b/tests/auto/gui/image/qimagereader/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qimagereader Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qimagereader LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qimagereader/images/image.pbm b/tests/auto/gui/image/qimagereader/images/image.pbm
index 67e5efa3e9..e529536ca4 100644
--- a/tests/auto/gui/image/qimagereader/images/image.pbm
+++ b/tests/auto/gui/image/qimagereader/images/image.pbm
@@ -1,8 +1,8 @@
P1
16 6
1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
+10 00 00 00 01 00 00 01
+1000 0000 0100 0001
+100000000 1000001
+1000000001000001
+10 000 0000 10000 01
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index cfd48ec1e4..96af8b4e9b 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -1,6 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -11,7 +10,7 @@
#include <QImageReader>
#include <QImageWriter>
#include <QPixmap>
-#include <QSet>
+#include <QScopeGuard>
#include <QTcpSocket>
#include <QTcpServer>
#include <QTimer>
@@ -63,6 +62,9 @@ private slots:
void setScaledSize_data();
void setScaledSize();
+ void setScaledSizeOneDimension_data();
+ void setScaledSizeOneDimension();
+
void setClipRect_data();
void setClipRect();
@@ -301,25 +303,52 @@ void tst_QImageReader::jpegRgbCmyk()
QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg"));
QImage image2(prefix + QLatin1String("YCbCr_cmyk.png"));
- if (image1 != image2) {
- // first, do some obvious tests
- QCOMPARE(image1.height(), image2.height());
- QCOMPARE(image1.width(), image2.width());
- QCOMPARE(image1.format(), image2.format());
- QCOMPARE(image1.format(), QImage::Format_RGB32);
-
- // compare all the pixels with a slack of 3. This ignores rounding errors
- // in libjpeg/libpng, where some versions sacrifice accuracy for speed.
- for (int h = 0; h < image1.height(); ++h) {
- const uchar *s1 = image1.constScanLine(h);
- const uchar *s2 = image2.constScanLine(h);
- for (int w = 0; w < image1.width() * 4; ++w) {
- if (*s1 != *s2) {
- QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16)));
- }
- s1++;
- s2++;
- }
+ QVERIFY(!image1.isNull());
+ QVERIFY(!image2.isNull());
+
+ QCOMPARE(image1.height(), image2.height());
+ QCOMPARE(image1.width(), image2.width());
+
+ QCOMPARE(image1.format(), QImage::Format_CMYK8888);
+ QCOMPARE(image2.format(), QImage::Format_RGB32);
+
+ // compare all the pixels with a slack of 3. This ignores rounding errors
+ // in libjpeg/libpng, where some versions sacrifice accuracy for speed.
+ const auto fuzzyCompareColors = [](const QColor &c1, const QColor &c2) {
+ int c1rgba[4];
+ int c2rgba[4];
+
+ c1.getRgb(c1rgba + 0,
+ c1rgba + 1,
+ c1rgba + 2,
+ c1rgba + 3);
+
+ c2.getRgb(c2rgba + 0,
+ c2rgba + 1,
+ c2rgba + 2,
+ c2rgba + 3);
+
+ const auto fuzzyCompare = [](int a, int b) {
+ return qAbs(a - b) <= 3;
+ };
+
+ return fuzzyCompare(c1rgba[0], c2rgba[0]) &&
+ fuzzyCompare(c1rgba[1], c2rgba[1]) &&
+ fuzzyCompare(c1rgba[2], c2rgba[2]) &&
+ fuzzyCompare(c1rgba[3], c2rgba[3]);
+ };
+
+ for (int h = 0; h < image1.height(); ++h) {
+ const uchar *sl1 = image1.constScanLine(h);
+ const uchar *sl2 = image2.constScanLine(h);
+ for (int w = 0; w < image1.width(); ++w) {
+ const uchar *s1 = sl1 + w * 4;
+ const uchar *s2 = sl2 + w * 4;
+
+ QColor c1 = QColor::fromCmyk(s1[0], s1[1], s1[2], s1[3]);
+ QColor c2 = QColor::fromRgb(s2[2], s2[1], s2[0]);
+ QVERIFY2(fuzzyCompareColors(c1, c2),
+ qPrintable(QString("images differ in line %1, col %2").arg(h).arg(w)));
}
}
}
@@ -372,6 +401,60 @@ void tst_QImageReader::setScaledSize()
QCOMPARE(image.size(), newSize);
}
+void tst_QImageReader::setScaledSizeOneDimension_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QByteArray>("format");
+
+ QTest::newRow("PNG: kollada") << QString("kollada") << QByteArray("png");
+ QTest::newRow("JPEG: beavis") << QString("beavis") << QByteArray("jpeg");
+ QTest::newRow("GIF: earth") << QString("earth") << QByteArray("gif");
+ QTest::newRow("SVG: rect") << QString("rect") << QByteArray("svg");
+ QTest::newRow("BMP: colorful") << QString("colorful") << QByteArray("bmp");
+ QTest::newRow("XPM: marble") << QString("marble") << QByteArray("xpm");
+ QTest::newRow("PPM: teapot") << QString("teapot") << QByteArray("ppm");
+ QTest::newRow("XBM: gnus") << QString("gnus") << QByteArray("xbm");
+}
+
+void tst_QImageReader::setScaledSizeOneDimension()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QByteArray, format);
+
+ SKIP_IF_UNSUPPORTED(format);
+
+ const QSize originalSize = QImageReader(prefix + fileName).size();
+ QVERIFY(!originalSize.isEmpty());
+
+ auto testScaledSize = [&] (const QSize &scaledSize) {
+ QSize expectedSize = scaledSize;
+ if (scaledSize.width() <= 0)
+ expectedSize.setWidth(qRound(originalSize.width() *
+ (qreal(scaledSize.height()) / originalSize.height())));
+ else if (scaledSize.height() <= 0)
+ expectedSize.setHeight(qRound(originalSize.height() *
+ (qreal(scaledSize.width()) / originalSize.width())));
+
+ QImageReader reader(prefix + fileName);
+ reader.setScaledSize(scaledSize);
+ QImage image = reader.read();
+ QVERIFY(!image.isNull());
+ QCOMPARE(image.size(), expectedSize);
+ };
+
+ // downscale
+ testScaledSize(QSize(originalSize.width() / 2, 0));
+ testScaledSize(QSize(originalSize.width() / 2, -1));
+ testScaledSize(QSize(0, originalSize.height() / 2));
+ testScaledSize(QSize(-1, originalSize.height() / 2));
+
+ // upscale
+ testScaledSize(QSize(originalSize.width() * 2, 0));
+ testScaledSize(QSize(originalSize.width() * 2, -1));
+ testScaledSize(QSize(0, originalSize.height() * 2));
+ testScaledSize(QSize(-1, originalSize.height() * 2));
+}
+
void tst_QImageReader::task255627_setNullScaledSize_data()
{
setScaledSize_data();
@@ -533,7 +616,7 @@ void tst_QImageReader::imageFormat_data()
QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32;
QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Grayscale8;
- QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
+ QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_CMYK8888;
QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32;
QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif") << QImage::Format_Invalid;
@@ -594,41 +677,31 @@ void tst_QImageReader::multiWordNamedColorXPM()
QCOMPARE(image.pixel(0, 2), qRgb(255, 250, 205)); // lemon chiffon
}
-void tst_QImageReader::supportedFormats()
+namespace {
+template <typename ForwardIterator>
+bool is_sorted_unique(ForwardIterator first, ForwardIterator last)
{
- QList<QByteArray> formats = QImageReader::supportedImageFormats();
- QList<QByteArray> sortedFormats = formats;
- std::sort(sortedFormats.begin(), sortedFormats.end());
-
- // check that the list is sorted
- QCOMPARE(formats, sortedFormats);
-
- QSet<QByteArray> formatSet;
- foreach (QByteArray format, formats)
- formatSet << format;
+ // a range is sorted with no dups iff each *i < *(i+1), so check that none are >=:
+ return std::adjacent_find(first, last, std::greater_equal<>{}) == last;
+}
+}
- // check that the list does not contain duplicates
- QCOMPARE(formatSet.size(), formats.size());
+void tst_QImageReader::supportedFormats()
+{
+ const QList<QByteArray> formats = QImageReader::supportedImageFormats();
+ auto printOnFailure = qScopeGuard([&] { qDebug() << formats; });
+ QVERIFY(is_sorted_unique(formats.begin(), formats.end()));
+ printOnFailure.dismiss();
}
void tst_QImageReader::supportedMimeTypes()
{
- QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
- QList<QByteArray> sortedMimeTypes = mimeTypes;
- std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
-
- // check that the list is sorted
- QCOMPARE(mimeTypes, sortedMimeTypes);
-
- QSet<QByteArray> mimeTypeSet;
- foreach (QByteArray mimeType, mimeTypes)
- mimeTypeSet << mimeType;
-
+ const QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes();
+ auto printOnFailure = qScopeGuard([&] { qDebug() << mimeTypes; });
+ QVERIFY(is_sorted_unique(mimeTypes.begin(), mimeTypes.end()));
// check the list as a minimum contains image/bmp
- QVERIFY(mimeTypeSet.contains("image/bmp"));
-
- // check that the list does not contain duplicates
- QCOMPARE(mimeTypeSet.size(), mimeTypes.size());
+ QVERIFY(mimeTypes.contains("image/bmp"));
+ printOnFailure.dismiss();
}
void tst_QImageReader::setBackgroundColor_data()
@@ -673,7 +746,7 @@ void tst_QImageReader::supportsAnimation_data()
QTest::newRow("BMP: colorful") << QString("colorful.bmp") << false;
QTest::newRow("BMP: font") << QString("font.bmp") << false;
QTest::newRow("BMP: signed char") << QString("crash-signed-char.bmp") << false;
- QTest::newRow("BMP: test32bfv4") << QString("test32bfv4.bmp") << false;;
+ QTest::newRow("BMP: test32bfv4") << QString("test32bfv4.bmp") << false;
QTest::newRow("BMP: test32v5") << QString("test32v5.bmp") << false;
QTest::newRow("XPM: marble") << QString("marble.xpm") << false;
QTest::newRow("PNG: kollada") << QString("kollada.png") << false;
@@ -1623,43 +1696,56 @@ void tst_QImageReader::supportsOption_data()
QTest::addColumn<QIntList>("options");
QTest::newRow("png") << QString("black.png")
- << (QIntList() << QImageIOHandler::Gamma
- << QImageIOHandler::Description
- << QImageIOHandler::Quality
- << QImageIOHandler::CompressionRatio
- << QImageIOHandler::Size
- << QImageIOHandler::ScaledSize);
+ << QIntList{
+ QImageIOHandler::Gamma,
+ QImageIOHandler::Description,
+ QImageIOHandler::Quality,
+ QImageIOHandler::CompressionRatio,
+ QImageIOHandler::Size,
+ QImageIOHandler::ScaledSize,
+ QImageIOHandler::ImageFormat,
+ };
}
void tst_QImageReader::supportsOption()
{
QFETCH(QString, fileName);
- QFETCH(QIntList, options);
-
- QSet<QImageIOHandler::ImageOption> allOptions;
- allOptions << QImageIOHandler::Size
- << QImageIOHandler::ClipRect
- << QImageIOHandler::Description
- << QImageIOHandler::ScaledClipRect
- << QImageIOHandler::ScaledSize
- << QImageIOHandler::CompressionRatio
- << QImageIOHandler::Gamma
- << QImageIOHandler::Quality
- << QImageIOHandler::Name
- << QImageIOHandler::SubType
- << QImageIOHandler::IncrementalReading
- << QImageIOHandler::Endianness
- << QImageIOHandler::Animation
- << QImageIOHandler::BackgroundColor;
+ QFETCH(const QIntList, options);
QImageReader reader(prefix + fileName);
- for (int i = 0; i < options.size(); ++i) {
- QVERIFY(reader.supportsOption(QImageIOHandler::ImageOption(options.at(i))));
- allOptions.remove(QImageIOHandler::ImageOption(options.at(i)));
- }
- foreach (QImageIOHandler::ImageOption option, allOptions)
- QVERIFY(!reader.supportsOption(option));
+ for (int i = 0; ; ++i) {
+ // this switch ensures the compiler warns when we miss an enumerator [-Wswitch]
+ // do _not_ add a default case!
+ switch (const auto o = QImageIOHandler::ImageOption(i)) {
+ case QImageIOHandler::Size:
+ case QImageIOHandler::ClipRect:
+ case QImageIOHandler::Description:
+ case QImageIOHandler::ScaledClipRect:
+ case QImageIOHandler::ScaledSize:
+ case QImageIOHandler::CompressionRatio:
+ case QImageIOHandler::Gamma:
+ case QImageIOHandler::Quality:
+ case QImageIOHandler::Name:
+ case QImageIOHandler::SubType:
+ case QImageIOHandler::IncrementalReading:
+ case QImageIOHandler::Endianness:
+ case QImageIOHandler::Animation:
+ case QImageIOHandler::BackgroundColor:
+ case QImageIOHandler::ImageFormat:
+ case QImageIOHandler::SupportedSubTypes:
+ case QImageIOHandler::OptimizedWrite:
+ case QImageIOHandler::ProgressiveScanWrite:
+ case QImageIOHandler::ImageTransformation:
+ {
+ auto printOnFailure = qScopeGuard([&] { qDebug("failed at %d", i); });
+ QCOMPARE(reader.supportsOption(o), options.contains(i));
+ printOnFailure.dismiss();
+ continue; // ... as long as `i` represents a valid ImageOption value
+ }
+ }
+ break; // ... once `i` no longer represents a valid ImageOption value
+ }
}
void tst_QImageReader::autoDetectImageFormat()
@@ -1828,13 +1914,13 @@ void tst_QImageReader::testIgnoresFormatAndExtension()
SKIP_IF_UNSUPPORTED(expected.toLatin1());
- QList<QByteArray> formats = QImageReader::supportedImageFormats();
+ const QList<QByteArray> formats = QImageReader::supportedImageFormats();
QString fileNameBase = prefix + name + QLatin1Char('.');
QString tempPath = m_temporaryDir.path();
if (!tempPath.endsWith(QLatin1Char('/')))
tempPath += QLatin1Char('/');
- foreach (const QByteArray &f, formats) {
+ for (const QByteArray &f : formats) {
if (f == extension.toLocal8Bit())
continue;
diff --git a/tests/auto/gui/image/qimagewriter/CMakeLists.txt b/tests/auto/gui/image/qimagewriter/CMakeLists.txt
index 31f1a1057a..06273ce7e4 100644
--- a/tests/auto/gui/image/qimagewriter/CMakeLists.txt
+++ b/tests/auto/gui/image/qimagewriter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qimagewriter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qimagewriter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index f64c94bb90..1059cc48ab 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QDebug>
diff --git a/tests/auto/gui/image/qmovie/CMakeLists.txt b/tests/auto/gui/image/qmovie/CMakeLists.txt
index 00fd2f22c5..52e0a347c4 100644
--- a/tests/auto/gui/image/qmovie/CMakeLists.txt
+++ b/tests/auto/gui/image/qmovie/CMakeLists.txt
@@ -5,10 +5,16 @@
## tst_qmovie Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmovie LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- animations/*)
+ animations/* multiframe/*)
list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qmovie
@@ -16,6 +22,7 @@ qt_internal_add_test(tst_qmovie
tst_qmovie.cpp
LIBRARIES
Qt::Gui
+ Qt::TestPrivate
TESTDATA ${test_data}
)
@@ -24,6 +31,7 @@ set(resources_resource_files
"animations/comicsecard.gif"
"animations/corrupt.gif"
"animations/trolltech.gif"
+ "multiframe/Obj_N2_Internal_Mem.ico"
)
qt_internal_add_resource(tst_qmovie "resources"
diff --git a/tests/auto/gui/image/qmovie/multiframe/Obj_N2_Internal_Mem.ico b/tests/auto/gui/image/qmovie/multiframe/Obj_N2_Internal_Mem.ico
new file mode 100644
index 0000000000..8da119efdd
--- /dev/null
+++ b/tests/auto/gui/image/qmovie/multiframe/Obj_N2_Internal_Mem.ico
Binary files differ
diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
index 1cf13f6f9c..29c3297043 100644
--- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp
+++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
@@ -1,10 +1,11 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QTestEventLoop>
#include <QSignalSpy>
+#include <QtTest/private/qpropertytesthelper_p.h>
#include <QIODevice>
#ifndef QT_NO_WIDGETS
@@ -35,12 +36,20 @@ private slots:
void playMovie();
void jumpToFrame_data();
void jumpToFrame();
+ void frameDelay();
void changeMovieFile();
#ifndef QT_NO_WIDGETS
void infiniteLoop();
#endif
void emptyMovie();
void bindings();
+ void automatedBindings();
+#ifndef QT_NO_ICO
+ void multiFrameImage();
+#endif
+
+ void setScaledSize_data();
+ void setScaledSize();
};
// Testing get/set functions
@@ -176,6 +185,17 @@ void tst_QMovie::jumpToFrame()
QCOMPARE(movie.currentFrameNumber(), 0);
}
+void tst_QMovie::frameDelay()
+{
+ QMovie movie(QFINDTESTDATA("animations/comicsecard.gif"));
+ QList<int> frameDelays{ 200, 800, 800, 2000, 2600 };
+ for (int i = 0; i < movie.frameCount(); i++) {
+ movie.jumpToFrame(i);
+ // Processing may have taken a little time, so round to nearest 100ms
+ QCOMPARE(100 * qRound(movie.nextFrameDelay() / 100.0f), frameDelays[i]);
+ }
+}
+
void tst_QMovie::changeMovieFile()
{
QMovie movie(QFINDTESTDATA("animations/comicsecard.gif"));
@@ -239,5 +259,78 @@ void tst_QMovie::bindings()
QCOMPARE(cacheModeObserver, QMovie::CacheAll);
}
+void tst_QMovie::automatedBindings()
+{
+ QMovie movie;
+
+ QTestPrivate::testReadWritePropertyBasics(movie, 50, 100, "speed");
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QMovie::speed");
+ return;
+ }
+
+ QTestPrivate::testReadWritePropertyBasics(movie, QMovie::CacheAll, QMovie::CacheNone,
+ "cacheMode");
+ if (QTest::currentTestFailed()) {
+ qDebug("Failed property test for QMovie::cacheMode");
+ return;
+ }
+}
+
+#ifndef QT_NO_ICO
+/*! \internal
+ Test behavior of QMovie with image formats that are multi-frame,
+ but not normally intended as animation formats (such as tiff and ico).
+*/
+void tst_QMovie::multiFrameImage()
+{
+ QMovie movie(QFINDTESTDATA("multiframe/Obj_N2_Internal_Mem.ico"));
+ const int expectedFrameCount = 9;
+
+ QCOMPARE(movie.frameCount(), expectedFrameCount);
+ QVERIFY(movie.isValid());
+ movie.setSpeed(1000); // speed up the test: play at 10 FPS (1000% of normal)
+ QElapsedTimer playTimer;
+ QSignalSpy frameChangedSpy(&movie, &QMovie::frameChanged);
+ QSignalSpy errorSpy(&movie, &QMovie::error);
+ QSignalSpy finishedSpy(&movie, &QMovie::finished);
+ playTimer.start();
+ movie.start();
+ QTRY_COMPARE(finishedSpy.size(), 1);
+ QCOMPARE_GE(playTimer.elapsed(), 100 * expectedFrameCount);
+ QCOMPARE(movie.nextFrameDelay(), 100);
+ QCOMPARE(errorSpy.size(), 0);
+ QCOMPARE(frameChangedSpy.size(), expectedFrameCount);
+}
+#endif
+
+void tst_QMovie::setScaledSize_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<QSize>("scaledSize");
+ QTest::addColumn<QSize>("expectedSize");
+
+ QTest::newRow("trolltech (50, 50)") << QString("animations/trolltech.gif") << QSize(50, 50) << QSize(50, 50);
+ QTest::newRow("trolltech (400, 400)") << QString("animations/trolltech.gif") << QSize(400, 400) << QSize(400, 400);
+ QTest::newRow("trolltech (50, 0)") << QString("animations/trolltech.gif") << QSize(50, 0) << QSize(50, 25);
+ QTest::newRow("trolltech (50, -1)") << QString("animations/trolltech.gif") << QSize(50, -1) << QSize(50, 25);
+ QTest::newRow("trolltech (0, 50)") << QString("animations/trolltech.gif") << QSize(0, 50) << QSize(100, 50);
+ QTest::newRow("trolltech (-1, 50)") << QString("animations/trolltech.gif") << QSize(-1, 50) << QSize(100, 50);
+}
+
+void tst_QMovie::setScaledSize()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QSize, scaledSize);
+ QFETCH(QSize, expectedSize);
+
+ QMovie movie(QFINDTESTDATA(fileName));
+ movie.setScaledSize(scaledSize);
+
+ movie.start();
+ QCOMPARE(movie.currentFrameNumber(), 0);
+ QCOMPARE(movie.currentImage().size(), expectedSize);
+}
+
QTEST_MAIN(tst_QMovie)
#include "tst_qmovie.moc"
diff --git a/tests/auto/gui/image/qpicture/CMakeLists.txt b/tests/auto/gui/image/qpicture/CMakeLists.txt
index af77725652..30b0aafd11 100644
--- a/tests/auto/gui/image/qpicture/CMakeLists.txt
+++ b/tests/auto/gui/image/qpicture/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpicture Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpicture LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpicture
SOURCES
tst_qpicture.cpp
diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
index de2b841927..2fa4436154 100644
--- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp
+++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/image/qpixmap/CMakeLists.txt b/tests/auto/gui/image/qpixmap/CMakeLists.txt
index 61267d396f..8531ef5b7b 100644
--- a/tests/auto/gui/image/qpixmap/CMakeLists.txt
+++ b/tests/auto/gui/image/qpixmap/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpixmap Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpixmap LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 4e9be4e033..d8c553b521 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QSet>
#include <QTemporaryFile>
@@ -1176,8 +1176,10 @@ void tst_QPixmap::dprPassthrough()
pm.convertFromImage(img);
QCOMPARE(pm.devicePixelRatio(), dpr);
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
QBitmap heuristicMask = src.createHeuristicMask();
QCOMPARE(heuristicMask.devicePixelRatio(), dpr);
+#endif
QBitmap maskFromColor = src.createMaskFromColor(Qt::white);
QCOMPARE(maskFromColor.devicePixelRatio(), dpr);
@@ -1423,7 +1425,7 @@ void tst_QPixmap::loadFromDataImage()
QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
QFile file(imagePath);
- file.open(QIODevice::ReadOnly);
+ QVERIFY(file.open(QIODevice::ReadOnly));
QByteArray rawData = file.readAll();
QPixmap directLoadingPixmap;
diff --git a/tests/auto/gui/image/qpixmapcache/CMakeLists.txt b/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
index 8855d07823..444de9cb3e 100644
--- a/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
+++ b/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpixmapcache Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpixmapcache LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpixmapcache
SOURCES
tst_qpixmapcache.cpp
diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
index d4c39a2130..8384a46491 100644
--- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -7,12 +7,16 @@
#include <qpixmapcache.h>
#include "private/qpixmapcache_p.h"
+#include <functional>
+
QT_BEGIN_NAMESPACE // The test requires QT_BUILD_INTERNAL
Q_AUTOTEST_EXPORT void qt_qpixmapcache_flush_detached_pixmaps();
Q_AUTOTEST_EXPORT int qt_qpixmapcache_qpixmapcache_total_used();
Q_AUTOTEST_EXPORT int q_QPixmapCache_keyHashSize();
QT_END_NAMESPACE
+using namespace Qt::StringLiterals;
+
class tst_QPixmapCache : public QObject
{
Q_OBJECT
@@ -29,13 +33,22 @@ private slots:
void setCacheLimit();
void find();
void insert();
+ void failedInsertReturnsInvalidKey();
+#if QT_DEPRECATED_SINCE(6, 6)
void replace();
+#endif
void remove();
void clear();
void pixmapKey();
void noLeak();
+ void clearDoesNotLeakStringKeys();
+ void evictionDoesNotLeakStringKeys();
+ void reducingCacheLimitDoesNotLeakStringKeys();
void strictCacheLimit();
void noCrashOnLargeInsert();
+
+private:
+ void stringLeak_impl(std::function<void()> whenOp);
};
static QPixmapCache::KeyData* getPrivate(QPixmapCache::Key &key)
@@ -102,28 +115,32 @@ void tst_QPixmapCache::setCacheLimit()
//The int part of the API
p1 = new QPixmap(2, 3);
QPixmapCache::Key key = QPixmapCache::insert(*p1);
- QVERIFY(QPixmapCache::find(key, p1) != 0);
+ QVERIFY(QPixmapCache::find(key, p1));
delete p1;
QPixmapCache::setCacheLimit(0);
- QVERIFY(QPixmapCache::find(key, p1) == 0);
+ QVERIFY(!QPixmapCache::find(key, p1));
- p1 = new QPixmap(2, 3);
QPixmapCache::setCacheLimit(1000);
- QPixmapCache::replace(key, *p1);
- QVERIFY(QPixmapCache::find(key, p1) == 0);
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ p1 = new QPixmap(2, 3);
+ QVERIFY(!QPixmapCache::replace(key, *p1));
+ QVERIFY(!QPixmapCache::find(key, p1));
delete p1;
+#endif // QT_DEPRECATED_SINCE(6, 6)
//Let check if keys are released when the pixmap cache is
//full or has been flushed.
QPixmapCache::clear();
p1 = new QPixmap(2, 3);
key = QPixmapCache::insert(*p1);
- QVERIFY(QPixmapCache::find(key, p1) != 0);
+ QVERIFY(QPixmapCache::find(key, p1));
p1->detach(); // dectach so that the cache thinks no-one is using it.
QPixmapCache::setCacheLimit(0);
- QVERIFY(QPixmapCache::find(key, p1) == 0);
+ QVERIFY(!QPixmapCache::find(key, p1));
QPixmapCache::setCacheLimit(1000);
key = QPixmapCache::insert(*p1);
QVERIFY(key.isValid());
@@ -137,7 +154,7 @@ void tst_QPixmapCache::setCacheLimit()
QPixmap p2;
p1 = new QPixmap(2, 3);
key = QPixmapCache::insert(*p1);
- QVERIFY(QPixmapCache::find(key, &p2) != 0);
+ QVERIFY(QPixmapCache::find(key, &p2));
//we flush the cache
p1->detach();
p2.detach();
@@ -145,8 +162,8 @@ void tst_QPixmapCache::setCacheLimit()
QPixmapCache::setCacheLimit(1000);
QPixmapCache::Key key2 = QPixmapCache::insert(*p1);
QCOMPARE(getPrivate(key2)->key, 1);
- QVERIFY(QPixmapCache::find(key, &p2) == 0);
- QVERIFY(QPixmapCache::find(key2, &p2) != 0);
+ QVERIFY(!QPixmapCache::find(key, &p2));
+ QVERIFY(QPixmapCache::find(key2, &p2));
QCOMPARE(p2, *p1);
delete p1;
@@ -169,7 +186,7 @@ void tst_QPixmapCache::setCacheLimit()
QCOMPARE(getPrivate(key2)->key, 1);
//This old key is not valid anymore after the flush
QVERIFY(!key.isValid());
- QVERIFY(QPixmapCache::find(key, &p2) == 0);
+ QVERIFY(!QPixmapCache::find(key, &p2));
delete p1;
}
@@ -207,7 +224,7 @@ void tst_QPixmapCache::find()
QPixmapCache::insert(p5);
//at that time the first key has been erase because no more place in the cache
- QVERIFY(QPixmapCache::find(key, &p1) == 0);
+ QVERIFY(!QPixmapCache::find(key, &p1));
QVERIFY(!key.isValid());
}
@@ -266,6 +283,7 @@ void tst_QPixmapCache::insert()
for (int i = 0; i < numberOfKeys; ++i) {
QPixmap p3(10,10);
keys.append(QPixmapCache::insert(p3));
+ QVERIFY(keys.back().isValid());
}
num = 0;
@@ -279,6 +297,35 @@ void tst_QPixmapCache::insert()
QVERIFY(num <= estimatedNum);
}
+void tst_QPixmapCache::failedInsertReturnsInvalidKey()
+{
+ //
+ // GIVEN: a pixmap whose memory footprint exceeds the cache's limit:
+ //
+ QPixmapCache::setCacheLimit(20);
+
+ QPixmap pm(256, 256);
+ pm.fill(Qt::transparent);
+ QCOMPARE_GT(pm.width() * pm.height() * pm.depth() / 8,
+ QPixmapCache::cacheLimit() * 1024);
+
+ //
+ // WHEN: trying to add this pixmap to the cache
+ //
+ const auto success = QPixmapCache::insert(u"foo"_s, pm); // QString API
+ { QPixmap r; QVERIFY(!QPixmapCache::find(u"foo"_s, &r)); }
+ const auto key = QPixmapCache::insert(pm); // "int" API
+
+ //
+ // THEN: failure is reported to the user
+ //
+ QVERIFY(!key.isValid()); // "int" API
+ QVERIFY(!success); // QString API
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void tst_QPixmapCache::replace()
{
//The int part of the API
@@ -307,6 +354,8 @@ void tst_QPixmapCache::replace()
//Broken keys
QCOMPARE(QPixmapCache::replace(QPixmapCache::Key(), p2), false);
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(6, 6)
void tst_QPixmapCache::remove()
{
@@ -340,11 +389,11 @@ void tst_QPixmapCache::remove()
QVERIFY(p1.toImage() == p1.toImage()); // sanity check
QPixmapCache::remove(key);
- QVERIFY(QPixmapCache::find(key, &p1) == 0);
+ QVERIFY(!QPixmapCache::find(key, &p1));
//Broken key
QPixmapCache::remove(QPixmapCache::Key());
- QVERIFY(QPixmapCache::find(QPixmapCache::Key(), &p1) == 0);
+ QVERIFY(!QPixmapCache::find(QPixmapCache::Key(), &p1));
//Test if keys are release
QPixmapCache::clear();
@@ -358,7 +407,7 @@ void tst_QPixmapCache::remove()
QPixmapCache::clear();
key = QPixmapCache::insert(p1);
QCOMPARE(getPrivate(key)->key, 1);
- QVERIFY(QPixmapCache::find(key, &p1) != 0);
+ QVERIFY(QPixmapCache::find(key, &p1));
QPixmapCache::remove(key);
QCOMPARE(p1.isDetached(), true);
@@ -368,8 +417,8 @@ void tst_QPixmapCache::remove()
QPixmapCache::insert("red", p1);
key = QPixmapCache::insert(p1);
QPixmapCache::remove(key);
- QVERIFY(QPixmapCache::find(key, &p1) == 0);
- QVERIFY(QPixmapCache::find("red", &p1) != 0);
+ QVERIFY(!QPixmapCache::find(key, &p1));
+ QVERIFY(QPixmapCache::find("red", &p1));
}
void tst_QPixmapCache::clear()
@@ -413,7 +462,7 @@ void tst_QPixmapCache::clear()
QPixmapCache::clear();
for (int k = 0; k < numberOfKeys; ++k) {
- QVERIFY(QPixmapCache::find(keys.at(k), &p1) == 0);
+ QVERIFY(!QPixmapCache::find(keys.at(k), &p1));
QVERIFY(!keys[k].isValid());
}
}
@@ -478,6 +527,68 @@ void tst_QPixmapCache::noLeak()
QCOMPARE(oldSize, newSize);
}
+void tst_QPixmapCache::clearDoesNotLeakStringKeys()
+{
+ stringLeak_impl([] { QPixmapCache::clear(); });
+}
+
+void tst_QPixmapCache::evictionDoesNotLeakStringKeys()
+{
+ stringLeak_impl([] {
+ // fill the cache with other pixmaps to force eviction of "our" pixmap:
+ constexpr int Iterations = 10;
+ for (int i = 0; i < Iterations; ++i) {
+ QPixmap pm(64, 64);
+ pm.fill(Qt::transparent);
+ [[maybe_unused]] auto r = QPixmapCache::insert(pm);
+ }
+ });
+}
+
+void tst_QPixmapCache::reducingCacheLimitDoesNotLeakStringKeys()
+{
+ stringLeak_impl([] {
+ QPixmapCache::setCacheLimit(0);
+ });
+}
+
+void tst_QPixmapCache::stringLeak_impl(std::function<void()> whenOp)
+{
+ QVERIFY(whenOp);
+
+ QPixmapCache::setCacheLimit(20); // 20KiB
+ //
+ // GIVEN: a QPixmap with QString key `key` in QPixmapCache
+ //
+ QString key;
+ {
+ QPixmap pm(64, 64);
+ QCOMPARE_LT(pm.width() * pm.height() * std::ceil(pm.depth() / 8.0),
+ QPixmapCache::cacheLimit() * 1024);
+ pm.fill(Qt::transparent);
+ key = u"theKey"_s.repeated(20); // avoid eventual QString SSO
+ QVERIFY(key.isDetached());
+ QPixmapCache::insert(key, pm);
+ }
+ QVERIFY(!key.isDetached()); // was saved inside QPixmapCache
+
+ //
+ // WHEN: performing the given operation
+ //
+ whenOp();
+ if (QTest::currentTestFailed())
+ return;
+
+ //
+ // THEN: `key` is no longer referenced by QPixmapCache:
+ //
+ QVERIFY(key.isDetached());
+ // verify that the pixmap is really gone from the cache
+ // (do it after the key check, because QPixmapCache cleans up `key` on a failed lookup)
+ QPixmap r;
+ QVERIFY(!QPixmapCache::find(key, &r));
+}
+
void tst_QPixmapCache::strictCacheLimit()
{
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
index 1132e02c09..85fb4fe2e1 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfilesystemmodel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfilesystemmodel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qfilesystemmodel
SOURCES
tst_qfilesystemmodel.cpp
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 3802f8afc6..8ef0b6272a 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -29,6 +29,7 @@
#include <algorithm>
using namespace Qt::StringLiterals;
+using namespace std::chrono;
#define WAITTIME 1000
@@ -64,6 +65,7 @@ private slots:
void rootPath();
void readOnly();
void iconProvider();
+ void nullIconProvider();
void rowCount();
@@ -79,6 +81,8 @@ private slots:
void filters_data();
void filters();
+ void showFilesOnly();
+
void nameFilters();
void setData_data();
@@ -308,6 +312,19 @@ void tst_QFileSystemModel::iconProvider()
QCOMPARE(myModel->fileIcon(myModel->index(QDir::homePath())).pixmap(50, 50), mb);
}
+void tst_QFileSystemModel::nullIconProvider()
+{
+ QFileSystemModel model;
+ QAbstractItemModelTester tester(&model);
+ tester.setUseFetchMore(false);
+ QVERIFY(model.iconProvider());
+ // No crash when setIconProvider(nullptr) is used
+ model.setIconProvider(nullptr);
+ const auto documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
+ QVERIFY(!documentPaths.isEmpty());
+ model.setRootPath(documentPaths.constFirst());
+}
+
bool tst_QFileSystemModel::createFiles(QFileSystemModel *model, const QString &test_path,
const QStringList &initial_files, int existingFileCount,
const QStringList &initial_dirs)
@@ -675,6 +692,39 @@ void tst_QFileSystemModel::filters()
#endif
}
+void tst_QFileSystemModel::showFilesOnly()
+{
+ QString tmp = flatDirTestPath;
+ QFileSystemModel model;
+ QAbstractItemModelTester tester(&model);
+ tester.setUseFetchMore(false);
+ QVERIFY(createFiles(&model, tmp, QStringList()));
+ const QStringList files{u"a"_s, u"b"_s, u"c"_s};
+ const auto subdir = u"sub_directory"_s;
+ QVERIFY(createFiles(&model, tmp, files, 0, {subdir}));
+
+ // The model changes asynchronously when we run the event loop in the QTRY_...
+ // macros, so the root index returned by an earlier call to setRootPath might
+ // become invalid. Make sure we use a fresh one for each iteration.
+
+ // QTBUG-74471
+ // WHAT: setting the root path of the model to a dir with some files and a subdir
+ QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size() + 1);
+
+ // Change the model to only show files
+ model.setFilter(QDir::Files);
+ QTRY_COMPARE(model.rowCount(model.setRootPath(tmp)), files.size());
+
+ // WHEN: setting the root path to a subdir
+ QModelIndex subIndex = model.setRootPath(tmp + u'/' + subdir);
+ QTRY_COMPARE(model.rowCount(subIndex), 0);
+
+ // THEN: setting the root path to the previous (parent) dir, the model should
+ // still only show files.
+ // Doubling the default timeout (5s) as this test to fails on macos on the CI
+ QTRY_COMPARE_WITH_TIMEOUT(model.rowCount(model.setRootPath(tmp)), files.size(), 10s);
+}
+
void tst_QFileSystemModel::nameFilters()
{
QStringList list;
@@ -761,6 +811,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
+ QCOMPARE(model->data(idx, QFileSystemModel::FileInfoRole).value<QFileInfo>().fileName(), newFileName);
QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
QCOMPARE(model->index(arguments.at(0).toString()), model->index(tmp));
QCOMPARE(arguments.at(1).toString(), oldFileName);
@@ -827,13 +878,13 @@ void tst_QFileSystemModel::sort()
//Create a file that will be at the end when sorting by name (For Mac, the default)
//but if we sort by size descending it will be the first
QFile tempFile(dirPath + "/plop2.txt");
- tempFile.open(QIODevice::WriteOnly | QIODevice::Text);
+ QVERIFY(tempFile.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out(&tempFile);
out << "The magic number is: " << 49 << "\n";
tempFile.close();
QFile tempFile2(dirPath + "/plop.txt");
- tempFile2.open(QIODevice::WriteOnly | QIODevice::Text);
+ QVERIFY(tempFile2.open(QIODevice::WriteOnly | QIODevice::Text));
QTextStream out2(&tempFile2);
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
tempFile2.close();
@@ -1028,11 +1079,12 @@ void tst_QFileSystemModel::drives()
QFileSystemModel model;
model.setRootPath(path);
model.fetchMore(QModelIndex());
- QFileInfoList drives = QDir::drives();
+ const QFileInfoList drives = QDir::drives();
int driveCount = 0;
- foreach(const QFileInfo& driveRoot, drives)
+ for (const QFileInfo& driveRoot : drives) {
if (driveRoot.exists())
driveCount++;
+ }
QTRY_COMPARE(model.rowCount(), driveCount);
}
diff --git a/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt b/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
index 33b7698a7a..db29eaaf94 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qstandarditem Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qstandarditem LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qstandarditem
SOURCES
tst_qstandarditem.cpp
diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
index 6f42c45821..093367c759 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -112,13 +112,17 @@ void tst_QStandardItem::getSetData()
item.setToolTip(toolTip);
QCOMPARE(item.toolTip(), toolTip);
+#ifndef QT_NO_STATUSTIP
QString statusTip = QLatin1String("statusTip ") + iS;
item.setStatusTip(statusTip);
QCOMPARE(item.statusTip(), statusTip);
+#endif
+#if QT_CONFIG(whatsthis)
QString whatsThis = QLatin1String("whatsThis ") + iS;
item.setWhatsThis(whatsThis);
QCOMPARE(item.whatsThis(), whatsThis);
+#endif
QSize sizeHint(64*i, 48*i);
item.setSizeHint(sizeHint);
@@ -157,8 +161,12 @@ void tst_QStandardItem::getSetData()
QCOMPARE(item.text(), text);
QCOMPARE(item.icon(), icon);
QCOMPARE(item.toolTip(), toolTip);
+#ifndef QT_NO_STATUSTIP
QCOMPARE(item.statusTip(), statusTip);
+#endif
+#if QT_CONFIG(whatsthis)
QCOMPARE(item.whatsThis(), whatsThis);
+#endif
QCOMPARE(item.sizeHint(), sizeHint);
QCOMPARE(item.font(), font);
QCOMPARE(item.textAlignment(), textAlignment);
@@ -171,8 +179,12 @@ void tst_QStandardItem::getSetData()
QCOMPARE(qvariant_cast<QString>(item.data(Qt::DisplayRole)), text);
QCOMPARE(qvariant_cast<QIcon>(item.data(Qt::DecorationRole)), icon);
QCOMPARE(qvariant_cast<QString>(item.data(Qt::ToolTipRole)), toolTip);
+#ifndef QT_NO_STATUSTIP
QCOMPARE(qvariant_cast<QString>(item.data(Qt::StatusTipRole)), statusTip);
+#endif
+#if QT_CONFIG(whatsthis)
QCOMPARE(qvariant_cast<QString>(item.data(Qt::WhatsThisRole)), whatsThis);
+#endif
QCOMPARE(qvariant_cast<QSize>(item.data(Qt::SizeHintRole)), sizeHint);
QCOMPARE(qvariant_cast<QFont>(item.data(Qt::FontRole)), font);
QCOMPARE(qvariant_cast<int>(item.data(Qt::TextAlignmentRole)), int(textAlignment));
@@ -844,7 +856,9 @@ void tst_QStandardItem::streamItem()
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
+#if QT_CONFIG(whatsthis)
item.setWhatsThis(QLatin1String("whatsThis"));
+#endif
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
@@ -866,7 +880,9 @@ void tst_QStandardItem::streamItem()
QCOMPARE(streamedItem.text(), item.text());
QCOMPARE(streamedItem.toolTip(), item.toolTip());
QCOMPARE(streamedItem.statusTip(), item.statusTip());
+#if QT_CONFIG(whatsthis)
QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
+#endif
QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
QCOMPARE(streamedItem.font(), item.font());
QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
@@ -905,7 +921,9 @@ void tst_QStandardItem::clone()
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
+#if QT_CONFIG(whatsthis)
item.setWhatsThis(QLatin1String("whatsThis"));
+#endif
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
@@ -920,7 +938,9 @@ void tst_QStandardItem::clone()
QCOMPARE(clone->text(), item.text());
QCOMPARE(clone->toolTip(), item.toolTip());
QCOMPARE(clone->statusTip(), item.statusTip());
+#if QT_CONFIG(whatsthis)
QCOMPARE(clone->whatsThis(), item.whatsThis());
+#endif
QCOMPARE(clone->sizeHint(), item.sizeHint());
QCOMPARE(clone->font(), item.font());
QCOMPARE(clone->textAlignment(), item.textAlignment());
@@ -1006,6 +1026,32 @@ public:
using QStandardItem::clone;
using QStandardItem::emitDataChanged;
+
+ void setData(const QVariant &value, int role) override
+ {
+ switch (role) {
+ case Qt::DisplayRole:
+ QStandardItem::setData(value, role);
+ break;
+ default:
+ // setFlags() uses "UserRole - 1" to store the flags, which is an
+ // implementation detail not exposed in the docs.
+ QStandardItem::setData(value, role);
+ break;
+ }
+ }
+
+ QVariant data(int role) const override
+ {
+ switch (role) {
+ case Qt::DisplayRole:
+ return QStandardItem::data(role);
+ default:
+ // flags() uses "UserRole - 1" to get the flags, which is an implementation
+ // detail not exposed in the docs.
+ return QStandardItem::data(role);
+ }
+ }
};
Q_DECLARE_METATYPE(QStandardItem*)
@@ -1041,6 +1087,12 @@ void tst_QStandardItem::subclassing()
QCOMPARE(item->child(0), child2);
QCOMPARE(item->child(1), child0);
QCOMPARE(item->child(2), child1);
+
+ item->setFlags(Qt::ItemFlags{0});
+ QCOMPARE(item->flags(), Qt::ItemFlags{0});
+
+ item->setFlags(Qt::ItemFlags{Qt::ItemIsEditable | Qt::ItemIsSelectable});
+ QCOMPARE(item->flags(), Qt::ItemFlags{Qt::ItemIsEditable | Qt::ItemIsSelectable});
}
void tst_QStandardItem::lessThan()
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt b/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
index c241d97294..31ae25d008 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qstandarditemmodel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qstandarditemmodel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qstandarditemmodel
SOURCES
tst_qstandarditemmodel.cpp
@@ -14,4 +20,5 @@ qt_internal_add_test(tst_qstandarditemmodel
Qt::GuiPrivate
Qt::Widgets
Qt::WidgetsPrivate
+ Qt::TestPrivate
)
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 07fc074577..ef2fd83d4c 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -1,16 +1,22 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QStandardItemModel>
#include <QTreeView>
+#include <QMap>
#include <QSignalSpy>
#include <QAbstractItemModelTester>
#include <private/qabstractitemmodel_p.h>
+#include <private/qpropertytesthelper_p.h>
#include <private/qtreeview_p.h>
+#include <algorithm>
+
+using namespace Qt::StringLiterals;
+
class tst_QStandardItemModel : public QObject
{
Q_OBJECT
@@ -87,6 +93,7 @@ private slots:
void indexFromItem();
void itemFromIndex();
void getSetItemPrototype();
+ void getSetItemData_data();
void getSetItemData();
void setHeaderLabels_data();
void setHeaderLabels();
@@ -113,6 +120,7 @@ private slots:
void taskQTBUG_45114_setItemData();
void setItemPersistentIndex();
void signalsOnTakeItem();
+ void takeChild();
void createPersistentOnLayoutAboutToBeChanged();
private:
QStandardItemModel *m_model = nullptr;
@@ -720,7 +728,7 @@ void tst_QStandardItemModel::data()
const QMap<int, QVariant> itmData = m_model->itemData(m_model->index(0, 0));
QCOMPARE(itmData.value(Qt::DisplayRole), QLatin1String("initialitem"));
QCOMPARE(itmData.value(Qt::ToolTipRole), QLatin1String("tooltip"));
- QVERIFY(!itmData.contains(Qt::UserRole - 1));
+ QVERIFY(!itmData.contains(Qt::UserRole - 1)); // Qt::UserRole - 1 is used to store flags
QVERIFY(m_model->itemData(QModelIndex()).isEmpty());
}
@@ -896,6 +904,9 @@ void tst_QStandardItemModel::sortRoleBindings()
sortRoleObserver.setBinding([&] { return model.sortRole(); });
model.setSortRole(Qt::EditRole);
QCOMPARE(sortRoleObserver, Qt::EditRole);
+
+ QTestPrivate::testReadWritePropertyBasics(model, static_cast<int>(Qt::DisplayRole),
+ static_cast<int>(Qt::EditRole), "sortRole");
}
void tst_QStandardItemModel::findItems()
@@ -1025,33 +1036,49 @@ void tst_QStandardItemModel::getSetItemPrototype()
QCOMPARE(model.itemPrototype(), nullptr);
}
+using RoleMap = QMap<int, QVariant>;
+using RoleList = QList<int>;
+
+static RoleMap getSetItemDataRoleMap(int textRole)
+{
+ return {{textRole, "text"_L1},
+ {Qt::StatusTipRole, "statusTip"_L1},
+ {Qt::ToolTipRole, "toolTip"_L1},
+ {Qt::WhatsThisRole, "whatsThis"_L1},
+ {Qt::SizeHintRole, QSize{64, 48}},
+ {Qt::FontRole, QFont{}},
+ {Qt::TextAlignmentRole, int(Qt::AlignLeft|Qt::AlignVCenter)},
+ {Qt::BackgroundRole, QColor(Qt::blue)},
+ {Qt::ForegroundRole, QColor(Qt::green)},
+ {Qt::CheckStateRole, int(Qt::PartiallyChecked)},
+ {Qt::AccessibleTextRole, "accessibleText"_L1},
+ {Qt::AccessibleDescriptionRole, "accessibleDescription"_L1}};
+}
+
+void tst_QStandardItemModel::getSetItemData_data()
+{
+ QTest::addColumn<RoleMap>("itemData");
+ QTest::addColumn<RoleMap>("expectedItemData");
+ QTest::addColumn<RoleList>("expectedRoles");
+
+ // QTBUG-112326: verify that text data set using Qt::EditRole is mapped to
+ // Qt::DisplayRole and both roles are in the changed signal
+ const RoleMap expectedItemData = getSetItemDataRoleMap(Qt::DisplayRole);
+ RoleList expectedRoles = expectedItemData.keys() << Qt::EditRole;
+ std::sort(expectedRoles.begin(), expectedRoles.end());
+
+ QTest::newRow("DisplayRole") << expectedItemData
+ << expectedItemData << expectedRoles;
+
+ QTest::newRow("EditRole") << getSetItemDataRoleMap(Qt::EditRole)
+ << expectedItemData << expectedRoles;
+}
+
void tst_QStandardItemModel::getSetItemData()
{
- QMap<int, QVariant> roles;
- QLatin1String text("text");
- roles.insert(Qt::DisplayRole, text);
- QLatin1String statusTip("statusTip");
- roles.insert(Qt::StatusTipRole, statusTip);
- QLatin1String toolTip("toolTip");
- roles.insert(Qt::ToolTipRole, toolTip);
- QLatin1String whatsThis("whatsThis");
- roles.insert(Qt::WhatsThisRole, whatsThis);
- QSize sizeHint(64, 48);
- roles.insert(Qt::SizeHintRole, sizeHint);
- QFont font;
- roles.insert(Qt::FontRole, font);
- Qt::Alignment textAlignment(Qt::AlignLeft|Qt::AlignVCenter);
- roles.insert(Qt::TextAlignmentRole, int(textAlignment));
- QColor backgroundColor(Qt::blue);
- roles.insert(Qt::BackgroundRole, backgroundColor);
- QColor textColor(Qt::green);
- roles.insert(Qt::ForegroundRole, textColor);
- Qt::CheckState checkState(Qt::PartiallyChecked);
- roles.insert(Qt::CheckStateRole, int(checkState));
- QLatin1String accessibleText("accessibleText");
- roles.insert(Qt::AccessibleTextRole, accessibleText);
- QLatin1String accessibleDescription("accessibleDescription");
- roles.insert(Qt::AccessibleDescriptionRole, accessibleDescription);
+ QFETCH(RoleMap, itemData);
+ QFETCH(RoleMap, expectedItemData);
+ QFETCH(RoleList, expectedRoles);
QStandardItemModel model;
model.insertRows(0, 1);
@@ -1060,11 +1087,17 @@ void tst_QStandardItemModel::getSetItemData()
QSignalSpy modelDataChangedSpy(
&model, &QStandardItemModel::dataChanged);
- QVERIFY(model.setItemData(idx, roles));
+ QVERIFY(model.setItemData(idx, itemData));
QCOMPARE(modelDataChangedSpy.size(), 1);
- QVERIFY(model.setItemData(idx, roles));
+ const QVariantList &args = modelDataChangedSpy.constFirst();
+ QCOMPARE(args.size(), 3);
+ auto roleList = args.at(2).value<QList<int> >();
+ std::sort(roleList.begin(), roleList.end());
+ QCOMPARE(roleList, expectedRoles);
+
+ QVERIFY(model.setItemData(idx, itemData));
QCOMPARE(modelDataChangedSpy.size(), 1); //it was already changed once
- QCOMPARE(model.itemData(idx), roles);
+ QCOMPARE(model.itemData(idx), expectedItemData);
}
void tst_QStandardItemModel::setHeaderLabels_data()
@@ -1581,15 +1614,21 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QList<QStandardItem *> row_taken = model.takeRow(6);
QCOMPARE(row_taken.size(), col_list.size());
- for (int c = 0; c < col_list.size(); c++)
- QCOMPARE(row_taken[c]->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
+ for (qsizetype c = 0; c < row_taken.size(); c++) {
+ auto item = row_taken.at(c);
+ QCOMPARE(item->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
+ delete item;
+ }
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
QCOMPARE(col_taken.size(), row_list.size());
- for (int r = 0; r < row_list.size(); r++)
- QCOMPARE(col_taken[r]->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
+ for (qsizetype r = 0; r < col_taken.size(); r++) {
+ auto item = col_taken.at(r);
+ QCOMPARE(item->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
+ delete item;
+ }
col_list.remove(10);
VERIFY_MODEL
}
@@ -1759,6 +1798,7 @@ void tst_QStandardItemModel::signalsOnTakeItem() // QTBUG-89145
QCOMPARE(takenItem->model(), nullptr);
QCOMPARE(takenItem->child(0, 0)->model(), nullptr);
QCOMPARE(m.index(1, 0).data(), QVariant());
+ delete takenItem;
}
void tst_QStandardItemModel::createPersistentOnLayoutAboutToBeChanged() // QTBUG-93466
@@ -1796,5 +1836,36 @@ void tst_QStandardItemModel::createPersistentOnLayoutAboutToBeChanged() // QTBUG
QCOMPARE(layoutChangedSpy.size(), 1);
}
+void tst_QStandardItemModel::takeChild() // QTBUG-117900
+{
+ {
+ // with model
+ QStandardItemModel model1;
+ QStandardItemModel model2;
+ QStandardItem base1("base1");
+ model1.setItem(0, 0, &base1);
+ QStandardItem base2("base2");
+ model2.setItem(0, 0, &base2);
+ auto item = new QStandardItem("item1");
+ item->appendRow(new QStandardItem("child"));
+ base1.appendRow(item);
+ base2.appendRow(base1.takeChild(0, 0));
+ QCOMPARE(base1.child(0, 0), nullptr);
+ QCOMPARE(base2.child(0, 0), item);
+ }
+ {
+ // without model
+ QStandardItem base1("base1");
+ QStandardItem base2("base2");
+ auto item = new QStandardItem("item1");
+ item->appendRow(new QStandardItem("child"));
+ base1.appendRow(item);
+ base2.appendRow(base1.takeChild(0, 0));
+ QCOMPARE(base1.child(0, 0), nullptr);
+ QCOMPARE(base2.child(0, 0), item);
+ }
+}
+
+
QTEST_MAIN(tst_QStandardItemModel)
#include "tst_qstandarditemmodel.moc"
diff --git a/tests/auto/gui/kernel/CMakeLists.txt b/tests/auto/gui/kernel/CMakeLists.txt
index a178942d5a..9acd817610 100644
--- a/tests/auto/gui/kernel/CMakeLists.txt
+++ b/tests/auto/gui/kernel/CMakeLists.txt
@@ -10,6 +10,7 @@ add_subdirectory(qcursor)
add_subdirectory(qdrag)
add_subdirectory(qevent)
add_subdirectory(qfileopenevent)
+add_subdirectory(qguichronotimer)
add_subdirectory(qguieventdispatcher)
add_subdirectory(qguitimer)
if(NOT ANDROID AND NOT WASM)
@@ -29,7 +30,7 @@ endif()
add_subdirectory(qpixelformat)
add_subdirectory(qrasterwindow)
add_subdirectory(qaddpostroutine)
-if(NOT ANDROID AND NOT UIKIT)
+if(NOT UIKIT)
add_subdirectory(qclipboard)
endif()
if(TARGET Qt::Network)
diff --git a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
index d54e72eda1..e9d3d96af9 100644
--- a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_noqteventloop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_noqteventloop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_noqteventloop
SOURCES
tst_noqteventloop.cpp
diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
index 8aec8ddcc6..65fe4a83ed 100644
--- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
+++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qaction/CMakeLists.txt b/tests/auto/gui/kernel/qaction/CMakeLists.txt
index 42a3726eaf..8f70a36c61 100644
--- a/tests/auto/gui/kernel/qaction/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaction/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qaction_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaction_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qaction_kernel
SOURCES
tst_qaction.cpp
diff --git a/tests/auto/gui/kernel/qaction/tst_qaction.cpp b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
index 930cee26b8..4a4d1a75c8 100644
--- a/tests/auto/gui/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
diff --git a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
index fe57719264..360a20cc95 100644
--- a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qactiongroup_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qactiongroup_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qactiongroup_kernel
SOURCES
tst_qactiongroup.cpp
diff --git a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
index 2e04e13b7e..a9e331e111 100644
--- a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
index 66559bc333..46a0475521 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qaddpostroutine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaddpostroutine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qaddpostroutine
SOURCES
tst_qaddpostroutine.cpp
diff --git a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
index c56eb3ff4c..c5cc0a9b20 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
+++ b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
index 3c34fa3813..811da8bb53 100644
--- a/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qbackingstore Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qbackingstore LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qbackingstore
SOURCES
tst_qbackingstore.cpp
diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
index d9528fc8e4..a830d14be8 100644
--- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
+++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
@@ -1,9 +1,11 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qwindow.h>
#include <qbackingstore.h>
#include <qpa/qplatformbackingstore.h>
+#include <qpa/qplatformintegration.h>
+#include <private/qguiapplication_p.h>
#include <qpainter.h>
#include <QTest>
@@ -30,6 +32,8 @@ private slots:
void scroll();
void flush();
+
+ void staticContents();
};
void tst_QBackingStore::initTestCase_data()
@@ -89,6 +93,11 @@ void tst_QBackingStore::paint()
QRect rect(0, 0, 100, 100);
backingStore.resize(rect.size());
+ // Partial fill of a fresh backingstore should not crash
+ backingStore.beginPaint(QRect(0, 0, 50, 50));
+ backingStore.endPaint();
+ backingStore.flush(rect);
+
// Two rounds, with flush in between
for (int i = 0; i < 2; ++i) {
backingStore.beginPaint(rect);
@@ -267,5 +276,79 @@ void tst_QBackingStore::flush()
QTRY_VERIFY(window.isExposed());
}
+void tst_QBackingStore::staticContents()
+{
+ const auto *integration = QGuiApplicationPrivate::platformIntegration();
+ if (!integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents))
+ QSKIP("Platform does not support static backingstore content");
+
+ QWindow window;
+ window.create();
+
+ const auto dpr = window.devicePixelRatio();
+
+ QBackingStore backingStore(&window);
+
+ QRect initialRect(0, 0, 100, 100);
+
+ // Static contents without paint first should not crash
+ backingStore.setStaticContents(initialRect);
+ backingStore.resize(initialRect.size());
+ QCOMPARE(backingStore.size(), initialRect.size());
+ backingStore.beginPaint(QRect(0, 0, 50, 50));
+ backingStore.endPaint();
+ backingStore.handle()->toImage();
+
+ {
+ backingStore.setStaticContents(QRect());
+ backingStore.beginPaint(initialRect);
+ QPainter p(backingStore.paintDevice());
+ p.fillRect(initialRect, Qt::green);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(initialRect.topLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.topRight() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomRight() * dpr), Qt::green);
+ }
+
+ {
+ backingStore.setStaticContents(initialRect);
+
+ QRect resizedRect(0, 0, 200, 200);
+ backingStore.resize(resizedRect.size());
+
+ QRegion repaintRegion = QRegion(resizedRect) - QRegion(initialRect);
+
+ backingStore.beginPaint(repaintRegion);
+ QPainter p(backingStore.paintDevice());
+ for (auto repaintRect : repaintRegion)
+ p.fillRect(repaintRect, Qt::red);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(initialRect.topLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.topRight() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomRight() * dpr), Qt::green);
+
+ for (auto repaintRect : repaintRegion) {
+ QCOMPARE(image.pixelColor(repaintRect.topLeft() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.bottomLeft() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.topRight() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.bottomRight() * dpr), Qt::red);
+ }
+ }
+}
+
#include <tst_qbackingstore.moc>
QTEST_MAIN(tst_QBackingStore);
diff --git a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
index ac71b91d11..b7a0467758 100644
--- a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qclipboard LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
add_subdirectory(copier)
add_subdirectory(paster)
add_subdirectory(test)
diff --git a/tests/auto/gui/kernel/qclipboard/copier/main.cpp b/tests/auto/gui/kernel/qclipboard/copier/main.cpp
index 411ac1e00e..362ede38b7 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/copier/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtCore/QStringList>
diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
index 06db447569..bf47b10ba6 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtGui/QImage>
diff --git a/tests/auto/gui/kernel/qclipboard/test/BLACKLIST b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST
new file mode 100644
index 0000000000..3ca7791b37
--- /dev/null
+++ b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST
@@ -0,0 +1,5 @@
+# QTBUG-87429
+[testSignals]
+android
+[setMimeData]
+android
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index 0b694bff73..30366c6aa1 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -23,6 +23,7 @@
# include <QtGui/private/qguiapplication_p.h>
# include <QtGui/qwindowsmimeconverter.h>
# include <QtGui/qpa/qplatformintegration.h>
+# include <QtCore/qt_windows.h>
#endif
class tst_QClipboard : public QObject
@@ -41,6 +42,7 @@ private slots:
void testSignals();
void setMimeData();
void clearBeforeSetText();
+ void getTextFromHTMLMimeType();
# ifdef Q_OS_WIN
void testWindowsMimeRegisterType();
void testWindowsMime_data();
@@ -61,7 +63,7 @@ void tst_QClipboard::initTestCase()
#if QT_CONFIG(clipboard)
void tst_QClipboard::init()
{
-#if QT_CONFIG(process)
+#if QT_CONFIG(process) && !defined(Q_OS_ANDROID)
const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath();
QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
#endif
@@ -424,6 +426,24 @@ void tst_QClipboard::clearBeforeSetText()
QCOMPARE(QGuiApplication::clipboard()->text(), text);
}
+void tst_QClipboard::getTextFromHTMLMimeType()
+{
+ QClipboard * clipboard = QGuiApplication::clipboard();
+ QMimeData * mimeData = new QMimeData();
+ const QString testString("TEST");
+ const QString htmlString(QLatin1String("<html><body>") + testString + QLatin1String("</body></html>"));
+
+ mimeData->setText(testString);
+ mimeData->setHtml(htmlString);
+ clipboard->setMimeData(mimeData);
+
+ QCOMPARE(clipboard->text(), testString);
+ QVERIFY(clipboard->mimeData()->hasText());
+ QVERIFY(clipboard->mimeData()->hasHtml());
+ QCOMPARE(clipboard->mimeData()->text(), testString);
+ QCOMPARE(clipboard->mimeData()->html(), htmlString);
+}
+
# ifdef Q_OS_WIN
using QWindowsMimeConverter = QWindowsMimeConverter;
diff --git a/tests/auto/gui/kernel/qcursor/CMakeLists.txt b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
index 7e29971566..52c88fc231 100644
--- a/tests/auto/gui/kernel/qcursor/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qcursor Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcursor LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qcursor
SOURCES
tst_qcursor.cpp
diff --git a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
index 42ef690efa..edc44b9ea6 100644
--- a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
+++ b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
#include <qcursor.h>
diff --git a/tests/auto/gui/kernel/qdrag/CMakeLists.txt b/tests/auto/gui/kernel/qdrag/CMakeLists.txt
index de1141b304..015cfe70d0 100644
--- a/tests/auto/gui/kernel/qdrag/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qdrag/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qdrag Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qdrag LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qdrag
SOURCES
tst_qdrag.cpp
diff --git a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp b/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
index 8891ddc4ea..9e0d5ad0f4 100644
--- a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
+++ b/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qevent/CMakeLists.txt b/tests/auto/gui/kernel/qevent/CMakeLists.txt
index 3603ff6ff4..c6ad861f25 100644
--- a/tests/auto/gui/kernel/qevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qevent/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qevent
SOURCES
tst_qevent.cpp
diff --git a/tests/auto/gui/kernel/qevent/tst_qevent.cpp b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
index f1ffb8c35e..8e8169b16c 100644
--- a/tests/auto/gui/kernel/qevent/tst_qevent.cpp
+++ b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
@@ -1,12 +1,57 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/qguiapplication.h>
#include <QtGui/qevent.h>
+#if QT_CONFIG(future)
#include <QtCore/private/qfutureinterface_p.h>
+#endif
+
+
+#if QT_CONFIG(future)
+#define X_QFutureCallOutEvent(X) X(QFutureCallOutEvent, ())
+#else
+#define X_QFutureCallOutEvent(X)
+#endif
+
+#if QT_CONFIG(wheelevent)
+#define X_QWheelEvent(X) X(QWheelEvent, ({}, {}, {}, {}, {}, {}, {}, {}))
+#else
+#define X_QWheelEvent(X)
+#endif
+
+#if QT_CONFIG(tabletevent)
+#define X_QTabletEvent(X) X(QTabletEvent, (QEvent::None, QPointingDevice::primaryPointingDevice(), {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}))
+#else
+#define X_QTabletEvent(X)
+#endif
+
+#if QT_CONFIG(gestures)
+#define X_QNativeGestureEvent(X) X(QNativeGestureEvent, ({}, QPointingDevice::primaryPointingDevice(), 0, {}, {}, {}, {}, {}))
+#else
+#define X_QNativeGestureEvent(X)
+#endif
+
+#if QT_CONFIG(whatsthis)
+#define X_QWhatsThisClickedEvent(X) X(QWhatsThisClickedEvent, ({}))
+#else
+#define X_QWhatsThisClickedEvent(X)
+#endif
+
+#if QT_CONFIG(action)
+#define X_QActionEvent(X) X(QActionEvent, (0, nullptr))
+#else
+#define X_QActionEvent(X)
+#endif
+
+#if QT_CONFIG(shortcut)
+#define X_QShortcutEvent(X) X(QShortcutEvent, ({}, 0))
+#else
+#define X_QShortcutEvent(X)
+#endif
#define FOR_EACH_CORE_EVENT(X) \
/* qcoreevent.h */ \
@@ -14,9 +59,8 @@
X(QTimerEvent, (42)) \
X(QChildEvent, (QEvent::ChildAdded, nullptr)) \
X(QDynamicPropertyChangeEvent, ("size")) \
- X(QDeferredDeleteEvent, ()) \
/* qfutureinterface_p.h */ \
- X(QFutureCallOutEvent, ()) \
+ X_QFutureCallOutEvent(X) \
/* end */
#define FOR_EACH_GUI_EVENT(X) \
@@ -28,9 +72,9 @@
X(QEnterEvent, ({}, {}, {})) \
X(QMouseEvent, (QEvent::None, {}, {}, {}, {}, {}, {}, {}, QPointingDevice::primaryPointingDevice())) \
X(QHoverEvent, (QEvent::None, {}, {}, QPointF{})) \
- X(QWheelEvent, ({}, {}, {}, {}, {}, {}, {}, {})) \
- X(QTabletEvent, (QEvent::None, QPointingDevice::primaryPointingDevice(), {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})) \
- X(QNativeGestureEvent, ({}, QPointingDevice::primaryPointingDevice(), 0, {}, {}, {}, {}, {})) \
+ X_QWheelEvent(X) \
+ X_QTabletEvent(X) \
+ X_QNativeGestureEvent(X) \
X(QKeyEvent, (QEvent::None, 0, {})) \
X(QFocusEvent, (QEvent::None)) \
X(QPaintEvent, (QRect{0, 0, 100, 100})) \
@@ -51,11 +95,11 @@
X(QDragLeaveEvent, ()) \
X(QHelpEvent, ({}, {}, {})) \
X(QStatusTipEvent, ({})) \
- X(QWhatsThisClickedEvent, ({})) \
- X(QActionEvent, (0, nullptr)) \
+ X_QWhatsThisClickedEvent(X) \
+ X_QActionEvent(X) \
X(QFileOpenEvent, (QString{})) \
X(QToolBarChangeEvent, (false)) \
- X(QShortcutEvent, ({}, 0)) \
+ X_QShortcutEvent(X) \
X(QWindowStateChangeEvent, ({})) \
X(QTouchEvent, (QEvent::None)) \
X(QScrollPrepareEvent, ({})) \
diff --git a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
index 837c807469..9906400a66 100644
--- a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
@@ -1,5 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfileopenevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
add_subdirectory(test)
add_subdirectory(qfileopeneventexternal)
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
index 0af605ccb6..bd74e7497f 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
#include <QEvent>
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
index 50671e17f2..4b9a23ffcf 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QTemporaryDir>
#include <QTest>
@@ -54,7 +54,7 @@ void tst_qfileopenevent::cleanupTestCase()
void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content)
{
QFile file(filename);
- file.open(QFile::WriteOnly);
+ QVERIFY(file.open(QFile::WriteOnly));
file.write(content);
file.close();
}
@@ -79,7 +79,8 @@ void tst_qfileopenevent::constructor()
QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
{
QFile file(event.file());
- file.open(QFile::ReadOnly);
+ if (!file.open(QFile::ReadOnly))
+ qFatal("Cannot open file %s", qPrintable(event.file()));
file.seek(0);
QByteArray data = file.readAll();
return data;
@@ -138,7 +139,7 @@ void tst_qfileopenevent::handleLifetime()
// check the content
QFile checkContent("testHandleLifetime");
- checkContent.open(QFile::ReadOnly);
+ QVERIFY(checkContent.open(QFile::ReadOnly));
QString content(checkContent.readAll());
QCOMPARE(content, QLatin1String("test content+closed original handles"));
checkContent.close();
diff --git a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
index 343866655a..6f1f845edd 100644
--- a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qguiapplication Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguiapplication LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
if (WIN32)
set(target_version "1.2.3.4")
else()
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 5a206d8177..d1a50e3d69 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -47,6 +47,7 @@ private slots:
void changeFocusWindow();
void keyboardModifiers();
void palette();
+ void paletteNoCrash();
void font();
void modalWindow();
void quitOnLastWindowClosed();
@@ -60,6 +61,8 @@ private slots:
void staticFunctions();
+ void topLevelAt();
+
void settableStyleHints_data();
void settableStyleHints(); // Needs to run last as it changes style hints.
};
@@ -122,8 +125,8 @@ void tst_QGuiApplication::desktopFileName()
QCOMPARE(QGuiApplication::desktopFileName(), QString());
- QGuiApplication::setDesktopFileName("io.qt.QGuiApplication.desktop");
- QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication.desktop"));
+ QGuiApplication::setDesktopFileName("io.qt.QGuiApplication");
+ QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication"));
QGuiApplication::setDesktopFileName(QString());
QCOMPARE(QGuiApplication::desktopFileName(), QString());
@@ -457,16 +460,12 @@ void tst_QGuiApplication::keyboardModifiers()
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// wheel events
- QPoint global = window->mapToGlobal(center);
QPoint delta(0, 1);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::NoModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::NoModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::AltModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::AltModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::AltModifier);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::ControlModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::ControlModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// touch events
@@ -552,6 +551,15 @@ void tst_QGuiApplication::palette()
QCOMPARE(QGuiApplication::palette(), QPalette());
}
+void tst_QGuiApplication::paletteNoCrash()
+{
+ QGuiApplication::setDesktopSettingsAware(false);
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ // this would crash on windows (QTBUG-111527)
+ QGuiApplication a(argc, argv);
+}
+
void tst_QGuiApplication::font()
{
int argc = 1;
@@ -996,8 +1004,8 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
});
{
- // Disabling QEventLoopLocker support should not affect
- // quitting when last window is closed.
+ // Disabling QEventLoopLocker automatic quit should not affect
+ // quitting when last window is closed if there are no lockers.
app.setQuitLockEnabled(false);
QuitSpy quitSpy;
@@ -1011,8 +1019,40 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
}
{
- // Disabling quitOnLastWindowClosed support should not affect
- // quitting when last QEventLoopLocker goes out of scope.
+ // Disabling QEventLoopLocker automatic quit should still block
+ // quitting when last window is closed if there is a locker alive.
+ app.setQuitLockEnabled(false);
+
+ QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker);
+
+ QuitSpy quitSpy;
+ QWindow window;
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTimer::singleShot(0, &window, &QWindow::close);
+ QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
+ app.exec();
+ QCOMPARE(quitSpy.quits, 0);
+ }
+
+ {
+ // Disabling quitOnLastWindowClosed automatic quit should not affect
+ // quitting when last QEventLoopLocker goes out of scope if
+ // there are no windows.
+ app.setQuitLockEnabled(true);
+ app.setQuitOnLastWindowClosed(false);
+
+ QuitSpy quitSpy;
+ QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker);
+ QTimer::singleShot(0, [&]{ locker.reset(nullptr); });
+ QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
+ app.exec();
+ QCOMPARE(quitSpy.quits, 1);
+ }
+
+ {
+ // Disabling quitOnLastWindowClosed automatic quit should still block
+ // quitting via QEventLoopLocker if there's a window alive.
app.setQuitLockEnabled(true);
app.setQuitOnLastWindowClosed(false);
@@ -1024,7 +1064,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
QTimer::singleShot(0, [&]{ locker.reset(nullptr); });
QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
app.exec();
- QCOMPARE(quitSpy.quits, 1);
+ QCOMPARE(quitSpy.quits, 0);
}
{
@@ -1315,6 +1355,40 @@ void tst_QGuiApplication::staticFunctions()
QPixmap::defaultDepth();
}
+void tst_QGuiApplication::topLevelAt()
+{
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ QGuiApplication app(argc, argv);
+
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("QGuiApplication::topLevelAt() is not Wayland compliant, see also QTBUG-121015");
+
+ QWindow bottom;
+ bottom.setObjectName("Bottom");
+ bottom.setFlag(Qt::FramelessWindowHint);
+ bottom.setGeometry(200, 200, 200, 200);
+ bottom.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&bottom));
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom);
+
+ QWindow top;
+ top.setObjectName("Top");
+ top.setFlag(Qt::FramelessWindowHint);
+ top.setGeometry(200, 200, 200, 200);
+ top.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&top));
+ top.raise();
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &top);
+
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowMasks))
+ QSKIP("QWindow::setMask() is not supported.");
+
+ top.setMask(QRect(0, 0, 50, 50));
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom);
+ QTRY_COMPARE(app.topLevelAt(QPoint(225, 225)), &top);
+}
+
void tst_QGuiApplication::settableStyleHints_data()
{
QTest::addColumn<bool>("appInstance");
diff --git a/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt b/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt
new file mode 100644
index 0000000000..37848d8cec
--- /dev/null
+++ b/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qguichronotimer Test:
+#####################################################################
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguichronotimer LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+function(addGuiChronoTimerTest test)
+ qt_internal_add_test(${test}
+ SOURCES
+ ../../../corelib/kernel/qchronotimer/tst_qchronotimer.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::TestPrivate
+ )
+endfunction()
+
+addGuiChronoTimerTest(tst_qguichronotimer)
+qt_internal_extend_target(tst_qguichronotimer
+ DEFINES
+ tst_Qtimer=tst_QGuiChronoTimer
+)
+
+if(QT_FEATURE_glib AND UNIX)
+ addGuiChronoTimerTest(tst_qguichronotimer_no_glib)
+ qt_internal_extend_target(tst_qguichronotimer_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QTimer=tst_QGuiChronoTimer_no_glib # Class name in the unittest
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
index f080722817..62299f77df 100644
--- a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
@@ -5,9 +5,36 @@
## tst_qguieventdispatcher Test:
#####################################################################
-qt_internal_add_test(tst_qguieventdispatcher
- SOURCES
- ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
- LIBRARIES
- Qt::Gui
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguieventdispatcher LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+set(test_names "tst_qguieventdispatcher")
+if(QT_FEATURE_glib AND UNIX)
+ list(APPEND test_names "tst_qguieventdispatcher_no_glib")
+endif()
+
+foreach(test ${test_names})
+ qt_internal_add_test(${test}
+ NO_BATCH
+ SOURCES
+ ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+ LIBRARIES
+ Qt::Gui
+ )
+endforeach()
+
+qt_internal_extend_target(tst_qguieventdispatcher
+ DEFINES
+ tst_QEventDispatcher=tst_qguieventdispatcher
)
+
+if (TARGET tst_qeventdispatcher_no_glib)
+ qt_internal_extend_target(tst_qguieventdispatcher_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QEventDispatcher=tst_qguieventdispatcher_no_glib
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
index 16f15fc18e..89c518be10 100644
--- a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qguieventloop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguieventloop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qguieventloop
SOURCES
../../../corelib/kernel/qeventloop/tst_qeventloop.cpp
diff --git a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
index 17537ce5a3..7c93e4b8a2 100644
--- a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qguimetatype Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguimetatype LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qguimetatype
SOURCES
tst_qguimetatype.cpp
diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index 686e2a0e8b..54e95a2b38 100644
--- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
diff --git a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
index cf63294fae..bc292e133b 100644
--- a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
@@ -5,10 +5,34 @@
## tst_qguitimer Test:
#####################################################################
-qt_internal_add_test(tst_qguitimer
- SOURCES
- ../../../corelib/kernel/qtimer/tst_qtimer.cpp
- LIBRARIES
- Qt::CorePrivate
- Qt::Gui
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguitimer LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+function(addGuiTimerTest test)
+ qt_internal_add_test(${test}
+ SOURCES
+ ../../../corelib/kernel/qtimer/tst_qtimer.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::TestPrivate
+ )
+endfunction()
+
+addGuiTimerTest(tst_qguitimer)
+qt_internal_extend_target(tst_qguitimer
+ DEFINES
+ tst_Qtimer=tst_QGuiTimer
)
+
+if(QT_FEATURE_glib AND UNIX)
+ addGuiTimerTest(tst_qguitimer_no_glib)
+ qt_internal_extend_target(tst_qguitimer_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QTimer=tst_QGuiTimer_no_glib # Class name in the unittest
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
index b7c2998bf0..4470411a3b 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
@@ -5,6 +5,12 @@
## no_application Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_gui_variant_no_application LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_gui_variant_no_application
SOURCES
main.cpp
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
index bf6e2080b2..2b6ec7b870 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
+++ b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
index 844412c937..36b732e4ae 100644
--- a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qguivariant Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguivariant LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
file(GLOB_RECURSE qguivariant_resource_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index 27ba5e9386..cb22024f76 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
index 3588c35f6c..aa61bfbb0b 100644
--- a/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qhighdpi Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qhighdpi LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qhighdpi
SOURCES
tst_qhighdpi.cpp
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index 9a2482b03e..6fe4faec03 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <private/qhighdpiscaling_p.h>
#include <qpa/qplatformscreen.h>
@@ -36,6 +36,7 @@ private slots:
void screenDpiAndDpr_data();
void screenDpiAndDpr();
void screenDpiChange();
+ void screenDpiChangeWithWindow();
void environment_QT_SCALE_FACTOR();
void environment_QT_SCREEN_SCALE_FACTORS_data();
void environment_QT_SCREEN_SCALE_FACTORS();
@@ -238,6 +239,9 @@ void tst_QHighDpi::screenDpiAndDpr()
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
+ window.setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
+ window.create();
+ QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
}
@@ -264,12 +268,48 @@ void tst_QHighDpi::screenDpiChange()
for (QScreen *screen : app->screens()) {
QCOMPARE(screen->devicePixelRatio(), newDpi / standardBaseDpi);
QCOMPARE(screen->logicalDotsPerInch(), newDpi / screen->devicePixelRatio());
+
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
+ window.create();
+ QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
QCOMPARE(app->devicePixelRatio(), newDpi / standardBaseDpi);
}
+void tst_QHighDpi::screenDpiChangeWithWindow()
+{
+ QList<qreal> dpiValues = { 96, 192, 288 };
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ // Create windows for screens
+ QList<QScreen *> screens = app->screens();
+ QList<QWindow *> windows;
+ for (int i = 0; i < screens.count(); ++i) {
+ QScreen *screen = screens[i];
+ QWindow *window = new QWindow();
+ windows.append(window);
+ window->setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
+ window->create();
+ QCOMPARE(window->devicePixelRatio(), dpiValues[i] / standardBaseDpi);
+ }
+
+ // Change screen DPI
+ QList<qreal> newDpiValues = { 288, 192, 96 };
+ QJsonValue config = offscreenConfiguration();
+ QCborMap map = QCborMap::fromJsonObject(config.toObject());
+ for (int i = 0; i < screens.count(); ++i) {
+ map[QLatin1String("screens")][i][QLatin1String("logicalDpi")] = newDpiValues[i];
+ }
+ setOffscreenConfiguration(map.toJsonObject());
+
+ // Verify that window DPR changes on Screen DPI change.
+ for (int i = 0; i < screens.count(); ++i) {
+ QWindow *window = windows[i];
+ QCOMPARE(window->devicePixelRatio(), newDpiValues[i] / standardBaseDpi);
+ }
+}
+
void tst_QHighDpi::environment_QT_SCALE_FACTOR()
{
qreal factor = 3.1415;
diff --git a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
index 390c5e39ab..afbfd9bb37 100644
--- a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qinputdevice Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qinputdevice LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qinputdevice
SOURCES
tst_qinputdevice.cpp
diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
index ac42f0da30..8587aebf2a 100644
--- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
+++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qpa/qwindowsysteminterface.h>
diff --git a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
index a5d684e017..e3ce0774bc 100644
--- a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qinputmethod Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qinputmethod LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qinputmethod
SOURCES
tst_qinputmethod.cpp
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index c562a5c362..619de7bed3 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
@@ -249,13 +249,13 @@ void tst_qinputmethod::query()
void tst_qinputmethod::inputDirection()
{
- QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 0);
+ auto originalCount = m_platformInputContext.m_inputDirectionCallCount;
qApp->inputMethod()->inputDirection();
- QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 1);
+ QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, originalCount + 1);
- QCOMPARE(m_platformInputContext.m_localeCallCount, 0);
+ originalCount = m_platformInputContext.m_localeCallCount;
qApp->inputMethod()->locale();
- QCOMPARE(m_platformInputContext.m_localeCallCount, 1);
+ QCOMPARE(m_platformInputContext.m_localeCallCount, originalCount + 1);
}
void tst_qinputmethod::inputMethodAccepted()
diff --git a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
index 8741cfc2aa..c3c9892d14 100644
--- a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qkeyevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qkeyevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qkeyevent
SOURCES
tst_qkeyevent.cpp
diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
index 4f2379fbb4..7d8e0aa5dc 100644
--- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
+++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QTest>
diff --git a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
index ded845fbfb..1676302d1b 100644
--- a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qkeysequence Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qkeysequence LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set(qkeysequence_resource_files
"keys_de.qm"
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index 976e4f76bb..67fef3cf44 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -473,6 +473,7 @@ void tst_QKeySequence::toStringFromKeycode_data()
QTest::newRow("A") << QKeySequence(Qt::Key_A) << "A";
QTest::newRow("-1") << QKeySequence(-1) << "";
QTest::newRow("Unknown") << QKeySequence(Qt::Key_unknown) << "";
+ QTest::newRow("Ctrl+Unknown") << QKeySequence(Qt::ControlModifier | Qt::Key_unknown) << "";
QTest::newRow("Ctrl+Num+Ins") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Insert) << "Ctrl+Num+Ins";
QTest::newRow("Ctrl+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Num+Del";
QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
diff --git a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
index 70fb5cc834..ac2200792b 100644
--- a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qmouseevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmouseevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qmouseevent
SOURCES
tst_qmouseevent.cpp
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index dda91225e5..f703111384 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -7,6 +7,8 @@
#include <qwindow.h>
#include <QtGui/private/qpointingdevice_p.h>
+#include <QtCore/qpointer.h>
+
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class MouseEventWidget : public QWindow
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
index 4539a80654..034b9c794d 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qmouseevent_modal Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmouseevent_modal LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qmouseevent_modal
SOURCES
tst_qmouseevent_modal.cpp
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
index e589e54195..0fe218d503 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
+++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
index 34333ac10a..0f57b98bc3 100644
--- a/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qopenglwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qopenglwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qopenglwindow
SOURCES
tst_qopenglwindow.cpp
diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
index e1c4bab677..06a1ffb296 100644
--- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
+++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtOpenGL/QOpenGLWindow>
#include <QTest>
@@ -119,6 +119,9 @@ void tst_QOpenGLWindow::resize()
if (isPlatformWayland())
QSKIP("Wayland: Crashes on Intel Mesa due to a driver bug (QTBUG-66848).");
+ if (QGuiApplication::platformName().startsWith(QLatin1String("eglfs"), Qt::CaseInsensitive))
+ QSKIP("EGLFS does not allow resizing on top level window");
+
Window w;
w.reset();
w.resize(640, 480);
diff --git a/tests/auto/gui/kernel/qpalette/CMakeLists.txt b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
index ce77f5866b..7983b9ac25 100644
--- a/tests/auto/gui/kernel/qpalette/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpalette Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpalette LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpalette
SOURCES
tst_qpalette.cpp
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index 81036bee0a..c21828bee2 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -23,6 +23,7 @@ private Q_SLOTS:
void cannotCheckIfInvalidBrushSet();
void checkIfBrushForCurrentGroupSet();
void cacheKey();
+ void dataStream();
};
void tst_QPalette::roleValues_data()
@@ -51,9 +52,10 @@ void tst_QPalette::roleValues_data()
QTest::newRow("QPalette::ToolTipBase") << int(QPalette::ToolTipBase) << 18;
QTest::newRow("QPalette::ToolTipText") << int(QPalette::ToolTipText) << 19;
QTest::newRow("QPalette::PlaceholderText") << int(QPalette::PlaceholderText) << 20;
+ QTest::newRow("QPalette::Accent") << int(QPalette::Accent) << 21;
// Change this value as you add more roles.
- QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 21;
+ QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 22;
}
void tst_QPalette::roleValues()
@@ -236,8 +238,14 @@ void tst_QPalette::setAllPossibleBrushes()
}
for (int r = 0; r < QPalette::NColorRoles; ++r) {
+ const QPalette::ColorRole role = static_cast<QPalette::ColorRole>(r);
for (int g = 0; g < QPalette::NColorGroups; ++g) {
- QVERIFY(p.isBrushSet(QPalette::ColorGroup(g), QPalette::ColorRole(r)));
+ const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(g);
+ // NoRole has no resolve bit => isBrushSet returns false
+ if (role == QPalette::NoRole)
+ QVERIFY(!p.isBrushSet(group, role));
+ else
+ QVERIFY(p.isBrushSet(group, role));
}
}
}
@@ -341,5 +349,44 @@ void tst_QPalette::cacheKey()
loggerShallowDetach.dismiss();
}
+void tst_QPalette::dataStream()
+{
+ const QColor highlight(42, 42, 42);
+ const QColor accent(13, 13, 13);
+ QPalette palette;
+ palette.setBrush(QPalette::Highlight, highlight);
+ palette.setBrush(QPalette::Accent, accent);
+
+ // When saved with Qt_6_5 or earlier, Accent defaults to Highlight
+ {
+ QByteArray b;
+ {
+ QDataStream stream(&b, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_6_5);
+ stream << palette;
+ }
+ QPalette test;
+ QDataStream stream (&b, QIODevice::ReadOnly);
+ stream.setVersion(QDataStream::Qt_6_5);
+ stream >> test;
+ QCOMPARE(test.accent().color(), highlight);
+ }
+
+ // When saved with Qt_6_6 or later, Accent is saved explicitly
+ {
+ QByteArray b;
+ {
+ QDataStream stream(&b, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_6_6);
+ stream << palette;
+ }
+ QPalette test;
+ QDataStream stream (&b, QIODevice::ReadOnly);
+ stream.setVersion(QDataStream::Qt_6_6);
+ stream >> test;
+ QCOMPARE(test.accent().color(), accent);
+ }
+}
+
QTEST_MAIN(tst_QPalette)
#include "tst_qpalette.moc"
diff --git a/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt b/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
index 435606de04..c711ceeafa 100644
--- a/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpixelformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpixelformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpixelformat
SOURCES
tst_qpixelformat.cpp
diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
index a0cf95c7f4..d6d471bf6b 100644
--- a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
+++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/qpixelformat.h>
diff --git a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
index fad0d3381b..dc9d6a70c7 100644
--- a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qrasterwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qrasterwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qrasterwindow
SOURCES
tst_qrasterwindow.cpp
diff --git a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
index 64e418a251..a06e360e35 100644
--- a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
+++ b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QRasterWindow>
#include <QTest>
@@ -45,7 +45,7 @@ void tst_QRasterWindow::basic()
w.reset();
w.resize(400, 400);
w.show();
- QVERIFY(QTest::qWaitForWindowExposed(&w));;
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QVERIFY(w.paintCount >= 1);
diff --git a/tests/auto/gui/kernel/qscreen/CMakeLists.txt b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
index 10f3633c34..8502176ca4 100644
--- a/tests/auto/gui/kernel/qscreen/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qscreen Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qscreen LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qscreen
SOURCES
tst_qscreen.cpp
diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
index f64add3117..74a03ac851 100644
--- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
+++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qpainter.h>
#include <qrasterwindow.h>
diff --git a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
index 85cc0c7ce0..517a4e8a1a 100644
--- a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
@@ -5,9 +5,16 @@
## tst_qshortcut_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qshortcut_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qshortcut_kernel
SOURCES
tst_qshortcut.cpp
LIBRARIES
Qt::Gui
+ Qt::GuiPrivate
)
diff --git a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
index 8a1b2888a2..cb6ebab800 100644
--- a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
@@ -1,56 +1,59 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/qguiapplication.h>
#include <QtGui/qshortcut.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qrasterwindow.h>
-#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
+#include <QtTest/qsignalspy.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
class tst_QShortcut : public QObject
{
Q_OBJECT
-public:
private slots:
- void trigger();
-};
-
-class ColoredWindow : public QRasterWindow {
-public:
- ColoredWindow(QColor c) : m_color(c) {}
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- const QColor m_color;
+ void applicationShortcut();
+ void windowShortcut();
};
-void ColoredWindow::paintEvent(QPaintEvent *)
+void tst_QShortcut::applicationShortcut()
{
- QPainter p(this);
- p.fillRect(QRect(QPoint(), size()), m_color);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("Window activation is not supported");
+
+ auto *shortcut = new QShortcut(Qt::CTRL | Qt::Key_A, this);
+ shortcut->setContext(Qt::ApplicationShortcut);
+ QSignalSpy activatedSpy(shortcut, &QShortcut::activated);
+
+ // Need a window to send key event to, even if the shortcut is application
+ // global. The documentation for Qt::ApplicationShortcut also says that
+ // the shortcut "is active when one of the applications windows are active",
+ // but this is only honored for Qt Widgets, not for Qt Gui. For now we
+ // activate the window just in case.
+ QWindow window;
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QTRY_COMPARE(QGuiApplication::applicationState(), Qt::ApplicationActive);
+ QTest::sendKeyEvent(QTest::Shortcut, &window, Qt::Key_A, 'a', Qt::ControlModifier);
+
+ QVERIFY(activatedSpy.size() > 0);
}
-static void sendKey(QWindow *target, Qt::Key k, char c, Qt::KeyboardModifiers modifiers)
+void tst_QShortcut::windowShortcut()
{
- QTest::sendKeyEvent(QTest::Press, target, k, c, modifiers);
- QTest::sendKeyEvent(QTest::Release, target, k, c, modifiers);
-}
-
-void tst_QShortcut::trigger()
-{
- ColoredWindow w(Qt::yellow);
- w.setTitle(QTest::currentTestFunction());
- w.resize(QGuiApplication::primaryScreen()->size() / 4);
+ QWindow w;
new QShortcut(Qt::CTRL | Qt::Key_Q, &w, SLOT(close()));
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
+
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QEXPECT_FAIL("", "It failed on Wayland, QTBUG-120334", Abort);
+
QTRY_VERIFY(QGuiApplication::applicationState() == Qt::ApplicationActive);
- sendKey(&w, Qt::Key_Q, 'q', Qt::ControlModifier);
+ QTest::sendKeyEvent(QTest::Click, &w, Qt::Key_Q, 'q', Qt::ControlModifier);
QTRY_VERIFY(!w.isVisible());
}
diff --git a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
index ae94135153..1303f48cf3 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qsurfaceformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qsurfaceformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qsurfaceformat
SOURCES
tst_qsurfaceformat.cpp
diff --git a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
index 0b2d301ad9..3f655bd905 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
+++ b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qsurfaceformat.h>
diff --git a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
index 6d5cb582e2..160263ac66 100644
--- a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtouchevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtouchevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtouchevent
SOURCES
tst_qtouchevent.cpp
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index be976adc5f..37ddcb8962 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QCursor>
#include <QtGui/QScreen>
@@ -20,6 +20,8 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
+#include <QtCore/qpointer.h>
+
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class tst_QTouchEventWidget : public QWidget
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index 328d3f51b1..69df8883c8 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -11,8 +11,6 @@ windows
# QTBUG-69162
windows-10
android
-[testInputEvents]
-rhel-7.4
[modalWindowPosition]
# QTBUG-69161
android
@@ -23,3 +21,8 @@ android
android
[modalWindowModallity]
android
+[enterLeaveOnWindowShowHide]
+windows-10
+windows-11
+android
+rhel
diff --git a/tests/auto/gui/kernel/qwindow/CMakeLists.txt b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
index 605761622f..5824989ac3 100644
--- a/tests/auto/gui/kernel/qwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qwindow
SOURCES
tst_qwindow.cpp
@@ -14,8 +20,9 @@ qt_internal_add_test(tst_qwindow
Qt::GuiPrivate
)
-if(APPLE OR WIN32)
+if(APPLE OR WIN32 OR QT_FEATURE_xcb)
qt_internal_add_test(tst_foreignwindow
+ LOWDPI
SOURCES
tst_foreignwindow.cpp
LIBRARIES
@@ -25,9 +32,14 @@ if(APPLE OR WIN32)
)
if(APPLE)
- target_compile_options(tst_foreignwindow PRIVATE -x objective-c++)
+ enable_language(OBJCXX)
+ set_source_files_properties(tst_foreignwindow.cpp PROPERTIES LANGUAGE OBJCXX)
set_property(TARGET tst_foreignwindow PROPERTY PROPERTY MACOSX_BUNDLE TRUE)
endif()
+
+ if(QT_FEATURE_xcb)
+ target_link_libraries(tst_foreignwindow PRIVATE XCB::XCB)
+ endif()
endif()
## Scopes:
diff --git a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
index 1d78178977..fdb1b333ef 100644
--- a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2023 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -7,114 +7,7 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
-#if defined(Q_OS_MACOS)
-# include <AppKit/AppKit.h>
-#elif defined(Q_OS_WIN)
-# include <winuser.h>
-#endif
-
-Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
-
-class NativeWindow
-{
- Q_DISABLE_COPY(NativeWindow)
-public:
- NativeWindow();
- ~NativeWindow();
-
- operator WId() const { return reinterpret_cast<WId>(m_handle); }
-
- void setGeometry(const QRect &rect);
- QRect geometry() const;
-
-private:
-#if defined(Q_OS_MACOS)
- NSView *m_handle = nullptr;
-#elif defined(Q_OS_WIN)
- HWND m_handle = nullptr;
-#endif
-};
-
-#if defined(Q_OS_MACOS)
-
-@interface View : NSView
-@end
-
-@implementation View
-- (instancetype)init
-{
- if ((self = [super init])) {
- qCDebug(lcTests) << "Initialized" << self;
- }
- return self;
-}
-
-- (void)dealloc
-{
- qCDebug(lcTests) << "Deallocating" << self;
- [super dealloc];
-}
-@end
-
-NativeWindow::NativeWindow()
- : m_handle([View new])
-{
-}
-
-NativeWindow::~NativeWindow()
-{
- [m_handle release];
-}
-
-void NativeWindow::setGeometry(const QRect &rect)
-{
- m_handle.frame = QRectF(rect).toCGRect();
-}
-
-QRect NativeWindow::geometry() const
-{
- return QRectF::fromCGRect(m_handle.frame).toRect();
-}
-
-#elif defined(Q_OS_WIN)
-
-NativeWindow::NativeWindow()
-{
- static const LPCWSTR className = []{
- WNDCLASS wc = {};
- wc.lpfnWndProc = DefWindowProc;
- wc.hInstance = GetModuleHandle(nullptr);
- wc.lpszClassName = L"Native Window";
- RegisterClass(&wc);
- return wc.lpszClassName;
- }();
- m_handle = CreateWindowEx(0, className, nullptr, WS_POPUP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
-}
-
-NativeWindow::~NativeWindow()
-{
- DestroyWindow(m_handle);
-}
-
-void NativeWindow::setGeometry(const QRect &rect)
-{
- MoveWindow(m_handle, rect.x(), rect.y(), rect.width(), rect.height(), false);
-}
-
-QRect NativeWindow::geometry() const
-{
- WINDOWPLACEMENT wp;
- wp.length = sizeof(WINDOWPLACEMENT);
- if (GetWindowPlacement(m_handle, &wp)) {
- RECT r = wp.rcNormalPosition;
- return QRect(r.left, r.top, r.right - r.left, r.bottom - r.top);
- }
- return {};
-}
-
-#endif
+#include "../../../../shared/nativewindow.h"
class tst_ForeignWindow: public QObject
{
@@ -130,6 +23,12 @@ private slots:
void fromWinId();
void initialState();
+
+ void embedForeignWindow();
+ void embedInForeignWindow();
+
+ void destroyExplicitly();
+ void destroyWhenParentIsDestroyed();
};
void tst_ForeignWindow::fromWinId()
@@ -165,6 +64,7 @@ void tst_ForeignWindow::initialState()
const QRect initialGeometry(123, 456, 321, 654);
nativeWindow.setGeometry(initialGeometry);
+ QTRY_COMPARE(nativeWindow.geometry(), initialGeometry);
std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
QCOMPARE(nativeWindow.geometry(), initialGeometry);
@@ -174,5 +74,123 @@ void tst_ForeignWindow::initialState()
QCOMPARE(foreignWindow->geometry(), initialGeometry);
}
+void tst_ForeignWindow::embedForeignWindow()
+{
+ // A foreign window embedded into a Qt UI requires that the rest of Qt
+ // is to be able to treat the foreign child window as any other window
+ // that it can show, hide, stack, and move around.
+
+ QWindow parentWindow;
+
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ // As a prerequisite to that, we must be able to reparent the foreign window
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ foreignWindow->setParent(&parentWindow);
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ // FIXME: This test is flakey on Linux. Figure out why
+#if !defined(Q_OS_LINUX)
+ foreignWindow->setParent(nullptr);
+ QTRY_VERIFY(nativeWindow.parentWinId() != parentWindow.winId());
+#endif
+}
+
+void tst_ForeignWindow::embedInForeignWindow()
+{
+ // When a foreign window is used as a container to embed a Qt UI
+ // in a foreign window hierarchy, the foreign window merely acts
+ // as a parent, and should not be modified.
+
+ {
+ // At a minimum, we must be able to reparent into the window
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+
+ QWindow embeddedWindow;
+ embeddedWindow.setParent(foreignWindow.get());
+ QTRY_VERIFY(nativeWindow.isParentOf(embeddedWindow.winId()));
+ }
+
+ {
+ // The foreign window's native window should not be reparent as a
+ // result of creating the foreign window, adding and removing children,
+ // or destroying the foreign window.
+
+ NativeWindow topLevelNativeWindow;
+ NativeWindow childNativeWindow;
+ childNativeWindow.setParent(topLevelNativeWindow);
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(childNativeWindow));
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ QWindow embeddedWindow;
+ embeddedWindow.setParent(foreignWindow.get());
+ QTRY_VERIFY(childNativeWindow.isParentOf(embeddedWindow.winId()));
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ embeddedWindow.setParent(nullptr);
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ foreignWindow.reset();
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+ }
+}
+
+void tst_ForeignWindow::destroyExplicitly()
+{
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ QVERIFY(foreignWindow->handle());
+
+ // Explicitly destroying a foreign window is a no-op, as
+ // the documentation claims that it "releases the native
+ // platform resources associated with this window.", which
+ // is not technically true for foreign windows.
+ auto *windowHandleBeforeDestroy = foreignWindow->handle();
+ foreignWindow->destroy();
+ QCOMPARE(foreignWindow->handle(), windowHandleBeforeDestroy);
+}
+
+void tst_ForeignWindow::destroyWhenParentIsDestroyed()
+{
+ QWindow parentWindow;
+
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ foreignWindow->setParent(&parentWindow);
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ // Reparenting into a window will result in creating it
+ QVERIFY(parentWindow.handle());
+
+ parentWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parentWindow));
+
+ // Destroying the parent window of the foreign window results
+ // in destroying the foreign window as well, as the foreign
+ // window no longer has a parent it can be embedded in.
+ QVERIFY(foreignWindow->handle());
+ parentWindow.destroy();
+ QVERIFY(!foreignWindow->handle());
+
+ // But the foreign window can be recreated again, and will
+ // continue to be a native child of the parent window.
+ foreignWindow->create();
+ QVERIFY(foreignWindow->handle());
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ parentWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parentWindow));
+}
+
#include <tst_foreignwindow.moc>
QTEST_MAIN(tst_ForeignWindow)
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 1cac1820d9..227fd77e1a 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qrasterwindow.h>
#include <qpa/qwindowsysteminterface.h>
@@ -7,6 +7,7 @@
#include <qpa/qplatformwindow.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
+#include <private/qwindow_p.h>
#include <QtGui/QPainter>
#include <QTest>
@@ -22,6 +23,12 @@
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
+static bool isPlatformEglFS()
+{
+ static const bool isEglFS = !QGuiApplication::platformName().compare(QLatin1String("eglfs"), Qt::CaseInsensitive);
+ return isEglFS;
+}
+
class tst_QWindow: public QObject
{
Q_OBJECT
@@ -30,6 +37,7 @@ private slots:
void create();
void setParent();
void setVisible();
+ void setVisibleThenCreate();
void setVisibleFalseDoesNotCreateWindow();
void eventOrderOnShow();
void paintEvent();
@@ -89,6 +97,13 @@ private slots:
void qobject_castOnDestruction();
void touchToMouseTranslationByPopup();
void stateChangeSignal();
+#ifndef QT_NO_CURSOR
+ void enterLeaveOnWindowShowHide_data();
+ void enterLeaveOnWindowShowHide();
+#endif
+ void windowExposedAfterReparent();
+ void childEvents();
+ void parentEvents();
private:
QPoint m_availableTopLeft;
@@ -106,6 +121,10 @@ static bool isPlatformWayland()
void tst_QWindow::initTestCase()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() == 33)
+ QSKIP("Is flaky on Android 13 / RHEL 8.6 and 8.8 (QTQAINFRA-5606)");
+#endif
// Size of reference window, 200 for < 2000, scale up for larger screens
// to avoid Windows warnings about minimum size for decorated windows.
int width = 200;
@@ -231,6 +250,40 @@ void tst_QWindow::setVisible()
QVERIFY(QTest::qWaitForWindowExposed(&i));
}
+class SurfaceCreatedWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ using QWindow::QWindow;
+
+ bool eventFilter(QObject *o, QEvent *e) override
+ {
+ if (e->type() == QEvent::PlatformSurface) {
+ auto type = static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType();
+ if (type == QPlatformSurfaceEvent::SurfaceCreated)
+ ++surfaceCreatedEvents;
+ }
+ return QWindow::eventFilter(o, e);
+ }
+
+ int surfaceCreatedEvents = 0;
+};
+
+void tst_QWindow::setVisibleThenCreate()
+{
+ QWindow parent;
+ parent.setObjectName("Parent");
+ SurfaceCreatedWindow child(&parent);
+ child.installEventFilter(&child);
+ child.setObjectName("Child");
+ child.setVisible(true);
+ child.create();
+ QCOMPARE(child.surfaceCreatedEvents, 1);
+ parent.setVisible(true);
+ QCOMPARE(child.surfaceCreatedEvents, 1);
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+}
+
void tst_QWindow::setVisibleFalseDoesNotCreateWindow()
{
QWindow w;
@@ -429,11 +482,16 @@ void tst_QWindow::resizeEventAfterResize()
// Make sure we get a resizeEvent after calling resize
window.resize(m_testWindowSize);
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QTRY_COMPARE(window.received(QEvent::Resize), 2);
}
void tst_QWindow::exposeEventOnShrink_QTBUG54040()
{
+ if (isPlatformEglFS())
+ QSKIP("", "eglfs windows are fullscreen by default.", Continue);
Window window;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.setTitle(QTest::currentTestFunction());
@@ -616,6 +674,8 @@ void tst_QWindow::childWindowPositioning_data()
void tst_QWindow::childWindowPositioning()
{
+ if (isPlatformEglFS())
+ QSKIP("eglfs does not support child windows.");
const QPoint topLeftOrigin(0, 0);
ColoredWindow topLevelWindowFirst(Qt::green);
@@ -1449,6 +1509,7 @@ void tst_QWindow::touchCancelWithTouchToMouse()
void tst_QWindow::touchInterruptedByPopup()
{
InputTestWindow window;
+ window.setObjectName("main");
window.setTitle(QLatin1String(QTest::currentTestFunction()));
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.show();
@@ -1469,6 +1530,7 @@ void tst_QWindow::touchInterruptedByPopup()
// Launch a popup window
InputTestWindow popup;
+ window.setObjectName("popup");
popup.setFlags(Qt::Popup);
popup.setModality(Qt::WindowModal);
popup.resize(m_testWindowSize / 2);
@@ -1491,9 +1553,6 @@ void tst_QWindow::touchInterruptedByPopup()
QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
QCoreApplication::processEvents();
QTRY_COMPARE(window.touchReleasedCount, 0);
-
- // Due to temporary fix for QTBUG-37371: the original window should receive a TouchCancel
- QTRY_COMPARE(window.touchEventType, QEvent::TouchCancel);
}
void tst_QWindow::orientation()
@@ -1576,6 +1635,13 @@ void tst_QWindow::sizes()
window.resize(80, 80);
window.setMaximumSize(QSize(70, 70));
QCOMPARE(window.size(), QSize(70, 70));
+
+ // QTBUG-113233
+ // test for an invalid min/max pair
+ window.setMinimumSize(QSize(80, 80)); // current maximumSize = QSize(70, 70)
+ QCOMPARE(window.size(), QSize(70, 70));
+ window.setMaximumSize(QSize(90, 90));
+ QCOMPARE(window.size(), QSize(80, 80));
}
class CloseOnCloseEventWindow : public QWindow
@@ -2080,6 +2146,10 @@ void tst_QWindow::initialSize()
w.setTitle(QLatin1String(QTest::currentTestFunction()));
w.setWidth(m_testWindowSize.width());
w.showNormal();
+
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QTRY_COMPARE(w.width(), m_testWindowSize.width());
QTRY_VERIFY(w.height() > 0);
}
@@ -2091,6 +2161,8 @@ void tst_QWindow::initialSize()
w.showNormal();
const QSize expectedSize = testSize;
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
QTRY_COMPARE(w.size(), expectedSize);
}
}
@@ -2266,6 +2338,10 @@ void tst_QWindow::modalWindowPosition()
window.setModality(Qt::WindowModal);
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QCOMPARE(window.geometry(), origGeo);
}
@@ -2294,6 +2370,9 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
if (isPlatformOffscreenOrMinimal())
QSKIP("Can't test window focusing on offscreen/minimal");
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
+
const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
const int childOffset = 16;
@@ -2474,6 +2553,8 @@ void tst_QWindow::spuriousMouseMove()
QSKIP("No enter events sent");
if (platformName == QLatin1String("wayland"))
QSKIP("Setting mouse cursor position is not possible on Wayland");
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
const QPoint center = screenGeometry.center();
QCursor::setPos(center);
@@ -2788,11 +2869,11 @@ void tst_QWindow::stateChangeSignal()
"On other operating systems, the signal may be emitted twice.");
#endif
QWindow w;
- Q_ASSUME(connect (&w, &QWindow::windowStateChanged, [](Qt::WindowState s){qCDebug(lcTests) << "State change to" << s;}));
+ Q_ASSERT(connect (&w, &QWindow::windowStateChanged, [](Qt::WindowState s){qCDebug(lcTests) << "State change to" << s;}));
QSignalSpy spy(&w, SIGNAL(windowStateChanged(Qt::WindowState)));
unsigned short signalCount = 0;
QList<Qt::WindowState> effectiveStates;
- Q_ASSUME(connect(&w, &QWindow::windowStateChanged, [&effectiveStates](Qt::WindowState state)
+ Q_ASSERT(connect(&w, &QWindow::windowStateChanged, [&effectiveStates](Qt::WindowState state)
{ effectiveStates.append(state); }));
// Part 1:
// => test signal emission on programmatic state changes
@@ -2876,6 +2957,268 @@ void tst_QWindow::stateChangeSignal()
CHECK_SIGNAL(Qt::WindowMinimized);
}
+#ifndef QT_NO_CURSOR
+void tst_QWindow::enterLeaveOnWindowShowHide_data()
+{
+ QTest::addColumn<Qt::WindowType>("windowType");
+ QTest::addRow("dialog") << Qt::Dialog;
+ QTest::addRow("popup") << Qt::Popup;
+}
+
+/*!
+ Verify that we get enter and leave events if the window under the mouse
+ opens and closes a modal dialog or popup. QWindow might get multiple
+ events in a row, as the various QPA plugins need to use different techniques
+ to synthesize events if the native platform doesn't provide them for us.
+*/
+void tst_QWindow::enterLeaveOnWindowShowHide()
+{
+ if (isPlatformWayland())
+ QSKIP("Can't set cursor position and qWaitForWindowActive on Wayland");
+
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
+
+ QFETCH(Qt::WindowType, windowType);
+
+ class Window : public QWindow
+ {
+ public:
+ int numEnterEvents = 0;
+ int numLeaveEvents = 0;
+ QPoint enterPosition;
+ protected:
+ bool event(QEvent *e) override
+ {
+ switch (e->type()) {
+ case QEvent::Enter:
+ ++numEnterEvents;
+ enterPosition = static_cast<QEnterEvent*>(e)->position().toPoint();
+ break;
+ case QEvent::Leave:
+ ++numLeaveEvents;
+ break;
+ default:
+ break;
+ }
+ return QWindow::event(e);
+ }
+ };
+
+ int expectedEnter = 0;
+ int expectedLeave = 0;
+
+ Window window;
+ const QRect screenGeometry = window.screen()->availableGeometry();
+ const QPoint cursorPos = screenGeometry.topLeft() + QPoint(50, 50);
+ window.setGeometry(QRect(cursorPos - QPoint(50, 50), screenGeometry.size() / 4));
+ QCursor::setPos(cursorPos);
+
+ if (!QTest::qWaitFor([&]{ return window.geometry().contains(QCursor::pos()); }))
+ QSKIP("We can't move the cursor");
+
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ ++expectedEnter;
+ QTRY_COMPARE_WITH_TIMEOUT(window.numEnterEvents, expectedEnter, 250);
+ QCOMPARE(window.enterPosition, window.mapFromGlobal(QCursor::pos()));
+
+ QWindow secondary;
+ secondary.setFlag(windowType);
+ secondary.setModality(Qt::WindowModal);
+ secondary.setTransientParent(&window);
+ secondary.setPosition(cursorPos + QPoint(50, 50));
+ secondary.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&secondary));
+ ++expectedLeave;
+ QTRY_VERIFY(window.numLeaveEvents >= expectedLeave);
+ secondary.close();
+ ++expectedEnter;
+ QTRY_VERIFY(window.numEnterEvents >= expectedEnter);
+ QCOMPARE(window.enterPosition, window.mapFromGlobal(QCursor::pos()));
+}
+#endif
+
+void tst_QWindow::windowExposedAfterReparent()
+{
+ QWindow parent;
+ QWindow child(&parent);
+ child.show();
+ parent.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+
+ child.setParent(nullptr);
+ QCoreApplication::processEvents();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+
+ child.setParent(&parent);
+ QCoreApplication::processEvents();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+}
+
+struct ParentWindow : public QWindow
+{
+ bool event(QEvent *event) override
+ {
+ [&]() -> void {
+ if (event->type() == QEvent::ChildWindowAdded
+ || event->type() == QEvent::ChildWindowRemoved) {
+ // We should not receive child events after the window has been destructed
+ QVERIFY(this->isWindowType());
+
+ auto *parentWindow = this;
+ auto *childEvent = static_cast<QChildWindowEvent*>(event);
+ auto *childWindow = childEvent->child();
+
+ if (event->type() == QEvent::ChildWindowAdded) {
+ QVERIFY(childWindow->parent());
+ QVERIFY(parentWindow->isAncestorOf(childWindow));
+ if (childWindow->handle())
+ QVERIFY(childWindow->handle()->parent() == parentWindow->handle());
+
+ } else {
+ QVERIFY(!childWindow->parent());
+ QVERIFY(!parentWindow->isAncestorOf(childWindow));
+ if (childWindow->handle())
+ QVERIFY(childWindow->handle()->parent() != parentWindow->handle());
+ }
+ }
+ }();
+
+ return QWindow::event(event);
+ }
+};
+
+void tst_QWindow::childEvents()
+{
+ ParentWindow parent;
+
+ {
+ // ChildAdded via constructor
+ QWindow constructorChild(&parent);
+ if (QTest::currentTestFailed()) return;
+ // ChildRemoved via destructor
+ }
+
+ if (QTest::currentTestFailed()) return;
+
+ // ChildAdded and ChildRemoved via setParent
+ QWindow child;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+
+ parent.create();
+ child.create();
+
+ // ChildAdded and ChildRemoved after creation
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+}
+
+struct ChildWindowPrivate;
+struct ChildWindow : public QWindow
+{
+ ChildWindow(QWindow *parent = nullptr);
+};
+
+struct ChildWindowPrivate : public QWindowPrivate
+{
+ ChildWindowPrivate() : QWindowPrivate()
+ {
+ receiveParentEvents = true;
+ }
+};
+
+ChildWindow::ChildWindow(QWindow *parent)
+ : QWindow(*new ChildWindowPrivate, parent)
+{}
+
+struct ParentEventTester : public QObject
+{
+ bool eventFilter(QObject *object, QEvent *event) override
+ {
+ [&]() -> void {
+ if (event->type() == QEvent::ParentWindowAboutToChange
+ || event->type() == QEvent::ParentWindowChange) {
+ // We should not receive parent events after the window has been destructed
+ QVERIFY(object->isWindowType());
+ auto *window = static_cast<QWindow*>(object);
+
+ if (event->type() == QEvent::ParentWindowAboutToChange) {
+ QVERIFY(window->parent() != nextExpectedParent);
+ if (window->handle()) {
+ QVERIFY(window->handle()->parent() !=
+ (nextExpectedParent ? nextExpectedParent->handle() : nullptr));
+ }
+ } else {
+ QVERIFY(window->parent() == nextExpectedParent);
+ if (window->handle()) {
+ QVERIFY(window->handle()->parent() ==
+ (nextExpectedParent ? nextExpectedParent->handle() : nullptr));
+ }
+ }
+ }
+ }();
+
+ return QObject::eventFilter(object, event);
+ }
+
+ QWindow *nextExpectedParent = nullptr;
+};
+
+
+
+void tst_QWindow::parentEvents()
+{
+ QWindow parent;
+
+ {
+ ParentEventTester tester;
+
+ {
+ // We can't hook in early enough to get the parent change during
+ // QObject construction.
+ ChildWindow child(&parent);
+
+ // But we can observe the one during destruction
+ child.installEventFilter(&tester);
+ tester.nextExpectedParent = nullptr;
+ }
+ }
+ if (QTest::currentTestFailed()) return;
+
+ ParentEventTester tester;
+ ChildWindow child;
+ child.installEventFilter(&tester);
+
+ tester.nextExpectedParent = &parent;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+
+ tester.nextExpectedParent = nullptr;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+
+ parent.create();
+ child.create();
+
+ tester.nextExpectedParent = &parent;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+
+ tester.nextExpectedParent = nullptr;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)
diff --git a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
index 506d4d5e19..22f581e9c8 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qmatrixnxn Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmatrixnxn LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qmatrixnxn
SOURCES
tst_qmatrixnxn.cpp
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index a984cd0ae7..e761f8cb3c 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtCore/qmath.h>
@@ -2343,7 +2343,7 @@ void tst_QMatrixNxN::rotate4x4()
ROTATE4(2.0f, 3.0f, 0.0f, 1.0f, p1x, p1y, p1z, p1w);
p1x /= p1w;
p1y /= p1w;
- p1z /= p1w;
+ Q_UNUSED(p1z);
QVector3D v1(2.0f, 3.0f, -4.0f);
QVector3D v2 = m1.map(v1);
diff --git a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
index f35dc1a148..205865faba 100644
--- a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qquaternion Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qquaternion LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qquaternion
SOURCES
tst_qquaternion.cpp
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index 6be46b9ee2..8cdc06354e 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QTest>
#include <QtCore/qmath.h>
diff --git a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
index f7478a1899..5de1ff11e6 100644
--- a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qvectornd Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qvectornd LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qvectornd
SOURCES
tst_qvectornd.cpp
diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
index beba252293..3272ffac0e 100644
--- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
+++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QVector2D>
#include <QVector3D>
diff --git a/tests/auto/gui/painting/CMakeLists.txt b/tests/auto/gui/painting/CMakeLists.txt
index 2c23cfab07..b49a80b180 100644
--- a/tests/auto/gui/painting/CMakeLists.txt
+++ b/tests/auto/gui/painting/CMakeLists.txt
@@ -10,7 +10,9 @@ add_subdirectory(qpagelayout)
add_subdirectory(qpageranges)
add_subdirectory(qpagesize)
add_subdirectory(qpainter)
-add_subdirectory(qpdfwriter)
+if (QT_FEATURE_pdf)
+ add_subdirectory(qpdfwriter)
+endif()
add_subdirectory(qpen)
add_subdirectory(qpaintengine)
add_subdirectory(qtransform)
diff --git a/tests/auto/gui/painting/qbrush/CMakeLists.txt b/tests/auto/gui/painting/qbrush/CMakeLists.txt
index cbb4e07134..313bce20a4 100644
--- a/tests/auto/gui/painting/qbrush/CMakeLists.txt
+++ b/tests/auto/gui/painting/qbrush/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qbrush Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qbrush LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qbrush
SOURCES
tst_qbrush.cpp
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index 64513b89c6..678c8d9b32 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/painting/qcolor/CMakeLists.txt b/tests/auto/gui/painting/qcolor/CMakeLists.txt
index 2ca7bbead5..52e551855c 100644
--- a/tests/auto/gui/painting/qcolor/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolor/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qcolor Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolor LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qcolor
SOURCES
tst_qcolor.cpp
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 60a63fadcb..f592db5544 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -73,7 +73,7 @@ private slots:
void toCmykNonDestructive();
void toHsl_data();
- void toHsl();;
+ void toHsl();
void toHslNonDestructive();
void convertTo();
diff --git a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
index a6565b57e7..383c1bb890 100644
--- a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qcolorspace Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolorspace LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc b/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc
new file mode 100644
index 0000000000..b5a73495bf
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/CGATS001Compat-v2-micro.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc b/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc
new file mode 100644
index 0000000000..e0ceaa12f8
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/Rec. ITU-R BT.2100 PQ.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc b/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc
new file mode 100644
index 0000000000..b96eb68136
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/VideoHD.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc b/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc
new file mode 100644
index 0000000000..2187b6786a
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/sGrey-v4.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc b/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc
new file mode 100644
index 0000000000..30da950907
--- /dev/null
+++ b/tests/auto/gui/painting/qcolorspace/resources/sRGB_ICC_v4_Appearance.icc
Binary files differ
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 08f45a2552..6c103ce4f3 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -42,7 +42,12 @@ private slots:
void imageConversionOverLargerGamut();
void imageConversionOverLargerGamut2_data();
void imageConversionOverLargerGamut2();
-
+ void imageConversionOverAnyGamutFP_data();
+ void imageConversionOverAnyGamutFP();
+ void imageConversionOverAnyGamutFP2_data();
+ void imageConversionOverAnyGamutFP2();
+ void imageConversionOverNonThreeComponentMatrix_data();
+ void imageConversionOverNonThreeComponentMatrix();
void loadImage();
void primaries();
@@ -61,6 +66,13 @@ private slots:
void transferFunctionTable();
void description();
+ void whitePoint_data();
+ void whitePoint();
+ void setWhitePoint();
+ void grayColorSpace();
+ void grayColorSpaceEffectivelySRgb();
+
+ void scaleAlphaValue();
};
tst_QColorSpace::tst_QColorSpace()
@@ -111,6 +123,15 @@ void tst_QColorSpace::namedColorSpaces_data()
QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb << true
<< QColorSpace::Primaries::ProPhotoRgb
<< QColorSpace::TransferFunction::ProPhotoRgb;
+ QTest::newRow("BT.2020") << QColorSpace::Bt2020 << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::Bt2020;
+ QTest::newRow("BT.2100 PQ") << QColorSpace::Bt2100Pq << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::St2084;
+ QTest::newRow("BT.2100 HLG") << QColorSpace::Bt2100Hlg << true
+ << QColorSpace::Primaries::Bt2020
+ << QColorSpace::TransferFunction::Hlg;
QTest::newRow("0") << QColorSpace::NamedColorSpace(0)
<< false
<< QColorSpace::Primaries::Custom
@@ -178,15 +199,46 @@ void tst_QColorSpace::fromIccProfile_data()
QTest::addColumn<QString>("testProfile");
QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
QTest::addColumn<QColorSpace::TransferFunction>("transferFunction");
+ QTest::addColumn<QColorSpace::TransformModel>("transformModel");
+ QTest::addColumn<QColorSpace::ColorModel>("colorModel");
QTest::addColumn<QString>("description");
QString prefix = QFINDTESTDATA("resources/");
// Read the official sRGB ICCv2 profile:
QTest::newRow("sRGB2014 (ICCv2)") << prefix + "sRGB2014.icc" << QColorSpace::SRgb
- << QColorSpace::TransferFunction::SRgb << QString("sRGB2014");
+ << QColorSpace::TransferFunction::SRgb
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("sRGB2014");
// My monitor's profile:
QTest::newRow("HP ZR30w (ICCv4)") << prefix + "HP_ZR30w.icc" << QColorSpace::NamedColorSpace(0)
- << QColorSpace::TransferFunction::Gamma << QString("HP Z30i");
+ << QColorSpace::TransferFunction::Gamma
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("HP Z30i");
+ // A profile to HD TV
+ QTest::newRow("VideoHD") << prefix + "VideoHD.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Rgb << QString("HDTV (Rec. 709)");
+ // sRGB on PCSLab format
+ QTest::newRow("sRGB ICCv4 Appearance") << prefix + "sRGB_ICC_v4_Appearance.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Rgb << QString("sRGB_ICC_v4_Appearance.icc");
+ // Grayscale profile
+ QTest::newRow("sGrey-v4") << prefix + "sGrey-v4.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::SRgb
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Gray << QString("sGry");
+ // CMYK profile
+ QTest::newRow("CGATS compat") << prefix + "CGATS001Compat-v2-micro.icc" << QColorSpace::NamedColorSpace(0)
+ << QColorSpace::TransferFunction::Custom
+ << QColorSpace::TransformModel::ElementListProcessing
+ << QColorSpace::ColorModel::Cmyk << QString("uCMY");
+ // BT.2100 PQ profile
+ QTest::newRow("BT.2100 PQ") << prefix + "Rec. ITU-R BT.2100 PQ.icc" << QColorSpace::Bt2100Pq
+ << QColorSpace::TransferFunction::St2084
+ << QColorSpace::TransformModel::ThreeComponentMatrix
+ << QColorSpace::ColorModel::Rgb << QString("Rec. ITU-R BT.2100 PQ");
}
void tst_QColorSpace::fromIccProfile()
@@ -194,10 +246,12 @@ void tst_QColorSpace::fromIccProfile()
QFETCH(QString, testProfile);
QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
QFETCH(QColorSpace::TransferFunction, transferFunction);
+ QFETCH(QColorSpace::TransformModel, transformModel);
+ QFETCH(QColorSpace::ColorModel, colorModel);
QFETCH(QString, description);
QFile file(testProfile);
- file.open(QIODevice::ReadOnly);
+ QVERIFY(file.open(QIODevice::ReadOnly));
QByteArray iccProfile = file.readAll();
QColorSpace fileColorSpace = QColorSpace::fromIccProfile(iccProfile);
QVERIFY(fileColorSpace.isValid());
@@ -206,7 +260,23 @@ void tst_QColorSpace::fromIccProfile()
QCOMPARE(fileColorSpace, namedColorSpace);
QCOMPARE(fileColorSpace.transferFunction(), transferFunction);
+ QCOMPARE(fileColorSpace.transformModel(), transformModel);
+ QCOMPARE(fileColorSpace.colorModel(), colorModel);
QCOMPARE(fileColorSpace.description(), description);
+
+ QByteArray iccProfile2 = fileColorSpace.iccProfile();
+ QCOMPARE(iccProfile, iccProfile2);
+ QColorSpace fileColorSpace2 = QColorSpace::fromIccProfile(iccProfile2);
+ QCOMPARE(fileColorSpace2, fileColorSpace);
+
+ // Change description to force generation of new icc profile data.
+ fileColorSpace2.setDescription("Hello my QTest description");
+ iccProfile2 = fileColorSpace2.iccProfile();
+ QCOMPARE_NE(iccProfile, iccProfile2);
+ fileColorSpace2 = QColorSpace::fromIccProfile(iccProfile2);
+ QVERIFY(fileColorSpace2.isValid());
+ // Note, we do not currently compare description in color space equality
+ QCOMPARE(fileColorSpace2, fileColorSpace);
}
void tst_QColorSpace::imageConversion_data()
@@ -217,9 +287,10 @@ void tst_QColorSpace::imageConversion_data()
QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3 << 0;
QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb << 2;
- QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0;
QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb << 2;
+ QTest::newRow("Adobe RGB -> Display-P3") << QColorSpace::AdobeRgb << QColorSpace::DisplayP3 << 4;
QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb << 2;
+ QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb << 0;
QTest::newRow("sRGB -> sRGB Linear") << QColorSpace::SRgb << QColorSpace::SRgbLinear << 0;
QTest::newRow("sRGB Linear -> sRGB") << QColorSpace::SRgbLinear << QColorSpace::SRgb << 0;
}
@@ -246,9 +317,9 @@ void tst_QColorSpace::imageConversion()
int lastBlue = 0;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qRed(p) >= lastRed);
- QVERIFY(qGreen(p) >= lastGreen);
- QVERIFY(qBlue(p) >= lastBlue);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -261,11 +332,12 @@ void tst_QColorSpace::imageConversion()
QCOMPARE(testImage.colorSpace(), QColorSpace(fromColorSpace));
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qAbs(qRed(p) - qGreen(p)) <= tolerance);
- QVERIFY(qAbs(qRed(p) - qBlue(p)) <= tolerance);
- QVERIFY((lastRed - qRed(p)) <= (tolerance / 2));
- QVERIFY((lastGreen - qGreen(p)) <= (tolerance / 2));
- QVERIFY((lastBlue - qBlue(p)) <= (tolerance / 2));
+ QCOMPARE_LE(qAbs(qRed(p) - qBlue(p)), tolerance);
+ QCOMPARE_LE(qAbs(qRed(p) - qGreen(p)), tolerance);
+ QCOMPARE_LE(qAbs(qGreen(p) - qBlue(p)), tolerance);
+ QCOMPARE_LE(lastRed - qRed(p), tolerance / 2);
+ QCOMPARE_LE(lastBlue - qBlue(p), tolerance / 2);
+ QCOMPARE_LE(lastGreen - qGreen(p), tolerance / 2);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -306,9 +378,9 @@ void tst_QColorSpace::imageConversion64()
int lastBlue = 0;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, 0);
- QVERIFY(qRed(p) >= lastRed);
- QVERIFY(qGreen(p) >= lastGreen);
- QVERIFY(qBlue(p) >= lastBlue);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -323,9 +395,9 @@ void tst_QColorSpace::imageConversion64()
QRgb p = testImage.pixel(i, 0);
QCOMPARE(qRed(p), qGreen(p));
QCOMPARE(qRed(p), qBlue(p));
- QVERIFY((lastRed - qRed(p)) <= 0);
- QVERIFY((lastGreen - qGreen(p)) <= 0);
- QVERIFY((lastBlue - qBlue(p)) <= 0);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -349,8 +421,10 @@ void tst_QColorSpace::imageConversion64PM()
for (int j = 0; j < 16; ++j) {
int a = j * 15;
- for (int i = 0; i < 256; ++i)
- testImage.setPixel(i, j, qPremultiply(qRgba(i, i, i, a)));
+ for (int i = 0; i < 256; ++i) {
+ QRgba64 color = QRgba64::fromRgba(i, i, i, a);
+ testImage.setPixelColor(i, j, QColor::fromRgba64(color));
+ }
}
testImage.setColorSpace(fromColorSpace);
@@ -366,17 +440,17 @@ void tst_QColorSpace::imageConversion64PM()
const int expectedAlpha = j * 15;
for (int i = 0; i < 256; ++i) {
QRgb p = testImage.pixel(i, j);
- QVERIFY(qRed(p) >= lastRed);
- QVERIFY(qGreen(p) >= lastGreen);
- QVERIFY(qBlue(p) >= lastBlue);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
QCOMPARE(qAlpha(p), expectedAlpha);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
}
- QVERIFY(lastRed <= expectedAlpha);
- QVERIFY(lastGreen <= expectedAlpha);
- QVERIFY(lastBlue <= expectedAlpha);
+ QCOMPARE_LE(lastRed, expectedAlpha);
+ QCOMPARE_LE(lastGreen, expectedAlpha);
+ QCOMPARE_LE(lastBlue, expectedAlpha);
lastRed = 0;
lastGreen = 0;
lastBlue = 0;
@@ -389,15 +463,15 @@ void tst_QColorSpace::imageConversion64PM()
for (int i = 0; i < 256; ++i) {
QRgb expected = qPremultiply(qRgba(i, i, i, expectedAlpha));
QRgb p = testImage.pixel(i, j);
- QCOMPARE(qRed(p), qGreen(p));
- QCOMPARE(qRed(p), qBlue(p));
+ QCOMPARE_LE(qAbs(qRed(p) - qGreen(p)), 1);
+ QCOMPARE_LE(qAbs(qRed(p) - qBlue(p)), 1);
QCOMPARE(qAlpha(p), expectedAlpha);
- QVERIFY((lastRed - qRed(p)) <= 0);
- QVERIFY((lastGreen - qGreen(p)) <= 0);
- QVERIFY((lastBlue - qBlue(p)) <= 0);
- QVERIFY(qAbs(qRed(p) - qRed(expected)) <= 1);
- QVERIFY(qAbs(qGreen(p) - qGreen(expected)) <= 1);
- QVERIFY(qAbs(qBlue(p) - qBlue(expected)) <= 1);
+ QCOMPARE_GE(qRed(p), lastRed);
+ QCOMPARE_GE(qGreen(p), lastGreen);
+ QCOMPARE_GE(qBlue(p), lastBlue);
+ QCOMPARE_LE(qAbs(qRed(p) - qRed(expected)), 1);
+ QCOMPARE_LE(qAbs(qGreen(p) - qGreen(expected)), 1);
+ QCOMPARE_LE(qAbs(qBlue(p) - qBlue(expected)), 1);
lastRed = qRed(p);
lastGreen = qGreen(p);
lastBlue = qBlue(p);
@@ -437,14 +511,14 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
testImage.setColorSpace(csfrom);
for (int y = 0; y < 256; ++y)
for (int x = 0; x < 256; ++x)
- testImage.setPixel(x, y, qRgb(x, y, 0));
+ testImage.setPixel(x, y, qRgb(x, y, qAbs(x - y)));
QImage resultImage = testImage.convertedToColorSpace(csto);
for (int y = 0; y < 256; ++y) {
int lastRed = 0;
for (int x = 0; x < 256; ++x) {
QRgb p = resultImage.pixel(x, y);
- QVERIFY(qRed(p) >= lastRed);
+ QCOMPARE_GE(qRed(p), lastRed);
lastRed = qRed(p);
}
}
@@ -452,7 +526,7 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
int lastGreen = 0;
for (int y = 0; y < 256; ++y) {
QRgb p = resultImage.pixel(x, y);
- QVERIFY(qGreen(p) >= lastGreen);
+ QCOMPARE_GE(qGreen(p), lastGreen);
lastGreen = qGreen(p);
}
}
@@ -515,6 +589,138 @@ void tst_QColorSpace::imageConversionOverLargerGamut2()
QVERIFY(resultImage.pixelColor(0, 255).greenF() > 1.0f);
}
+void tst_QColorSpace::imageConversionOverAnyGamutFP_data()
+{
+ QTest::addColumn<QColorSpace::NamedColorSpace>("fromColorSpace");
+ QTest::addColumn<QColorSpace::NamedColorSpace>("toColorSpace");
+
+ QTest::newRow("sRGB -> Display-P3") << QColorSpace::SRgb << QColorSpace::DisplayP3;
+ QTest::newRow("sRGB -> Adobe RGB") << QColorSpace::SRgb << QColorSpace::AdobeRgb;
+ QTest::newRow("sRGB -> ProPhoto RGB") << QColorSpace::SRgb << QColorSpace::ProPhotoRgb;
+ QTest::newRow("Adobe RGB -> sRGB") << QColorSpace::AdobeRgb << QColorSpace::SRgb;
+ QTest::newRow("Adobe RGB -> Display-P3") << QColorSpace::AdobeRgb << QColorSpace::DisplayP3;
+ QTest::newRow("Adobe RGB -> ProPhoto RGB") << QColorSpace::AdobeRgb << QColorSpace::ProPhotoRgb;
+ QTest::newRow("Display-P3 -> sRGB") << QColorSpace::DisplayP3 << QColorSpace::SRgb;
+ QTest::newRow("Display-P3 -> Adobe RGB") << QColorSpace::DisplayP3 << QColorSpace::AdobeRgb;
+ QTest::newRow("Display-P3 -> ProPhoto RGB") << QColorSpace::DisplayP3 << QColorSpace::ProPhotoRgb;
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP()
+{
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
+
+ QColorSpace csfrom(fromColorSpace);
+ QColorSpace csto(toColorSpace);
+ csfrom.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ csto.setTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QImage testImage(256, 256, QImage::Format_RGBX32FPx4);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto);
+ resultImage.convertToColorSpace(csfrom);
+
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ QCOMPARE(resultImage.pixel(x, y), testImage.pixel(x, y));
+ }
+ }
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP2_data()
+{
+ imageConversionOverAnyGamutFP_data();
+}
+
+void tst_QColorSpace::imageConversionOverAnyGamutFP2()
+{
+ QFETCH(QColorSpace::NamedColorSpace, fromColorSpace);
+ QFETCH(QColorSpace::NamedColorSpace, toColorSpace);
+
+ // Same as imageConversionOverAnyGamutFP but using format switching transform
+ QColorSpace csfrom(fromColorSpace);
+ QColorSpace csto(toColorSpace);
+ csfrom.setTransferFunction(QColorSpace::TransferFunction::Linear);
+ csto.setTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QImage testImage(256, 256, QImage::Format_RGB32);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto, QImage::Format_RGBX32FPx4);
+ resultImage.convertToColorSpace(csfrom, QImage::Format_RGB32);
+
+ for (int y = 0; y < 256; ++y) {
+ for (int x = 0; x < 256; ++x) {
+ QCOMPARE(resultImage.pixel(x, y), testImage.pixel(x, y));
+ }
+ }
+}
+
+void tst_QColorSpace::imageConversionOverNonThreeComponentMatrix_data()
+{
+ QTest::addColumn<QColorSpace>("fromColorSpace");
+ QTest::addColumn<QColorSpace>("toColorSpace");
+
+ QString prefix = QFINDTESTDATA("resources/");
+ QFile file1(prefix + "VideoHD.icc");
+ QFile file2(prefix + "sRGB_ICC_v4_Appearance.icc");
+ QVERIFY(file1.open(QFile::ReadOnly));
+ QVERIFY(file2.open(QFile::ReadOnly));
+ QByteArray iccProfile1 = file1.readAll();
+ QByteArray iccProfile2 = file2.readAll();
+ QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccProfile1);
+ QColorSpace srgbPcsColorSpace = QColorSpace::fromIccProfile(iccProfile2);
+
+ QTest::newRow("sRGB PCSLab -> sRGB") << srgbPcsColorSpace << QColorSpace(QColorSpace::SRgb);
+ QTest::newRow("sRGB -> sRGB PCSLab") << QColorSpace(QColorSpace::SRgb) << srgbPcsColorSpace;
+ QTest::newRow("HDTV -> sRGB") << hdtvColorSpace << QColorSpace(QColorSpace::SRgb);
+ QTest::newRow("sRGB -> HDTV") << QColorSpace(QColorSpace::SRgb) << hdtvColorSpace;
+ QTest::newRow("sRGB PCSLab -> HDTV") << srgbPcsColorSpace << hdtvColorSpace;
+ QTest::newRow("HDTV -> sRGB PCSLab") << hdtvColorSpace << srgbPcsColorSpace;
+}
+
+void tst_QColorSpace::imageConversionOverNonThreeComponentMatrix()
+{
+ QFETCH(QColorSpace, fromColorSpace);
+ QFETCH(QColorSpace, toColorSpace);
+ QVERIFY(fromColorSpace.isValid());
+ QVERIFY(toColorSpace.isValidTarget());
+
+ QVERIFY(!fromColorSpace.transformationToColorSpace(toColorSpace).isIdentity());
+
+ QImage testImage(256, 256, QImage::Format_RGBX64);
+ testImage.setColorSpace(fromColorSpace);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgb(x, y, 0));
+
+ QImage resultImage = testImage.convertedToColorSpace(toColorSpace);
+ QCOMPARE(resultImage.size(), testImage.size());
+ for (int y = 0; y < 256; ++y) {
+ int lastRed = 0;
+ for (int x = 0; x < 256; ++x) {
+ QRgb p = resultImage.pixel(x, y);
+ QVERIFY(qRed(p) >= lastRed);
+ lastRed = qRed(p);
+ }
+ }
+ for (int x = 0; x < 256; ++x) {
+ int lastGreen = 0;
+ for (int y = 0; y < 256; ++y) {
+ QRgb p = resultImage.pixel(x, y);
+ QVERIFY(qGreen(p) >= lastGreen);
+ lastGreen = qGreen(p);
+ }
+ }
+}
+
void tst_QColorSpace::loadImage()
{
QString prefix = QFINDTESTDATA("resources/");
@@ -692,10 +898,28 @@ void tst_QColorSpace::changePrimaries()
cs.setPrimaries(QColorSpace::Primaries::DciP3D65);
QVERIFY(cs.isValid());
QCOMPARE(cs, QColorSpace(QColorSpace::DisplayP3));
+ QCOMPARE(cs.transformModel(), QColorSpace::TransformModel::ThreeComponentMatrix);
cs.setTransferFunction(QColorSpace::TransferFunction::Linear);
cs.setPrimaries(QPointF(0.3127, 0.3290), QPointF(0.640, 0.330),
QPointF(0.3000, 0.6000), QPointF(0.150, 0.060));
QCOMPARE(cs, QColorSpace(QColorSpace::SRgbLinear));
+
+
+ QFile iccFile(QFINDTESTDATA("resources/") + "VideoHD.icc");
+ QVERIFY(iccFile.open(QFile::ReadOnly));
+ QByteArray iccData = iccFile.readAll();
+ QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccData);
+ QVERIFY(hdtvColorSpace.isValid());
+ QCOMPARE(hdtvColorSpace.transformModel(), QColorSpace::TransformModel::ElementListProcessing);
+ QCOMPARE(hdtvColorSpace.primaries(), QColorSpace::Primaries::Custom);
+ QCOMPARE(hdtvColorSpace.transferFunction(), QColorSpace::TransferFunction::Custom);
+ // Unsets both primaries and transferfunction because they were inseparable in element list processing
+ hdtvColorSpace.setPrimaries(QColorSpace::Primaries::SRgb);
+ QVERIFY(!hdtvColorSpace.isValid());
+ hdtvColorSpace.setTransferFunction(QColorSpace::TransferFunction::SRgb);
+ QVERIFY(hdtvColorSpace.isValid());
+ QCOMPARE(hdtvColorSpace.transformModel(), QColorSpace::TransformModel::ThreeComponentMatrix);
+ QCOMPARE(hdtvColorSpace, QColorSpace(QColorSpace::SRgb));
}
void tst_QColorSpace::transferFunctionTable()
@@ -744,5 +968,101 @@ void tst_QColorSpace::description()
QCOMPARE(srgb.description(), QLatin1String("Linear sRGB")); // Set to empty returns default behavior
}
+void tst_QColorSpace::whitePoint_data()
+{
+ QTest::addColumn<QColorSpace::NamedColorSpace>("namedColorSpace");
+ QTest::addColumn<QPointF>("whitePoint");
+
+ QTest::newRow("sRGB") << QColorSpace::SRgb << QColorVector::D65Chromaticity();
+ QTest::newRow("Adobe RGB") << QColorSpace::AdobeRgb << QColorVector::D65Chromaticity();
+ QTest::newRow("Display-P3") << QColorSpace::DisplayP3 << QColorVector::D65Chromaticity();
+ QTest::newRow("ProPhoto RGB") << QColorSpace::ProPhotoRgb << QColorVector::D50Chromaticity();
+}
+
+void tst_QColorSpace::whitePoint()
+{
+ QFETCH(QColorSpace::NamedColorSpace, namedColorSpace);
+ QFETCH(QPointF, whitePoint);
+
+ QColorSpace colorSpace(namedColorSpace);
+ QPointF wpt = colorSpace.whitePoint();
+ QCOMPARE_LE(qAbs(wpt.x() - whitePoint.x()), 0.0000001);
+ QCOMPARE_LE(qAbs(wpt.y() - whitePoint.y()), 0.0000001);
+}
+
+void tst_QColorSpace::setWhitePoint()
+{
+ QColorSpace colorSpace(QColorSpace::SRgb);
+ colorSpace.setWhitePoint(QPointF(0.33, 0.33));
+ QCOMPARE_NE(colorSpace, QColorSpace(QColorSpace::SRgb));
+ colorSpace.setWhitePoint(QColorVector::D65Chromaticity());
+ // Check our matrix manipulations returned us to where we came from
+ QCOMPARE(colorSpace, QColorSpace(QColorSpace::SRgb));
+}
+
+void tst_QColorSpace::grayColorSpace()
+{
+ QColorSpace spc;
+ QCOMPARE(spc.colorModel(), QColorSpace::ColorModel::Undefined);
+ QVERIFY(!spc.isValid());
+ spc.setWhitePoint(QColorVector::D65Chromaticity());
+ spc.setTransferFunction(QColorSpace::TransferFunction::SRgb);
+ QVERIFY(spc.isValid());
+ QCOMPARE(spc.colorModel(), QColorSpace::ColorModel::Gray);
+
+ QColorSpace spc2(QColorVector::D65Chromaticity(), QColorSpace::TransferFunction::SRgb);
+ QVERIFY(spc2.isValid());
+ QCOMPARE(spc2.colorModel(), QColorSpace::ColorModel::Gray);
+ QCOMPARE(spc, spc2);
+
+ QImage rgbImage(1, 8, QImage::Format_RGB32);
+ QImage grayImage(1, 255, QImage::Format_Grayscale8);
+ // RGB images can not have gray color space
+ rgbImage.setColorSpace(spc2);
+ grayImage.setColorSpace(spc2);
+ QCOMPARE_NE(rgbImage.colorSpace(), spc2);
+ QCOMPARE(grayImage.colorSpace(), spc2);
+ // But gray images can have RGB color space
+ rgbImage.setColorSpace(QColorSpace::SRgb);
+ grayImage.setColorSpace(QColorSpace::SRgb);
+ QCOMPARE(rgbImage.colorSpace(), QColorSpace(QColorSpace::SRgb));
+ QCOMPARE(grayImage.colorSpace(), QColorSpace(QColorSpace::SRgb));
+
+ // While we can not set a grayscale color space on rgb image, we can convert to one
+ QImage grayImage2 = rgbImage.convertedToColorSpace(spc2);
+ QCOMPARE(grayImage2.colorSpace(), spc2);
+ QCOMPARE(grayImage2.format(), QImage::Format_Grayscale8);
+}
+
+void tst_QColorSpace::grayColorSpaceEffectivelySRgb()
+{
+ // Test grayscale colorspace conversion by making a gray color space that should act like sRGB on gray values.
+ QColorSpace sRgb(QColorSpace::SRgb);
+ QColorSpace sRgbGray(QColorVector::D65Chromaticity(), QColorSpace::TransferFunction::SRgb);
+
+ QImage grayImage1(256, 1, QImage::Format_Grayscale8);
+ QImage grayImage2(256, 1, QImage::Format_Grayscale8);
+ for (int i = 0; i < 256; ++i) {
+ grayImage1.bits()[i] = i;
+ grayImage2.bits()[i] = i;
+ }
+ grayImage1.setColorSpace(sRgb);
+ grayImage2.setColorSpace(sRgbGray);
+
+ QImage rgbImage1 = grayImage1.convertedTo(QImage::Format_RGB32);
+ QImage rgbImage2 = grayImage2.convertedToColorSpace(sRgb, QImage::Format_RGB32);
+
+ QCOMPARE(rgbImage1, rgbImage2);
+}
+
+void tst_QColorSpace::scaleAlphaValue()
+{
+ QImage image(1, 1, QImage::Format_ARGB32);
+ image.setPixel(0, 0, qRgba(255, 255, 255, 125));
+ image.setColorSpace(QColorSpace::SRgb);
+ image.convertToColorSpace(QColorSpace::SRgbLinear, QImage::Format_RGBA64);
+ QCOMPARE(reinterpret_cast<const QRgba64 *>(image.constBits())->alpha(), 257 * 125);
+}
+
QTEST_MAIN(tst_QColorSpace)
#include "tst_qcolorspace.moc"
diff --git a/tests/auto/gui/painting/qcolortransform/CMakeLists.txt b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
index 061902f175..4aa4a8bc4a 100644
--- a/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qcolortransform Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcolortransform LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qcolortransform
SOURCES
tst_qcolortransform.cpp
diff --git a/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
index 06e8db3e71..7a976b5f5e 100644
--- a/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
+++ b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -182,21 +182,21 @@ void tst_QColorTransform::mapRGBAFP16x4()
else
QVERIFY(result != testColor);
- testColor = QRgbaFloat16{0.0f, 0.0f, 0.0f, 1.0f};
+ testColor = QRgbaFloat16{qfloat16(0.0f), qfloat16(0.0f), qfloat16(0.0f), qfloat16(1.0f)};
result = transform.map(testColor);
QCOMPARE(result, testColor);
- testColor = QRgbaFloat16{1.0f, 1.0f, 1.0f, 1.0f};
+ testColor = QRgbaFloat16{qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
result = transform.map(testColor);
QCOMPARE(result, testColor);
- testColor = QRgbaFloat16{1.0f, 1.0f, 0.0f, 1.0f};
+ testColor = QRgbaFloat16{qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
result = transform.map(testColor);
QCOMPARE(result.alpha(), 1.0f);
if (sharesRed)
QCOMPARE(result.red(), 1.0f);
- testColor = QRgbaFloat16{0.0f, 1.0f, 1.0f, 1.0f};
+ testColor = QRgbaFloat16{qfloat16(0.0f), qfloat16(1.0f), qfloat16(1.0f), qfloat16(1.0f)};
result = transform.map(testColor);
// QRgbaFloat16 might overflow blue if we convert to a smaller gamut:
QCOMPARE(result.blue16(), 65535);
diff --git a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
index 129b9a67b8..b19568592b 100644
--- a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpagelayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpagelayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpagelayout
SOURCES
tst_qpagelayout.cpp
diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
index 123663a0e3..4490877e87 100644
--- a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
+++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2014 John Layt <jlayt@kde.org>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/qpagelayout.h>
@@ -12,6 +12,9 @@ private slots:
void invalid();
void basics();
void setGetMargins();
+ void setGetClampedMargins();
+ void setUnits_data();
+ void setUnits();
};
void tst_QPageLayout::invalid()
@@ -88,12 +91,14 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.margins(QPageLayout::Millimeter), QMarginsF(3.53, 3.53, 3.53, 3.53));
QCOMPARE(tenpoint.marginsPoints(), QMargins(10, 10, 10, 10));
QCOMPARE(tenpoint.marginsPixels(72), QMargins(10, 10, 10, 10));
+ QCOMPARE(tenpoint.marginsPixels(600), QMargins(83, 83, 83, 83));
QCOMPARE(tenpoint.minimumMargins(), QMarginsF(0, 0, 0, 0));
QCOMPARE(tenpoint.maximumMargins(), QMarginsF(595, 842, 595, 842));
QCOMPARE(tenpoint.fullRect(), QRectF(0, 0, 595, 842));
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 595, 842));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 4958, 7016));
QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 575, 822));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 202.94, 289.94));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).x(), 3.53);
@@ -106,6 +111,7 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter).bottom(), 293.47);
QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 575, 822));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 575, 822));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(83, 83, 4792, 6850));
// Change orientation
tenpoint.setOrientation(QPageLayout::Landscape);
@@ -117,10 +123,12 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 7016, 4958));
QCOMPARE(tenpoint.paintRect(), QRectF(10, 10, 822, 575));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(3.53, 3.53, 289.94, 202.94));
QCOMPARE(tenpoint.paintRectPoints(), QRect(10, 10, 822, 575));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(10, 10, 822, 575));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(83, 83, 6850, 4792));
// Change mode
QCOMPARE(tenpoint.mode(), QPageLayout::StandardMode);
@@ -134,15 +142,82 @@ void tst_QPageLayout::basics()
QCOMPARE(tenpoint.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.fullRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.fullRectPixels(600), QRect(0, 0, 7016, 4958));
QCOMPARE(tenpoint.paintRect(), QRectF(0, 0, 842, 595));
QCOMPARE(tenpoint.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
QCOMPARE(tenpoint.paintRectPoints(), QRect(0, 0, 842, 595));
QCOMPARE(tenpoint.paintRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(tenpoint.paintRectPixels(600), QRect(0, 0, 7016, 4958));
+
+ // A4, 8.4pt margins
+ QPageLayout fraction = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.isValid(), true);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.margins(QPageLayout::Millimeter), QMarginsF(2.96, 2.96, 2.96, 2.96));
+ QCOMPARE(fraction.marginsPoints(), QMarginsF(8, 8, 8, 8));
+ QCOMPARE(fraction.marginsPixels(72), QMargins(8, 8, 8, 8));
+ QCOMPARE(fraction.marginsPixels(600), QMargins(70, 70, 70, 70));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(595, 842, 595, 842));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 210, 297));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 4958, 7016));
+ QCOMPARE(fraction.paintRect(), QRectF(8.4, 8.4, 578.2, 825.2));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(2.96, 2.96, 204.08, 291.08));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).x(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).y(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).width(), 204.08);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).height(), 291.08);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).left(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).right(), 207.04);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).top(), 2.96);
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter).bottom(), 294.04);
+ QCOMPARE(fraction.paintRectPoints(), QRect(8, 8, 579, 826));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(8, 8, 579, 826));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(70, 70, 4818, 6876));
+
+ // Change orientation
+ fraction.setOrientation(QPageLayout::Landscape);
+ QCOMPARE(fraction.orientation(), QPageLayout::Landscape);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 7016, 4958));
+ QCOMPARE(fraction.paintRect(), QRectF(8.4, 8.4, 825.2, 578.2));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(2.96, 2.96, 291.08, 204.08));
+ QCOMPARE(fraction.paintRectPoints(), QRect(8, 8, 826, 579));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(8, 8, 826, 579));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(70, 70, 6876, 4818));
+
+ // Change mode
+ QCOMPARE(fraction.mode(), QPageLayout::StandardMode);
+ fraction.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(fraction.mode(), QPageLayout::FullPageMode);
+ QCOMPARE(fraction.orientation(), QPageLayout::Landscape);
+ QCOMPARE(fraction.margins(), QMarginsF(8.4, 8.4, 8.4, 8.4));
+ QCOMPARE(fraction.minimumMargins(), QMarginsF(0, 0, 0, 0));
+ QCOMPARE(fraction.maximumMargins(), QMarginsF(842, 595, 842, 595));
+ QCOMPARE(fraction.fullRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.fullRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.fullRectPixels(600), QRect(0, 0, 7016, 4958));
+ QCOMPARE(fraction.paintRect(), QRectF(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRect(QPageLayout::Millimeter), QRectF(0, 0, 297, 210));
+ QCOMPARE(fraction.paintRectPoints(), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRectPixels(72), QRect(0, 0, 842, 595));
+ QCOMPARE(fraction.paintRectPixels(600), QRect(0, 0, 7016, 4958));
}
void tst_QPageLayout::setGetMargins()
{
- // A4, 20pt margins
+ // A4, 10pt margins
QMarginsF margins = QMarginsF(10, 10, 10, 10);
QMarginsF min = QMarginsF(10, 10, 10, 10);
QMarginsF max = QMarginsF(585, 832, 585, 832);
@@ -155,7 +230,7 @@ void tst_QPageLayout::setGetMargins()
QCOMPARE(change.minimumMargins(), min);
QCOMPARE(change.maximumMargins(), max);
- // Set magins within min/max ok
+ // Set margins within min/max ok
margins = QMarginsF(20, 20, 20, 20);
change.setMargins(margins);
QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(7.06, 7.06, 7.06, 7.06));
@@ -215,7 +290,7 @@ void tst_QPageLayout::setGetMargins()
fullPage.setMargins(margins);
QCOMPARE(fullPage.margins(), margins);
- // Set margins all above max is rejected
+ // Set margins all above max is accepted
margins = QMarginsF(1000, 1000, 1000, 1000);
fullPage.setMargins(margins);
QCOMPARE(fullPage.margins(), margins);
@@ -238,6 +313,174 @@ void tst_QPageLayout::setGetMargins()
QCOMPARE(fullPage.maximumMargins(), max);
}
+void tst_QPageLayout::setGetClampedMargins()
+{
+ // A4, 10pt margins
+ QMarginsF margins = QMarginsF(10, 10, 10, 10);
+ QMarginsF min = QMarginsF(10, 10, 10, 10);
+ QMarginsF max = QMarginsF(585, 832, 585, 832);
+ QPageLayout change = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ QCOMPARE(change.isValid(), true);
+
+ // Clamp margins within min/max ok
+ margins = QMarginsF(20, 20, 20, 20);
+ change.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(QPageLayout::Millimeter), QMarginsF(7.06, 7.06, 7.06, 7.06));
+ QCOMPARE(change.marginsPoints(), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.marginsPixels(72), QMargins(20, 20, 20, 20));
+ QCOMPARE(change.margins(), margins);
+
+ // Clamp margins all below min
+ change.setMargins(QMarginsF(0, 0, 0, 0), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), change.minimumMargins());
+
+ // Clamp margins all above max
+ change.setMargins(QMarginsF(1000, 1000, 1000, 1000), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), change.maximumMargins());
+
+ // Only 1 wrong, clamp still works
+ change.setMargins(QMarginsF(50, 50, 50, 0), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins(), QMarginsF(50, 50, 50, change.minimumMargins().bottom()));
+
+ // A4, 20pt margins
+ margins = QMarginsF(20, 20, 20, 20);
+ min = QMarginsF(10, 10, 10, 10);
+ max = QMarginsF(585, 832, 585, 832);
+ QPageLayout fullPage = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ fullPage.setMode(QPageLayout::FullPageMode);
+ QCOMPARE(fullPage.isValid(), true);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+
+ // Clamp margins within min/max ok
+ margins = QMarginsF(50, 50, 50, 50);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Clamp margins all below min, no clamping
+ margins = QMarginsF(0, 0, 0, 0);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Clamp margins all above max, no clamping
+ margins = QMarginsF(1000, 1000, 1000, 1000);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Only 1 wrong, no clamping
+ margins = QMarginsF(50, 50, 50, 0);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+
+ // Set page size, sets min/max, clamps existing margins
+ margins = QMarginsF(20, 500, 20, 500);
+ fullPage.setMargins(margins, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(fullPage.margins(), margins);
+ min = QMarginsF(30, 30, 30, 30);
+ max = QMarginsF(267, 390, 267, 390);
+ fullPage.setPageSize(QPageSize(QPageSize::A6));
+ fullPage.setMinimumMargins(min);
+ QCOMPARE(fullPage.margins(), margins);
+ QCOMPARE(fullPage.minimumMargins(), min);
+ QCOMPARE(fullPage.maximumMargins(), max);
+
+ // Test set* API calls
+ min = QMarginsF(1, 2, 3, 4);
+ max = QMarginsF(595 - min.right(), 842 - min.bottom(), 595 - min.left(), 842 - min.top());
+ change = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, margins, QPageLayout::Point, min);
+ QCOMPARE(change.minimumMargins(), min);
+ QCOMPARE(change.maximumMargins(), max);
+
+ // Test setLeftMargin
+ change.setLeftMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), min.left());
+ change.setLeftMargin(change.fullRectPoints().width(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), max.left());
+ change.setLeftMargin(min.left(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), min.left());
+ change.setLeftMargin(max.left(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().left(), max.left());
+
+ // Test setTopMargin
+ change.setTopMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), min.top());
+ change.setTopMargin(change.fullRectPoints().height(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), max.top());
+ change.setTopMargin(min.top(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), min.top());
+ change.setTopMargin(max.top(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().top(), max.top());
+
+ // Test setRightMargin
+ change.setRightMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), min.right());
+ change.setRightMargin(change.fullRectPoints().width(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), max.right());
+ change.setRightMargin(min.right(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), min.right());
+ change.setRightMargin(max.right(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().right(), max.right());
+
+ // Test setBottomMargin
+ change.setBottomMargin(0, QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), min.bottom());
+ change.setBottomMargin(change.fullRectPoints().height(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), max.bottom());
+ change.setBottomMargin(min.bottom(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), min.bottom());
+ change.setBottomMargin(max.bottom(), QPageLayout::OutOfBoundsPolicy::Clamp);
+ QCOMPARE(change.margins().bottom(), max.bottom());
+}
+
+void tst_QPageLayout::setUnits_data()
+{
+ QTest::addColumn<QPageLayout::Unit>("units");
+ QTest::newRow("Millimeter") << QPageLayout::Millimeter;
+ QTest::newRow("Point") << QPageLayout::Point;
+ QTest::newRow("Inch") << QPageLayout::Inch;
+ QTest::newRow("Pica") << QPageLayout::Pica;
+ QTest::newRow("Didot") << QPageLayout::Didot;
+ QTest::newRow("Cicero") << QPageLayout::Cicero;
+}
+
+void tst_QPageLayout::setUnits()
+{
+ QFETCH(QPageLayout::Unit, units);
+ QPageLayout pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(), units);
+ int maxLeftX100 = qFloor(pageLayout.maximumMargins().left() * 100);
+ QVERIFY(maxLeftX100 > 0);
+ for (int i = 1; i <= maxLeftX100; ++i) {
+ const qreal margin = i / 100.;
+ const QMarginsF unitsMargins = QMarginsF(margin, margin, margin, margin);
+ pageLayout.setMargins(unitsMargins);
+ pageLayout.setUnits(QPageLayout::Point);
+ const QMarginsF pointsMargins = pageLayout.margins();
+ if (units == QPageLayout::Point) {
+ QCOMPARE(pointsMargins, unitsMargins);
+ } else {
+ QCOMPARE_GT(pointsMargins.left(), unitsMargins.left());
+ QCOMPARE_GT(pointsMargins.top(), unitsMargins.top());
+ QCOMPARE_GT(pointsMargins.right(), unitsMargins.right());
+ QCOMPARE_GT(pointsMargins.bottom(), unitsMargins.bottom());
+ }
+ pageLayout.setUnits(units);
+ const QMarginsF convertedUnitsMargins = pageLayout.margins();
+ if (units == QPageLayout::Didot) {
+ // When using Didot units, the small multiplier and ceiling function in conversion
+ // may cause the converted units to not match the original exactly. However, we
+ // can verify that the converted margins are always greater than or equal to the
+ // original.
+ QCOMPARE_GE(convertedUnitsMargins.left(), unitsMargins.left());
+ QCOMPARE_GE(convertedUnitsMargins.top(), unitsMargins.top());
+ QCOMPARE_GE(convertedUnitsMargins.right(), unitsMargins.right());
+ QCOMPARE_GE(convertedUnitsMargins.bottom(), unitsMargins.bottom());
+ } else {
+ QCOMPARE(convertedUnitsMargins, unitsMargins);
+ }
+ }
+}
+
QTEST_APPLESS_MAIN(tst_QPageLayout)
#include "tst_qpagelayout.moc"
diff --git a/tests/auto/gui/painting/qpageranges/CMakeLists.txt b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
index b779b51618..99ab477eae 100644
--- a/tests/auto/gui/painting/qpageranges/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpageranges Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpageranges LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpageranges
SOURCES
tst_qpageranges.cpp
diff --git a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
index 4677399b3f..d2dbf990e3 100644
--- a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
+++ b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qpageranges.h>
diff --git a/tests/auto/gui/painting/qpagesize/CMakeLists.txt b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
index 009272aeff..b16cd2714a 100644
--- a/tests/auto/gui/painting/qpagesize/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpagesize Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpagesize LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpagesize
SOURCES
tst_qpagesize.cpp
diff --git a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
index bac7e9cdf8..de9b799902 100644
--- a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
+++ b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGlobal>
@@ -49,11 +49,13 @@ void tst_QPageSize::basics()
QCOMPARE(a4.size(QPageSize::Pica), QSizeF(49.58, 70.17));
QCOMPARE(a4.sizePoints(), QSize(595, 842));
QCOMPARE(a4.sizePixels(72), QSize(595, 842));
+ QCOMPARE(a4.sizePixels(600), QSize(4958, 7016)); // Rounded down
QCOMPARE(a4.rect(QPageSize::Millimeter), QRectF(0, 0, 210, 297));
QCOMPARE(a4.rect(QPageSize::Inch), QRectF(0, 0, 8.27, 11.69));
QCOMPARE(a4.rect(QPageSize::Pica), QRectF(0, 0, 49.58, 70.17));
QCOMPARE(a4.rectPoints(), QRect(0, 0, 595, 842));
QCOMPARE(a4.rectPixels(72), QRect(0, 0, 595, 842));
+ QCOMPARE(a4.rectPixels(600), QRect(0, 0, 4958, 7016)); // Rounded down
// Simple QPageSize::PaperSizeId later in list
QPageSize folio = QPageSize(QPageSize::Folio);
diff --git a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
index bb34f49bee..4cd0151a01 100644
--- a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpaintengine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpaintengine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpaintengine
SOURCES
tst_qpaintengine.cpp
diff --git a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
index 24e13c2821..02441de54c 100644
--- a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
+++ b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/painting/qpainter/CMakeLists.txt b/tests/auto/gui/painting/qpainter/CMakeLists.txt
index 31a59dedcd..261e1eb2cf 100644
--- a/tests/auto/gui/painting/qpainter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpainter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 92c3ea4a5a..92b28f65bd 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -1,6 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <qpainter.h>
@@ -62,6 +61,7 @@ private slots:
#endif
void drawPixmapFragments();
void drawPixmapNegativeScale();
+ void drawPixmapRounding();
void drawLine_data();
void drawLine();
@@ -170,6 +170,7 @@ private slots:
void radialGradientRgb30();
#endif
+ void radialGradient_QTBUG120332_ubsan();
void fpe_pixmapTransform();
void fpe_zeroLengthLines();
void fpe_divByZero();
@@ -747,6 +748,16 @@ void tst_QPainter::drawPixmapNegativeScale()
QVERIFY(resultImage.pixel(12, 8) == qRgba(0, 0, 0, 255)); // and right strip is now black
}
+void tst_QPainter::drawPixmapRounding()
+{
+ // Just test that we don't assert
+ QBitmap bm(8, 8);
+ QImage out(64, 64, QImage::Format_RGB32);
+ QPainter p(&out);
+ qreal y = 26.499999999999996;
+ p.drawPixmap(QPointF(0, y), bm);
+}
+
void tst_QPainter::drawLine_data()
{
QTest::addColumn<QLine>("line");
@@ -2082,21 +2093,22 @@ void tst_QPainter::clippedLines_data()
QPen pen2(QColor(223, 223, 0, 223));
pen2.setWidth(2);
- QList<QLineF> lines;
- lines << QLineF(15, 15, 65, 65)
- << QLineF(14, 14, 66, 66)
- << QLineF(16, 16, 64, 64)
- << QLineF(65, 65, 15, 15)
- << QLineF(66, 66, 14, 14)
- << QLineF(64, 64, 14, 14)
- << QLineF(15, 50, 15, 64)
- << QLineF(15, 50, 15, 65)
- << QLineF(15, 50, 15, 66)
- << QLineF(15, 50, 64, 50)
- << QLineF(15, 50, 65, 50)
- << QLineF(15, 50, 66, 50);
-
- foreach (QLineF line, lines) {
+ const auto lines = {
+ QLineF(15, 15, 65, 65),
+ QLineF(14, 14, 66, 66),
+ QLineF(16, 16, 64, 64),
+ QLineF(65, 65, 15, 15),
+ QLineF(66, 66, 14, 14),
+ QLineF(64, 64, 14, 14),
+ QLineF(15, 50, 15, 64),
+ QLineF(15, 50, 15, 65),
+ QLineF(15, 50, 15, 66),
+ QLineF(15, 50, 64, 50),
+ QLineF(15, 50, 65, 50),
+ QLineF(15, 50, 66, 50),
+ };
+
+ for (QLineF line : lines) {
const QByteArray desc = "line (" + QByteArray::number(line.x1())
+ ", " + QByteArray::number(line.y1()) + ", "
+ QByteArray::number(line.x2()) + ", " + QByteArray::number(line.y2())
@@ -2497,6 +2509,12 @@ void tst_QPainter::drawhelper_blend_untransformed_data()
setOpacity_data();
}
+static const auto &defaultOpacities()
+{
+ static const std::array opacities = {qreal(0.0), 0.1 , 0.01, 0.4, 0.5, 0.6, 0.9, 1.0};
+ return opacities;
+}
+
void tst_QPainter::drawhelper_blend_untransformed()
{
QFETCH(QImage::Format, destFormat);
@@ -2517,9 +2535,7 @@ void tst_QPainter::drawhelper_blend_untransformed()
p.fillRect(paintRect, srcColor);
p.end();
- QList<qreal> opacities = (QList<qreal>() << 0.0 << 0.1 << 0.01 << 0.4
- << 0.5 << 0.6 << 0.9 << 1.0);
- foreach (qreal opacity, opacities) {
+ for (qreal opacity : defaultOpacities()) {
p.begin(&dest);
p.fillRect(paintRect, destColor);
@@ -2574,9 +2590,7 @@ void tst_QPainter::drawhelper_blend_tiled_untransformed()
const QBrush brush(src);
- QList<qreal> opacities = (QList<qreal>() << 0.0 << 0.1 << 0.01 << 0.4
- << 0.5 << 0.6 << 0.9 << 1.0);
- foreach (qreal opacity, opacities) {
+ for (qreal opacity : defaultOpacities()) {
p.begin(&dest);
p.fillRect(paintRect, destColor);
@@ -2770,7 +2784,7 @@ void tst_QPainter::monoImages()
for (int i = 1; i < QImage::NImageFormats; ++i) {
for (int j = 0; j < numColorPairs; ++j) {
const QImage::Format format = QImage::Format(i);
- if (format == QImage::Format_Indexed8)
+ if (format == QImage::Format_Indexed8 || format == QImage::Format_CMYK8888)
continue;
QImage img(2, 2, format);
@@ -3540,9 +3554,13 @@ void tst_QPainter::drawImage_data()
for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) {
for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) {
- // Indexed8 can't be painted to, and Alpha8 can't hold a color.
- if (dstFormat == QImage::Format_Indexed8 || dstFormat == QImage::Format_Alpha8)
+ // Indexed8 and CMYK8888 can't be painted to, and Alpha8 can't hold a color.
+ if (dstFormat == QImage::Format_Indexed8 ||
+ dstFormat == QImage::Format_CMYK8888 ||
+ dstFormat == QImage::Format_Alpha8) {
continue;
+ }
+
for (int odd_x = 0; odd_x <= 1; ++odd_x) {
for (int odd_width = 0; odd_width <= 1; ++odd_width) {
QTest::addRow("srcFormat %d, dstFormat %d, odd x: %d, odd width: %d",
@@ -3785,10 +3803,10 @@ static QLinearGradient inverseGradient(QLinearGradient g)
{
QLinearGradient g2 = g;
- QGradientStops stops = g.stops();
+ const QGradientStops stops = g.stops();
QGradientStops inverse;
- foreach (QGradientStop stop, stops)
+ for (const QGradientStop &stop : stops)
inverse << QGradientStop(1 - stop.first, stop.second);
g2.setStops(inverse);
@@ -3894,6 +3912,21 @@ void tst_QPainter::gradientPixelFormat()
QCOMPARE(a, b.convertToFormat(QImage::Format_ARGB32_Premultiplied));
}
+void tst_QPainter::radialGradient_QTBUG120332_ubsan()
+{
+ // Check if Radial Gradient will cause division by zero or not when
+ // the center point coincide with the focal point.
+ QImage image(8, 8, QImage::Format_ARGB32_Premultiplied);
+ QPainter painter(&image);
+
+ QPointF center(0.5, 0.5);
+ QPointF focal(0.5, 0.5);
+ QRadialGradient gradient(center, 0.5, focal, 0.5);
+ gradient.setColorAt(0, Qt::blue);
+ gradient.setColorAt(1, Qt::red);
+ painter.fillRect(image.rect(), QBrush(gradient));
+}
+
void tst_QPainter::gradientInterpolation()
{
QImage image(256, 8, QImage::Format_ARGB32_Premultiplied);
@@ -4897,10 +4930,7 @@ void tst_QPainter::QTBUG25153_drawLine()
{
QImage image(2, 2, QImage::Format_RGB32);
- QList<Qt::PenCapStyle> styles;
- styles << Qt::FlatCap << Qt::SquareCap << Qt::RoundCap;
-
- foreach (Qt::PenCapStyle style, styles) {
+ for (Qt::PenCapStyle style : {Qt::FlatCap, Qt::SquareCap, Qt::RoundCap}) {
image.fill(0xffffffff);
QPainter p(&image);
p.setPen(QPen(Qt::black, 0, Qt::SolidLine, style));
diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
index 092986045a..7cb9e74216 100644
--- a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
+++ b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qapplication.h>
diff --git a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
index 7e77c1012f..1da6e25511 100644
--- a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpainterpath Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainterpath LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpainterpath
SOURCES
tst_qpainterpath.cpp
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index 20ee6e07c7..c00dc3a78a 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -81,6 +81,8 @@ private slots:
void intersectionEquality();
void intersectionPointOnEdge();
+
+ void boundsAtStartPoint();
};
void tst_QPainterPath::cleanupTestCase()
@@ -763,6 +765,21 @@ void tst_QPainterPath::testOperatorDatastream()
}
QCOMPARE(other, path);
+
+ // Check reset & detach
+ QPainterPath p3;
+ p3.lineTo(1, 1);
+ QCOMPARE(p3.elementCount(), 2);
+ QPainterPath p4 = p3;
+ QCOMPARE(p4.elementCount(), 2);
+ {
+ QFile data(tempDir.path() + "/data");
+ QVERIFY(data.open(QFile::ReadOnly));
+ QDataStream stream(&data);
+ stream >> p3;
+ }
+ QCOMPARE(p3.elementCount(), path.elementCount());
+ QCOMPARE(p4.elementCount(), 2);
}
void tst_QPainterPath::closing()
@@ -1442,6 +1459,32 @@ void tst_QPainterPath::intersectionPointOnEdge()
QVERIFY(p.intersects(r));
}
+void tst_QPainterPath::boundsAtStartPoint()
+{
+ const QPointF startPoint(10, 10);
+ const QPainterPath constructedPath(startPoint);
+ {
+ const auto boundingRect = constructedPath.boundingRect();
+ const auto topLeft = boundingRect.topLeft();
+ QCOMPARE(topLeft, startPoint);
+ QCOMPARE(topLeft, constructedPath.elementAt(0));
+ QCOMPARE(boundingRect, constructedPath.controlPointRect());
+ }
+
+ QPainterPath defaultPath;
+ defaultPath.moveTo(startPoint);
+ {
+ const auto boundingRect = defaultPath.boundingRect();
+ const auto topLeft = boundingRect.topLeft();
+ QCOMPARE(topLeft, startPoint);
+ QCOMPARE(topLeft, defaultPath.elementAt(0));
+ QCOMPARE(boundingRect, defaultPath.controlPointRect());
+ }
+
+ QCOMPARE(constructedPath.boundingRect(), defaultPath.boundingRect());
+ QCOMPARE(constructedPath.controlPointRect(), defaultPath.controlPointRect());
+}
+
QTEST_APPLESS_MAIN(tst_QPainterPath)
#include "tst_qpainterpath.moc"
diff --git a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
index 7716500534..d30778de3f 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpainterpathstroker Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpainterpathstroker LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpainterpathstroker
SOURCES
tst_qpainterpathstroker.cpp
diff --git a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
index 3a3f8ff89f..ce80019273 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
+++ b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
index 3b2d123382..2cf25cfdf2 100644
--- a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpathclipper LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
if(NOT QT_FEATURE_private_tests)
return()
endif()
diff --git a/tests/auto/gui/painting/qpathclipper/pathcompare.h b/tests/auto/gui/painting/qpathclipper/pathcompare.h
index d1207cfdc0..593176686e 100644
--- a/tests/auto/gui/painting/qpathclipper/pathcompare.h
+++ b/tests/auto/gui/painting/qpathclipper/pathcompare.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PATHCOMPARE_H
#define PATHCOMPARE_H
diff --git a/tests/auto/gui/painting/qpathclipper/paths.cpp b/tests/auto/gui/painting/qpathclipper/paths.cpp
index e6be402df7..7b1486152b 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.cpp
+++ b/tests/auto/gui/painting/qpathclipper/paths.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "paths.h"
QPainterPath Paths::rect()
diff --git a/tests/auto/gui/painting/qpathclipper/paths.h b/tests/auto/gui/painting/qpathclipper/paths.h
index 8c421dec2e..73b41d324a 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.h
+++ b/tests/auto/gui/painting/qpathclipper/paths.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PATHS_H
#define PATHS_H
diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
index 4ecfa24105..c5ef8373fd 100644
--- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
+++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "private/qpathclipper_p.h"
#include "paths.h"
#include "pathcompare.h"
@@ -776,7 +776,7 @@ void tst_QPathClipper::testIntersections7()
void tst_QPathClipper::testIntersections8()
{
QPainterPath path1 = Paths::node() * QTransform().translate(100, 50);
- QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);;
+ QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
@@ -824,7 +824,7 @@ void tst_QPathClipper::testIntersections9()
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
- path1 = QPainterPath();;
+ path1 = QPainterPath();
path2 = QPainterPath();
path1.addRect(QRectF(-1,191, 136, 106));
@@ -832,7 +832,7 @@ void tst_QPathClipper::testIntersections9()
QVERIFY(path1.intersects(path2));
QVERIFY(path2.intersects(path1));
- path1 = QPainterPath();;
+ path1 = QPainterPath();
path2 = QPainterPath();
path1.moveTo(-1 , 143);
diff --git a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
index 059c0f4fc0..3a42d81600 100644
--- a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpdfwriter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpdfwriter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpdfwriter
SOURCES
tst_qpdfwriter.cpp
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index aaa0877625..4d6b1f01b9 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGlobal>
diff --git a/tests/auto/gui/painting/qpen/CMakeLists.txt b/tests/auto/gui/painting/qpen/CMakeLists.txt
index 97aa8c3f80..05fbbfb552 100644
--- a/tests/auto/gui/painting/qpen/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpen/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpen Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpen LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpen
SOURCES
tst_qpen.cpp
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index e13a8e3270..b3ff1c76f9 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/painting/qpolygon/CMakeLists.txt b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
index cae26e0153..42b108efcd 100644
--- a/tests/auto/gui/painting/qpolygon/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qpolygon Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpolygon LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpolygon
SOURCES
tst_qpolygon.cpp
diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
index 512381ab95..cd24135ac6 100644
--- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/painting/qregion/CMakeLists.txt b/tests/auto/gui/painting/qregion/CMakeLists.txt
index 39fe5d5c9f..ba580438cd 100644
--- a/tests/auto/gui/painting/qregion/CMakeLists.txt
+++ b/tests/auto/gui/painting/qregion/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qregion Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qregion LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qregion
SOURCES
tst_qregion.cpp
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 14e210a056..934725844a 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -138,12 +138,15 @@ void tst_QRegion::rects()
QRegion region(rect);
QVERIFY(region.isEmpty());
QCOMPARE(region.begin(), region.end());
+ QVERIFY(region.rects().isEmpty());
}
{
QRect rect(10, -20, 30, 40);
QRegion region(rect);
QCOMPARE(region.end(), region.begin() + 1);
QCOMPARE(*region.begin(), rect);
+ QCOMPARE(region.rects().size(), 1);
+ QCOMPARE(region.rects()[0], rect);
}
{
QRect r(QPoint(10, 10), QPoint(40, 40));
@@ -190,6 +193,7 @@ void tst_QRegion::setRects()
QCOMPARE(region, QRegion());
QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
QRegion region;
@@ -197,12 +201,15 @@ void tst_QRegion::setRects()
region.setRects(&rect, 1);
QCOMPARE(region.begin(), region.end());
QVERIFY(!region.boundingRect().isValid());
+ QVERIFY(region.rects().isEmpty());
}
{
QRegion region;
QRect rect(10, -20, 30, 40);
region.setRects(&rect, 1);
QCOMPARE(region.end(), region.begin() + 1);
+ QCOMPARE(region.rects().size(), 1);
+ QCOMPARE(region.rects()[0], rect);
QCOMPARE(*region.begin(), rect);
}
}
@@ -316,10 +323,12 @@ void tst_QRegion::emptyPolygonRegion()
QRegion r(pa);
QTEST(r.isEmpty(), "isEmpty");
QTEST(int(std::distance(r.begin(), r.end())), "numRects");
- QList<QRect> rects;
- std::copy(r.begin(), r.end(), std::back_inserter(rects));
+ QList<QRect> rects{r.begin(), r.end()};
QTEST(int(rects.size()), "numRects");
QTEST(rects, "rects");
+ const auto span = r.rects();
+ rects.assign(span.begin(), span.end());
+ QTEST(rects, "rects");
}
@@ -862,6 +871,7 @@ void tst_QRegion::isEmpty()
QCOMPARE(region, QRegion());
QCOMPARE(region.rectCount(), 0);
QCOMPARE(region.boundingRect(), QRect());
+ QVERIFY(region.rects().isEmpty());
}
void tst_QRegion::regionFromPath()
@@ -877,6 +887,10 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[0], QRect(0, 0, 10, 10));
QCOMPARE(rgn.begin()[1], QRect(0, 100, 100, 1000));
+ QCOMPARE(rgn.rects().size(), 2);
+ QCOMPARE(rgn.rects()[0], QRect(0, 0, 10, 10));
+ QCOMPARE(rgn.rects()[1], QRect(0, 100, 100, 1000));
+
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 1100));
}
@@ -893,6 +907,12 @@ void tst_QRegion::regionFromPath()
QCOMPARE(rgn.begin()[2], QRect(90, 10, 10, 80));
QCOMPARE(rgn.begin()[3], QRect(0, 90, 100, 10));
+ QCOMPARE(rgn.rects().size(), 4);
+ QCOMPARE(rgn.rects()[0], QRect(0, 0, 100, 10));
+ QCOMPARE(rgn.rects()[1], QRect(0, 10, 10, 80));
+ QCOMPARE(rgn.rects()[2], QRect(90, 10, 10, 80));
+ QCOMPARE(rgn.rects()[3], QRect(0, 90, 100, 10));
+
QCOMPARE(rgn.boundingRect(), QRect(0, 0, 100, 100));
}
}
diff --git a/tests/auto/gui/painting/qtransform/CMakeLists.txt b/tests/auto/gui/painting/qtransform/CMakeLists.txt
index c4549e9807..557e5fa742 100644
--- a/tests/auto/gui/painting/qtransform/CMakeLists.txt
+++ b/tests/auto/gui/painting/qtransform/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtransform Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtransform LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtransform
SOURCES
tst_qtransform.cpp
diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
index ecc8f7e4cc..428174bfc6 100644
--- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
+++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/platform/qx11info/CMakeLists.txt b/tests/auto/gui/platform/qx11info/CMakeLists.txt
index c14630825c..40188f24a0 100644
--- a/tests/auto/gui/platform/qx11info/CMakeLists.txt
+++ b/tests/auto/gui/platform/qx11info/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qx11info LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qx11info
SOURCES
tst_qx11info.cpp
diff --git a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
index 315dc55069..a4effb07cc 100644
--- a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
+++ b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2016 David Faure <david.faure@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
#include <QtTest/QtTest>
diff --git a/tests/auto/gui/qopengl/CMakeLists.txt b/tests/auto/gui/qopengl/CMakeLists.txt
index e9c39fa38d..48e07d2878 100644
--- a/tests/auto/gui/qopengl/CMakeLists.txt
+++ b/tests/auto/gui/qopengl/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qopengl Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qopengl LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qopengl
SOURCES
tst_qopengl.cpp
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 09554a542f..af59f3e31a 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtOpenGL/QOpenGLFramebufferObject>
#include <QtOpenGL/QOpenGLPaintDevice>
diff --git a/tests/auto/gui/qopenglconfig/CMakeLists.txt b/tests/auto/gui/qopenglconfig/CMakeLists.txt
index 9d3f6423b6..ea70afd20a 100644
--- a/tests/auto/gui/qopenglconfig/CMakeLists.txt
+++ b/tests/auto/gui/qopenglconfig/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qopenglconfig Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qopenglconfig LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
list(APPEND test_data "buglist.json")
diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
index 2572c47096..423f9419da 100644
--- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
+++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QScreen>
diff --git a/tests/auto/gui/qvulkan/CMakeLists.txt b/tests/auto/gui/qvulkan/CMakeLists.txt
index bce98888bd..d4e2dd6f87 100644
--- a/tests/auto/gui/qvulkan/CMakeLists.txt
+++ b/tests/auto/gui/qvulkan/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qvulkan Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qvulkan LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qvulkan
SOURCES
tst_qvulkan.cpp
diff --git a/tests/auto/gui/qvulkan/tst_qvulkan.cpp b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
index 0afebfba28..c8f5c27481 100644
--- a/tests/auto/gui/qvulkan/tst_qvulkan.cpp
+++ b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QVulkanInstance>
#include <QtGui/QVulkanFunctions>
@@ -27,10 +27,6 @@ private slots:
void tst_QVulkan::vulkanInstance()
{
-#ifdef Q_OS_ANDROID
- if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
- QSKIP("Fails on Android 12 (QTBUG-111236)");
-#endif
QVulkanInstance inst;
if (!inst.create())
QSKIP("Vulkan init failed; skip");
@@ -67,10 +63,6 @@ void tst_QVulkan::vulkanInstance()
void tst_QVulkan::vulkanCheckSupported()
{
-#ifdef Q_OS_ANDROID
- if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
- QSKIP("Fails on Android 12 (QTBUG-111236)");
-#endif
// Test the early calls to supportedLayers/extensions/apiVersion that need
// the library and some basics, but do not initialize the instance.
QVulkanInstance inst;
@@ -214,10 +206,6 @@ void tst_QVulkan::vulkanPlainWindow()
void tst_QVulkan::vulkanVersionRequest()
{
-#ifdef Q_OS_ANDROID
- if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
- QSKIP("Fails on Android 12 (QTBUG-111236)");
-#endif
QVulkanInstance inst;
if (!inst.create())
QSKIP("Vulkan init failed; skip");
@@ -264,10 +252,6 @@ static void waitForUnexposed(QWindow *w)
void tst_QVulkan::vulkanWindow()
{
-#ifdef Q_OS_ANDROID
- if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
- QSKIP("Fails on Android 12 (QTBUG-111236)");
-#endif
QVulkanInstance inst;
if (!inst.create())
QSKIP("Vulkan init failed; skip");
diff --git a/tests/auto/gui/rhi/qrhi/CMakeLists.txt b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
index 3f5e5ab7c5..3b0d643060 100644
--- a/tests/auto/gui/rhi/qrhi/CMakeLists.txt
+++ b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qrhi Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qrhi LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
file(GLOB_RECURSE qrhi_resource_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
diff --git a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
index 5b07c7bf2b..fe40459719 100644
--- a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
+++ b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
@@ -1,5 +1,5 @@
:: Copyright (C) 2019 The Qt Company Ltd.
-:: SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+:: SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simple.vert.qsb simple.vert
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simple.frag.qsb simple.frag
@@ -26,3 +26,5 @@ qsb --glsl 320es,430 --msl 21 --msltess tessinterfaceblocks.vert -o tessinterfac
qsb --glsl 320es,430 --msl 21 --tess-mode triangles tessinterfaceblocks.tesc -o tessinterfaceblocks.tesc.qsb
qsb --glsl 320es,430 --msl 21 --tess-vertex-count 3 tessinterfaceblocks.tese -o tessinterfaceblocks.tese.qsb
qsb --glsl 320es,430 --msl 21 simpletess.frag -o tessinterfaceblocks.frag.qsb
+qsb --view-count 2 --glsl "300 es,330" --hlsl 61 -c --msl 12 multiview.vert -o multiview.vert.qsb
+qsb --glsl "300 es,330" --hlsl 61 -c --msl 12 multiview.frag -o multiview.frag.qsb
diff --git a/tests/auto/gui/rhi/qrhi/data/multiview.frag b/tests/auto/gui/rhi/qrhi/data/multiview.frag
new file mode 100644
index 0000000000..375587662f
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/multiview.frag
@@ -0,0 +1,10 @@
+#version 440
+
+layout(location = 0) in vec3 v_color;
+
+layout(location = 0) out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(v_color, 1.0);
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/multiview.frag.qsb b/tests/auto/gui/rhi/qrhi/data/multiview.frag.qsb
new file mode 100644
index 0000000000..db8133f12e
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/multiview.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/multiview.vert b/tests/auto/gui/rhi/qrhi/data/multiview.vert
new file mode 100644
index 0000000000..b9c9e5a704
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/multiview.vert
@@ -0,0 +1,18 @@
+#version 440
+#extension GL_EXT_multiview : require
+
+layout(location = 0) in vec4 pos;
+layout(location = 1) in vec3 color;
+
+layout(location = 0) out vec3 v_color;
+
+layout(std140, binding = 0) uniform buf
+{
+ mat4 mvp[2];
+};
+
+void main()
+{
+ v_color = color;
+ gl_Position = mvp[gl_ViewIndex] * pos;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/multiview.vert.qsb b/tests/auto/gui/rhi/qrhi/data/multiview.vert.qsb
new file mode 100644
index 0000000000..cf1f67f58f
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/multiview.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp
index fd6cabebc5..ffa0bc7004 100644
--- a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp
@@ -2,7 +2,7 @@
layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
-layout (binding = 0, std430) buffer toGpu
+layout (binding = 0, std430) readonly buffer toGpu
{
float _float;
vec2 _vec2;
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb
index 77887ed941..b02f541cc5 100644
--- a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 844bd6a521..8929b69cec 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QThread>
@@ -9,14 +9,11 @@
#include <qrgbafloat.h>
#include <qrgba64.h>
-#include <QtGui/private/qrhi_p.h>
-#include <QtGui/private/qrhi_p_p.h>
-#include <QtGui/private/qrhinull_p.h>
+#include <private/qrhi_p.h>
#if QT_CONFIG(opengl)
# include <QOpenGLContext>
# include <QOpenGLFunctions>
-# include <QtGui/private/qrhigles2_p.h>
# include <QtGui/private/qguiapplication_p.h>
# include <qpa/qplatformintegration.h>
# define TST_GL
@@ -25,19 +22,15 @@
#if QT_CONFIG(vulkan)
# include <QVulkanInstance>
# include <QVulkanFunctions>
-# include <QtGui/private/qrhivulkan_p.h>
# define TST_VK
#endif
#ifdef Q_OS_WIN
-#include <QtGui/private/qrhid3d11_p.h>
-#include <QtGui/private/qrhid3d12_p.h>
# define TST_D3D11
# define TST_D3D12
#endif
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
-# include <QtGui/private/qrhimetal_p.h>
+#if QT_CONFIG(metal)
# define TST_MTL
#endif
@@ -78,6 +71,8 @@ private slots:
void resourceUpdateBatchTextureRawDataStride();
void resourceUpdateBatchLotsOfResources_data();
void resourceUpdateBatchLotsOfResources();
+ void resourceUpdateBatchBetweenFrames_data();
+ void resourceUpdateBatchBetweenFrames();
void invalidPipeline_data();
void invalidPipeline();
void srbLayoutCompatibility_data();
@@ -88,6 +83,8 @@ private slots:
void renderPassDescriptorCompatibility();
void renderPassDescriptorClone_data();
void renderPassDescriptorClone();
+ void textureWithSampleCount_data();
+ void textureWithSampleCount();
void renderToTextureSimple_data();
void renderToTextureSimple();
@@ -117,6 +114,8 @@ private slots:
void renderToTextureSrbReuse();
void renderToTextureIndexedDraw_data();
void renderToTextureIndexedDraw();
+ void renderToTextureArrayMultiView_data();
+ void renderToTextureArrayMultiView();
void renderToWindowSimple_data();
void renderToWindowSimple();
void finishWithinSwapchainFrame_data();
@@ -319,8 +318,13 @@ void tst_QRhi::create()
QVERIFY(resUpd);
resUpd->release();
- QVERIFY(!rhi->supportedSampleCounts().isEmpty());
- QVERIFY(rhi->supportedSampleCounts().contains(1));
+ const QVector<int> supportedSampleCounts = rhi->supportedSampleCounts();
+ QVERIFY(!supportedSampleCounts.isEmpty());
+ QVERIFY(supportedSampleCounts.contains(1));
+ for (int i = 1; i < supportedSampleCounts.count(); ++i) {
+ // Verify the list is sorted. Internally the backends rely on this.
+ QVERIFY(supportedSampleCounts[i] > supportedSampleCounts[i - 1]);
+ }
QVERIFY(rhi->ubufAlignment() > 0);
QCOMPARE(rhi->ubufAligned(123), aligned(123, rhi->ubufAlignment()));
@@ -418,7 +422,10 @@ void tst_QRhi::create()
QRhi::OneDimensionalTextureMipmaps,
QRhi::HalfAttributes,
QRhi::RenderToOneDimensionalTexture,
- QRhi::ThreeDimensionalTextureMipmaps
+ QRhi::ThreeDimensionalTextureMipmaps,
+ QRhi::MultiView,
+ QRhi::TextureViewFormat,
+ QRhi::ResolveDepthStencil
};
for (size_t i = 0; i <sizeof(features) / sizeof(QRhi::Feature); ++i)
rhi->isFeatureSupported(features[i]);
@@ -492,6 +499,8 @@ void tst_QRhi::nativeHandles()
case QRhi::Vulkan:
{
const QRhiVulkanNativeHandles *vkHandles = static_cast<const QRhiVulkanNativeHandles *>(rhiHandles);
+ QVERIFY(vkHandles->inst);
+ QCOMPARE(vkHandles->inst, &vulkanInstance);
QVERIFY(vkHandles->physDev);
QVERIFY(vkHandles->dev);
QVERIFY(vkHandles->gfxQueue);
@@ -983,7 +992,7 @@ void tst_QRhi::resourceUpdateBatchBuffer()
batch->updateDynamicBuffer(dynamicBuffer.data(), 10, bufferSize - 10, a.constData());
batch->updateDynamicBuffer(dynamicBuffer.data(), 0, 12, b.constData());
- QRhiBufferReadbackResult readResult;
+ QRhiReadbackResult readResult;
bool readCompleted = false;
readResult.completed = [&readCompleted] { readCompleted = true; };
batch->readBackBuffer(dynamicBuffer.data(), 5, 10, &readResult);
@@ -1010,7 +1019,7 @@ void tst_QRhi::resourceUpdateBatchBuffer()
batch->uploadStaticBuffer(dynamicBuffer.data(), 10, bufferSize - 10, a.constData());
batch->uploadStaticBuffer(dynamicBuffer.data(), 0, 12, b.constData());
- QRhiBufferReadbackResult readResult;
+ QRhiReadbackResult readResult;
bool readCompleted = false;
readResult.completed = [&readCompleted] { readCompleted = true; };
@@ -1532,6 +1541,86 @@ void tst_QRhi::resourceUpdateBatchLotsOfResources()
submitResourceUpdates(rhi.data(), b);
}
+void tst_QRhi::resourceUpdateBatchBetweenFrames_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::resourceUpdateBatchBetweenFrames()
+{
+ QFETCH(QRhi::Implementation, impl);
+ QFETCH(QRhiInitParams *, initParams);
+
+ QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ if (!rhi)
+ QSKIP("QRhi could not be created, skipping testing resource updates");
+
+ QImage image(128, 128, QImage::Format_RGBA8888_Premultiplied);
+ image.fill(Qt::red);
+ static const float bufferData[64] = {};
+
+ QRhiCommandBuffer *cb = nullptr;
+ QRhi::FrameOpResult result = rhi->beginOffscreenFrame(&cb);
+ QVERIFY(result == QRhi::FrameOpSuccess);
+ QVERIFY(cb);
+
+ static const int TEXTURE_COUNT = 123;
+ static const int BUFFER_COUNT = 456;
+
+ QRhiResourceUpdateBatch *u = rhi->nextResourceUpdateBatch();
+ std::vector<std::unique_ptr<QRhiTexture>> textures;
+ std::vector<std::unique_ptr<QRhiBuffer>> buffers;
+
+ for (int i = 0; i < TEXTURE_COUNT; ++i) {
+ std::unique_ptr<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8,
+ image.size(),
+ 1,
+ QRhiTexture::UsedAsTransferSource));
+ QVERIFY(texture->create());
+ u->uploadTexture(texture.get(), image);
+ textures.push_back(std::move(texture));
+ }
+
+ for (int i = 0; i < BUFFER_COUNT; ++i) {
+ std::unique_ptr<QRhiBuffer> buffer(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 256));
+ QVERIFY(buffer->create());
+ u->uploadStaticBuffer(buffer.get(), bufferData);
+ buffers.push_back(std::move(buffer));
+ }
+
+ rhi->endOffscreenFrame();
+ cb = nullptr;
+
+ // 'u' stays valid, commit it in another frame
+
+ result = rhi->beginOffscreenFrame(&cb);
+ QVERIFY(result == QRhi::FrameOpSuccess);
+ QVERIFY(cb);
+
+ cb->resourceUpdate(u); // this should work
+
+ rhi->endOffscreenFrame();
+
+ u = rhi->nextResourceUpdateBatch();
+ QRhiReadbackResult readResult;
+ bool readCompleted = false;
+ readResult.completed = [&readCompleted] { readCompleted = true; };
+ u->readBackTexture(textures[5].get(), &readResult);
+
+ QVERIFY(submitResourceUpdates(rhi.data(), u));
+ QVERIFY(readCompleted);
+ QCOMPARE(readResult.format, QRhiTexture::RGBA8);
+ QCOMPARE(readResult.pixelSize, image.size());
+
+ QImage wrapperImage(reinterpret_cast<const uchar *>(readResult.data.constData()),
+ readResult.pixelSize.width(), readResult.pixelSize.height(),
+ QImage::Format_RGBA8888_Premultiplied);
+ for (int y = 0; y < image.height(); ++y) {
+ for (int x = 0; x < image.width(); ++x)
+ QCOMPARE(wrapperImage.pixel(x, y), qRgba(255, 0, 0, 255));
+ }
+}
+
static QShader loadShader(const char *name)
{
QFile f(QString::fromUtf8(name));
@@ -3618,6 +3707,182 @@ void tst_QRhi::renderToTextureIndexedDraw()
QVERIFY(redCount > blueCount);
}
+void tst_QRhi::renderToTextureArrayMultiView_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::renderToTextureArrayMultiView()
+{
+ QFETCH(QRhi::Implementation, impl);
+ QFETCH(QRhiInitParams *, initParams);
+
+ QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ if (!rhi)
+ QSKIP("QRhi could not be created, skipping testing rendering");
+
+ if (!rhi->isFeatureSupported(QRhi::MultiView))
+ QSKIP("Multiview not supported, skipping testing on this backend");
+
+ if (rhi->backend() == QRhi::Vulkan && rhi->driverInfo().deviceType == QRhiDriverInfo::CpuDevice)
+ QSKIP("lavapipe does not like multiview, skip for now");
+
+ for (int sampleCount : rhi->supportedSampleCounts()) {
+ const QSize outputSize(1920, 1080);
+ QRhiTexture::Flags textureFlags = QRhiTexture::RenderTarget;
+ if (sampleCount <= 1)
+ textureFlags |= QRhiTexture::UsedAsTransferSource;
+ QScopedPointer<QRhiTexture> texture(rhi->newTextureArray(QRhiTexture::RGBA8, 2, outputSize, sampleCount, textureFlags));
+ QVERIFY(texture->create());
+
+ // exercise a depth-stencil buffer as well, not that the triangle needs it; note that this also needs to be a two-layer texture array
+ QScopedPointer<QRhiTexture> ds(rhi->newTextureArray(QRhiTexture::D24S8, 2, outputSize, sampleCount, QRhiTexture::RenderTarget));
+ QVERIFY(ds->create());
+
+ QScopedPointer<QRhiTexture> resolveTexture;
+ if (sampleCount > 1) {
+ resolveTexture.reset(rhi->newTextureArray(QRhiTexture::RGBA8, 2, outputSize, 1, QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource));
+ QVERIFY(resolveTexture->create());
+ }
+
+ QRhiColorAttachment multiViewAtt(texture.get());
+ multiViewAtt.setMultiViewCount(2);
+ if (sampleCount > 1)
+ multiViewAtt.setResolveTexture(resolveTexture.get());
+
+ QRhiTextureRenderTargetDescription rtDesc(multiViewAtt);
+ rtDesc.setDepthTexture(ds.get());
+
+ QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget(rtDesc));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
+ rt->setRenderPassDescriptor(rpDesc.data());
+ QVERIFY(rt->create());
+
+ QRhiCommandBuffer *cb = nullptr;
+ QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess);
+ QVERIFY(cb);
+
+ QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch();
+
+ static float triangleData[] = {
+ 0.0f, 0.5f, 1.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
+ 0.5f, -0.5f, 0.0f, 0.0f, 1.0f
+ };
+
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(triangleData)));
+ QVERIFY(vbuf->create());
+ updates->uploadStaticBuffer(vbuf.data(), triangleData);
+
+ QScopedPointer<QRhiBuffer> ubuf(rhi->newBuffer(QRhiBuffer::Dynamic, QRhiBuffer::UniformBuffer, 128)); // mat4 mvp[2]
+ QVERIFY(ubuf->create());
+
+ QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
+ srb->setBindings({
+ QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage | QRhiShaderResourceBinding::FragmentStage, ubuf.get())
+ });
+ QVERIFY(srb->create());
+
+ QScopedPointer<QRhiGraphicsPipeline> ps(rhi->newGraphicsPipeline());
+ ps->setShaderStages({
+ { QRhiShaderStage::Vertex, loadShader(":/data/multiview.vert.qsb") },
+ { QRhiShaderStage::Fragment, loadShader(":/data/multiview.frag.qsb") }
+ });
+ ps->setMultiViewCount(2); // the view count must be set both on the render target and the pipeline
+ QRhiVertexInputLayout inputLayout;
+ inputLayout.setBindings({
+ { 5 * sizeof(float) }
+ });
+ inputLayout.setAttributes({
+ { 0, 0, QRhiVertexInputAttribute::Float2, 0 },
+ { 0, 1, QRhiVertexInputAttribute::Float3, quint32(2 * sizeof(float)) }
+ });
+ ps->setDepthTest(true);
+ ps->setDepthWrite(true);
+ ps->setSampleCount(sampleCount);
+ ps->setVertexInputLayout(inputLayout);
+ ps->setShaderResourceBindings(srb.get());
+ ps->setRenderPassDescriptor(rpDesc.get());
+ QVERIFY(ps->create());
+
+ QMatrix4x4 mvp = rhi->clipSpaceCorrMatrix();
+ mvp.perspective(45.0f, outputSize.width() / float(outputSize.height()), 0.01f, 1000.0f);
+ mvp.translate(0, 0, -2);
+ mvp.rotate(90, 0, 0, 1); // point left
+ updates->updateDynamicBuffer(ubuf.get(), 0, 64, mvp.constData());
+ mvp.rotate(-180, 0, 0, 1); // point right
+ updates->updateDynamicBuffer(ubuf.get(), 64, 64, mvp.constData());
+
+ cb->beginPass(rt.data(), Qt::black, { 1.0f, 0 }, updates);
+ cb->setGraphicsPipeline(ps.data());
+ cb->setShaderResources();
+ cb->setViewport({ 0, 0, float(outputSize.width()), float(outputSize.height()) });
+ QRhiCommandBuffer::VertexInput vbindings(vbuf.data(), 0);
+ cb->setVertexInput(0, 1, &vbindings);
+ cb->draw(3);
+
+ QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch();
+ QRhiReadbackResult readResult[2];
+ QRhiReadbackDescription readbackDesc;
+ if (sampleCount > 1)
+ readbackDesc.setTexture(resolveTexture.get());
+ else
+ readbackDesc.setTexture(texture.get());
+ readbackDesc.setLayer(0);
+ readbackBatch->readBackTexture(readbackDesc, &readResult[0]);
+ readbackDesc.setLayer(1);
+ readbackBatch->readBackTexture(readbackDesc, &readResult[1]);
+
+ cb->endPass(readbackBatch);
+
+ rhi->endOffscreenFrame();
+
+ if (rhi->backend() == QRhi::Null)
+ QSKIP("No real content with Null backend, skipping multiview content check");
+
+ // both readbacks should be finished now due to using offscreen frames
+
+ QImage image0 = QImage(reinterpret_cast<const uchar *>(readResult[0].data.constData()),
+ readResult[0].pixelSize.width(), readResult[0].pixelSize.height(),
+ QImage::Format_RGBA8888);
+ if (rhi->isYUpInFramebuffer()) // note that we used clipSpaceCorrMatrix
+ image0 = image0.mirrored();
+
+ QImage image1 = QImage(reinterpret_cast<const uchar *>(readResult[1].data.constData()),
+ readResult[1].pixelSize.width(), readResult[1].pixelSize.height(),
+ QImage::Format_RGBA8888);
+ if (rhi->isYUpInFramebuffer())
+ image1 = image1.mirrored();
+
+ QVERIFY(!image0.isNull());
+ QVERIFY(!image1.isNull());
+
+ // image0 should have a triangle rotated so that it points left with the red
+ // tip. image1 should have a triangle rotated so that it points right with
+ // the red tip. Both are centered, so we will check in range 0..width/2 for
+ // image0 and width/2..width-1 for image1 to see if the red-enough pixels
+ // are present.
+
+ int y = image0.height() / 2;
+ int n = 0;
+ for (int x = 0; x < image0.width() / 2; ++x) {
+ QRgb c = image0.pixel(x, y);
+ if (qRed(c) > 250 && qGreen(c) < 10 && qBlue(c) < 10)
+ ++n;
+ }
+ QVERIFY(n >= 10);
+
+ y = image1.height() / 2;
+ n = 0;
+ for (int x = image1.width() / 2; x < image1.width(); ++x) {
+ QRgb c = image1.pixel(x, y);
+ if (qRed(c) > 250 && qGreen(c) < 10 && qBlue(c) < 10)
+ ++n;
+ }
+ QVERIFY(n >= 10);
+ }
+}
+
void tst_QRhi::renderToWindowSimple_data()
{
rhiTestData();
@@ -3872,7 +4137,7 @@ void tst_QRhi::resourceUpdateBatchBufferTextureWithSwapchainFrames()
const char *b = "abcdefghi";
bool readCompleted = false;
- QRhiBufferReadbackResult readResult;
+ QRhiReadbackResult readResult;
readResult.completed = [&readCompleted] { readCompleted = true; };
QRhiReadbackResult texReadResult;
texReadResult.completed = [&readCompleted] { readCompleted = true; };
@@ -4505,6 +4770,59 @@ void tst_QRhi::renderPassDescriptorCompatibility()
} else {
qDebug("Skipping texture format dependent tests");
}
+
+ if (rhi->isFeatureSupported(QRhi::MultiView)) {
+ {
+ QScopedPointer<QRhiTexture> texArr(rhi->newTextureArray(QRhiTexture::RGBA8, 2, QSize(512, 512), 1, QRhiTexture::RenderTarget));
+ QVERIFY(texArr->create());
+ QRhiColorAttachment multiViewAtt(texArr.data());
+ multiViewAtt.setMultiViewCount(2);
+ QRhiTextureRenderTargetDescription rtDesc(multiViewAtt);
+ QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget(rtDesc));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
+ rt->setRenderPassDescriptor(rpDesc.data());
+ QVERIFY(rt->create());
+
+ QScopedPointer<QRhiTextureRenderTarget> rt2(rhi->newTextureRenderTarget(rtDesc));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc2(rt2->newCompatibleRenderPassDescriptor());
+ rt2->setRenderPassDescriptor(rpDesc2.data());
+ QVERIFY(rt2->create());
+
+ QVERIFY(rpDesc->isCompatible(rpDesc2.data()));
+ QVERIFY(rpDesc2->isCompatible(rpDesc.data()));
+ QCOMPARE(rpDesc->serializedFormat(), rpDesc2->serializedFormat());
+
+ QScopedPointer<QRhiRenderPassDescriptor> rpDescClone(rpDesc->newCompatibleRenderPassDescriptor());
+ QVERIFY(rpDesc->isCompatible(rpDescClone.data()));
+ QVERIFY(rpDesc2->isCompatible(rpDescClone.data()));
+ QCOMPARE(rpDesc->serializedFormat(), rpDescClone->serializedFormat());
+
+ // With Vulkan the multiViewCount really matters since it is baked
+ // in to underlying native object (VkRenderPass). Verify that the
+ // compatibility check fails when the view count differs. Other
+ // backends cannot do this test since they will likely report the
+ // rps being compatible regardless.
+ if (impl == QRhi::Vulkan) {
+ QRhiColorAttachment nonMultiViewAtt(texArr.data());
+ QRhiTextureRenderTargetDescription rtDesc3(nonMultiViewAtt);
+ QScopedPointer<QRhiTextureRenderTarget> rt3(rhi->newTextureRenderTarget(rtDesc3));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc3(rt3->newCompatibleRenderPassDescriptor());
+ rt3->setRenderPassDescriptor(rpDesc3.data());
+ QVERIFY(rt3->create());
+
+ QVERIFY(!rpDesc->isCompatible(rpDesc3.data()));
+ QVERIFY(!rpDesc2->isCompatible(rpDesc3.data()));
+ QVERIFY(rpDesc->serializedFormat() != rpDesc3->serializedFormat());
+
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc3Clone(rpDesc3->newCompatibleRenderPassDescriptor());
+ QVERIFY(!rpDesc->isCompatible(rpDesc3Clone.data()));
+ QVERIFY(!rpDesc2->isCompatible(rpDesc3Clone.data()));
+ QVERIFY(rpDesc->serializedFormat() != rpDesc3Clone->serializedFormat());
+ }
+ }
+ } else {
+ qDebug("Skipping multiview dependent tests");
+ }
}
void tst_QRhi::renderPassDescriptorClone_data()
@@ -4622,6 +4940,59 @@ void tst_QRhi::pipelineCache()
}
}
+void tst_QRhi::textureWithSampleCount_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::textureWithSampleCount()
+{
+ QFETCH(QRhi::Implementation, impl);
+ QFETCH(QRhiInitParams *, initParams);
+
+ QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ if (!rhi)
+ QSKIP("QRhi could not be created, skipping testing renderpass descriptors");
+
+ if (!rhi->isFeatureSupported(QRhi::MultisampleTexture))
+ QSKIP("No multisample texture support with this backend, skipping");
+
+ {
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1));
+ QVERIFY(tex->create());
+ }
+
+ // Ensure 0 is accepted the same way as 1.
+ {
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 0));
+ QVERIFY(tex->create());
+ }
+
+ // Note that we intentionally do not pass in RenderTarget in flags. Where
+ // matters for create(), the backend is expected to act as if it was
+ // specified whenever samples > 1. (in practice it does not make sense to not
+ // have the flag for an msaa texture, but we only care about create() here)
+
+ // Pick the commonly supported sample count of 4.
+ {
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 4));
+ QVERIFY(tex->create());
+ }
+
+ // Now a bogus value that is typically in-between the supported values.
+ {
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 3));
+ QVERIFY(tex->create());
+ }
+
+ // Now a bogus value that is out of range.
+ {
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 123));
+ QVERIFY(tex->create());
+ }
+}
+
+
void tst_QRhi::textureImportOpenGL()
{
#ifdef TST_GL
@@ -5450,12 +5821,36 @@ void tst_QRhi::leakedResourceDestroy()
rt->setRenderPassDescriptor(rpDesc.data());
QVERIFY(rt->create());
+ QRhiRenderBuffer *rb = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512));
+ QVERIFY(rb->create());
+
+ QRhiShaderResourceBindings *srb = rhi->newShaderResourceBindings();
+ QVERIFY(srb->create());
+
if (impl == QRhi::Vulkan)
qDebug("Vulkan validation layer warnings may be printed below - this is expected");
+ if (impl == QRhi::D3D12)
+ qDebug("QD3D12CpuDescriptorPool warnings may be printed below - this is expected");
+
+ qDebug("QRhi resource leak check warnings may be printed below - this is expected");
+
+ // make the QRhi go away early
rhi.reset();
- // let the scoped ptr do its job with the resources
+ // see if the internal rhi backpointer got nulled out
+ QVERIFY(buffer->rhi() == nullptr);
+ QVERIFY(texture->rhi() == nullptr);
+ QVERIFY(rt->rhi() == nullptr);
+ QVERIFY(rpDesc->rhi() == nullptr);
+ QVERIFY(rb->rhi() == nullptr);
+ QVERIFY(srb->rhi() == nullptr);
+
+ // test out deleteLater on some of the resources
+ rb->deleteLater();
+ srb->deleteLater();
+
+ // let the scoped ptr do its job with the rest
}
void tst_QRhi::renderToFloatTexture_data()
@@ -5937,7 +6332,7 @@ void tst_QRhi::tessellationInterfaceBlocks()
QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch();
readbackBatch->readBackTexture({ texture.data() }, &readResult);
- QRhiBufferReadbackResult bufferReadResult;
+ QRhiReadbackResult bufferReadResult;
bufferReadResult.completed = []() {};
readbackBatch->readBackBuffer(buffer.data(), 0, 1024, &bufferReadResult);
@@ -6193,7 +6588,7 @@ void tst_QRhi::storageBuffer()
u->uploadStaticBuffer(fromGpuBuffer.data(), 0, blocks["fromGpu"].knownSize, QByteArray(blocks["fromGpu"].knownSize, 0).constData());
QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
- srb->setBindings({QRhiShaderResourceBinding::bufferLoadStore(blocks["toGpu"].binding, QRhiShaderResourceBinding::ComputeStage, toGpuBuffer.data()),
+ srb->setBindings({QRhiShaderResourceBinding::bufferLoad(blocks["toGpu"].binding, QRhiShaderResourceBinding::ComputeStage, toGpuBuffer.data()),
QRhiShaderResourceBinding::bufferLoadStore(blocks["fromGpu"].binding, QRhiShaderResourceBinding::ComputeStage, fromGpuBuffer.data())});
QVERIFY(srb->create());
@@ -6213,7 +6608,7 @@ void tst_QRhi::storageBuffer()
QVERIFY(u);
int readCompletedNotifications = 0;
- QRhiBufferReadbackResult result;
+ QRhiReadbackResult result;
result.completed = [&readCompletedNotifications]() { readCompletedNotifications++; };
u->readBackBuffer(fromGpuBuffer.data(), 0, blocks["fromGpu"].knownSize, &result);
@@ -6338,7 +6733,7 @@ void tst_QRhi::storageBuffer()
u = rhi->nextResourceUpdateBatch();
QVERIFY(u);
int readbackCompleted = 0;
- QRhiBufferReadbackResult result;
+ QRhiReadbackResult result;
result.completed = [&readbackCompleted]() { readbackCompleted++; };
u->readBackBuffer(fromGpuBuffer.data(), 0, fromGpuBuffer->size(), &result);
@@ -6599,9 +6994,9 @@ void tst_QRhi::halfPrecisionAttributes()
// To avoid these errors, we pad the vertices to 8 byte stride.
//
static const qfloat16 vertices[] = {
- -1.0, -1.0, 0.0, 0.0,
- 1.0, -1.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
+ qfloat16(-1.0), qfloat16(-1.0), qfloat16(0.0), qfloat16(0.0),
+ qfloat16(1.0), qfloat16(-1.0), qfloat16(0.0), qfloat16(0.0),
+ qfloat16(0.0), qfloat16(1.0), qfloat16(0.0), qfloat16(0.0),
};
QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertices)));
diff --git a/tests/auto/gui/rhi/qshader/CMakeLists.txt b/tests/auto/gui/rhi/qshader/CMakeLists.txt
index e8a9b830af..09bf0d585d 100644
--- a/tests/auto/gui/rhi/qshader/CMakeLists.txt
+++ b/tests/auto/gui/rhi/qshader/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qshader Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qshader LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
file(GLOB_RECURSE qshader_resource_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
diff --git a/tests/auto/gui/rhi/qshader/tst_qshader.cpp b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
index 425b5951d0..9e179c95c3 100644
--- a/tests/auto/gui/rhi/qshader/tst_qshader.cpp
+++ b/tests/auto/gui/rhi/qshader/tst_qshader.cpp
@@ -1,12 +1,12 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QFile>
#include <QBuffer>
-#include <QtGui/private/qshaderdescription_p_p.h>
-#include <QtGui/private/qshader_p_p.h>
+#include <private/qshaderdescription_p.h>
+#include <private/qshader_p.h>
class tst_QShader : public QObject
{
diff --git a/tests/auto/gui/text/CMakeLists.txt b/tests/auto/gui/text/CMakeLists.txt
index 2ba0a96774..30b35fb10a 100644
--- a/tests/auto/gui/text/CMakeLists.txt
+++ b/tests/auto/gui/text/CMakeLists.txt
@@ -11,7 +11,9 @@ add_subdirectory(qstatictext)
add_subdirectory(qsyntaxhighlighter)
add_subdirectory(qtextblock)
add_subdirectory(qtextcursor)
-add_subdirectory(qtextdocumentfragment)
+if(QT_FEATURE_texthtmlparser)
+ add_subdirectory(qtextdocumentfragment)
+endif()
add_subdirectory(qtextdocumentlayout)
add_subdirectory(qtextformat)
add_subdirectory(qtextimagehandler)
@@ -26,7 +28,6 @@ endif()
if(QT_FEATURE_private_tests)
add_subdirectory(qfontcache)
add_subdirectory(qtextlayout)
- add_subdirectory(qzip)
add_subdirectory(qtextodfwriter)
endif()
if(TARGET Qt::Xml)
diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt b/tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt
index 247326253a..316b9cd3c6 100644
--- a/tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt
+++ b/tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qabstracttextdocumentlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qabstracttextdocumentlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qabstracttextdocumentlayout
SOURCES
tst_qabstracttextdocumentlayout.cpp
diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
index 037964f42b..3d0fab4603 100644
--- a/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
+++ b/tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -22,9 +22,11 @@ public:
private slots:
void getSetCheck();
void maximumBlockCount();
+#ifndef QT_NO_TEXTHTMLPARSER
void anchorAt();
void imageAt();
void formatAt();
+#endif
};
tst_QAbstractTextDocumentLayout::tst_QAbstractTextDocumentLayout()
@@ -119,6 +121,7 @@ void tst_QAbstractTextDocumentLayout::maximumBlockCount()
QCOMPARE(layout.blockCount, 10);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QAbstractTextDocumentLayout::anchorAt()
{
QTextDocument doc;
@@ -204,6 +207,7 @@ void tst_QAbstractTextDocumentLayout::formatAt()
QVERIFY(!format.toCharFormat().fontItalic());
QVERIFY(!format.isImageFormat());
}
+#endif
QTEST_MAIN(tst_QAbstractTextDocumentLayout)
#include "tst_qabstracttextdocumentlayout.moc"
diff --git a/tests/auto/gui/text/qcssparser/CMakeLists.txt b/tests/auto/gui/text/qcssparser/CMakeLists.txt
index 4f9401d8db..e766ec5484 100644
--- a/tests/auto/gui/text/qcssparser/CMakeLists.txt
+++ b/tests/auto/gui/text/qcssparser/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qcssparser Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcssparser LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index 5ca983450a..203fe003a0 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -1,5 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
#include <QTest>
#include <QtXml/QtXml>
#include <QtGui/QFontInfo>
@@ -55,6 +56,10 @@ private slots:
void quotedAndUnquotedIdentifiers();
void whitespaceValues_data();
void whitespaceValues();
+ void strokeLineCapValues_data();
+ void strokeLineCapValues();
+ void strokeLineJoinValues_data();
+ void strokeLineJoinValues();
};
void tst_QCssParser::scanner_data()
@@ -69,7 +74,8 @@ void tst_QCssParser::scanner_data()
#endif
d.cd("testdata");
d.cd("scanner");
- foreach (QFileInfo test, d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+ const auto entries = d.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (const QFileInfo &test : entries) {
QString dir = test.absoluteFilePath() + QDir::separator();
QTest::newRow(qPrintable(test.baseName()))
<< dir + "input"
@@ -1543,20 +1549,26 @@ void tst_QCssParser::gradient()
QList<QCss::StyleRule> rules = testSelector.styleRulesForNode(n);
QList<QCss::Declaration> decls = rules.at(0).declarations;
QCss::ValueExtractor ve(decls);
- QBrush fg, sfg, pfg;
- QBrush sbg, abg;
- QVERIFY(ve.extractPalette(&fg, &sfg, &sbg, &abg, &pfg));
+ QBrush foreground;
+ QBrush selectedForeground;
+ QBrush selectedBackground;
+ QBrush alternateBackground;
+ QBrush placeHolderTextForeground;
+ QBrush accent;
+ QVERIFY(ve.extractPalette(&foreground, &selectedForeground, &selectedBackground,
+ &alternateBackground, &placeHolderTextForeground, &accent));
+
if (type == "linear") {
- QCOMPARE(sbg.style(), Qt::LinearGradientPattern);
- const QLinearGradient *lg = static_cast<const QLinearGradient *>(sbg.gradient());
+ QCOMPARE(selectedBackground.style(), Qt::LinearGradientPattern);
+ const auto *lg = static_cast<const QLinearGradient *>(selectedBackground.gradient());
QCOMPARE(lg->start(), start);
QCOMPARE(lg->finalStop(), finalStop);
} else if (type == "conical") {
- QCOMPARE(sbg.style(), Qt::ConicalGradientPattern);
- const QConicalGradient *cg = static_cast<const QConicalGradient *>(sbg.gradient());
+ QCOMPARE(selectedBackground.style(), Qt::ConicalGradientPattern);
+ const auto *cg = static_cast<const QConicalGradient *>(selectedBackground.gradient());
QCOMPARE(cg->center(), start);
}
- const QGradient *g = sbg.gradient();
+ const QGradient *g = selectedBackground.gradient();
QCOMPARE(g->spread(), QGradient::Spread(spread));
QCOMPARE(g->stops().at(0).first, stop0);
QCOMPARE(g->stops().at(0).second, color0);
@@ -1751,6 +1763,57 @@ void tst_QCssParser::whitespaceValues()
QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
}
+void tst_QCssParser::strokeLineCapValues_data()
+{
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("flatcap") << "flatcap";
+ QTest::newRow("roundcap") << "roundcap";
+ QTest::newRow("squarecap") << "squarecap";
+}
+
+void tst_QCssParser::strokeLineCapValues()
+{
+ QFETCH(QString, value);
+ QCss::Parser parser(QString("foo { -qt-stroke-linecap: %1 }").arg(value));
+ QCss::StyleSheet sheet;
+ QVERIFY(parser.parse(&sheet));
+
+ QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
+ sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+ QCOMPARE(rule.declarations.size(), 1);
+
+ QCOMPARE(rule.declarations.at(0).d->property, QLatin1String("-qt-stroke-linecap"));
+ QCOMPARE(rule.declarations.at(0).d->values.first().type, QCss::Value::KnownIdentifier);
+ QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
+}
+
+void tst_QCssParser::strokeLineJoinValues_data()
+{
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("beveljoin") << "beveljoin";
+ QTest::newRow("miterjoin") << "miterjoin";
+ QTest::newRow("roundjoin") << "roundjoin";
+ QTest::newRow("svgmiterjoin") << "svgmiterjoin";
+}
+
+void tst_QCssParser::strokeLineJoinValues()
+{
+ QFETCH(QString, value);
+ QCss::Parser parser(QString("foo { -qt-stroke-linejoin: %1 }").arg(value));
+ QCss::StyleSheet sheet;
+ QVERIFY(parser.parse(&sheet));
+
+ QCss::StyleRule rule = (!sheet.styleRules.isEmpty()) ?
+ sheet.styleRules.at(0) : *sheet.nameIndex.begin();
+ QCOMPARE(rule.declarations.size(), 1);
+
+ QCOMPARE(rule.declarations.at(0).d->property, QLatin1String("-qt-stroke-linejoin"));
+ QCOMPARE(rule.declarations.at(0).d->values.first().type, QCss::Value::KnownIdentifier);
+ QCOMPARE(rule.declarations.at(0).d->values.first().toString(), value);
+}
+
QTEST_MAIN(tst_QCssParser)
#include "tst_qcssparser.moc"
diff --git a/tests/auto/gui/text/qfont/CMakeLists.txt b/tests/auto/gui/text/qfont/CMakeLists.txt
index c51df322f9..88ae9959e4 100644
--- a/tests/auto/gui/text/qfont/CMakeLists.txt
+++ b/tests/auto/gui/text/qfont/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfont Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfont LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set(testfont_resource_files
"datastream.515"
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index 76d844b007..5426d7b117 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include <QTest>
#include <QBuffer>
@@ -19,6 +21,9 @@
#endif
#include <qlist.h>
#include <QtTest/private/qemulationdetector_p.h>
+#include <private/qcomparisontesthelper_p.h>
+
+using namespace Qt::StringLiterals;
class tst_QFont : public QObject
{
@@ -54,6 +59,9 @@ private slots:
void setFamilies();
void setFamiliesAndFamily_data();
void setFamiliesAndFamily();
+ void featureAccessors();
+ void tagCompares_data();
+ void tagCompares();
};
// Testing get/set functions
@@ -150,7 +158,7 @@ void tst_QFont::italicOblique()
continue;
}
QFont f = QFontDatabase::font(family, style, 12);
- QVERIFY(f.italic());
+ QVERIFY2(f.italic(), qPrintable(QString::asprintf("Failed for font \"%ls\"", qUtf16Printable(f.family()))));
}
}
}
@@ -841,5 +849,83 @@ void tst_QFont::setFamiliesAndFamily()
QFontDatabase::removeApplicationFont(weirdFontId);
}
+void tst_QFont::featureAccessors()
+{
+ const QFont::Tag abcdTag("abcd");
+ QCOMPARE(abcdTag.toString(), "abcd");
+ QVERIFY(abcdTag.isValid());
+
+ QFont font;
+ QVERIFY(font.featureTags().isEmpty());
+ font.setFeature("abcd", 0xc0ffee);
+
+ QVERIFY(font.isFeatureSet(abcdTag));
+ QVERIFY(!font.isFeatureSet("bcde"));
+ QCOMPARE(font.featureTags().size(), 1);
+ QCOMPARE(font.featureTags().first(), abcdTag);
+ QCOMPARE(font.featureTags().first(), "abcd");
+ QCOMPARE(font.featureValue(abcdTag), 0xc0ffeeU);
+ QCOMPARE(font.featureValue("bcde"), 0U);
+ font.setFeature(abcdTag, 0xf00d);
+ QCOMPARE(font.featureTags().size(), 1);
+ QCOMPARE(font.featureValue(abcdTag), 0xf00dU);
+
+ QFont::Tag invalidTag;
+ QVERIFY(!invalidTag.isValid());
+ font.setFeature(invalidTag, 0xcaca0);
+ QVERIFY(!font.isFeatureSet(invalidTag));
+ QCOMPARE(font.featureTags().size(), 1);
+ QFont font2 = font;
+
+ font.unsetFeature("abcd");
+ QVERIFY(!font.isFeatureSet("abcd"));
+ QVERIFY(font.featureTags().isEmpty());
+
+ QVERIFY(font2.isFeatureSet("abcd"));
+ font2.clearFeatures();
+ QVERIFY(font.featureTags().isEmpty());
+
+ // various constructor compile tests
+ QFont::Tag tag;
+ tag = QFont::Tag("1234");
+ QVERIFY(QFont::Tag::fromString(QByteArray("abcd")));
+ QVERIFY(QFont::Tag::fromString(u"frac"_s));
+
+ // named constructors with invalid input
+ QTest::ignoreMessage(QtWarningMsg, "The tag name must be exactly 4 characters long!");
+ QVERIFY(!QFont::Tag::fromString(u"fraction"_s));
+ QVERIFY(!QFont::Tag::fromValue(0));
+ QVERIFY(QFont::Tag::fromValue(abcdTag.value()));
+
+ enum Features {
+ Frac = QFont::Tag("frac").value()
+ };
+}
+
+void tst_QFont::tagCompares_data()
+{
+ QTestPrivate::testAllComparisonOperatorsCompile<QFont::Tag>();
+
+ QTest::addColumn<QFont::Tag>("lhs");
+ QTest::addColumn<QFont::Tag>("rhs");
+ QTest::addColumn<Qt::strong_ordering>("expectedOrder");
+
+ auto row = [](QFont::Tag left, QFont::Tag right) {
+ QTest::addRow("%s<=>%s", left.toString().constData(), right.toString().constData())
+ << left << right << Qt::compareThreeWay(left.value(), right.value());
+ };
+ row("frac", "wght");
+}
+
+void tst_QFont::tagCompares()
+{
+ QFETCH(QFont::Tag, lhs);
+ QFETCH(QFont::Tag, rhs);
+ QFETCH(Qt::strong_ordering, expectedOrder);
+
+ QVERIFY(comparesEqual(lhs, lhs));
+ QCOMPARE(compareThreeWay(lhs, rhs), expectedOrder);
+}
+
QTEST_MAIN(tst_QFont)
#include "tst_qfont.moc"
diff --git a/tests/auto/gui/text/qfontcache/CMakeLists.txt b/tests/auto/gui/text/qfontcache/CMakeLists.txt
index a95128caba..d9645c115a 100644
--- a/tests/auto/gui/text/qfontcache/CMakeLists.txt
+++ b/tests/auto/gui/text/qfontcache/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfontcache Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfontcache LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qfontcache
SOURCES
tst_qfontcache.cpp
diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp
index 7d30baf876..79f24a2f0d 100644
--- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp
+++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/text/qfontdatabase/CMakeLists.txt b/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
index b1eaf8e3df..0cb6e8d7c8 100644
--- a/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
+++ b/tests/auto/gui/text/qfontdatabase/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfontdatabase Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfontdatabase LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
list(APPEND test_data "LED_REAL.TTF")
@@ -31,12 +37,18 @@ set_source_files_properties("../../../shared/resources/testfont_italic.ttf"
set_source_files_properties("../../../shared/resources/testfont_open.otf"
PROPERTIES QT_RESOURCE_ALIAS "testfont_open.otf"
)
+set_source_files_properties("../../../shared/resources/testfont_variable.ttf"
+ PROPERTIES QT_RESOURCE_ALIAS "testfont_variable.ttf"
+)
set(testdata_resource_files
"../../../shared/resources/testfont.ttf"
"../../../shared/resources/testfont_condensed.ttf"
"../../../shared/resources/testfont_italic.ttf"
"../../../shared/resources/testfont_open.otf"
+ "../../../shared/resources/testfont_variable.ttf"
"LED_REAL.TTF"
+ "QtTestLimitedFont-Regular.ttf"
+ "QtTestFallbackFont-Regular.ttf"
)
qt_internal_add_resource(tst_qfontdatabase "testdata"
diff --git a/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf b/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf
new file mode 100644
index 0000000000..ae21fec9a5
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/QtTestFallbackFont-Regular.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf b/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf
new file mode 100644
index 0000000000..2891f8aeff
--- /dev/null
+++ b/tests/auto/gui/text/qfontdatabase/QtTestLimitedFont-Regular.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 665ee75a35..8733f64d97 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QSignalSpy>
@@ -12,6 +12,9 @@
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
#include <qpa/qplatformfontdatabase.h>
+#include <qpa/qplatformintegration.h>
+
+#include <QtGui/private/qguiapplication_p.h>
using namespace Qt::StringLiterals;
@@ -61,15 +64,22 @@ private slots:
void stretchRespected();
+ void variableFont();
+
#ifdef Q_OS_WIN
void findCourier();
#endif
+ void addApplicationFontFallback();
+
private:
QString m_ledFont;
QString m_testFont;
QString m_testFontCondensed;
QString m_testFontItalic;
+ QString m_testFontVariable;
+ QString m_limitedFont;
+ QString m_fallbackFont;
};
tst_QFontDatabase::tst_QFontDatabase()
@@ -82,10 +92,16 @@ void tst_QFontDatabase::initTestCase()
m_testFont = QFINDTESTDATA("testfont.ttf");
m_testFontCondensed = QFINDTESTDATA("testfont_condensed.ttf");
m_testFontItalic = QFINDTESTDATA("testfont_italic.ttf");
+ m_testFontVariable = QFINDTESTDATA("testfont_variable.ttf");
+ m_limitedFont = QFINDTESTDATA("QtTestLimitedFont-Regular.ttf");
+ m_fallbackFont = QFINDTESTDATA("QtTestFallbackFont-Regular.ttf");
QVERIFY(!m_ledFont.isEmpty());
QVERIFY(!m_testFont.isEmpty());
QVERIFY(!m_testFontCondensed.isEmpty());
QVERIFY(!m_testFontItalic.isEmpty());
+ QVERIFY(!m_testFontVariable.isEmpty());
+ QVERIFY(!m_limitedFont.isEmpty());
+ QVERIFY(!m_fallbackFont.isEmpty());
}
void tst_QFontDatabase::styles_data()
@@ -223,7 +239,7 @@ void tst_QFontDatabase::addAppFont()
int id;
if (useMemoryFont) {
QFile fontfile(m_ledFont);
- fontfile.open(QIODevice::ReadOnly);
+ QVERIFY(fontfile.open(QIODevice::ReadOnly));
QByteArray fontdata = fontfile.readAll();
QVERIFY(!fontdata.isEmpty());
id = QFontDatabase::addApplicationFontFromData(fontdata);
@@ -319,8 +335,8 @@ void tst_QFontDatabase::fallbackFonts()
layout.createLine();
layout.endLayout();
- QList<QGlyphRun> runs = layout.glyphRuns(0, 1);
- foreach (QGlyphRun run, runs) {
+ const QList<QGlyphRun> runs = layout.glyphRuns(0, 1);
+ for (QGlyphRun run : runs) {
QRawFont rawFont = run.rawFont();
QVERIFY(rawFont.isValid());
@@ -381,8 +397,14 @@ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
void tst_QFontDatabase::condensedFontWidth()
{
- QFontDatabase::addApplicationFont(m_testFont);
- QFontDatabase::addApplicationFont(m_testFontCondensed);
+ int testFontId = QFontDatabase::addApplicationFont(m_testFont);
+ int testFontCondensedId = QFontDatabase::addApplicationFont(m_testFontCondensed);
+ auto cleanup = qScopeGuard([&testFontId, &testFontCondensedId] {
+ if (testFontId >= 0)
+ QFontDatabase::removeApplicationFont(testFontId);
+ if (testFontCondensedId >= 0)
+ QFontDatabase::removeApplicationFont(testFontCondensedId);
+ });
QVERIFY(QFontDatabase::hasFamily("QtBidiTestFont"));
if (!QFontDatabase::hasFamily("QtBidiTestFontCondensed"))
@@ -400,10 +422,16 @@ void tst_QFontDatabase::condensedFontWidth()
void tst_QFontDatabase::condensedFontMatching()
{
QFontDatabase::removeAllApplicationFonts();
- QFontDatabase::addApplicationFont(m_testFontCondensed);
+ int testFontCondensedId = QFontDatabase::addApplicationFont(m_testFontCondensed);
if (!QFontDatabase::hasFamily("QtBidiTestFont"))
QSKIP("This platform doesn't support preferred font family names (QTBUG-53478)");
- QFontDatabase::addApplicationFont(m_testFont);
+ int testFontId = QFontDatabase::addApplicationFont(m_testFont);
+ auto cleanup = qScopeGuard([&testFontId, &testFontCondensedId] {
+ if (testFontId >= 0)
+ QFontDatabase::removeApplicationFont(testFontId);
+ if (testFontCondensedId >= 0)
+ QFontDatabase::removeApplicationFont(testFontCondensedId);
+ });
// Test we correctly get the condensed font using different font matching methods:
QFont tfcByStretch("QtBidiTestFont");
@@ -415,8 +443,10 @@ void tst_QFontDatabase::condensedFontMatching()
QFont f;
f.setStyleStrategy(QFont::NoFontMerging);
QFontPrivate *font_d = QFontPrivate::get(f);
- if (font_d->engineForScript(QChar::Script_Common)->type() != QFontEngine::Freetype)
+ if (font_d->engineForScript(QChar::Script_Common)->type() != QFontEngine::Freetype
+ && font_d->engineForScript(QChar::Script_Common)->type() != QFontEngine::DirectWrite) {
QEXPECT_FAIL("","No matching of sub-family by stretch on Windows", Continue);
+ }
#endif
QCOMPARE(QFontMetrics(tfcByStretch).horizontalAdvance(testString()),
@@ -505,5 +535,230 @@ void tst_QFontDatabase::findCourier()
}
#endif
+void tst_QFontDatabase::variableFont()
+{
+ {
+ QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
+ if (!pfdb->supportsVariableApplicationFonts())
+ QSKIP("Variable application fonts not supported on this platform");
+ }
+
+ int id = QFontDatabase::addApplicationFont(m_testFontVariable);
+ if (id == -1)
+ QSKIP("Skip the test since app fonts are not supported on this system");
+
+ QString family = QFontDatabase::applicationFontFamilies(id).first();
+ {
+ QFont font(family);
+ QCOMPARE(QFontInfo(font).styleName(), u"Regular"_s);
+ QCOMPARE(QFontInfo(font).weight(), QFont::Normal);
+ }
+
+ {
+ QFont font(family);
+ font.setWeight(QFont::Black);
+ QCOMPARE(QFontInfo(font).styleName(), u"QtExtraBold"_s);
+ QCOMPARE(QFontInfo(font).weight(), int(QFont::Black));
+ }
+
+ {
+ QFont regularFont(family);
+ QFont extraBoldFont(family);
+ extraBoldFont.setStyleName(u"QtExtraBold"_s);
+
+ QFontMetricsF regularFm(regularFont);
+ QFontMetricsF extraBoldFm(extraBoldFont);
+
+ QVERIFY(regularFm.horizontalAdvance(QLatin1Char('1')) < extraBoldFm.horizontalAdvance(QLatin1Char('1')));
+ }
+
+ QFontDatabase::removeApplicationFont(id);
+}
+
+void tst_QFontDatabase::addApplicationFontFallback()
+{
+ int ledId = -1;
+ int id = -1;
+ int limitedId = -1;
+ int fallbackId = -1;
+ auto cleanup = qScopeGuard([&id, &ledId, &limitedId, &fallbackId] {
+ if (id >= 0)
+ QFontDatabase::removeApplicationFont(id);
+ if (ledId >= 0)
+ QFontDatabase::removeApplicationFont(ledId);
+ if (limitedId >= 0)
+ QFontDatabase::removeApplicationFont(limitedId);
+ if (fallbackId >= 0)
+ QFontDatabase::removeApplicationFont(fallbackId);
+ });
+
+ const QChar hebrewChar(0x05D0); // Hebrew 'aleph'
+
+ ledId = QFontDatabase::addApplicationFont(m_ledFont);
+ if (ledId < 0)
+ QSKIP("Skip the test since app fonts are not supported on this system");
+
+ auto getHebrewFont = [&]() {
+ QTextLayout layout;
+ layout.setText(hebrewChar);
+ layout.setFont(QFont(u"LED Real"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ if (glyphRuns.isEmpty())
+ return QString{};
+
+ return glyphRuns.first().rawFont().familyName();
+ };
+
+ QString defaultHebrewFont = getHebrewFont();
+ if (defaultHebrewFont.isEmpty())
+ QSKIP("Skip the test since Hebrew is not supported on this system");
+
+ QVERIFY(QFontDatabase::applicationFallbackFontFamilies(QChar::Script_Hebrew).isEmpty());
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Hebrew, u"QtBidiTestFont"_s);
+
+ QCOMPARE(QFontDatabase::applicationFallbackFontFamilies(QChar::Script_Hebrew).size(), 1);
+ QCOMPARE(QFontDatabase::applicationFallbackFontFamilies(QChar::Script_Hebrew).first(), u"QtBidiTestFont"_s);
+
+ {
+ QString hebrewFontNow = getHebrewFont();
+ QCOMPARE(hebrewFontNow, defaultHebrewFont);
+ }
+
+ id = QFontDatabase::addApplicationFont(m_testFont);
+ QVERIFY(id >= 0);
+
+ {
+ QString hebrewFontNow = getHebrewFont();
+ QCOMPARE(hebrewFontNow, u"QtBidiTestFont"_s);
+ }
+
+ QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Hebrew, u"QtBidiTestFont"_s);
+
+ {
+ QString hebrewFontNow = getHebrewFont();
+ QCOMPARE(hebrewFontNow, defaultHebrewFont);
+ }
+
+ QFontDatabase::setApplicationFallbackFontFamilies(QChar::Script_Hebrew, QStringList(u"QtBidiTestFont"_s));
+
+ {
+ QString hebrewFontNow = getHebrewFont();
+ QCOMPARE(hebrewFontNow, u"QtBidiTestFont"_s);
+ }
+
+ QFontDatabase::setApplicationFallbackFontFamilies(QChar::Script_Hebrew, QStringList{});
+
+ {
+ QString hebrewFontNow = getHebrewFont();
+ QCOMPARE(hebrewFontNow, defaultHebrewFont);
+ }
+
+ limitedId = QFontDatabase::addApplicationFont(m_limitedFont);
+ QVERIFY(limitedId >= 0);
+
+ fallbackId = QFontDatabase::addApplicationFont(m_fallbackFont);
+ QVERIFY(fallbackId >= 0);
+
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Common, u"QtTestFallbackFont"_s);
+
+ // The fallback for Common will be used also for Latin, because Latin and Common are
+ // considered the same script by the font matching engine.
+ {
+ QTextLayout layout;
+ layout.setText(u"A'B,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QVERIFY(glyphRuns.size() > 1);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ // When the text only consists of common script characters, the fallback font will also be used.
+ {
+ QTextLayout layout;
+ layout.setText(u"',"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Common, u"QtTestFallbackFont"_s));
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Latin, u"QtTestFallbackFont"_s);
+
+ // Latin fallback works just the same as Common fallback
+ {
+ QTextLayout layout;
+ layout.setText(u"A'B,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ // When the common character is placed next to a Cyrillic characters, it gets adapted to this,
+ // so the fallback font will not be selected, even if it supports the character in question
+ {
+ QTextLayout layout;
+ layout.setText(u"A'Б,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() != u"QtTestFallbackFont"_s);
+ }
+ }
+
+ QFontDatabase::addApplicationFallbackFontFamily(QChar::Script_Cyrillic, u"QtTestFallbackFont"_s);
+
+ // When we set the fallback font for Cyrillic as well, it gets selected
+ {
+ QTextLayout layout;
+ layout.setText(u"A'Б,"_s);
+ layout.setFont(QFont(u"QtTestLimitedFont"_s));
+ layout.beginLayout();
+ layout.createLine();
+ layout.endLayout();
+
+ QList<QGlyphRun> glyphRuns = layout.glyphRuns();
+ QCOMPARE(glyphRuns.size(), 2);
+ for (int i = 0; i < glyphRuns.size(); ++i) {
+ QVERIFY(glyphRuns.at(i).rawFont().familyName() == u"QtTestFallbackFont"_s
+ || glyphRuns.at(i).rawFont().familyName() == u"QtTestLimitedFont"_s);
+ }
+ }
+
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Cyrillic, u"QtTestFallbackFont"_s));
+ QVERIFY(QFontDatabase::removeApplicationFallbackFontFamily(QChar::Script_Latin, u"QtTestFallbackFont"_s));
+}
+
QTEST_MAIN(tst_QFontDatabase)
#include "tst_qfontdatabase.moc"
diff --git a/tests/auto/gui/text/qfontmetrics/CMakeLists.txt b/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
index d63ae61a10..ee2f76ef76 100644
--- a/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
+++ b/tests/auto/gui/text/qfontmetrics/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfontmetrics Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfontmetrics LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qfontmetrics
SOURCES
tst_qfontmetrics.cpp
@@ -18,8 +24,12 @@ qt_internal_add_test(tst_qfontmetrics
set_source_files_properties("../../../shared/resources/testfont.ttf"
PROPERTIES QT_RESOURCE_ALIAS "testfont.ttf"
)
+set_source_files_properties("../../../shared/resources/testfont_linemetrics.otf"
+ PROPERTIES QT_RESOURCE_ALIAS "testfont_linemetrics.otf"
+)
set(testfont_resource_files
"../../../shared/resources/testfont.ttf"
+ "../../../shared/resources/testfont_linemetrics.otf"
"ucs4font.ttf"
)
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index 5516492365..bad33ab0a4 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -34,6 +34,9 @@ private slots:
void zeroWidthMetrics();
void verticalMetrics_data();
void verticalMetrics();
+ void largeText_data();
+ void largeText(); // QTBUG-123339
+ void typoLineMetrics();
};
void tst_QFontMetrics::same()
@@ -261,7 +264,7 @@ void tst_QFontMetrics::inFontUcs4()
glyphs.glyphs[0] = 0;
QVERIFY(engine->stringToCMap(string.constData(), string.size(),
&glyphs, &glyphs.numGlyphs,
- QFontEngine::GlyphIndicesOnly));
+ QFontEngine::GlyphIndicesOnly) > 0);
QCOMPARE(glyphs.numGlyphs, 1);
QCOMPARE(glyphs.glyphs[0], uint(1));
}
@@ -273,7 +276,7 @@ void tst_QFontMetrics::inFontUcs4()
glyphs.glyphs[0] = 0;
QVERIFY(engine->stringToCMap(string.constData(), string.size(),
&glyphs, &glyphs.numGlyphs,
- QFontEngine::GlyphIndicesOnly));
+ QFontEngine::GlyphIndicesOnly) >= 0);
QVERIFY(glyphs.glyphs[0] != 1);
}
}
@@ -388,5 +391,68 @@ void tst_QFontMetrics::verticalMetrics()
QVERIFY(fm.ascent() != 0 || fm.descent() != 0);
}
+void tst_QFontMetrics::largeText_data()
+{
+ QTest::addColumn<qsizetype>("size");
+ for (int i = 1; i < 20; ++i) {
+ qsizetype size = qsizetype(1) << i;
+ QByteArray rowText = QByteArray::number(size);
+ QTest::newRow(rowText.constData()) << size;
+ }
+}
+
+void tst_QFontMetrics::largeText()
+{
+ QFont font;
+ QFontMetrics fm(font);
+ QFETCH(qsizetype, size);
+ QString string(size, QLatin1Char('A'));
+ QRect boundingRect = fm.boundingRect(string);
+ QVERIFY(boundingRect.isValid());
+}
+
+void tst_QFontMetrics::typoLineMetrics()
+{
+ QString testFont = QFINDTESTDATA("fonts/testfont_linemetrics.otf");
+ QVERIFY(!testFont.isEmpty());
+
+ int id = QFontDatabase::addApplicationFont(testFont);
+ QVERIFY(id >= 0);
+
+ {
+ auto cleanup = qScopeGuard([&id] {
+ if (id >= 0)
+ QFontDatabase::removeApplicationFont(id);
+ });
+
+ QImage img(100, 100, QImage::Format_ARGB32);
+ img.setDevicePixelRatio(1.0);
+ QFont font(QFontDatabase::applicationFontFamilies(id).at(0), &img);
+ font.setPixelSize(18);
+
+ const qreal unitsPerEm = 1000.0;
+
+ QFontMetrics defaultFm(font);
+ const int defaultAscent = defaultFm.ascent();
+ const int defaultDescent = defaultFm.descent();
+ const int defaultLeading = defaultFm.leading();
+
+ QCOMPARE(defaultAscent, qRound(1234.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(defaultDescent, qRound(5678.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(defaultLeading, 0.0);
+
+ font.setStyleStrategy(QFont::PreferTypoLineMetrics);
+ const QFontMetrics typoFm(font);
+
+ const int typoAscent = typoFm.ascent();
+ const int typoDescent = typoFm.descent();
+ const int typoLeading = typoFm.leading();
+
+ QCOMPARE(typoAscent, qRound(2000.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(typoDescent, qRound(3000.0 / unitsPerEm * font.pixelSize()));
+ QCOMPARE(typoLeading, qRound(1000.0 / unitsPerEm * font.pixelSize()));
+ }
+}
+
QTEST_MAIN(tst_QFontMetrics)
#include "tst_qfontmetrics.moc"
diff --git a/tests/auto/gui/text/qglyphrun/BLACKLIST b/tests/auto/gui/text/qglyphrun/BLACKLIST
deleted file mode 100644
index 86e857fb23..0000000000
--- a/tests/auto/gui/text/qglyphrun/BLACKLIST
+++ /dev/null
@@ -1,7 +0,0 @@
-# QTBUG-68860
-[mixedScripts]
-ubuntu-18.04
-ubuntu-20.04
-ubuntu-22.04
-# QTBUG-100928
-qnx
diff --git a/tests/auto/gui/text/qglyphrun/CMakeLists.txt b/tests/auto/gui/text/qglyphrun/CMakeLists.txt
index ffee80ea03..a9ffd3729d 100644
--- a/tests/auto/gui/text/qglyphrun/CMakeLists.txt
+++ b/tests/auto/gui/text/qglyphrun/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qglyphrun Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qglyphrun LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set_source_files_properties("../../../shared/resources/test.ttf"
PROPERTIES QT_RESOURCE_ALIAS "test.ttf"
diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
index 9bc9391989..8c0c0324c9 100644
--- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
+++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -408,7 +408,7 @@ void tst_QGlyphRun::drawMultiScriptText1()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
+ const QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 1);
{
@@ -418,8 +418,7 @@ void tst_QGlyphRun::drawMultiScriptText1()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphRun glyphs, glyphsList)
- p.drawGlyphRun(QPointF(50, 50), glyphs);
+ p.drawGlyphRun(QPointF(50, 50), glyphsList.first());
}
#if defined(DEBUG_SAVE_IMAGE)
@@ -449,7 +448,7 @@ void tst_QGlyphRun::drawMultiScriptText2()
QPixmap drawGlyphs(1000, 1000);
drawGlyphs.fill(Qt::white);
- QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
+ const QList<QGlyphRun> glyphsList = textLayout.glyphRuns();
QCOMPARE(glyphsList.size(), 2);
{
@@ -459,7 +458,7 @@ void tst_QGlyphRun::drawMultiScriptText2()
{
QPainter p(&drawGlyphs);
- foreach (QGlyphRun glyphs, glyphsList)
+ for (const QGlyphRun &glyphs : glyphsList)
p.drawGlyphRun(QPointF(50, 50), glyphs);
}
@@ -564,6 +563,9 @@ void tst_QGlyphRun::boundingRect()
void tst_QGlyphRun::mixedScripts()
{
+ if (QFontDatabase::families(QFontDatabase::Korean).isEmpty())
+ QSKIP("This test requires support for Hangul text");
+
QString s;
s += QChar(0x31); // The character '1'
s += QChar(0xbc14); // Hangul character
diff --git a/tests/auto/gui/text/qinputcontrol/CMakeLists.txt b/tests/auto/gui/text/qinputcontrol/CMakeLists.txt
index 04e99b2c7c..75fc85bc39 100644
--- a/tests/auto/gui/text/qinputcontrol/CMakeLists.txt
+++ b/tests/auto/gui/text/qinputcontrol/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qinputcontrol Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qinputcontrol LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qinputcontrol
SOURCES
tst_qinputcontrol.cpp
diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
index a75975664b..678f4491c4 100644
--- a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
+++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/text/qrawfont/CMakeLists.txt b/tests/auto/gui/text/qrawfont/CMakeLists.txt
index aebbca15f7..d2a318a2a3 100644
--- a/tests/auto/gui/text/qrawfont/CMakeLists.txt
+++ b/tests/auto/gui/text/qrawfont/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qrawfont Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qrawfont LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set_source_files_properties("../../../shared/resources/testfont.ttf"
PROPERTIES QT_RESOURCE_ALIAS "testfont.ttf"
diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
index 8b203f439e..5ec2536718 100644
--- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
+++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtGui/QFontDatabase>
@@ -398,13 +398,13 @@ void tst_QRawFont::textLayout()
void tst_QRawFont::fontTable_data()
{
- QTest::addColumn<QByteArray>("tagName");
+ QTest::addColumn<QFont::Tag>("tag");
QTest::addColumn<QFont::HintingPreference>("hintingPreference");
QTest::addColumn<int>("offset");
QTest::addColumn<quint32>("expectedValue");
QTest::newRow("Head table, magic number, default hinting")
- << QByteArray("head")
+ << QFont::Tag("head")
<< QFont::PreferDefaultHinting
<< 12
<< (QSysInfo::ByteOrder == QSysInfo::BigEndian
@@ -412,7 +412,7 @@ void tst_QRawFont::fontTable_data()
: 0xF53C0F5F);
QTest::newRow("Head table, magic number, no hinting")
- << QByteArray("head")
+ << QFont::Tag("head")
<< QFont::PreferNoHinting
<< 12
<< (QSysInfo::ByteOrder == QSysInfo::BigEndian
@@ -420,7 +420,7 @@ void tst_QRawFont::fontTable_data()
: 0xF53C0F5F);
QTest::newRow("Head table, magic number, vertical hinting")
- << QByteArray("head")
+ << QFont::Tag("head")
<< QFont::PreferVerticalHinting
<< 12
<< (QSysInfo::ByteOrder == QSysInfo::BigEndian
@@ -428,7 +428,7 @@ void tst_QRawFont::fontTable_data()
: 0xF53C0F5F);
QTest::newRow("Head table, magic number, full hinting")
- << QByteArray("head")
+ << QFont::Tag("head")
<< QFont::PreferFullHinting
<< 12
<< (QSysInfo::ByteOrder == QSysInfo::BigEndian
@@ -438,7 +438,7 @@ void tst_QRawFont::fontTable_data()
void tst_QRawFont::fontTable()
{
- QFETCH(QByteArray, tagName);
+ QFETCH(QFont::Tag, tag);
QFETCH(QFont::HintingPreference, hintingPreference);
QFETCH(int, offset);
QFETCH(quint32, expectedValue);
@@ -446,11 +446,13 @@ void tst_QRawFont::fontTable()
QRawFont font(testFont, 10, hintingPreference);
QVERIFY(font.isValid());
- QByteArray table = font.fontTable(tagName);
+ QByteArray table = font.fontTable(tag);
QVERIFY(!table.isEmpty());
const quint32 *value = reinterpret_cast<const quint32 *>(table.constData() + offset);
QCOMPARE(*value, expectedValue);
+
+ QCOMPARE(font.fontTable(tag.toString()), table);
}
typedef QList<QFontDatabase::WritingSystem> WritingSystemList;
@@ -490,7 +492,7 @@ void tst_QRawFont::supportedWritingSystems_data()
void tst_QRawFont::supportedWritingSystems()
{
QFETCH(QString, fileName);
- QFETCH(WritingSystemList, writingSystems);
+ QFETCH(const WritingSystemList, writingSystems);
QFETCH(QFont::HintingPreference, hintingPreference);
QRawFont font(fileName, 10, hintingPreference);
@@ -499,7 +501,7 @@ void tst_QRawFont::supportedWritingSystems()
WritingSystemList actualWritingSystems = font.supportedWritingSystems();
QCOMPARE(actualWritingSystems.size(), writingSystems.size());
- foreach (QFontDatabase::WritingSystem writingSystem, writingSystems)
+ for (QFontDatabase::WritingSystem writingSystem : writingSystems)
QVERIFY(actualWritingSystems.contains(writingSystem));
}
@@ -1052,7 +1054,7 @@ void tst_QRawFont::qtbug65923_partal_clone_data()
void tst_QRawFont::qtbug65923_partal_clone()
{
QFile file(testFont);
- file.open(QIODevice::ReadOnly);
+ QVERIFY(file.open(QIODevice::ReadOnly));
QByteArray fontData = file.readAll();
QRawFont outerFont;
diff --git a/tests/auto/gui/text/qstatictext/CMakeLists.txt b/tests/auto/gui/text/qstatictext/CMakeLists.txt
index 5c0a149c35..bdad2609fe 100644
--- a/tests/auto/gui/text/qstatictext/CMakeLists.txt
+++ b/tests/auto/gui/text/qstatictext/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qstatictext Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qstatictext LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qstatictext
SOURCES
tst_qstatictext.cpp
@@ -15,7 +21,7 @@ qt_internal_add_test(tst_qstatictext
## Scopes:
#####################################################################
-qt_internal_extend_target(tst_qstatictext CONDITION QT_FEATURE_private_tests
+qt_internal_extend_target(tst_qstatictext CONDITION QT_FEATURE_developer_build
LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
index e6e16374d3..add2303199 100644
--- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QtCore/QSet>
@@ -50,10 +50,6 @@ private slots:
void rotatedPainter();
void scaledPainter();
void projectedPainter();
-#if 0
- void rotatedScaledAndTranslatedPainter_data();
- void rotatedScaledAndTranslatedPainter();
-#endif
void transformationChanged();
void plainTextVsRichText();
@@ -501,61 +497,6 @@ void tst_QStaticText::projectedPainter()
QCOMPARE(imageDrawStaticText, imageDrawText);
}
-#if 0
-void tst_QStaticText::rotatedScaledAndTranslatedPainter_data()
-{
- QTest::addColumn<qreal>("offset");
-
- for (int i=0; i<100; ++i) {
- qreal offset = 300 + i / 100.;
- QTest::newRow(QByteArray::number(offset).constData()) << offset;
- }
-}
-
-void tst_QStaticText::rotatedScaledAndTranslatedPainter()
-{
- QFETCH(qreal, offset);
-
- QPixmap imageDrawText(1000, 1000);
- imageDrawText.fill(Qt::white);
- {
- QPainter p(&imageDrawText);
- p.translate(offset, 0);
- p.rotate(45.0);
- p.scale(2.0, 2.0);
- p.translate(100, 200);
-
- p.drawText(11, 12, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- }
-
- QPixmap imageDrawStaticText(1000, 1000);
- imageDrawStaticText.fill(Qt::white);
- {
- QPainter p(&imageDrawStaticText);
- p.translate(offset, 0);
- p.rotate(45.0);
- p.scale(2.0, 2.0);
- p.translate(100, 200);
-
- QStaticText text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
- text.setTextFormat(Qt::PlainText);
-
- p.drawStaticText(QPointF(11, 12 - QFontMetricsF(p.font()).ascent()), text);
- }
-
-#if defined(DEBUG_SAVE_IMAGE)
- imageDrawText.save("rotatedScaledAndPainter_imageDrawText.png");
- imageDrawStaticText.save("rotatedScaledAndPainter_imageDrawStaticText.png");
-#endif
-
- QVERIFY(imageDrawText.toImage() != m_whiteSquare);
-
- if (!supportsTransformations())
- QEXPECT_FAIL("", "Graphics system does not support transformed text on this platform", Abort);
- QCOMPARE(imageDrawStaticText, imageDrawText);
-}
-#endif
-
void tst_QStaticText::transformationChanged()
{
QPixmap imageDrawText(1000, 1000);
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt b/tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt
index c4bb65a7ac..f1c9146ce1 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt
+++ b/tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qsyntaxhighlighter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qsyntaxhighlighter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qsyntaxhighlighter
SOURCES
tst_qsyntaxhighlighter.cpp
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index 2d92d49f4f..748f494a41 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
+++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/text/qtextblock/CMakeLists.txt b/tests/auto/gui/text/qtextblock/CMakeLists.txt
index 4b000a42cd..83cc1ce08e 100644
--- a/tests/auto/gui/text/qtextblock/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextblock/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextblock Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextblock LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextblock
SOURCES
tst_qtextblock.cpp
diff --git a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
index e6400fafb0..50331ddef2 100644
--- a/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
+++ b/tests/auto/gui/text/qtextblock/tst_qtextblock.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
diff --git a/tests/auto/gui/text/qtextcursor/CMakeLists.txt b/tests/auto/gui/text/qtextcursor/CMakeLists.txt
index fef0a84e7d..487965f9f8 100644
--- a/tests/auto/gui/text/qtextcursor/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextcursor/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextcursor Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextcursor LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextcursor
SOURCES
tst_qtextcursor.cpp
diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
index 1780b321ab..8f5cacae4a 100644
--- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -39,7 +39,9 @@ private slots:
void navigation7();
void navigation8();
void navigation9();
+#ifndef QT_NO_TEXTHTMLPARSER
void navigation10();
+#endif
void movePositionEndOfLine();
void insertBlock();
void insertWithBlockSeparator1();
@@ -431,6 +433,7 @@ void tst_QTextCursor::navigation9()
QCOMPARE(cursor.position(), 15);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QTextCursor::navigation10()
{
doc->setHtml("<html><p>just a simple paragraph.</p>"
@@ -542,6 +545,7 @@ void tst_QTextCursor::navigation10()
QVERIFY(ok);
QCOMPARE(cursor.position(), 1); // a
}
+#endif
void tst_QTextCursor::insertBlock()
{
diff --git a/tests/auto/gui/text/qtextdocument/CMakeLists.txt b/tests/auto/gui/text/qtextdocument/CMakeLists.txt
index 1dc94ce4b4..62fa1d46ca 100644
--- a/tests/auto/gui/text/qtextdocument/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextdocument/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextdocument Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextdocument LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextdocument
SOURCES
common.h
diff --git a/tests/auto/gui/text/qtextdocument/common.h b/tests/auto/gui/text/qtextdocument/common.h
index 5b45315704..3c05913008 100644
--- a/tests/auto/gui/text/qtextdocument/common.h
+++ b/tests/auto/gui/text/qtextdocument/common.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QAbstractTextDocumentLayout>
#include <private/qtextdocument_p.h>
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index f6527fbff6..600b45575f 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -181,6 +181,10 @@ private slots:
void insertHtmlWithComments();
void delayedLayout();
+ void undoContentChangeIndices();
+
+ void restoreStrokeFromHtml();
+ void restoreForegroundGradientFromHtml();
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -743,6 +747,9 @@ void tst_QTextDocument::mightBeRichText_data()
" PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\">\n"
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";
QVERIFY(Qt::mightBeRichText(QString::fromLatin1(qtDocuHeader)));
+ QVERIFY(Qt::mightBeRichText(QLatin1StringView(qtDocuHeader)));
+ QVERIFY(QUtf8StringView(qtDocuHeader).isValidUtf8());
+ QVERIFY(Qt::mightBeRichText(QUtf8StringView(qtDocuHeader)));
QTest::addColumn<QString>("input");
QTest::addColumn<bool>("result");
@@ -762,6 +769,10 @@ void tst_QTextDocument::mightBeRichText()
QFETCH(QString, input);
QFETCH(bool, result);
QCOMPARE(result, Qt::mightBeRichText(input));
+ QCOMPARE(result, Qt::mightBeRichText(QStringView(input)));
+ QCOMPARE(result, Qt::mightBeRichText(QUtf8StringView(input.toUtf8())));
+ QVERIFY(QtPrivate::isLatin1(input));
+ QCOMPARE(result, Qt::mightBeRichText(QLatin1StringView(input.toLatin1())));
}
Q_DECLARE_METATYPE(QTextDocumentFragment)
@@ -1161,7 +1172,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(2, 2);
QTest::newRow("simpletable") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
@@ -1175,7 +1186,7 @@ void tst_QTextDocument::toHtml_data()
table->mergeCells(0, 2, 1, 2);
QTest::newRow("tablespans") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td colspan=\"2\"></td>\n<td colspan=\"2\"></td></tr>"
"</table>");
}
@@ -1194,7 +1205,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(2, 2, fmt);
QTest::newRow("tableattrs") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" style=\" float: right;\" align=\"center\" width=\"50%\" cellspacing=\"3\" cellpadding=\"3\" bgcolor=\"#ff00ff\">"
+ << QString("<table border=\"1\" style=\" float: right; border-collapse:collapse;\" align=\"center\" width=\"50%\" cellspacing=\"3\" cellpadding=\"3\" bgcolor=\"#ff00ff\">"
"\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
@@ -1216,7 +1227,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(2, 2, fmt);
QTest::newRow("tableattrs2") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" style=\" float: right; margin-top:0px; margin-bottom:35px; margin-left:25px; margin-right:0px;\" align=\"center\" width=\"50%\" cellspacing=\"3\" cellpadding=\"3\" bgcolor=\"#ff00ff\">"
+ << QString("<table border=\"1\" style=\" float: right; margin-top:0px; margin-bottom:35px; margin-left:25px; margin-right:0px; border-collapse:collapse;\" align=\"center\" width=\"50%\" cellspacing=\"3\" cellpadding=\"3\" bgcolor=\"#ff00ff\">"
"\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
@@ -1230,7 +1241,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(4, 2, fmt);
QTest::newRow("tableheader") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"<thead>\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr></thead>"
"\n<tr>\n<td></td>\n<td></td></tr>"
@@ -1246,8 +1257,8 @@ void tst_QTextDocument::toHtml_data()
subTable->cellAt(0, 0).firstCursorPosition().insertText("Hey");
QTest::newRow("nestedtable") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
- "\n<tr>\n<td></td>\n<td>\n<table border=\"1\" cellspacing=\"2\">\n<tr>\n<td>\n<p DEFAULTBLOCKSTYLE>Hey</p></td></tr></table></td></tr>"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
+ "\n<tr>\n<td></td>\n<td>\n<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">\n<tr>\n<td>\n<p DEFAULTBLOCKSTYLE>Hey</p></td></tr></table></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
}
@@ -1264,7 +1275,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(1, 3, fmt);
QTest::newRow("colwidths") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td></td>\n<td width=\"30%\"></td>\n<td width=\"40\"></td></tr>"
"</table>");
}
@@ -1281,7 +1292,7 @@ void tst_QTextDocument::toHtml_data()
cellCurs.mergeBlockCharFormat(fmt);
QTest::newRow("cellproperties") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td bgcolor=\"#ffffff\"></td></tr>"
"</table>");
}
@@ -1548,7 +1559,7 @@ void tst_QTextDocument::toHtml_data()
table->setFormat(fmt);
QTest::newRow("mergedtablecolwidths") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td colspan=\"2\"></td></tr>"
"\n<tr>\n<td width=\"20\"></td>\n<td width=\"40\"></td></tr>"
"</table>");
@@ -1611,7 +1622,7 @@ void tst_QTextDocument::toHtml_data()
table->cellAt(0, 0).firstCursorPosition().insertText("Blah");
QTest::newRow("table-vertical-alignment") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td style=\" vertical-align:middle;\">\n"
"<p DEFAULTBLOCKSTYLE>Blah</p></td>"
"\n<td style=\" vertical-align:top;\"></td></tr>"
@@ -1640,7 +1651,7 @@ void tst_QTextDocument::toHtml_data()
table->cellAt(0, 0).firstCursorPosition().insertText("Blah");
QTest::newRow("table-cell-paddings") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td style=\" padding-left:1;\">\n"
"<p DEFAULTBLOCKSTYLE>Blah</p></td>"
"\n<td style=\" padding-right:1;\"></td></tr>"
@@ -1658,7 +1669,7 @@ void tst_QTextDocument::toHtml_data()
cursor.insertTable(2, 2, fmt);
QTest::newRow("tableborder") << QTextDocumentFragment(&doc)
- << QString("<table border=\"1\" style=\" border-color:#0000ff; border-style:solid;\" cellspacing=\"2\">"
+ << QString("<table border=\"1\" style=\" border-color:#0000ff; border-style:solid; border-collapse:collapse;\" cellpadding=\"4\">"
"\n<tr>\n<td></td>\n<td></td></tr>"
"\n<tr>\n<td></td>\n<td></td></tr>"
"</table>");
@@ -1700,7 +1711,7 @@ void tst_QTextDocument::toHtml_data()
<< QString("EMPTYBLOCK") +
QString("<p OPENDEFAULTBLOCKSTYLE page-break-before:always;\">Foo</p>"
"\n<p OPENDEFAULTBLOCKSTYLE page-break-before:always; page-break-after:always;\">Bar</p>"
- "\n<table border=\"1\" style=\" page-break-after:always;\" cellspacing=\"2\">\n<tr>\n<td></td></tr></table>");
+ "\n<table border=\"1\" style=\" page-break-after:always; border-collapse:collapse;\" cellpadding=\"4\">\n<tr>\n<td></td></tr></table>");
}
{
@@ -3981,5 +3992,258 @@ void tst_QTextDocument::delayedLayout()
QCOMPARE(layout->lineCount(), 1); // layout happened
}
+void tst_QTextDocument::undoContentChangeIndices() // QTBUG-113865
+{
+ QTextDocument doc;
+ QTestDocumentLayout *layout = new QTestDocumentLayout(&doc);
+ QString content = QString("<html><body>"
+ "<ul><li>Undo</li></ul>"
+ "<ul><li>operation</li></ul>"
+ "<ul><li>of</li></ul>"
+ "<ul><li>unnumbered</li></ul>"
+ "<ul><li>lists</li></ul>"
+ "<ul><li>shows</li></ul>"
+ "<ul><li>invalid</li></ul>"
+ "<ul><li>content</li></ul>"
+ "<ul><li>indices</li></ul>"
+ "</body></html>");
+ doc.setDocumentLayout(layout);
+ doc.setHtml(content);
+
+ // Select the entire document content
+ QTextCursor cursor(&doc);
+ cursor.select(QTextCursor::Document);
+ cursor.removeSelectedText();
+
+ // Undo above operation
+ doc.undo();
+
+ // Move the cursor to the end
+ cursor.movePosition(QTextCursor::End);
+ cursor.insertHtml(content);
+
+ // Select the whole document and remove the content
+ cursor.select(QTextCursor::Document);
+ cursor.removeSelectedText();
+
+ int documentLength = 0;
+ int changeRemoved = 0;
+ int changeAdded = 0;
+ int changePos = 0;
+ connect(&doc, &QTextDocument::contentsChange, this, [&](int pos, int removed, int added){
+ documentLength = doc.characterCount();
+ changeRemoved = removed;
+ changeAdded = added;
+ changePos = pos;
+ });
+
+ // Undo above operation
+ doc.undo();
+
+ const int changeEnd = changeAdded + changeRemoved;
+
+ QVERIFY(documentLength > 0);
+ QCOMPARE(changePos, 0);
+ QVERIFY(changeRemoved >= 0);
+ QVERIFY(documentLength >= changeEnd);
+}
+
+void tst_QTextDocument::restoreStrokeFromHtml()
+{
+ QTextDocument document;
+ QTextCursor textCursor(&document);
+ QTextCharFormat textOutline;
+
+ // Set stroke color and width
+ {
+ QPen pen(Qt::red, 2.3, Qt::SolidLine);
+ textOutline.setTextOutline(pen);
+ textCursor.insertText("Outlined text", textOutline);
+ }
+
+ // Set Cap and Join styles
+ {
+ QPen pen;
+ pen.setCapStyle(Qt::FlatCap);
+ pen.setJoinStyle(Qt::RoundJoin);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Cap and Join Style", textOutline);
+ }
+
+ // Set Miter limit
+ {
+ QPen pen;
+ pen.setJoinStyle(Qt::MiterJoin);
+ pen.setMiterLimit(4);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Miter Limit", textOutline);
+ }
+
+ // Set Dash Array and Dash Offset
+ {
+ QPen pen;
+ QList<qreal> pattern;
+ const int dash = 2;
+ const int gap = 4;
+ pattern << dash << gap << dash << gap << dash << gap;
+ pen.setDashPattern(pattern);
+ pen.setDashOffset(3);
+ textOutline.setTextOutline(pen);
+ textCursor.insertBlock();
+ textCursor.insertText("Dash Pattern", textOutline);
+ }
+
+ {
+ QTextDocument otherDocument;
+ otherDocument.setHtml(document.toHtml());
+ QCOMPARE(otherDocument.blockCount(), document.blockCount());
+
+ QTextBlock block;
+ QTextFragment fragment;
+ QTextCharFormat fmt;
+ QPen pen;
+
+ {
+ block = otherDocument.findBlockByNumber(0);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Outlined text"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.color(), QColor(Qt::red));
+ QCOMPARE(pen.widthF(), 2.3);
+ }
+
+ {
+ block = otherDocument.findBlockByNumber(1);
+ qDebug() << block.text();
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Cap and Join Style"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.capStyle(), Qt::FlatCap);
+ QCOMPARE(pen.joinStyle(), Qt::RoundJoin);
+ }
+
+ {
+ block = otherDocument.findBlockByNumber(2);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Miter Limit"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.joinStyle(), Qt::MiterJoin);
+ QCOMPARE(pen.miterLimit(), 4);
+ }
+
+
+ {
+ block = otherDocument.findBlockByNumber(3);
+ fragment = block.begin().fragment();
+ QCOMPARE(fragment.text(), QStringLiteral("Dash Pattern"));
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::TextOutline));
+ pen = fmt.textOutline();
+ QCOMPARE(pen.dashOffset(), 3);
+ QList<qreal> pattern;
+ const int dash = 2;
+ const int gap = 4;
+ pattern << dash << gap << dash << gap << dash << gap;
+ QCOMPARE(pen.dashPattern(), pattern);
+ }
+ }
+}
+
+void tst_QTextDocument::restoreForegroundGradientFromHtml()
+{
+ QTextDocument document;
+
+ QTextCursor textCursor(&document);
+
+ QTextCharFormat foregroundGradient;
+ QLinearGradient lg;
+ lg.setColorAt(0.0, Qt::green);
+ lg.setColorAt(1.0, Qt::blue);
+ lg.setStart(QPointF(0,0));
+ lg.setFinalStop(QPointF(800, 1000));
+ foregroundGradient.setForeground(QBrush(lg));
+ textCursor.insertText("Linear gradient text\n", foregroundGradient);
+
+ QRadialGradient rg;
+ rg.setCoordinateMode(QGradient::ObjectBoundingMode);
+ rg.setSpread(QGradient::ReflectSpread);
+ rg.setColorAt(0.0, Qt::green);
+ rg.setColorAt(1.0, Qt::blue);
+ QPointF center(0.5, 0.5);
+ rg.setCenter(center);
+ rg.setFocalPoint(center);
+ rg.setRadius(0.5);
+ foregroundGradient.setForeground(QBrush(rg));
+ textCursor.insertText("Radial gradient text\n", foregroundGradient);
+
+ QConicalGradient cg;
+ cg.setCoordinateMode(QGradient::ObjectMode);
+ cg.setSpread(QGradient::RepeatSpread);
+ cg.setColorAt(0.0, Qt::green);
+ cg.setColorAt(1.0, Qt::blue);
+ cg.setCenter(QPointF(0.5, 0.5));
+ cg.setAngle(0.0);
+ foregroundGradient.setForeground(QBrush(cg));
+ textCursor.insertText("Conical gradient text\n", foregroundGradient);
+
+ {
+ QTextDocument otherDocument;
+ otherDocument.setHtml(document.toHtml());
+
+ QCOMPARE(otherDocument.blockCount(), document.blockCount());
+
+ QTextBlock block = otherDocument.firstBlock();
+ QTextFragment fragment = block.begin().fragment();
+
+ QCOMPARE(fragment.text(), QStringLiteral("Linear gradient text"));
+
+ QTextCharFormat fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::ForegroundBrush));
+
+ QBrush brush = fmt.foreground();
+ QCOMPARE(brush.style(), Qt::LinearGradientPattern);
+ QCOMPARE(brush.gradient()->coordinateMode(), lg.coordinateMode());
+ QCOMPARE(brush.gradient()->spread(), lg.spread());
+ QCOMPARE(brush.gradient()->stops().size(), lg.stops().size());
+ QCOMPARE(static_cast<const QLinearGradient *>(brush.gradient())->start(), lg.start());
+ QCOMPARE(static_cast<const QLinearGradient *>(brush.gradient())->finalStop(), lg.finalStop());
+
+ block = block.next();
+ fragment = block.begin().fragment();
+
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::ForegroundBrush));
+
+ brush = fmt.foreground();
+ QCOMPARE(brush.style(), Qt::RadialGradientPattern);
+ QCOMPARE(brush.gradient()->coordinateMode(), rg.coordinateMode());
+ QCOMPARE(brush.gradient()->spread(), rg.spread());
+ QCOMPARE(static_cast<const QRadialGradient *>(brush.gradient())->center(), rg.center());
+ QCOMPARE(static_cast<const QRadialGradient *>(brush.gradient())->focalPoint(), rg.focalPoint());
+ QCOMPARE(static_cast<const QRadialGradient *>(brush.gradient())->radius(), rg.radius());
+
+ block = block.next();
+ fragment = block.begin().fragment();
+
+ fmt = fragment.charFormat();
+ QVERIFY(fmt.hasProperty(QTextCharFormat::ForegroundBrush));
+
+ brush = fmt.foreground();
+ QCOMPARE(brush.style(), Qt::ConicalGradientPattern);
+ QCOMPARE(brush.gradient()->coordinateMode(), cg.coordinateMode());
+ QCOMPARE(brush.gradient()->spread(), cg.spread());
+ QCOMPARE(static_cast<const QConicalGradient *>(brush.gradient())->center(), cg.center());
+ QCOMPARE(static_cast<const QConicalGradient *>(brush.gradient())->angle(), cg.angle());
+ }
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"
diff --git a/tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt b/tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt
index 179b77af3b..4a4075106e 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextdocumentfragment Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextdocumentfragment LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextdocumentfragment
SOURCES
tst_qtextdocumentfragment.cpp
diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
index ca23c56b3e..f2c3b36dcd 100644
--- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
+++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -16,6 +16,8 @@
#include <qtextcursor.h>
+using namespace Qt::StringLiterals;
+
QT_FORWARD_DECLARE_CLASS(QTextDocument)
class tst_QTextDocumentFragment : public QObject
@@ -245,6 +247,7 @@ private slots:
void html_fromFirefox();
void html_emptyInlineInsideBlock();
void css_fontAndWordSpacing();
+ void html_brWithWhitespaceAfterList();
private:
inline void setHtml(const QString &html)
@@ -4320,5 +4323,24 @@ void tst_QTextDocumentFragment::css_fontAndWordSpacing()
}
}
+void tst_QTextDocumentFragment::html_brWithWhitespaceAfterList() // QTBUG-81662
+{
+ setHtml(QString::fromLatin1("<ul><li>one</li><li>two</li></ul>\n <br/>\nhello"));
+
+ QCOMPARE(doc->blockCount(), 3);
+
+ QTextBlock block = doc->begin();
+ QVERIFY(block.textList());
+
+ block = block.next();
+ QVERIFY(block.textList());
+
+ block = block.next();
+ QCOMPARE(block.text(), u"\u2028hello"_s);
+
+ block = block.next();
+ QVERIFY(block.text().isEmpty());
+}
+
QTEST_MAIN(tst_QTextDocumentFragment)
#include "tst_qtextdocumentfragment.moc"
diff --git a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST
index 5a2f81c448..ed85376c92 100644
--- a/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST
+++ b/tests/auto/gui/text/qtextdocumentlayout/BLACKLIST
@@ -1,6 +1,3 @@
[imageAtRightAlignedTab]
-rhel-6.6
-rhel-7.4
-rhel-7.6
sles
centos
diff --git a/tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt b/tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt
index 4556281b65..07386d4e24 100644
--- a/tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextdocumentlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextdocumentlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextdocumentlayout
SOURCES
tst_qtextdocumentlayout.cpp
diff --git a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
index 010fe002d4..2ae31849bf 100644
--- a/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
+++ b/tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -24,18 +24,24 @@ private slots:
void cleanupTestCase();
void defaultPageSizeHandling();
void idealWidth();
+#ifndef QT_NO_TEXTHTMLPARSER
void lineSeparatorFollowingTable();
+#endif
#ifndef QT_NO_WIDGETS
void wrapAtWordBoundaryOrAnywhere();
#endif
void inlineImage();
+#ifndef QT_NO_TEXTHTMLPARSER
void clippedTableCell();
+#endif
void floatingTablePageBreak();
void imageAtRightAlignedTab();
void blockVisibility();
+#ifndef QT_NO_TEXTHTMLPARSER
void testHitTest();
void largeImage();
+#endif
private:
QTextDocument *doc;
@@ -99,6 +105,7 @@ void tst_QTextDocumentLayout::idealWidth()
QVERIFY(doc->idealWidth() > 0);
}
+#ifndef QT_NO_TEXTHTMLPARSER
// none of the QTextLine items in the document should intersect with the margin rect
void tst_QTextDocumentLayout::lineSeparatorFollowingTable()
{
@@ -145,6 +152,7 @@ void tst_QTextDocumentLayout::lineSeparatorFollowingTable()
}
}
}
+#endif
#ifndef QT_NO_WIDGETS
void tst_QTextDocumentLayout::wrapAtWordBoundaryOrAnywhere()
@@ -184,6 +192,7 @@ void tst_QTextDocumentLayout::inlineImage()
QCOMPARE(doc->pageCount(), 1);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QTextDocumentLayout::clippedTableCell()
{
const char *html =
@@ -224,6 +233,7 @@ void tst_QTextDocumentLayout::clippedTableCell()
expected.save("expected.png");
QCOMPARE(img, expected);
}
+#endif
void tst_QTextDocumentLayout::floatingTablePageBreak()
{
@@ -323,6 +333,7 @@ void tst_QTextDocumentLayout::blockVisibility()
QCOMPARE(doc->size(), halfSize);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QTextDocumentLayout::largeImage()
{
auto img = QImage(400, 500, QImage::Format_ARGB32_Premultiplied);
@@ -416,6 +427,7 @@ void tst_QTextDocumentLayout::testHitTest()
QVERIFY(positionY - topMargin <= y);
}
}
+#endif
QTEST_MAIN(tst_QTextDocumentLayout)
#include "tst_qtextdocumentlayout.moc"
diff --git a/tests/auto/gui/text/qtextformat/CMakeLists.txt b/tests/auto/gui/text/qtextformat/CMakeLists.txt
index e5b714ad9f..4dea90900e 100644
--- a/tests/auto/gui/text/qtextformat/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextformat/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextformat
SOURCES
tst_qtextformat.cpp
diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
index 1b28274748..6c6145561d 100644
--- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -7,7 +7,9 @@
#include <qcoreapplication.h>
#include <qdebug.h>
+#if QT_CONFIG(settings)
#include <qsettings.h>
+#endif
#include <qtextformat.h>
#include <private/qtextformat_p.h>
#include <qtextdocument.h>
@@ -27,7 +29,9 @@ Q_OBJECT
private slots:
void getSetCheck();
void defaultAlignment();
+#if QT_CONFIG(settings)
void testQTextCharFormat() const;
+#endif
void testUnderlinePropertyPrecedence();
void toFormat();
void resolveFont();
@@ -47,6 +51,7 @@ private slots:
#endif
};
+#if QT_CONFIG(settings)
/*! \internal
This (used to) trigger a crash in:
@@ -61,6 +66,7 @@ void tst_QTextFormat::testQTextCharFormat() const
settings.value("test", test);
}
+#endif
// Testing get/set functions
void tst_QTextFormat::getSetCheck()
diff --git a/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt
index 45feab12f1..8d282b8f2c 100644
--- a/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextimagehandler LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
list(APPEND test_data "data/image.png")
list(APPEND test_data "data/image@2x.png")
diff --git a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
index b640efc8e4..0048623d0e 100644
--- a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
+++ b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp
@@ -1,11 +1,15 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QPainter>
#include <private/qtextimagehandler_p.h>
+using namespace Qt::StringLiterals;
+
+// #define DEBUG_WRITE_HTML
+
class tst_QTextImageHandler : public QObject
{
Q_OBJECT
@@ -18,7 +22,11 @@ private slots:
void cleanup();
void cleanupTestCase();
void loadAtNImages_data();
+#ifndef QT_NO_TEXTHTMLPARSER
void loadAtNImages();
+ void maxWidth_data();
+ void maxWidth();
+#endif
};
tst_QTextImageHandler::tst_QTextImageHandler()
@@ -42,11 +50,12 @@ void tst_QTextImageHandler::loadAtNImages_data()
QTest::addColumn<QString>("imageFile");
QTest::addRow("file") << QFINDTESTDATA("data/image.png");
- QTest::addRow("file_url") << QString("file:/") + QFINDTESTDATA("data/image.png");
+ QTest::addRow("file_url") << QUrl::fromLocalFile(QFINDTESTDATA("data/image.png")).toString();
QTest::addRow("resource") << ":/data/image.png";
QTest::addRow("qrc_url") << "qrc:/data/image.png";
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QTextImageHandler::loadAtNImages()
{
QFETCH(QString, imageFile);
@@ -58,7 +67,7 @@ void tst_QTextImageHandler::loadAtNImages()
const auto it = std::find_if(formats.begin(), formats.end(), [](const auto &format){
return format.objectType() == QTextFormat::ImageObject;
});
- QVERIFY(it != formats.end());
+ QCOMPARE_NE(it, formats.end());
const QTextImageFormat format = (*it).toImageFormat();
QTextImageHandler handler;
@@ -75,5 +84,64 @@ void tst_QTextImageHandler::loadAtNImages()
}
}
+void tst_QTextImageHandler::maxWidth_data()
+{
+ QTest::addColumn<QString>("imageFile");
+ QTest::addColumn<QSizeF>("pageSize");
+ QTest::addColumn<QTextLength>("maxWidth");
+ QTest::addColumn<QSizeF>("expectedSize");
+
+ QTest::addRow("constrained-percentage") << QFINDTESTDATA("data/image.png") << QSizeF(16, 16) << QTextLength(QTextLength::PercentageLength, 100) << QSizeF(12, 12);
+ QTest::addRow("not-constrained-percentage") << QFINDTESTDATA("data/image.png") << QSizeF(200, 200) << QTextLength(QTextLength::PercentageLength, 100) << QSizeF(16, 16);
+ QTest::addRow("constrained-fixed") << QFINDTESTDATA("data/image.png") << QSizeF(16, 16) << QTextLength(QTextLength::FixedLength, 5) << QSizeF(5, 5);
+ QTest::addRow("not-constrained-fixed") << QFINDTESTDATA("data/image.png") << QSizeF(200, 200) << QTextLength(QTextLength::FixedLength, 5) << QSizeF(5, 5);
+ QTest::addRow("not-constrained-default") << QFINDTESTDATA("data/image.png") << QSizeF(200, 200) << QTextLength(QTextLength::VariableLength, 5) << QSizeF(16, 16);
+}
+
+void tst_QTextImageHandler::maxWidth()
+{
+ QFETCH(QString, imageFile);
+ QFETCH(QSizeF, pageSize);
+ QFETCH(QTextLength, maxWidth);
+ QFETCH(QSizeF, expectedSize);
+
+ QTextDocument doc;
+ doc.setPageSize(pageSize);
+ doc.setDocumentMargin(2);
+ QTextCursor c(&doc);
+ QString style;
+ if (maxWidth.type() == QTextLength::PercentageLength)
+ style = " style=\"max-width:"_L1 + QString::number(maxWidth.rawValue()) + "%;\""_L1;
+ else if (maxWidth.type() == QTextLength::FixedLength)
+ style = " style=\"max-width:"_L1 + QString::number(maxWidth.rawValue()) + "px;\""_L1;
+ const QString html = "<img src=\"" + imageFile + u'\"' + style + "\">";
+ c.insertHtml(html);
+
+#ifdef DEBUG_WRITE_HTML
+ {
+ QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".html");
+ out.open(QFile::WriteOnly);
+ out.write(html.toLatin1());
+ out.close();
+ }
+ {
+ QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + "_rewrite.html");
+ out.open(QFile::WriteOnly);
+ out.write(doc.toHtml().toLatin1());
+ out.close();
+ }
+#endif
+ const auto formats = doc.allFormats();
+ const auto it = std::find_if(formats.begin(), formats.end(), [](const auto &format){
+ return format.objectType() == QTextFormat::ImageObject;
+ });
+ QCOMPARE_NE(it, formats.end());
+ const QTextImageFormat format = (*it).toImageFormat();
+ QTextImageHandler handler;
+
+ QCOMPARE(handler.intrinsicSize(&doc, 0, format), expectedSize);
+}
+#endif
+
QTEST_MAIN(tst_QTextImageHandler)
#include "tst_qtextimagehandler.moc"
diff --git a/tests/auto/gui/text/qtextlayout/CMakeLists.txt b/tests/auto/gui/text/qtextlayout/CMakeLists.txt
index 025a3451e8..655c0985a0 100644
--- a/tests/auto/gui/text/qtextlayout/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextlayout/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextlayout Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextlayout LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextlayout
SOURCES
tst_qtextlayout.cpp
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 51bb1a65db..209f5a56e2 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
/*
!!!!!! Warning !!!!!
@@ -2736,13 +2737,25 @@ void tst_QTextLayout::min_maximumWidth()
void tst_QTextLayout::negativeLineWidth()
{
- QTextLayout layout;
- layout.setText("Foo bar");
- layout.beginLayout();
- QTextLine line = layout.createLine();
- line.setLineWidth(-1);
- QVERIFY(line.textLength() > 0);
- layout.endLayout();
+ {
+ QTextLayout layout;
+ layout.setText("Foo bar");
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(-1);
+ QVERIFY(line.textLength() > 0);
+ layout.endLayout();
+ }
+
+ {
+ QTextLayout layout;
+ layout.setText("Foo bar");
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setNumColumns(2, -1);
+ QVERIFY(line.textLength() > 0);
+ layout.endLayout();
+ }
}
QTEST_MAIN(tst_QTextLayout)
diff --git a/tests/auto/gui/text/qtextlist/CMakeLists.txt b/tests/auto/gui/text/qtextlist/CMakeLists.txt
index d8f8a0ddf4..5764df3e99 100644
--- a/tests/auto/gui/text/qtextlist/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextlist/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextlist Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextlist LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextlist
SOURCES
../qtextdocument/common.h
diff --git a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
index b2d880f6cf..10d44f6d70 100644
--- a/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
+++ b/tests/auto/gui/text/qtextlist/tst_qtextlist.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -140,6 +140,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
QCOMPARE(list->count(), 28);
+#ifndef QT_NO_TEXTHTMLPARSER
QString htmlExport = doc->toHtml();
QTextDocument importDoc;
importDoc.setHtml(htmlExport);
@@ -152,6 +153,7 @@ void tst_QTextList::autoNumberingPrefixAndSuffixHtmlExportImport()
QCOMPARE(importCursor.currentList()->itemNumber(importCursor.block()), 27);
QCOMPARE(importCursor.currentList()->itemText(importCursor.block()), QLatin1String("\"ab#"));
QCOMPARE(importCursor.currentList()->format().indent(), 10);
+#endif
}
void tst_QTextList::autoNumberingRTL()
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt b/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt
index a82d4437db..937dd5bd80 100644
--- a/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt
@@ -5,11 +5,17 @@
## tst_qtextmarkdownimporter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextmarkdownimporter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
-list(APPEND test_data "data/thematicBreaks.md")
-list(APPEND test_data "data/headingBulletsContinuations.md")
-list(APPEND test_data "data/fuzz20450.md")
-list(APPEND test_data "data/fuzz20580.md")
+file(GLOB_RECURSE test_data
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*
+)
qt_internal_add_test(tst_qtextmarkdownimporter
SOURCES
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/paragraphs.md b/tests/auto/gui/text/qtextmarkdownimporter/data/paragraphs.md
new file mode 100644
index 0000000000..3d89536376
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownimporter/data/paragraphs.md
@@ -0,0 +1,9 @@
+This paragraph has enough text to auto-wrap when QTextMarkdownWriter writes it
+to a markdown file. The wrapping should be around 80 columns.
+
+This paragrah has been broken up into shorter lines.
+Each line break is created
+by hitting shift-enter in QTextEdit.
+But it's treated as one QTextBlock.
+
+This paragraph also has short lines.
Each ends with a Unicode LineSeparator.

diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md
index 7a0d5388ad..e784879326 100644
--- a/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md
+++ b/tests/auto/gui/text/qtextmarkdownimporter/data/thematicBreaks.md
@@ -11,6 +11,7 @@ stars
stars with tabs between
***
stars with whitespace after
+
---
hyphens with whitespace after
_____
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/yaml-only.md b/tests/auto/gui/text/qtextmarkdownimporter/data/yaml-only.md
new file mode 100644
index 0000000000..1eff4db37f
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownimporter/data/yaml-only.md
@@ -0,0 +1,6 @@
+---
+name: "Space"
+title: "Outer space"
+keywords:
+ - astronomy
+---
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/data/yaml.md b/tests/auto/gui/text/qtextmarkdownimporter/data/yaml.md
new file mode 100644
index 0000000000..41303a0187
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownimporter/data/yaml.md
@@ -0,0 +1,11 @@
+---
+name: "Venus"
+discoverer: "Galileo Galilei"
+title: "A description of the planet Venus"
+keywords:
+ - planets
+ - solar system
+ - astronomy
+---
+*Venus* is the second planet from the Sun, orbiting it every 224.7 Earth days.
+
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
index a9b519f2d7..d9fe000253 100644
--- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QBuffer>
@@ -29,6 +29,7 @@ class tst_QTextMarkdownImporter : public QObject
Q_OBJECT
private slots:
+ void paragraphs();
void headingBulletsContinuations();
void thematicBreaks();
void lists_data();
@@ -43,6 +44,10 @@ private slots:
void pathological();
void fencedCodeBlocks_data();
void fencedCodeBlocks();
+ void frontMatter_data();
+ void frontMatter();
+ void toRawText_data();
+ void toRawText();
private:
bool isMainFontFixed();
@@ -76,6 +81,43 @@ bool tst_QTextMarkdownImporter::isMainFontFixed()
return ret;
}
+void tst_QTextMarkdownImporter::paragraphs()
+{
+ QFile f(QFINDTESTDATA("data/paragraphs.md"));
+ QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text));
+ QString md = QString::fromUtf8(f.readAll());
+ f.close();
+
+ int lineSeparatorCount = 0;
+ QTextDocument doc;
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(md);
+ QTextFrame::iterator iterator = doc.rootFrame()->begin();
+ int i = 0;
+ while (!iterator.atEnd()) {
+ QTextBlock block = iterator.currentBlock();
+ int lineSeparatorPos = block.text().indexOf(QChar::LineSeparator);
+ qCDebug(lcTests) << i << block.text();
+ while (lineSeparatorPos > 0) {
+ ++lineSeparatorCount;
+ qCDebug(lcTests) << " LineSeparator @" << lineSeparatorPos;
+ lineSeparatorPos = block.text().indexOf(QChar::LineSeparator, lineSeparatorPos + 1);
+ }
+ ++iterator;
+ ++i;
+ }
+ QCOMPARE(doc.blockCount(), 3);
+ QCOMPARE(lineSeparatorCount, 2);
+
+#ifdef DEBUG_WRITE_HTML
+ {
+ QFile out("/tmp/paragraphs.html");
+ out.open(QFile::WriteOnly);
+ out.write(doc.toHtml().toLatin1());
+ out.close();
+ }
+#endif
+}
+
void tst_QTextMarkdownImporter::headingBulletsContinuations()
{
const QStringList expectedBlocks = QStringList() <<
@@ -101,7 +143,7 @@ void tst_QTextMarkdownImporter::headingBulletsContinuations()
f.close();
QTextDocument doc;
- QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md);
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(md);
QTextFrame::iterator iterator = doc.rootFrame()->begin();
QTextFrame *currentFrame = iterator.currentFrame();
QStringList::const_iterator expectedIt = expectedBlocks.constBegin();
@@ -149,7 +191,7 @@ void tst_QTextMarkdownImporter::thematicBreaks()
f.close();
QTextDocument doc;
- QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, md);
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(md);
QTextFrame::iterator iterator = doc.rootFrame()->begin();
QTextFrame *currentFrame = iterator.currentFrame();
int i = 0;
@@ -214,7 +256,7 @@ void tst_QTextMarkdownImporter::lists_data()
QTest::newRow("hyphen space newline") << "- \n" << 0 << 1 << 1 << true << "- \n";
QTest::newRow("hyphen space letter newline") << "- a\n" << 0 << 1 << 1 << false << "- a\n";
QTest::newRow("hyphen nbsp newline") <<
- QString::fromUtf8("-\u00A0\n") << 0 << 1 << 0 << true << "-\u00A0\n\n";
+ QString::fromUtf8("-\u00A0\n") << 0 << 1 << 0 << true << "\\-\u00A0\n\n";
QTest::newRow("nested empty lists") << "*\n *\n *\n" << 0 << 1 << 1 << true << " * \n";
QTest::newRow("list nested in empty list") << "-\n * a\n" << 0 << 1 << 2 << false << "- \n * a\n";
QTest::newRow("lists nested in empty lists")
@@ -423,7 +465,7 @@ void tst_QTextMarkdownImporter::avoidBlankLineAtBeginning() // QTBUG-81060
QFETCH(int, expectedNumberOfParagraphs);
QTextDocument doc;
- QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, input);
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(input);
QTextFrame::iterator iterator = doc.rootFrame()->begin();
int i = 0;
while (!iterator.atEnd()) {
@@ -468,7 +510,7 @@ void tst_QTextMarkdownImporter::fragmentsAndProperties()
QFETCH(int, expectedNumberOfFragments);
QTextDocument doc;
- QTextMarkdownImporter(QTextMarkdownImporter::DialectGitHub).import(&doc, input);
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(input);
#ifdef DEBUG_WRITE_HTML
{
QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".html");
@@ -536,6 +578,10 @@ void tst_QTextMarkdownImporter::fencedCodeBlocks_data()
<< "```pseudocode\nprint('hello world\\n')\n```\n"
<< 1 << 0 << "pseudocode" << "`"
<< "```pseudocode\nprint('hello world\\n')\n```\n\n";
+ QTest::newRow("backtick fence with punctuated language")
+ << "```html+js\n<html><head><script>function hi() { console.log('\\\"hello world') }</script></head>blah</html>\n```\n"
+ << 1 << 0 << "html+js" << "`"
+ << "```html+js\n<html><head><script>function hi() { console.log('\\\"hello world') }</script></head>blah</html>\n```\n\n";
QTest::newRow("tilde fence with language")
<< "~~~pseudocode\nprint('hello world\\n')\n~~~\n"
<< 1 << 0 << "pseudocode" << "~"
@@ -595,5 +641,135 @@ void tst_QTextMarkdownImporter::fencedCodeBlocks()
QCOMPARE(doc.toMarkdown(), rewrite);
}
+void tst_QTextMarkdownImporter::frontMatter_data()
+{
+ QTest::addColumn<QString>("inputFile");
+ QTest::addColumn<int>("expectedBlockCount");
+
+ QTest::newRow("yaml + markdown") << QFINDTESTDATA("data/yaml.md") << 1;
+ QTest::newRow("yaml only") << QFINDTESTDATA("data/yaml-only.md") << 0;
+}
+
+void tst_QTextMarkdownImporter::frontMatter()
+{
+ QFETCH(QString, inputFile);
+ QFETCH(int, expectedBlockCount);
+
+ QFile f(inputFile);
+ QVERIFY(f.open(QFile::ReadOnly | QIODevice::Text));
+ QString md = QString::fromUtf8(f.readAll());
+ f.close();
+ const int yamlBegin = md.indexOf("name:");
+ const int yamlEnd = md.indexOf("---", yamlBegin);
+ const QString yaml = md.sliced(yamlBegin, yamlEnd - yamlBegin);
+
+ QTextDocument doc;
+ QTextMarkdownImporter(&doc, QTextMarkdownImporter::DialectGitHub).import(md);
+ int blockCount = 0;
+ for (QTextFrame::iterator iterator = doc.rootFrame()->begin(); !iterator.atEnd(); ++iterator) {
+ // Check whether the block is text or a horizontal rule
+ if (!iterator.currentBlock().text().isEmpty())
+ ++blockCount;
+ }
+ QCOMPARE(blockCount, expectedBlockCount); // yaml is not part of the markdown text
+ QCOMPARE(doc.metaInformation(QTextDocument::FrontMatter), yaml); // without fences
+}
+
+void tst_QTextMarkdownImporter::toRawText_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expectedRawText");
+
+ // tests to verify that fixing QTBUG-122083 is safe
+ // https://spec.commonmark.org/0.31.2/#example-12
+ QTest::newRow("punctuation backslash escapes") <<
+ R"(\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\\\]\^\_\`\{\|\}\~)" <<
+ R"(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)";
+ // https://spec.commonmark.org/0.31.2/#example-13
+ QTest::newRow("literal backslashes") <<
+ QString(uR"(\→\A\a\ \3\φ\«)") <<
+ QString(uR"(\→\A\a\ \3\φ\«)");
+ // https://spec.commonmark.org/0.31.2/#example-14
+ QTest::newRow("escape to avoid em") <<
+ R"(\*not emphasized*)" <<
+ R"(*not emphasized*)";
+ QTest::newRow("escape to avoid html") <<
+ R"(\<br/> not a tag)" <<
+ R"(<br/> not a tag)";
+ QTest::newRow("escape to avoid link") <<
+ R"(\[not a link](/foo))" <<
+ R"([not a link](/foo))";
+ QTest::newRow("escape to avoid mono") <<
+ R"(\`not code`)" <<
+ R"(`not code`)";
+ QTest::newRow("escape to avoid num list") <<
+ R"(1\. not a list)" <<
+ R"(1. not a list)";
+ QTest::newRow("escape to avoid list") <<
+ R"(\* not a list)" <<
+ R"(* not a list)";
+ QTest::newRow("escape to avoid heading") <<
+ R"(\# not a heading)" <<
+ R"(# not a heading)";
+ QTest::newRow("escape to avoid reflink") <<
+ R"(\[foo]: /url "not a reference")" <<
+ R"([foo]: /url "not a reference")";
+ QTest::newRow("escape to avoid entity") <<
+ R"(\&ouml; not a character entity)" <<
+ R"(&ouml; not a character entity)";
+ // https://spec.commonmark.org/0.31.2/#example-15
+ QTest::newRow("escape backslash only") <<
+ R"(\\*emphasis*)" <<
+ R"(\emphasis)";
+ // https://spec.commonmark.org/0.31.2/#example-16
+ QTest::newRow("backslash line break") <<
+ "foo\\\nbar" <<
+ "foo\u2029bar";
+ // https://spec.commonmark.org/0.31.2/#example-17
+ QTest::newRow("backslash in mono span") <<
+ R"(`` \[\` ``)" <<
+ R"(\[\`)";
+ // https://spec.commonmark.org/0.31.2/#example-18
+ QTest::newRow("backslash in indented code") <<
+ R"( \[\])" <<
+ R"(\[\])";
+ // https://spec.commonmark.org/0.31.2/#example-19
+ QTest::newRow("backslash in fenced code") <<
+ "~~~\n\\[\\]\n~~~" <<
+ R"(\[\])";
+ // https://spec.commonmark.org/0.31.2/#example-20
+ QTest::newRow("backslash in autolink") <<
+ R"(<https://example.com?find=\*>)" <<
+ R"(https://example.com?find=\*)";
+ // https://spec.commonmark.org/0.31.2/#example-21
+ QTest::newRow("backslash in autolink") <<
+ "<a href=\"/bar\\/)\"" <<
+ "<a href=\"/bar/)\"";
+ // https://spec.commonmark.org/0.31.2/#example-22
+ QTest::newRow("escapes in link") <<
+ R"([foo](/bar\* "ti\*tle"))" <<
+ R"(foo)";
+ // https://spec.commonmark.org/0.31.2/#example-24
+ QTest::newRow("backslash in code lang") <<
+ "```\nfoo\\+bar\nfoo\n```" <<
+ "foo\\+bar\u2029foo";
+ // end of tests to verify that fixing QTBUG-122083 is safe
+ // (it's ok to add unrelated markdown-to-rawtext cases later)
+}
+
+void tst_QTextMarkdownImporter::toRawText()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, expectedRawText);
+
+ QTextDocument doc;
+ doc.setMarkdown(input);
+
+ // These are testing md4c more than Qt, so any change may be an md4c bug, or a fix
+ QCOMPARE(doc.toRawText(), expectedRawText);
+ if (doc.blockCount() == 1)
+ QCOMPARE(doc.firstBlock().text(), expectedRawText);
+}
+
QTEST_MAIN(tst_QTextMarkdownImporter)
#include "tst_qtextmarkdownimporter.moc"
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt b/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt
index 7779ee4267..0cdf1d9225 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt
@@ -5,9 +5,17 @@
## tst_qtextmarkdownwriter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextmarkdownwriter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
-list(APPEND test_data "data/example.md")
-list(APPEND test_data "data/blockquotes.md")
+file(GLOB_RECURSE test_data
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ data/*
+)
qt_internal_add_test(tst_qtextmarkdownwriter
SOURCES
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
index a021f15aba..8e605ef7e6 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md
@@ -8,17 +8,17 @@ MacFarlane writes:
> What distinguishes Markdown from many other lightweight markup syntaxes,
> which are often easier to write, is its readability. As Gruber writes:
-
+>
> > The overriding design goal for Markdown's formatting syntax is to make it
> > as readable as possible. The idea is that a Markdown-formatted document should
> > be publishable as-is, as plain text, without looking like it's been marked up
> > with tags or formatting instructions. (
> > <http://daringfireball.net/projects/markdown/> )
-
+>
> The point can be illustrated by comparing a sample of AsciiDoc with an
> equivalent sample of Markdown. Here is a sample of AsciiDoc from the AsciiDoc
> manual:
-
+>
> ```AsciiDoc
> 1. List item one.
> +
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotesWithLists.md b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotesWithLists.md
new file mode 100644
index 0000000000..1728889adc
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/blockquotesWithLists.md
@@ -0,0 +1,14 @@
+What if we have a quotation containing a list?
+
+> First some quoted text, and then a list:
+>
+> - one
+> - two is longer and has enough words to form a paragraph with text continuing
+> onto the next line
+>
+> enough of that, let's try a numbered list
+>
+> 1. List item one
+> 2. List item two is longer and has enough words to form a paragraph with
+> text continuing onto the next line.
+> \ No newline at end of file
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
index 15b30598e6..8fdad207ae 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
@@ -40,7 +40,7 @@ numerals in the same list structure:
1. Introduction
2. Qt Tools
1) Qt Assistant
- 2) Qt Designer
+ 2) Qt Widgets Designer
1. Form Editor
2. Component Architecture
3) Qt Linguist
@@ -70,7 +70,7 @@ column spans, text formatting within cells, and size constraints for columns.
|-------------|------------------------------------|---------------------------|-------------------------|
|9:00 - 11:00 |Introduction to Qt |||
|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt |
-|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles |
+|13:00 - 15:00|Qt Widgets Designer Tutorial |Extreme Programming |Writing Custom Styles |
|15:00 - 17:00|Qt Linguist and Internationalization|Test-Driven Development | |
*Try adding text to the cells in the table and experiment with the alignment of
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/listItemWithBlockquote.md b/tests/auto/gui/text/qtextmarkdownwriter/data/listItemWithBlockquote.md
new file mode 100644
index 0000000000..c417125fea
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/listItemWithBlockquote.md
@@ -0,0 +1,6 @@
+What if we have a list item containing a block quote?
+
+- one
+- > two is longer and has enough words to form a paragraph with text continuing
+ > onto the next line
+
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md b/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md
new file mode 100644
index 0000000000..72692b4845
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/longHeadings.md
@@ -0,0 +1,9 @@
+# The quick brown fox jumped over the lazy dog while the cat played the fiddle and the cow jumped over the moon
+
+Hey diddle diddle
+
+## This document has a verbose subheading too, which we do not expect to wrap in the output
+
+Qt can write it right. Long text here in this paragraph will actually wrap,
+even though its heading doesn't.
+
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/yaml.md b/tests/auto/gui/text/qtextmarkdownwriter/data/yaml.md
new file mode 100644
index 0000000000..41303a0187
--- /dev/null
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/yaml.md
@@ -0,0 +1,11 @@
+---
+name: "Venus"
+discoverer: "Galileo Galilei"
+title: "A description of the planet Venus"
+keywords:
+ - planets
+ - solar system
+ - astronomy
+---
+*Venus* is the second planet from the Sun, orbiting it every 224.7 Earth days.
+
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
index 36b494e550..0d261bc27e 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QTextDocument>
@@ -36,10 +36,19 @@ private slots:
void testWriteNestedNumericLists();
void testWriteNumericListWithStart();
void testWriteTable();
+ void frontMatter();
+ void charFormatWrapping_data();
+ void charFormatWrapping();
+ void charFormat_data();
+ void charFormat();
void rewriteDocument_data();
void rewriteDocument();
void fromHtml_data();
void fromHtml();
+ void fromPlainTextAndBack_data();
+ void fromPlainTextAndBack();
+ void escapeSpecialCharacters_data();
+ void escapeSpecialCharacters();
private:
bool isMainFontFixed();
@@ -48,6 +57,8 @@ private:
private:
QTextDocument *document;
+ QFont m_monoFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ QFont m_defaultFont;
};
void tst_QTextMarkdownWriter::init()
@@ -525,16 +536,231 @@ void tst_QTextMarkdownWriter::testWriteTable()
QCOMPARE(md, expected);
}
+void tst_QTextMarkdownWriter::frontMatter()
+{
+ QTextCursor cursor(document);
+ cursor.insertText("bar");
+ document->setMetaInformation(QTextDocument::FrontMatter, "foo");
+
+ const QString output = documentToUnixMarkdown();
+ const QString expectedOutput("---\nfoo\n---\nbar\n\n");
+ if (output != expectedOutput && isMainFontFixed())
+ QEXPECT_FAIL("", "fixed-pitch main font (QTBUG-103484)", Continue);
+ QCOMPARE(output, expectedOutput);
+}
+
+void tst_QTextMarkdownWriter::charFormatWrapping_data()
+{
+ QTest::addColumn<QTextFormat::Property>("property");
+ QTest::addColumn<QVariant>("propertyValue");
+ QTest::addColumn<QString>("followingText");
+ QTest::addColumn<QString>("expectedIndicator");
+
+ const QString spaced = " after";
+ const QString unspaced = ", and some more after";
+
+ QTest::newRow("FontFixedPitch-spaced")
+ << QTextFormat::FontFixedPitch << QVariant(true) << spaced << "`";
+ QTest::newRow("FontFixedPitch-unspaced")
+ << QTextFormat::FontFixedPitch << QVariant(true) << unspaced << "`";
+ QTest::newRow("FontItalic")
+ << QTextFormat::FontItalic << QVariant(true) << spaced << "*";
+ QTest::newRow("FontUnderline")
+ << QTextFormat::FontUnderline << QVariant(true) << spaced << "_";
+ QTest::newRow("FontStrikeOut")
+ << QTextFormat::FontStrikeOut << QVariant(true) << spaced << "~~";
+ QTest::newRow("FontWeight-spaced")
+ << QTextFormat::FontWeight << QVariant(700) << spaced << "**";
+ QTest::newRow("FontWeight-unspaced")
+ << QTextFormat::FontWeight << QVariant(700) << unspaced << "**";
+}
+
+void tst_QTextMarkdownWriter::charFormatWrapping() // QTBUG-116927
+{
+ QFETCH(QTextFormat::Property, property);
+ QFETCH(QVariant, propertyValue);
+ QFETCH(QString, expectedIndicator);
+ QFETCH(QString, followingText);
+
+ const QString newLine("\n");
+ QTextCursor cursor(document);
+ cursor.insertText("around sixty-four characters to go before some formatted words ");
+ QTextCharFormat fmt;
+ fmt.setProperty(property, propertyValue);
+ cursor.setCharFormat(fmt);
+ cursor.insertText("formatted text");
+
+ cursor.setCharFormat({});
+ cursor.insertText(followingText);
+ qsizetype lastNewLineIndex = 100;
+
+ for (int push = 0; push < 10; ++push) {
+ if (push > 0) {
+ cursor.movePosition(QTextCursor::StartOfBlock);
+ cursor.insertText("a");
+ }
+
+ const QString output = documentToUnixMarkdown().trimmed(); // get rid of trailing newlines
+ const auto nlIdx = output.indexOf(newLine);
+ qCDebug(lcTests) << "push" << push << ":" << output << "newline @" << nlIdx;
+ // we're always wrapping in this test: expect to find a newline
+ QCOMPARE_GT(nlIdx, 70);
+ // don't expect the newline to be more than one character to the right of where we found it last time
+ // i.e. if we already started breaking in the middle: "`formatted\ntext`",
+ // then we would not expect that prepending one more character would make it go
+ // back to breaking afterwards: "`formatted text`\n" (because then the line becomes longer than necessary)
+ QCOMPARE_LE(nlIdx, lastNewLineIndex + 1);
+ lastNewLineIndex = nlIdx;
+ const QString nextChars = output.sliced(nlIdx + newLine.size(), expectedIndicator.size());
+ const auto startingIndicatorIdx = output.indexOf(expectedIndicator);
+ // the starting indicator always exists, except in case of font problems on some CI platforms
+ if (startingIndicatorIdx <= 0)
+ QSKIP("starting indicator not found, probably due to platform font problems (QTBUG-103484 etc.)");
+ const auto endingIndicatorIdx = output.indexOf(expectedIndicator, startingIndicatorIdx + 5);
+ qCDebug(lcTests) << "next chars past newline" << nextChars
+ << "indicators @" << startingIndicatorIdx << endingIndicatorIdx;
+ // the closing indicator must exist
+ QCOMPARE_GT(endingIndicatorIdx, startingIndicatorIdx);
+ // don't start a new line with an ending indicator:
+ // we can have "**formatted\ntext**" or "**formatted text**\n" or "\n**formatted text**"
+ // but not "**formatted text\n**"
+ if (startingIndicatorIdx < nlIdx)
+ QCOMPARE_NE(nextChars, expectedIndicator);
+ }
+}
+
+void tst_QTextMarkdownWriter::charFormat_data()
+{
+ QTest::addColumn<QTextFormat::Property>("property");
+ QTest::addColumn<QVariant>("propertyValue");
+ QTest::addColumn<QFont>("explicitFont");
+ QTest::addColumn<QString>("expectedOutput");
+
+ const QTextFormat::Property NoProperty = QTextFormat::ObjectIndex;
+
+ QTest::newRow("FontFixedPitch")
+ << QTextFormat::FontFixedPitch << QVariant(true) << m_defaultFont
+ << "before `formatted` after";
+ if (!isFixedFontProportional()) {
+ // QTBUG-54623 QTBUG-75649 QTBUG-79900 QTBUG-103484 etc.
+ QTest::newRow("mono font") << NoProperty << QVariant() << m_monoFont
+ << "before `formatted` after";
+ }
+
+ {
+ QFont font;
+ font.setItalic(true);
+ QTest::newRow("italic font")
+ << NoProperty << QVariant() << font
+ << "before *formatted* after";
+ }
+ QTest::newRow("FontItalic")
+ << QTextFormat::FontItalic << QVariant(true) << m_defaultFont
+ << "before *formatted* after";
+
+ {
+ QFont font;
+ font.setUnderline(true);
+ QTest::newRow("underline font")
+ << NoProperty << QVariant() << font
+ << "before _formatted_ after";
+ }
+ QTest::newRow("FontUnderline")
+ << QTextFormat::FontUnderline << QVariant(true) << m_defaultFont
+ << "before _formatted_ after";
+
+ {
+ QFont font;
+ font.setStrikeOut(true);
+ QTest::newRow("strikeout font")
+ << NoProperty << QVariant() << font
+ << "before ~~formatted~~ after";
+ }
+ QTest::newRow("FontStrikeOut")
+ << QTextFormat::FontStrikeOut << QVariant(true) << m_defaultFont
+ << "before ~~formatted~~ after";
+
+ {
+ QFont font;
+ font.setBold(true);
+ QTest::newRow("bold font")
+ << NoProperty << QVariant() << font
+ << "before **formatted** after";
+ }
+ {
+ QFont font;
+ font.setWeight(QFont::Black);
+ QTest::newRow("black font")
+ << NoProperty << QVariant() << font
+ << "before **formatted** after";
+ }
+ QTest::newRow("FontWeight")
+ << QTextFormat::FontWeight << QVariant(700) << m_defaultFont
+ << "before **formatted** after";
+
+ QTest::newRow("AnchorHref")
+ << QTextFormat::AnchorHref << QVariant("linky linky") << m_defaultFont
+ << "before [formatted](linky linky) after";
+
+ QTest::newRow("TextToolTip") // no effect without AnchorHref
+ << QTextFormat::TextToolTip << QVariant("such a tool") << m_defaultFont
+ << "before formatted after";
+}
+
+void tst_QTextMarkdownWriter::charFormat()
+{
+ if (isMainFontFixed())
+ QSKIP("QTextMarkdownWriter would generate bogus backticks");
+
+ QFETCH(QTextFormat::Property, property);
+ QFETCH(QVariant, propertyValue);
+ QFETCH(QFont, explicitFont);
+ QFETCH(QString, expectedOutput);
+
+ QTextCursor cursor(document);
+ cursor.insertText("before ");
+
+ QTextCharFormat fmt;
+ if (explicitFont != m_defaultFont)
+ fmt.setFont(explicitFont);
+ if (property != QTextFormat::ObjectIndex) // != 0
+ fmt.setProperty(property, propertyValue);
+ if (explicitFont == m_monoFont) {
+ QFontInfo fontInfo(fmt.font());
+ qCDebug(lcTests) << "mono font" << explicitFont << "fontInfo fixedPitch" << fontInfo.fixedPitch() << "fmt fixedPitch" << fmt.fontFixedPitch();
+ }
+ cursor.setCharFormat(fmt);
+ cursor.insertText("formatted");
+
+ cursor.setCharFormat({});
+ cursor.insertText(" after");
+
+ const QString output = documentToUnixMarkdown();
+#ifdef DEBUG_WRITE_OUTPUT
+ {
+ QFile out(QDir::temp().filePath(QLatin1String(QTest::currentDataTag()) + ".md"));
+ out.open(QFile::WriteOnly);
+ out.write(output.toUtf8());
+ out.close();
+ }
+#endif
+ QCOMPARE(output.trimmed(), expectedOutput);
+}
+
void tst_QTextMarkdownWriter::rewriteDocument_data()
{
QTest::addColumn<QString>("inputFile");
QTest::newRow("block quotes") << "blockquotes.md";
+ QTest::newRow("block quotes with lists") << "blockquotesWithLists.md";
+ // QTest::newRow("list item with block quote") << "listItemWithBlockquote.md"; // not supported for now
QTest::newRow("example") << "example.md";
QTest::newRow("list items after headings") << "headingsAndLists.md";
QTest::newRow("word wrap") << "wordWrap.md";
QTest::newRow("links") << "links.md";
QTest::newRow("lists and code blocks") << "listsAndCodeBlocks.md";
+ QTest::newRow("front matter") << "yaml.md";
+ QTest::newRow("long headings") << "longHeadings.md";
}
void tst_QTextMarkdownWriter::rewriteDocument()
@@ -567,7 +793,7 @@ void tst_QTextMarkdownWriter::fromHtml_data()
QTest::newRow("long URL") <<
"<span style=\"font-style:italic;\">https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/</span>" <<
- "*https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/*\n\n";
+ "\n*https://www.example.com/dir/subdir/subsubdir/subsubsubdir/subsubsubsubdir/subsubsubsubsubdir/*\n\n";
QTest::newRow("non-emphasis inline asterisk") << "3 * 4" << "3 * 4\n\n";
QTest::newRow("arithmetic") << "(2 * a * x + b)^2 = b^2 - 4 * a * c" << "(2 * a * x + b)^2 = b^2 - 4 * a * c\n\n";
QTest::newRow("escaped asterisk after newline") <<
@@ -600,16 +826,42 @@ void tst_QTextMarkdownWriter::fromHtml_data()
QTest::newRow("code") <<
"<pre class=\"language-pseudocode\">\n#include \"foo.h\"\n\nblock {\n statement();\n}\n\n</pre>" <<
"```pseudocode\n#include \"foo.h\"\n\nblock {\n statement();\n}\n\n```\n\n";
- // TODO
-// QTest::newRow("escaped number and paren after double newline") <<
-// "<p>(The first sentence of this paragraph is a line, the next paragraph has a number</p>13) but that's not part of an ordered list" <<
-// "(The first sentence of this paragraph is a line, the next paragraph has a number\n\n13\\) but that's not part of an ordered list\n\n";
+ QTest::newRow("escaped number and paren after single newline") <<
+ "<p>(The first sentence of this paragraph is a line, next paragraph has a number 13) but that's not part of an ordered list</p>" <<
+ "(The first sentence of this paragraph is a line, next paragraph has a number\n13\\) but that's not part of an ordered list\n\n";
+ QTest::newRow("escaped number and paren after double newline") <<
+ "<p>(The first sentence of this paragraph is a line, the next paragraph has a number</p>13) but that's not part of an ordered list" <<
+ "(The first sentence of this paragraph is a line, the next paragraph has a number\n\n13\\) but that's not part of an ordered list\n\n";
QTest::newRow("preformats with embedded backticks") <<
"<pre>none `one` ``two``</pre>plain<pre>```three``` ````four````</pre>plain" <<
"```\nnone `one` ``two``\n\n```\nplain\n\n```\n```three``` ````four````\n\n```\nplain\n\n";
QTest::newRow("list items with and without checkboxes") <<
"<ul><li>bullet</li><li class=\"unchecked\">unchecked item</li><li class=\"checked\">checked item</li></ul>" <<
"- bullet\n- [ ] unchecked item\n- [x] checked item\n";
+ QTest::newRow("table with backslash in cell") << // QTBUG-96051
+ "<table><tr><td>1011011 [</td><td>1011100 backslash \\</td></tr></table>" <<
+ "|1011011 [|1011100 backslash \\\\|";
+ // https://spec.commonmark.org/0.31.2/#example-12
+ // escaping punctuation is ok, but QTextMarkdownWriter currently doesn't do that (which is also ok)
+ QTest::newRow("punctuation") <<
+ R"(<p>!&quot;#$%&amp;'()*+,-./:;&lt;=&gt;?@[\]^_`{|}~</p>)" <<
+ R"(!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~)";
+ // https://spec.commonmark.org/0.31.2/#example-14
+ QTest::newRow("backslash asterisk no emphasis") << // QTBUG-122083
+ R"(\*no emphasis*)" <<
+ R"(\\\*no emphasis*)";
+ // https://spec.commonmark.org/0.31.2/#example-15
+ QTest::newRow("backslash before emphasis") <<
+ R"(\<em>emphasis</em>)" <<
+ R"(\\*emphasis*)";
+ // https://spec.commonmark.org/0.31.2/#example-20
+ QTest::newRow("backslash-asterisk in autolink") <<
+ R"(<p><a href="https://example.com?find=\\*">https://example.com?find=\*</a></p>)" <<
+ R"(<https://example.com?find=\\*>)";
+ // https://spec.commonmark.org/0.31.2/#example-24
+ QTest::newRow("plus in fenced code lang") <<
+ "<pre class=\"language-foo+bar\">foo</pre>" <<
+ "```foo+bar\nfoo\n```";
}
void tst_QTextMarkdownWriter::fromHtml()
@@ -629,6 +881,137 @@ void tst_QTextMarkdownWriter::fromHtml()
}
#endif
+ output = output.trimmed();
+ expectedOutput = expectedOutput.trimmed();
+ if (output != expectedOutput && (isMainFontFixed() || isFixedFontProportional()))
+ QEXPECT_FAIL("", "fixed main font or proportional fixed font (QTBUG-103484)", Continue);
+ QCOMPARE(output, expectedOutput);
+}
+
+void tst_QTextMarkdownWriter::fromPlainTextAndBack_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expectedMarkdown");
+
+ // tests to verify that fixing QTBUG-122083 is safe
+ QTest::newRow("single backslashes") <<
+ R"(\ again: \ not esc: \* \-\-\ \*abc*)" <<
+ R"(\\ again: \\ not esc: \\* \\-\\-\\ \\\*abc*)";
+ // https://spec.commonmark.org/0.31.2/#example-12
+ QTest::newRow("punctuation") <<
+ R"(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)" <<
+ R"(!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~)";
+ // https://spec.commonmark.org/0.31.2/#example-13
+ QTest::newRow("literal backslashes") <<
+ QString(uR"(\→\A\a\ \3\φ\«)") <<
+ "\\\\\u2192\\\\A\\\\a\\\\ \\\\3\\\\\u03C6\\\\\u00AB";
+ // https://spec.commonmark.org/0.31.2/#example-14
+ QTest::newRow("escape to avoid em") <<
+ R"(*not emphasized*)" <<
+ R"(\*not emphasized*)";
+ QTest::newRow("escape to avoid html") <<
+ R"(<br/> not a tag)" <<
+ R"(\<br/> not a tag)";
+ QTest::newRow("escape to avoid link") <<
+ R"([not a link](/foo))" <<
+ R"(\[not a link](/foo))";
+ QTest::newRow("escape to avoid mono") <<
+ R"(`not code`)" <<
+ R"(\`not code`)";
+ QTest::newRow("escape to avoid num list") <<
+ R"(1. not a list)" <<
+ R"(1\. not a list)";
+ QTest::newRow("escape to avoid list") <<
+ R"(* not a list)" <<
+ R"(\* not a list)";
+ QTest::newRow("escape to avoid heading") <<
+ R"(# not a heading)" <<
+ R"(\# not a heading)";
+ QTest::newRow("escape to avoid reflink") <<
+ R"([foo]: /url "not a reference")" <<
+ R"(\[foo]: /url "not a reference")";
+ QTest::newRow("escape to avoid entity") <<
+ R"(&ouml; not a character entity)" <<
+ R"(\&ouml; not a character entity)";
+ // end of tests to verify that fixing QTBUG-122083 is safe
+ // (it's ok to add unrelated plain-to-markdown-to-plaintext cases later)
+}
+
+void tst_QTextMarkdownWriter::fromPlainTextAndBack()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, expectedMarkdown);
+
+ document->setPlainText(input);
+ QString output = documentToUnixMarkdown();
+
+#ifdef DEBUG_WRITE_OUTPUT
+ {
+ QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md");
+ out.open(QFile::WriteOnly);
+ out.write(output.toUtf8());
+ out.close();
+ }
+#endif
+
+ output = output.trimmed();
+ expectedMarkdown = expectedMarkdown.trimmed();
+ if (output != expectedMarkdown && (isMainFontFixed() || isFixedFontProportional()))
+ QSKIP("", "fixed main font or proportional fixed font (QTBUG-103484)");
+ QCOMPARE(output, expectedMarkdown);
+ QCOMPARE(document->toPlainText(), input);
+ document->setMarkdown(output);
+ QCOMPARE(document->toPlainText(), input);
+ if (document->blockCount() == 1)
+ QCOMPARE(document->firstBlock().text(), input);
+}
+
+void tst_QTextMarkdownWriter::escapeSpecialCharacters_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expectedOutput");
+
+ QTest::newRow("backslash") << "foo \\ bar \\\\ baz \\" << "foo \\\\ bar \\\\\\\\ baz \\\\";
+ QTest::newRow("not emphasized") << "*normal* **normal too**" << "\\*normal* \\**normal too**";
+ QTest::newRow("not code") << "`normal` `normal too`" << "\\`normal` \\`normal too`";
+ QTest::newRow("code fence") << "```not a fence; ``` no risk here; ```not a fence" // TODO slightly inconsistent
+ << "\\```not a fence; ``` no risk here; \\```not a fence";
+ QTest::newRow("not html") << "<p>not a tag: <br/> nope</p>" << "\\<p>not a tag: \\<br/> nope\\</p>";
+ QTest::newRow("not a link") << "text [not a link](/foo)" << "text \\[not a link](/foo)";
+ QTest::newRow("not a circle") << "* polaris" << "\\* polaris";
+ QTest::newRow("not a square") << "+ groovy" << "\\+ groovy";
+ QTest::newRow("not a bullet") << "- stayin alive" << "\\- stayin alive";
+ QTest::newRow("arithmetic") << "1 + 2 - 3 * 4" << "1 + 2 - 3 * 4";
+ QTest::newRow("not a list") << "1. not a list" << "1\\. not a list";
+ QTest::newRow("not a list either") << "Jupiter and 10." << "Jupiter and 10.";
+ QTest::newRow("not a heading") << "# not a heading" << "\\# not a heading";
+ QTest::newRow("a non-entity") << "&ouml; not a character entity" << "\\&ouml; not a character entity";
+}
+
+/*! \internal
+ If the user types into a Qt-based editor plain text that the
+ markdown parser would misinterpret, escape it when we save to markdown
+ to clarify that it's plain text.
+ https://spec.commonmark.org/0.31.2/#backslash-escapes
+*/
+void tst_QTextMarkdownWriter::escapeSpecialCharacters() // QTBUG-96051, QTBUG-122083
+{
+ QFETCH(QString, input);
+ QFETCH(QString, expectedOutput);
+
+ document->setPlainText(input);
+ QString output = documentToUnixMarkdown();
+
+#ifdef DEBUG_WRITE_OUTPUT
+ {
+ QFile out("/tmp/" + QLatin1String(QTest::currentDataTag()) + ".md");
+ out.open(QFile::WriteOnly);
+ out.write(output.toUtf8());
+ out.close();
+ }
+#endif
+
+ output = output.trimmed();
if (output != expectedOutput && (isMainFontFixed() || isFixedFontProportional()))
QEXPECT_FAIL("", "fixed main font or proportional fixed font (QTBUG-103484)", Continue);
QCOMPARE(output, expectedOutput);
diff --git a/tests/auto/gui/text/qtextobject/CMakeLists.txt b/tests/auto/gui/text/qtextobject/CMakeLists.txt
index a5d10f3d4f..dd7aeae60e 100644
--- a/tests/auto/gui/text/qtextobject/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextobject/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextobject Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextobject LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextobject
SOURCES
tst_qtextobject.cpp
diff --git a/tests/auto/gui/text/qtextobject/tst_qtextobject.cpp b/tests/auto/gui/text/qtextobject/tst_qtextobject.cpp
index 8a84dfd40c..e75dfcb270 100644
--- a/tests/auto/gui/text/qtextobject/tst_qtextobject.cpp
+++ b/tests/auto/gui/text/qtextobject/tst_qtextobject.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
diff --git a/tests/auto/gui/text/qtextodfwriter/CMakeLists.txt b/tests/auto/gui/text/qtextodfwriter/CMakeLists.txt
index 86134f02eb..d371fe2ee1 100644
--- a/tests/auto/gui/text/qtextodfwriter/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextodfwriter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextodfwriter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextodfwriter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextodfwriter
SOURCES
tst_qtextodfwriter.cpp
diff --git a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
index 3ae6046bdb..6b56e7c727 100644
--- a/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
+++ b/tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QTextDocument>
diff --git a/tests/auto/gui/text/qtextpiecetable/CMakeLists.txt b/tests/auto/gui/text/qtextpiecetable/CMakeLists.txt
index 27c803ca5b..8bdf17890c 100644
--- a/tests/auto/gui/text/qtextpiecetable/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextpiecetable/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextpiecetable LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
if(WIN32)
return()
endif()
diff --git a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
index cac84de7e2..f47d5dc0d6 100644
--- a/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
+++ b/tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -99,21 +99,21 @@ void tst_QTextPieceTable::cleanup()
void tst_QTextPieceTable::insertion1()
{
- table->insert(0, "aacc", charFormatIndex);
+ table->insert(0, u"aacc", charFormatIndex);
QCOMPARE(table->plainText(), QString("aacc"));
- table->insert(2, "bb", charFormatIndex);
+ table->insert(2, u"bb", charFormatIndex);
QCOMPARE(table->plainText(), QString("aabbcc"));
- table->insert(1, "1", charFormatIndex);
+ table->insert(1, u"1", charFormatIndex);
QCOMPARE(table->plainText(), QString("a1abbcc"));
- table->insert(6, "d", charFormatIndex);
+ table->insert(6, u"d", charFormatIndex);
QCOMPARE(table->plainText(), QString("a1abbcdc"));
- table->insert(8, "z", charFormatIndex);
+ table->insert(8, u"z", charFormatIndex);
QCOMPARE(table->plainText(), QString("a1abbcdcz"));
}
void tst_QTextPieceTable::insertion2()
{
- table->insert(0, "bb", charFormatIndex);
+ table->insert(0, u"bb", charFormatIndex);
QCOMPARE(table->plainText(), QString("bb"));
}
@@ -176,21 +176,21 @@ void tst_QTextPieceTable::insertion5()
void tst_QTextPieceTable::removal1()
{
- table->insert(0, "abbccc", charFormatIndex);
+ table->insert(0, u"abbccc", charFormatIndex);
QCOMPARE(table->plainText(), QString("abbccc"));
table->remove(1, 2);
QCOMPARE(table->plainText(), QString("accc"));
- table->insert(1, "1", charFormatIndex);
+ table->insert(1, u"1", charFormatIndex);
QCOMPARE(table->plainText(), QString("a1ccc"));
table->remove(4, 1);
QCOMPARE(table->plainText(), QString("a1cc"));
- table->insert(4, "z", charFormatIndex);
+ table->insert(4, u"z", charFormatIndex);
QCOMPARE(table->plainText(), QString("a1ccz"));
}
void tst_QTextPieceTable::removal2()
{
- table->insert(0, "bb", charFormatIndex);
+ table->insert(0, u"bb", charFormatIndex);
QCOMPARE(table->plainText(), QString("bb"));
table->remove(0, 2);
QCOMPARE(table->plainText(), QString(""));
@@ -199,7 +199,7 @@ void tst_QTextPieceTable::removal2()
table->remove(0, 1);
QCOMPARE(table->plainText(), QString(""));
- table->insert(0, "bb", charFormatIndex);
+ table->insert(0, u"bb", charFormatIndex);
QCOMPARE(table->plainText(), QString("bb"));
table->insertBlock(1, blockFormatIndex, charFormatIndex);
QCOMPARE(table->plainText(), QString("b") + QString(QChar(QChar::ParagraphSeparator)) + QString("b"));
@@ -270,16 +270,16 @@ void tst_QTextPieceTable::removal4()
void tst_QTextPieceTable::undoRedo1()
{
- table->insert(0, "01234567", charFormatIndex);
- table->insert(0, "a", charFormatIndex);
- table->insert(1, "b", charFormatIndex);
+ table->insert(0, u"01234567", charFormatIndex);
+ table->insert(0, u"a", charFormatIndex);
+ table->insert(1, u"b", charFormatIndex);
QCOMPARE(table->plainText(), QString("ab01234567"));
table->undo();
QCOMPARE(table->plainText(), QString("01234567"));
table->redo();
QCOMPARE(table->plainText(), QString("ab01234567"));
table->undo();
- table->insert(1, "c", charFormatIndex);
+ table->insert(1, u"c", charFormatIndex);
QCOMPARE(table->plainText(), QString("0c1234567"));
table->undo();
QCOMPARE(table->plainText(), QString("01234567"));
@@ -289,8 +289,8 @@ void tst_QTextPieceTable::undoRedo1()
void tst_QTextPieceTable::undoRedo2()
{
- table->insert(0, "01", charFormatIndex);
- table->insert(1, "a", charFormatIndex);
+ table->insert(0, u"01", charFormatIndex);
+ table->insert(1, u"a", charFormatIndex);
QCOMPARE(table->plainText(), QString("0a1"));
table->undo();
QCOMPARE(table->plainText(), QString("01"));
@@ -304,8 +304,8 @@ void tst_QTextPieceTable::undoRedo2()
void tst_QTextPieceTable::undoRedo3()
{
- table->insert(0, "01", charFormatIndex);
- table->insert(2, "ab", charFormatIndex);
+ table->insert(0, u"01", charFormatIndex);
+ table->insert(2, u"ab", charFormatIndex);
table->remove(2, 1);
QCOMPARE(table->plainText(), QString("01b"));
table->undo();
@@ -320,8 +320,8 @@ void tst_QTextPieceTable::undoRedo3()
void tst_QTextPieceTable::undoRedo4()
{
- table->insert(0, "01", charFormatIndex);
- table->insert(0, "ab", charFormatIndex);
+ table->insert(0, u"01", charFormatIndex);
+ table->insert(0, u"ab", charFormatIndex);
table->remove(0, 1);
QCOMPARE(table->plainText(), QString("b01"));
table->undo();
@@ -341,7 +341,7 @@ void tst_QTextPieceTable::undoRedo4()
void tst_QTextPieceTable::undoRedo5()
{
table->beginEditBlock();
- table->insert(0, "01", charFormatIndex);
+ table->insert(0, u"01", charFormatIndex);
table->remove(1, 1);
table->endEditBlock();
QCOMPARE(table->plainText(), QString("0"));
@@ -384,8 +384,8 @@ void tst_QTextPieceTable::undoRedo6()
void tst_QTextPieceTable::undoRedo7()
{
- table->insert(0, "a", charFormatIndex);
- table->insert(1, "b", charFormatIndex);
+ table->insert(0, u"a", charFormatIndex);
+ table->insert(1, u"b", charFormatIndex);
QCOMPARE(table->plainText(), QString("ab"));
table->undo();
@@ -394,8 +394,8 @@ void tst_QTextPieceTable::undoRedo7()
void tst_QTextPieceTable::undoRedo8()
{
- table->insert(0, "a", charFormatIndex);
- table->insert(1, "b", charFormatIndex);
+ table->insert(0, u"a", charFormatIndex);
+ table->insert(1, u"b", charFormatIndex);
QCOMPARE(table->plainText(), QString("ab"));
table->remove(0, 1);
@@ -408,8 +408,8 @@ void tst_QTextPieceTable::undoRedo8()
void tst_QTextPieceTable::undoRedo9()
{
- table->insert(0, "a", charFormatIndex);
- table->insert(1, "b", charFormatIndex);
+ table->insert(0, u"a", charFormatIndex);
+ table->insert(1, u"b", charFormatIndex);
QCOMPARE(table->plainText(), QString("ab"));
table->remove(1, 1);
@@ -430,9 +430,9 @@ void tst_QTextPieceTable::undoRedo10()
QTextBlockFormat f;
int idx = table->formatCollection()->indexForFormat(f);
- table->insert(0, "a", cfIdx);
+ table->insert(0, u"a", cfIdx);
table->insertBlock(1, idx, cfIdx);
- table->insert(1, "b", cfIdx);
+ table->insert(1, u"b", cfIdx);
cf.setForeground(Qt::red);
int newCfIdx = table->formatCollection()->indexForFormat(cf);
@@ -485,7 +485,7 @@ void tst_QTextPieceTable::checkDocumentChanged()
// single insert
layout->expect(0, 0, 15);
- table->insert(0, "012345678901234", charFormatIndex);
+ table->insert(0, u"012345678901234", charFormatIndex);
QVERIFY(!layout->error);
// single remove
@@ -496,7 +496,7 @@ void tst_QTextPieceTable::checkDocumentChanged()
// symmetric insert/remove
layout->expect(0, 0, 0);
table->beginEditBlock();
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->remove(0, 5);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -504,7 +504,7 @@ void tst_QTextPieceTable::checkDocumentChanged()
layout->expect(0, 5, 5);
table->beginEditBlock();
table->remove(0, 5);
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -512,13 +512,13 @@ void tst_QTextPieceTable::checkDocumentChanged()
layout->expect(0, 3, 5);
table->beginEditBlock();
table->remove(0, 3);
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 0, 2);
table->beginEditBlock();
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->remove(0, 3);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -526,14 +526,14 @@ void tst_QTextPieceTable::checkDocumentChanged()
// insert + remove inside insert block
layout->expect(0, 0, 2);
table->beginEditBlock();
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->remove(1, 3);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 0, 2);
table->beginEditBlock();
- table->insert(0, "01234", charFormatIndex);
+ table->insert(0, u"01234", charFormatIndex);
table->remove(2, 3);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -541,42 +541,42 @@ void tst_QTextPieceTable::checkDocumentChanged()
// insert + remove partly outside
layout->expect(0, 1, 0);
table->beginEditBlock();
- table->insert(1, "0", charFormatIndex);
+ table->insert(1, u"0", charFormatIndex);
table->remove(0, 2);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 1, 1);
table->beginEditBlock();
- table->insert(1, "01", charFormatIndex);
+ table->insert(1, u"01", charFormatIndex);
table->remove(0, 2);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 1, 2);
table->beginEditBlock();
- table->insert(1, "012", charFormatIndex);
+ table->insert(1, u"012", charFormatIndex);
table->remove(0, 2);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(1, 1, 0);
table->beginEditBlock();
- table->insert(1, "0", charFormatIndex);
+ table->insert(1, u"0", charFormatIndex);
table->remove(1, 2);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(1, 1, 1);
table->beginEditBlock();
- table->insert(1, "01", charFormatIndex);
+ table->insert(1, u"01", charFormatIndex);
table->remove(2, 2);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(1, 1, 2);
table->beginEditBlock();
- table->insert(1, "012", charFormatIndex);
+ table->insert(1, u"012", charFormatIndex);
table->remove(3, 2);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -584,14 +584,14 @@ void tst_QTextPieceTable::checkDocumentChanged()
// insert + remove non overlapping
layout->expect(0, 1, 1);
table->beginEditBlock();
- table->insert(1, "0", charFormatIndex);
+ table->insert(1, u"0", charFormatIndex);
table->remove(0, 1);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 2, 2);
table->beginEditBlock();
- table->insert(2, "1", charFormatIndex);
+ table->insert(2, u"1", charFormatIndex);
table->remove(0, 1);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -599,14 +599,14 @@ void tst_QTextPieceTable::checkDocumentChanged()
layout->expect(0, 2, 2);
table->beginEditBlock();
table->remove(0, 1);
- table->insert(1, "0", charFormatIndex);
+ table->insert(1, u"0", charFormatIndex);
table->endEditBlock();
QVERIFY(!layout->error);
layout->expect(0, 3, 3);
table->beginEditBlock();
table->remove(0, 1);
- table->insert(2, "1", charFormatIndex);
+ table->insert(2, u"1", charFormatIndex);
table->endEditBlock();
@@ -631,9 +631,9 @@ void tst_QTextPieceTable::checkDocumentChanged2()
layout->expect(0, 0, 12);
table->beginEditBlock();
- table->insert(0, "0123", charFormatIndex);
- table->insert(4, "4567", anotherCharFormatIndex);
- table->insert(8, "8901", charFormatIndex);
+ table->insert(0, u"0123", charFormatIndex);
+ table->insert(4, u"4567", anotherCharFormatIndex);
+ table->insert(8, u"8901", charFormatIndex);
table->endEditBlock();
QVERIFY(!layout->error);
@@ -696,7 +696,7 @@ void tst_QTextPieceTable::blockInsertion2()
int pos = 0;
table->insertBlock(pos, blockFormatIndex, charFormatIndex);
pos += 1;
- table->insert(pos, "a", charFormatIndex);
+ table->insert(pos, u"a", charFormatIndex);
pos += 1;
pos -= 1;
@@ -719,11 +719,11 @@ void tst_QTextPieceTable::blockRemoval1()
int idx1 = table->formatCollection()->indexForFormat(fmt1);
int idx2 = table->formatCollection()->indexForFormat(fmt2);
- table->insert(0, "0123", charFormatIndex);
+ table->insert(0, u"0123", charFormatIndex);
table->insertBlock(4, idx1, charFormatIndex);
- table->insert(5, "5678", charFormatIndex);
+ table->insert(5, u"5678", charFormatIndex);
table->insertBlock(9, idx2, charFormatIndex);
- table->insert(10, "0123", charFormatIndex);
+ table->insert(10, u"0123", charFormatIndex);
QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
@@ -767,11 +767,11 @@ void tst_QTextPieceTable::blockRemoval2()
int idx1 = table->formatCollection()->indexForFormat(fmt1);
int idx2 = table->formatCollection()->indexForFormat(fmt2);
- table->insert(0, "0123", charFormatIndex);
+ table->insert(0, u"0123", charFormatIndex);
table->insertBlock(4, idx1, charFormatIndex);
- table->insert(5, "5678", charFormatIndex);
+ table->insert(5, u"5678", charFormatIndex);
table->insertBlock(9, idx2, charFormatIndex);
- table->insert(10, "0123", charFormatIndex);
+ table->insert(10, u"0123", charFormatIndex);
QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
@@ -813,11 +813,11 @@ void tst_QTextPieceTable::blockRemoval3()
int idx1 = table->formatCollection()->indexForFormat(fmt1);
int idx2 = table->formatCollection()->indexForFormat(fmt2);
- table->insert(0, "0123", charFormatIndex);
+ table->insert(0, u"0123", charFormatIndex);
table->insertBlock(4, idx1, charFormatIndex);
- table->insert(5, "5678", charFormatIndex);
+ table->insert(5, u"5678", charFormatIndex);
table->insertBlock(9, idx2, charFormatIndex);
- table->insert(10, "0123", charFormatIndex);
+ table->insert(10, u"0123", charFormatIndex);
QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
@@ -910,11 +910,11 @@ void tst_QTextPieceTable::blockRemoval5()
int idx1 = table->formatCollection()->indexForFormat(fmt1);
int idx2 = table->formatCollection()->indexForFormat(fmt2);
- table->insert(0, "0123", charFormatIndex);
+ table->insert(0, u"0123", charFormatIndex);
table->insertBlock(4, idx1, charFormatIndex);
- table->insert(5, "5678", charFormatIndex);
+ table->insert(5, u"5678", charFormatIndex);
table->insertBlock(9, idx2, charFormatIndex);
- table->insert(10, "0123", charFormatIndex);
+ table->insert(10, u"0123", charFormatIndex);
QCOMPARE(table->blocksFind(0).blockFormat(), QTextBlockFormat());
QCOMPARE(table->blocksFind(4).blockFormat(), QTextBlockFormat());
@@ -962,7 +962,7 @@ void tst_QTextPieceTable::checkBlockSeparation()
void tst_QTextPieceTable::checkFrames1()
{
QTextFrameFormat ffmt;
- table->insert(0, "Hello", charFormatIndex);
+ table->insert(0, u"Hello", charFormatIndex);
QPointer<QTextFrame> frame = table->insertFrame(1, 3, ffmt);
QTextFrame *root = table->rootFrame();
@@ -1031,7 +1031,7 @@ void tst_QTextPieceTable::checkFrames1()
void tst_QTextPieceTable::removeFrameDirect()
{
QTextFrameFormat ffmt;
- table->insert(0, "Hello", charFormatIndex);
+ table->insert(0, u"Hello", charFormatIndex);
QTextFrame *frame = table->insertFrame(1, 5, ffmt);
@@ -1065,7 +1065,7 @@ void tst_QTextPieceTable::removeWithChildFrame()
In this case frameAt(2) != frameAt(6), so the assertion in remove() needed an adjustement.
*/
QTextFrameFormat ffmt;
- table->insert(0, "Hello World", charFormatIndex);
+ table->insert(0, u"Hello World", charFormatIndex);
QTextFrame *frame = table->insertFrame(1, 6, ffmt);
QTextFrame *childFrame = table->insertFrame(3, 5, ffmt);
@@ -1095,7 +1095,7 @@ void tst_QTextPieceTable::clearWithFrames()
The idea is to remove from [1] until [7].
*/
QTextFrameFormat ffmt;
- table->insert(0, "Hello World", charFormatIndex);
+ table->insert(0, u"Hello World", charFormatIndex);
QTextFrame *firstFrame = table->insertFrame(1, 2, ffmt);
QTextFrame *secondFrame = table->insertFrame(4, 6, ffmt);
diff --git a/tests/auto/gui/text/qtextscriptengine/CMakeLists.txt b/tests/auto/gui/text/qtextscriptengine/CMakeLists.txt
index 9307e01b85..9bb9e4c13b 100644
--- a/tests/auto/gui/text/qtextscriptengine/CMakeLists.txt
+++ b/tests/auto/gui/text/qtextscriptengine/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtextscriptengine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtextscriptengine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtextscriptengine
SOURCES
tst_qtextscriptengine.cpp
diff --git a/tests/auto/gui/text/qtextscriptengine/generate/main.cpp b/tests/auto/gui/text/qtextscriptengine/generate/main.cpp
index fa0512fb50..5082c2b406 100644
--- a/tests/auto/gui/text/qtextscriptengine/generate/main.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/generate/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QApplication>
diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
index d3267d024b..975658005e 100644
--- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
+++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <private/qfontengine_p.h>
@@ -56,9 +56,6 @@ private slots:
void shapingDisabledDevanagari();
void shapingDisabledLatin();
-
- void privateUseArea();
-
private:
bool haveTestFonts;
};
@@ -1097,11 +1094,12 @@ void tst_QTextScriptEngine::combiningMarks_qtbug15675_data()
bool hasTests = false;
- QStringList families;
- families << QStringLiteral("Monaco");
- families << QStringLiteral("DejaVu Sans Mono");
+ const QString families[] = {
+ QStringLiteral("Monaco"),
+ QStringLiteral("DejaVu Sans Mono"),
+ };
- foreach (const QString &family, families) {
+ for (const QString &family : families) {
QFont font(family);
font.setStyleStrategy(QFont::NoFontMerging);
if (QFontInfo(font).family() != family)
@@ -1315,41 +1313,5 @@ void tst_QTextScriptEngine::shapingDisabledDevanagari()
QCOMPARE(noShapingRuns.first().glyphIndexes().size(), normalRuns.first().glyphIndexes().size());
}
-void tst_QTextScriptEngine::privateUseArea()
-{
- QString privateUseAreaString = QString::fromUtf8("");
-
- QFont font;
- QList<QGlyphRun> withFontMerging;
- {
- QTextLayout layout;
- layout.setText(privateUseAreaString);
- layout.setFont(font);
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
-
- withFontMerging = layout.glyphRuns();
- }
-
- font.setStyleStrategy(QFont::NoFontMerging);
- QList<QGlyphRun> withoutFontMerging;
- {
- QTextLayout layout;
- layout.setText(privateUseAreaString);
- layout.setFont(font);
- layout.beginLayout();
- layout.createLine();
- layout.endLayout();
-
- withoutFontMerging = layout.glyphRuns();
- }
-
- QCOMPARE(withFontMerging.size(), withoutFontMerging.size());
-
- for (int i = 0; i < withFontMerging.size(); ++i)
- QCOMPARE(withFontMerging.at(i).glyphIndexes(), withoutFontMerging.at(i).glyphIndexes());
-}
-
QTEST_MAIN(tst_QTextScriptEngine)
#include "tst_qtextscriptengine.moc"
diff --git a/tests/auto/gui/text/qtexttable/CMakeLists.txt b/tests/auto/gui/text/qtexttable/CMakeLists.txt
index 5b23903ffc..e83a38f087 100644
--- a/tests/auto/gui/text/qtexttable/CMakeLists.txt
+++ b/tests/auto/gui/text/qtexttable/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qtexttable Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtexttable LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtexttable
SOURCES
tst_qtexttable.cpp
diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
index ae5502852c..a7e319ef62 100644
--- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
+++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -75,6 +75,8 @@ private slots:
#endif
void checkBorderAttributes_data();
void checkBorderAttributes();
+ void checkTableBorderAttributes_data();
+ void checkTableBorderAttributes();
#ifndef QT_NO_WIDGETS
void columnWidthWithSpans();
@@ -1234,6 +1236,7 @@ void tst_QTextTable::checkBorderAttributes()
QFETCH(QBrush, leftBorderBrush);
QFETCH(QBrush, rightBorderBrush);
+#ifndef QT_NO_TEXTHTMLPARSER
QTextDocument doc;
doc.setHtml(html);
QTextCursor cursor(doc.firstBlock());
@@ -1259,6 +1262,75 @@ void tst_QTextTable::checkBorderAttributes()
QCOMPARE(cellFormat.brushProperty(QTextFormat::TableCellRightBorderBrush), rightBorderBrush);
}
}
+#endif
+}
+
+void tst_QTextTable::checkTableBorderAttributes_data()
+{
+ QTest::addColumn<QString>("html");
+ QTest::addColumn<qreal>("tableBorderWidth");
+ QTest::addColumn<QTextFrameFormat::BorderStyle>("tableBorderStyle");
+ QTest::addColumn<QBrush>("tableBorderBrush");
+
+ const QString tableHtmlStart = QStringLiteral("<html><head><style>");
+ const QString tableHtmlEnd1 = QStringLiteral("</style></head><body>"
+ "<table><tr><td>One</td><td>Two</td></tr></table>"
+ "</body></html>");
+ const QString tableHtmlEnd2 = QStringLiteral("</style></head><body>"
+ "<table border=10><tr><td>One</td><td>Two</td></tr></table>"
+ "</body></html>");
+
+ QTest::newRow("table-border-attributes-shorthand")
+ << QString("%1"
+ "table {"
+ "border: 2px solid red;"
+ "}"
+ "%2").arg(tableHtmlStart).arg(tableHtmlEnd1)
+ << 2.0 << QTextFrameFormat::BorderStyle_Solid << QBrush(Qt::red);
+
+ QTest::newRow("table-border-attributes-explicit")
+ << QString("%1"
+ "table {"
+ "border-width: 2px;"
+ "border-color: red;"
+ "border-style: dashed;"
+ "}"
+ "%2").arg(tableHtmlStart).arg(tableHtmlEnd1)
+ << 2.0 << QTextFrameFormat::BorderStyle_Dashed << QBrush(Qt::red);
+
+ QTest::newRow("table-border-override")
+ << QString("%1"
+ "table {"
+ "border: 2px solid red;"
+ "}"
+ "%2").arg(tableHtmlStart).arg(tableHtmlEnd2)
+ << 2.0 << QTextFrameFormat::BorderStyle_Solid << QBrush(Qt::red);
+
+ QTest::newRow("table-border-default")
+ << QString("%1"
+ "%2").arg(tableHtmlStart).arg(tableHtmlEnd2)
+ << 10.0 << QTextFrameFormat::BorderStyle_Outset << QBrush(Qt::darkGray);
+}
+
+void tst_QTextTable::checkTableBorderAttributes()
+{
+ QFETCH(QString, html);
+ QFETCH(qreal, tableBorderWidth);
+ QFETCH(QTextFrameFormat::BorderStyle, tableBorderStyle);
+ QFETCH(QBrush, tableBorderBrush);
+
+#ifndef QT_NO_TEXTHTMLPARSER
+ QTextDocument doc;
+ doc.setHtml(html);
+ QTextCursor cursor(doc.firstBlock());
+ cursor.movePosition(QTextCursor::Right);
+
+ QTextTable *currentTable = cursor.currentTable();
+ QVERIFY(currentTable);
+ QCOMPARE(currentTable->format().border(), tableBorderWidth);
+ QCOMPARE(currentTable->format().borderStyle(), tableBorderStyle);
+ QCOMPARE(currentTable->format().borderBrush(), tableBorderBrush);
+#endif
}
#ifndef QT_NO_WIDGETS
@@ -1317,6 +1389,7 @@ void tst_QTextTable::columnWidthWithImage()
QFETCH(QString, rightHtml);
QFETCH(QSize, imageSize);
+#ifndef QT_NO_TEXTHTMLPARSER
QTextDocument doc;
doc.setHtml(tableTemplate.arg(leftHtml).arg(rightHtml));
QTextEdit textEdit;
@@ -1336,6 +1409,7 @@ void tst_QTextTable::columnWidthWithImage()
const QRectF rightRect = currentTable->document()->documentLayout()->blockBoundingRect(block);
QCOMPARE(leftRect.size().toSize(), imageSize);
QVERIFY(rightRect.left() > leftRect.right());
+#endif
}
#endif
diff --git a/tests/auto/gui/text/qzip/.gitignore b/tests/auto/gui/text/qzip/.gitignore
deleted file mode 100644
index 2d7dfbe70c..0000000000
--- a/tests/auto/gui/text/qzip/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qzip
diff --git a/tests/auto/gui/text/qzip/CMakeLists.txt b/tests/auto/gui/text/qzip/CMakeLists.txt
deleted file mode 100644
index 73bf0fda7f..0000000000
--- a/tests/auto/gui/text/qzip/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-#####################################################################
-## tst_qzip Test:
-#####################################################################
-
-# Collect test data
-file(GLOB_RECURSE test_data
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- testdata/*
-)
-
-qt_internal_add_test(tst_qzip
- SOURCES
- tst_qzip.cpp
- LIBRARIES
- Qt::Gui
- Qt::GuiPrivate
- TESTDATA ${test_data}
-)
diff --git a/tests/auto/gui/text/qzip/testdata/symlink.zip b/tests/auto/gui/text/qzip/testdata/symlink.zip
deleted file mode 100644
index 027f96477a..0000000000
--- a/tests/auto/gui/text/qzip/testdata/symlink.zip
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/text/qzip/testdata/test.zip b/tests/auto/gui/text/qzip/testdata/test.zip
deleted file mode 100644
index a57ba4e2a9..0000000000
--- a/tests/auto/gui/text/qzip/testdata/test.zip
+++ /dev/null
Binary files differ
diff --git a/tests/auto/gui/text/qzip/tst_qzip.cpp b/tests/auto/gui/text/qzip/tst_qzip.cpp
deleted file mode 100644
index 3e2dc39983..0000000000
--- a/tests/auto/gui/text/qzip/tst_qzip.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <QTest>
-#include <QDebug>
-#include <QBuffer>
-
-#include <private/qzipwriter_p.h>
-#include <private/qzipreader_p.h>
-
-class tst_QZip : public QObject
-{
- Q_OBJECT
-
-private slots:
- void basicUnpack();
- void symlinks();
- void readTest();
- void createArchive();
-};
-
-void tst_QZip::basicUnpack()
-{
- QZipReader zip(QFINDTESTDATA("/testdata/test.zip"), QIODevice::ReadOnly);
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.size(), 2);
-
- QZipReader::FileInfo fi = files.at(0);
- QVERIFY(fi.isValid());
- QCOMPARE(fi.filePath, QString("test"));
- QCOMPARE(uint(fi.isDir), (uint) 1);
- QCOMPARE(uint(fi.isFile), (uint) 0);
- QCOMPARE(uint(fi.isSymLink), (uint) 0);
-
- QCOMPARE(fi.permissions,QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner
- | QFile::ReadUser | QFile::WriteUser | QFile::ExeUser ));
-
- QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
-
- fi = files.at(1);
- QVERIFY(fi.isValid());
- QCOMPARE(fi.filePath, QString("test/test.txt"));
- QCOMPARE(uint(fi.isDir), (uint) 0);
- QCOMPARE(uint(fi.isFile), (uint) 1);
- QCOMPARE(uint(fi.isSymLink), (uint) 0);
-
- QVERIFY(fi.permissions == QFile::Permissions( QFile::ReadOwner | QFile::WriteOwner
- | QFile::ReadUser | QFile::WriteUser ));
-
- QCOMPARE(fi.lastModified, QDateTime::fromString("2005.11.11 13:08:02", "yyyy.MM.dd HH:mm:ss"));
-
- QCOMPARE(zip.fileData("test/test.txt"), QByteArray("content\n"));
-
- fi = zip.entryInfoAt(-1);
- QVERIFY(!fi.isValid());
-}
-
-void tst_QZip::symlinks()
-{
- QZipReader zip(QFINDTESTDATA("/testdata/symlink.zip"), QIODevice::ReadOnly);
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.size(), 2);
-
- QZipReader::FileInfo fi = files.at(0);
- QVERIFY(fi.isValid());
- QCOMPARE(fi.filePath, QString("symlink"));
- QVERIFY(!fi.isDir);
- QVERIFY(!fi.isFile);
- QVERIFY(fi.isSymLink);
-
- QCOMPARE(zip.fileData("symlink"), QByteArray("destination"));
-
- fi = files.at(1);
- QVERIFY(fi.isValid());
- QCOMPARE(fi.filePath, QString("destination"));
- QVERIFY(!fi.isDir);
- QVERIFY(fi.isFile);
- QVERIFY(!fi.isSymLink);
-}
-
-void tst_QZip::readTest()
-{
- QZipReader zip("foobar.zip", QIODevice::ReadOnly); // non existing file.
- QList<QZipReader::FileInfo> files = zip.fileInfoList();
- QCOMPARE(files.size(), 0);
- QByteArray b = zip.fileData("foobar");
- QCOMPARE(b.size(), 0);
-}
-
-void tst_QZip::createArchive()
-{
- QBuffer buffer;
- QZipWriter zip(&buffer);
- QByteArray fileContents("simple file contents\nline2\n");
- zip.addFile("My Filename", fileContents);
- zip.close();
- QByteArray zipFile = buffer.buffer();
-
- // QFile f("createArchiveTest.zip"); f.open(QIODevice::WriteOnly); f.write(zipFile); f.close();
-
- QBuffer buffer2(&zipFile);
- QZipReader zip2(&buffer2);
- QList<QZipReader::FileInfo> files = zip2.fileInfoList();
- QCOMPARE(files.size(), 1);
- QZipReader::FileInfo file = files.at(0);
- QCOMPARE(file.filePath, QString("My Filename"));
- QCOMPARE(uint(file.isDir), (uint) 0);
- QCOMPARE(uint(file.isFile), (uint) 1);
- QCOMPARE(uint(file.isSymLink), (uint) 0);
- QCOMPARE(file.permissions, QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadUser | QFile::WriteUser) );
- QCOMPARE(file.size, (long long) 27);
- QCOMPARE(zip2.fileData("My Filename"), fileContents);
-}
-
-QTEST_MAIN(tst_QZip)
-#include "tst_qzip.moc"
diff --git a/tests/auto/gui/util/CMakeLists.txt b/tests/auto/gui/util/CMakeLists.txt
index 830a9ff2f0..1efdf85b97 100644
--- a/tests/auto/gui/util/CMakeLists.txt
+++ b/tests/auto/gui/util/CMakeLists.txt
@@ -1,10 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-add_subdirectory(qdesktopservices)
+if(QT_FEATURE_desktopservices)
+ add_subdirectory(qdesktopservices)
+endif()
add_subdirectory(qdoublevalidator)
add_subdirectory(qintvalidator)
add_subdirectory(qregularexpressionvalidator)
add_subdirectory(qtexturefilereader)
-add_subdirectory(qundogroup)
-add_subdirectory(qundostack)
+if(QT_FEATURE_undogroup)
+ add_subdirectory(qundogroup)
+endif()
+if(QT_FEATURE_undocommand)
+ add_subdirectory(qundostack)
+endif()
diff --git a/tests/auto/gui/util/qdesktopservices/CMakeLists.txt b/tests/auto/gui/util/qdesktopservices/CMakeLists.txt
index dd66083c28..64a1aaa930 100644
--- a/tests/auto/gui/util/qdesktopservices/CMakeLists.txt
+++ b/tests/auto/gui/util/qdesktopservices/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qdesktopservices Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qdesktopservices LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qdesktopservices
SOURCES
tst_qdesktopservices.cpp
diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
index b338e01684..e75626eda7 100644
--- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
+++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -42,10 +42,6 @@ public slots:
}
};
-#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
-# define CAN_IMPLICITLY_UNSET
-#endif
-
void tst_qdesktopservices::handlers()
{
MyUrlHandler fooHandler;
@@ -53,12 +49,10 @@ void tst_qdesktopservices::handlers()
QDesktopServices::setUrlHandler(QString("foo"), &fooHandler, "handle");
QDesktopServices::setUrlHandler(QString("bar"), &barHandler, "handle");
-#ifndef CAN_IMPLICITLY_UNSET
const auto unsetHandlers = qScopeGuard([] {
QDesktopServices::unsetUrlHandler(u"bar"_s);
QDesktopServices::unsetUrlHandler(u"foo"_s);
});
-#endif
QUrl fooUrl("foo://blub/meh");
QUrl barUrl("bar://hmm/hmmmm");
@@ -68,15 +62,6 @@ void tst_qdesktopservices::handlers()
QCOMPARE(fooHandler.lastHandledUrl.toString(), fooUrl.toString());
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString());
-
-#ifdef CAN_IMPLICITLY_UNSET
- for (int i = 0; i < 2; ++i)
- QTest::ignoreMessage(QtWarningMsg,
- "Please call QDesktopServices::unsetUrlHandler() before destroying a "
- "registered URL handler object.\n"
- "Support for destroying a registered URL handler object is deprecated, "
- "and will be removed in Qt 6.6.");
-#endif
}
QTEST_MAIN(tst_qdesktopservices)
diff --git a/tests/auto/gui/util/qdoublevalidator/CMakeLists.txt b/tests/auto/gui/util/qdoublevalidator/CMakeLists.txt
index 272efd8168..f79fe8b00c 100644
--- a/tests/auto/gui/util/qdoublevalidator/CMakeLists.txt
+++ b/tests/auto/gui/util/qdoublevalidator/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qdoublevalidator Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qdoublevalidator LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qdoublevalidator
SOURCES
tst_qdoublevalidator.cpp
diff --git a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
index 859c198595..b44975ea0b 100644
--- a/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
+++ b/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -417,7 +417,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("C standard with invalid digit grouping")
<< "C" << QDoubleValidator::StandardNotation << -1 << "1,234,5.678"
<< "12345.678";
- QTest::newRow("C standard with invalid number of decimals")
+ QTest::newRow("C standard with invalid group size")
<< "C" << QDoubleValidator::StandardNotation << 2 << "-12,34.678"
<< "-1234.68";
QTest::newRow("C standard truncate decimals")
@@ -446,7 +446,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("C scientific with invalid digit grouping")
<< "C" << QDoubleValidator::ScientificNotation << -1 << "12,34.98765e2"
<< "1.23498765e+05";
- QTest::newRow("C scientific with invalid number of decimals")
+ QTest::newRow("C scientific with invalid group size")
<< "C" << QDoubleValidator::ScientificNotation << 2 << "-12,34.98765e2"
<< "-1.23e+05";
QTest::newRow("C scientific truncate decimals")
@@ -486,7 +486,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("en standard with invalid digit grouping")
<< "en" << QDoubleValidator::StandardNotation << -1 << "-1,234,5.678"
<< "-12,345.678";
- QTest::newRow("en standard with invalid number of decimals")
+ QTest::newRow("en standard with invalid group size")
<< "en" << QDoubleValidator::StandardNotation << 2 << "12,34.678"
<< "1,234.68";
QTest::newRow("en standard no fractional part")
@@ -502,7 +502,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("en scientific with invalid digit grouping")
<< "en" << QDoubleValidator::ScientificNotation << -1 << "-12,34.98765e2"
<< "-1.23498765E+05";
- QTest::newRow("en scientific with invalid number of decimals")
+ QTest::newRow("en scientific with invalid group size")
<< "en" << QDoubleValidator::ScientificNotation << 2 << "12,34.98765e2"
<< "1.23E+05";
QTest::newRow("en scientific no fractional part")
@@ -529,7 +529,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("de standard with invalid digit grouping")
<< "de" << QDoubleValidator::StandardNotation << -1 << "1.234.5,678"
<< "12.345,678";
- QTest::newRow("de standard with invalid number of decimals")
+ QTest::newRow("de standard with invalid group size")
<< "de" << QDoubleValidator::StandardNotation << 2 << "-12.34,678"
<< "-1.234,68";
QTest::newRow("de standard no fractional part")
@@ -544,7 +544,7 @@ void tst_QDoubleValidator::fixup_data()
QTest::newRow("de scientific with invalid digit grouping")
<< "de" << QDoubleValidator::ScientificNotation << -1 << "12.34,98765e2"
<< "1,23498765E+05";
- QTest::newRow("de scientific with invalid number of decimals")
+ QTest::newRow("de scientific with invalid group size")
<< "de" << QDoubleValidator::ScientificNotation << 2 << "-12.34,98765e2"
<< "-1,23E+05";
QTest::newRow("de scientific no fractional part")
@@ -560,6 +560,22 @@ void tst_QDoubleValidator::fixup_data()
<< "de" << QDoubleValidator::ScientificNotation << -1 << "-12.34"
<< "-1,234E+03";
+ // es locale uses ',' as decimal point and '.' as grouping separator.
+ // It doesn't apply grouping unless the the next-to-least significant group
+ // has more than one digit in it.
+ QTest::newRow("es standard no digit grouping")
+ << "es" << QDoubleValidator::StandardNotation << -1 << "1234,567" << "1234,567";
+ QTest::newRow("es standard with digit grouping")
+ << "es" << QDoubleValidator::StandardNotation << -1 << "-12.345,678" << "-12.345,678";
+ QTest::newRow("es standard with invalid group size")
+ << "es" << QDoubleValidator::StandardNotation << -1 << "1.234.5,678" << "12.345,678";
+ QTest::newRow("es standard with invalid digit grouping")
+ << "es" << QDoubleValidator::StandardNotation << 2 << "-1.234,678" << "-1234,68";
+ QTest::newRow("es standard big with invalid digit grouping")
+ << "es" << QDoubleValidator::StandardNotation << 2 << "-1234.678,9" << "-1.234.678,9";
+ QTest::newRow("es standard no fractional part")
+ << "es" << QDoubleValidator::StandardNotation << -1 << "12.34" << "1234";
+
// hi locale uses '.' as decimal point and ',' as grouping separator.
// The rightmost group is of three digits, all the others contain two
// digits.
diff --git a/tests/auto/gui/util/qintvalidator/CMakeLists.txt b/tests/auto/gui/util/qintvalidator/CMakeLists.txt
index aca564992b..841b83a8e0 100644
--- a/tests/auto/gui/util/qintvalidator/CMakeLists.txt
+++ b/tests/auto/gui/util/qintvalidator/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qintvalidator Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qintvalidator LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qintvalidator
SOURCES
tst_qintvalidator.cpp
diff --git a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
index 5b0f30cf9a..bfa69c90b8 100644
--- a/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
+++ b/tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -167,7 +167,8 @@ void tst_QIntValidator::validateFrench()
int i;
// Grouping separator is a narrow no-break space; QLocale accepts a space as it.
QString s = QLatin1String("1 ");
- QCOMPARE(validator.validate(s, i), QValidator::Acceptable);
+ // Shouldn't end with a group separator
+ QCOMPARE(validator.validate(s, i), QValidator::Intermediate);
validator.fixup(s);
QCOMPARE(s, s);
@@ -307,9 +308,9 @@ void tst_QIntValidator::fixup_data()
// Normally the groups contain three digits, but the leftmost group should
// have at least two digits.
QTest::newRow("es no digit grouping 1000") << "es" << "1000" << "1000";
- QTest::newRow("es no digit grouping 10000") << "es" << "10000" << "10.000";
- QTest::newRow("es with digit grouping") << "es" << "1000.000" << "1000.000";
- QTest::newRow("es invalid digit grouping") << "es" << "1.000.000" << "1000.000";
+ QTest::newRow("es with digit grouping 10000") << "es" << "10000" << "10.000";
+ QTest::newRow("es with digit grouping million") << "es" << "1.000.000" << "1.000.000";
+ QTest::newRow("es invalid digit grouping") << "es" << "1000.000" << "1.000.000";
}
QTEST_APPLESS_MAIN(tst_QIntValidator)
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt b/tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt
index cab0088d23..1d48205537 100644
--- a/tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt
+++ b/tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qregularexpressionvalidator Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qregularexpressionvalidator LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qregularexpressionvalidator
SOURCES
tst_qregularexpressionvalidator.cpp
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
index c2ddafa2c6..17f9e6a1bd 100644
--- a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
+++ b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui/QRegularExpressionValidator>
#include <QTest>
diff --git a/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt b/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt
index 2949dfd0d6..70e2c02417 100644
--- a/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt
+++ b/tests/auto/gui/util/qtexturefilereader/CMakeLists.txt
@@ -5,12 +5,19 @@
## tst_qtexturefilereader Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtexturefilereader LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set(qtexturefilereader_resource_files
"texturefiles/car.ktx"
"texturefiles/car_mips.ktx"
"texturefiles/cubemap_float32_rgba.ktx"
"texturefiles/cubemap_metadata.ktx"
+ "texturefiles/invalid.ktx"
"texturefiles/newlogo.astc"
"texturefiles/newlogo_srgb.astc"
"texturefiles/pattern.pkm"
diff --git a/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx b/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx
new file mode 100644
index 0000000000..68a92221db
--- /dev/null
+++ b/tests/auto/gui/util/qtexturefilereader/texturefiles/invalid.ktx
Binary files differ
diff --git a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
index 9d7205a921..62760e3844 100644
--- a/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
+++ b/tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <private/qtexturefilereader_p.h>
#include <QTest>
@@ -11,6 +11,7 @@ class tst_qtexturefilereader : public QObject
private slots:
void checkHandlers_data();
void checkHandlers();
+ void checkInvalid();
void checkMetadata();
};
@@ -140,6 +141,18 @@ void tst_qtexturefilereader::checkMetadata()
QCOMPARE(kvs.value("test C"), QByteArrayLiteral("3\x0000"));
}
+void tst_qtexturefilereader::checkInvalid()
+{
+ QFile f(":/texturefiles/invalid.ktx");
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QTextureFileReader r(&f);
+ QTextureFileData d = r.read();
+ auto kvs = d.keyValueMetadata();
+
+ // Basically just checking that we don't crash on and invalid file
+ QVERIFY(kvs.empty());
+}
+
QTEST_MAIN(tst_qtexturefilereader)
#include "tst_qtexturefilereader.moc"
diff --git a/tests/auto/gui/util/qundogroup/CMakeLists.txt b/tests/auto/gui/util/qundogroup/CMakeLists.txt
index ed925e94cc..98c2f64f88 100644
--- a/tests/auto/gui/util/qundogroup/CMakeLists.txt
+++ b/tests/auto/gui/util/qundogroup/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qundogroup Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qundogroup LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qundogroup
SOURCES
tst_qundogroup.cpp
diff --git a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
index f554e94a98..36f72b2ca0 100644
--- a/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/gui/util/qundogroup/tst_qundogroup.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QUndoGroup>
#include <QUndoStack>
diff --git a/tests/auto/gui/util/qundostack/CMakeLists.txt b/tests/auto/gui/util/qundostack/CMakeLists.txt
index c2ca413d96..de36f4a1ad 100644
--- a/tests/auto/gui/util/qundostack/CMakeLists.txt
+++ b/tests/auto/gui/util/qundostack/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qundostack Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qundostack LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qundostack
SOURCES
tst_qundostack.cpp
diff --git a/tests/auto/gui/util/qundostack/tst_qundostack.cpp b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
index b47a4ee1a9..3567bc6097 100644
--- a/tests/auto/gui/util/qundostack/tst_qundostack.cpp
+++ b/tests/auto/gui/util/qundostack/tst_qundostack.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>