summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/CMakeLists.txt3
-rw-r--r--tests/auto/gui/image/CMakeLists.txt12
-rw-r--r--tests/auto/gui/image/qicoimageformat/CMakeLists.txt34
-rw-r--r--tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc18
-rw-r--r--tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp29
-rw-r--r--tests/auto/gui/image/qicon/CMakeLists.txt7
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp33
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.qrc31
-rw-r--r--tests/auto/gui/image/qiconhighdpi/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp29
-rw-r--r--tests/auto/gui/image/qimage/CMakeLists.txt43
-rw-r--r--tests/auto/gui/image/qimage/qimage.qrc22
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp91
-rw-r--r--tests/auto/gui/image/qimageiohandler/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp29
-rw-r--r--tests/auto/gui/image/qimagereader/BLACKLIST8
-rw-r--r--tests/auto/gui/image/qimagereader/CMakeLists.txt26
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp102
-rw-r--r--tests/auto/gui/image/qimagewriter/CMakeLists.txt35
-rw-r--r--tests/auto/gui/image/qimagewriter/qimagewriter.qrc16
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp33
-rw-r--r--tests/auto/gui/image/qmovie/CMakeLists.txt12
-rw-r--r--tests/auto/gui/image/qmovie/tst_qmovie.cpp32
-rw-r--r--tests/auto/gui/image/qpicture/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qpicture/tst_qpicture.cpp29
-rw-r--r--tests/auto/gui/image/qpixmap/CMakeLists.txt9
-rw-r--r--tests/auto/gui/image/qpixmap/qpixmap.qrc51
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp31
-rw-r--r--tests/auto/gui/image/qpixmapcache/CMakeLists.txt5
-rw-r--r--tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp45
-rw-r--r--tests/auto/gui/itemmodels/CMakeLists.txt3
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST3
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt14
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp161
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt5
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp47
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt5
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp135
-rw-r--r--tests/auto/gui/kernel/CMakeLists.txt14
-rw-r--r--tests/auto/gui/kernel/noqteventloop/CMakeLists.txt7
-rw-r--r--tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp32
-rw-r--r--tests/auto/gui/kernel/qaction/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qaction/tst_qaction.cpp91
-rw-r--r--tests/auto/gui/kernel/qactiongroup/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp29
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp29
-rw-r--r--tests/auto/gui/kernel/qbackingstore/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp240
-rw-r--r--tests/auto/gui/kernel/qclipboard/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt15
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/main.cpp29
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt15
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/main.cpp29
-rw-r--r--tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp89
-rw-r--r--tests/auto/gui/kernel/qcursor/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qcursor/tst_qcursor.cpp29
-rw-r--r--tests/auto/gui/kernel/qdrag/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qdrag/tst_qdrag.cpp29
-rw-r--r--tests/auto/gui/kernel/qevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qevent/tst_qevent.cpp108
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp33
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp44
-rw-r--r--tests/auto/gui/kernel/qguiapplication/BLACKLIST5
-rw-r--r--tests/auto/gui/kernel/qguiapplication/CMakeLists.txt52
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp156
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc6
-rw-r--r--tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qguieventloop/CMakeLists.txt7
-rw-r--r--tests/auto/gui/kernel/qguimetatype/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp103
-rw-r--r--tests/auto/gui/kernel/qguitimer/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qguivariant/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt7
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/main.cpp29
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt26
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/qguivariant.qrc5
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp31
-rw-r--r--tests/auto/gui/kernel/qhighdpi/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp181
-rw-r--r--tests/auto/gui/kernel/qinputdevice/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp81
-rw-r--r--tests/auto/gui/kernel/qinputmethod/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp35
-rw-r--r--tests/auto/gui/kernel/qkeyevent/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp29
-rw-r--r--tests/auto/gui/kernel/qkeysequence/CMakeLists.txt27
-rw-r--r--tests/auto/gui/kernel/qkeysequence/qkeysequence.qrc6
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp37
-rw-r--r--tests/auto/gui/kernel/qmouseevent/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp53
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp29
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp29
-rw-r--r--tests/auto/gui/kernel/qpalette/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp132
-rw-r--r--tests/auto/gui/kernel/qpixelformat/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp29
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp29
-rw-r--r--tests/auto/gui/kernel/qscreen/BLACKLIST4
-rw-r--r--tests/auto/gui/kernel/qscreen/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qscreen/tst_qscreen.cpp74
-rw-r--r--tests/auto/gui/kernel/qshortcut/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp29
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp29
-rw-r--r--tests/auto/gui/kernel/qtouchevent/BLACKLIST6
-rw-r--r--tests/auto/gui/kernel/qtouchevent/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp463
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST7
-rw-r--r--tests/auto/gui/kernel/qwindow/CMakeLists.txt23
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp121
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp327
-rw-r--r--tests/auto/gui/math3d/CMakeLists.txt3
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt7
-rw-r--r--tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp204
-rw-r--r--tests/auto/gui/math3d/qquaternion/CMakeLists.txt5
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp92
-rw-r--r--tests/auto/gui/math3d/qvectornd/CMakeLists.txt5
-rw-r--r--tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp62
-rw-r--r--tests/auto/gui/painting/CMakeLists.txt7
-rw-r--r--tests/auto/gui/painting/qbrush/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qbrush/tst_qbrush.cpp29
-rw-r--r--tests/auto/gui/painting/qcolor/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp104
-rw-r--r--tests/auto/gui/painting/qcolorspace/CMakeLists.txt34
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp80
-rw-r--r--tests/auto/gui/painting/qcolortransform/CMakeLists.txt14
-rw-r--r--tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp380
-rw-r--r--tests/auto/gui/painting/qpagelayout/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp29
-rw-r--r--tests/auto/gui/painting/qpageranges/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp33
-rw-r--r--tests/auto/gui/painting/qpagesize/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp29
-rw-r--r--tests/auto/gui/painting/qpaintengine/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp29
-rw-r--r--tests/auto/gui/painting/qpainter/CMakeLists.txt202
-rw-r--r--tests/auto/gui/painting/qpainter/testdata.qrc186
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp206
-rw-r--r--tests/auto/gui/painting/qpainter/utils/createImages/main.cpp29
-rw-r--r--tests/auto/gui/painting/qpainterpath/BLACKLIST2
-rw-r--r--tests/auto/gui/painting/qpainterpath/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp84
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp29
-rw-r--r--tests/auto/gui/painting/qpathclipper/CMakeLists.txt10
-rw-r--r--tests/auto/gui/painting/qpathclipper/pathcompare.h29
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.cpp29
-rw-r--r--tests/auto/gui/painting/qpathclipper/paths.h29
-rw-r--r--tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp51
-rw-r--r--tests/auto/gui/painting/qpdfwriter/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp29
-rw-r--r--tests/auto/gui/painting/qpen/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qpen/tst_qpen.cpp29
-rw-r--r--tests/auto/gui/painting/qpolygon/CMakeLists.txt7
-rw-r--r--tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp45
-rw-r--r--tests/auto/gui/painting/qregion/CMakeLists.txt5
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp29
-rw-r--r--tests/auto/gui/painting/qtransform/CMakeLists.txt7
-rw-r--r--tests/auto/gui/painting/qtransform/tst_qtransform.cpp29
-rw-r--r--tests/auto/gui/platform/CMakeLists.txt3
-rw-r--r--tests/auto/gui/platform/qx11info/CMakeLists.txt5
-rw-r--r--tests/auto/gui/platform/qx11info/tst_qx11info.cpp41
-rw-r--r--tests/auto/gui/qopengl/CMakeLists.txt5
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp54
-rw-r--r--tests/auto/gui/qopenglconfig/CMakeLists.txt5
-rw-r--r--tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp29
-rw-r--r--tests/auto/gui/qvulkan/CMakeLists.txt5
-rw-r--r--tests/auto/gui/qvulkan/tst_qvulkan.cpp74
-rw-r--r--tests/auto/gui/rhi/CMakeLists.txt3
-rw-r--r--tests/auto/gui/rhi/qrhi/BLACKLIST12
-rw-r--r--tests/auto/gui/rhi/qrhi/CMakeLists.txt26
-rw-r--r--tests/auto/gui/rhi/qrhi/data/buildshaders.bat54
-rw-r--r--tests/auto/gui/rhi/qrhi/data/half.vert10
-rw-r--r--tests/auto/gui/rhi/qrhi/data/half.vert.qsbbin0 -> 815 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.frag10
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.frag.qsbbin0 -> 591 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.tesc22
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.tesc.qsbbin0 -> 1402 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.tese17
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.tese.qsbbin0 -> 1401 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.vert12
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletess.vert.qsbbin0 -> 936 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag14
-rw-r--r--tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag.qsbbin0 -> 1258 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer.comp28
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsbbin0 -> 1239 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp25
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp.qsbbin0 -> 1415 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag33
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag.qsbbin0 -> 1259 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc42
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc.qsbbin0 -> 2024 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese39
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese.qsbbin0 -> 1854 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert48
-rw-r--r--tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert.qsbbin0 -> 2047 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.frag.qsbbin0 -> 590 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc56
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc.qsbbin0 -> 2873 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese96
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese.qsbbin0 -> 4526 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert20
-rw-r--r--tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert.qsbbin0 -> 1306 bytes
-rw-r--r--tests/auto/gui/rhi/qrhi/qrhi.qrc5
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp2845
-rw-r--r--tests/auto/gui/rhi/qshader/CMakeLists.txt26
-rw-r--r--tests/auto/gui/rhi/qshader/data/metal_enabled_tessellation_v7.frag.qsbbin0 -> 729 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data/metal_enabled_tessellation_v7.tesc.qsbbin0 -> 1749 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data/metal_enabled_tessellation_v7.tese.qsbbin0 -> 2390 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data/metal_enabled_tessellation_v7.vert.qsbbin0 -> 1106 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data/storage_buffer_info_v8.comp.qsbbin0 -> 902 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data/texture_sep_v6.frag.qsbbin0 -> 1265 bytes
-rw-r--r--tests/auto/gui/rhi/qshader/data_src/color.vert (renamed from tests/auto/gui/rhi/qshader/data/color.vert)0
-rw-r--r--tests/auto/gui/rhi/qshader/data_src/texture.frag (renamed from tests/auto/gui/rhi/qshader/data/texture.frag)0
-rw-r--r--tests/auto/gui/rhi/qshader/data_src/texture_sep.frag17
-rw-r--r--tests/auto/gui/rhi/qshader/qshader.qrc5
-rw-r--r--tests/auto/gui/rhi/qshader/tst_qshader.cpp296
-rw-r--r--tests/auto/gui/text/CMakeLists.txt9
-rw-r--r--tests/auto/gui/text/qabstracttextdocumentlayout/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qabstracttextdocumentlayout/tst_qabstracttextdocumentlayout.cpp35
-rw-r--r--tests/auto/gui/text/qcssparser/CMakeLists.txt47
-rw-r--r--tests/auto/gui/text/qcssparser/testdata.qrc18
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp165
-rw-r--r--tests/auto/gui/text/qfont/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qfont/CMakeLists.txt28
-rw-r--r--tests/auto/gui/text/qfont/datastream.515bin0 -> 121 bytes
-rw-r--r--tests/auto/gui/text/qfont/testfont.qrc5
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp84
-rw-r--r--tests/auto/gui/text/qfontcache/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qfontcache/tst_qfontcache.cpp29
-rw-r--r--tests/auto/gui/text/qfontdatabase/BLACKLIST7
-rw-r--r--tests/auto/gui/text/qfontdatabase/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qfontdatabase/testdata.qrc9
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp83
-rw-r--r--tests/auto/gui/text/qfontmetrics/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qfontmetrics/testfont.qrc6
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp48
-rw-r--r--tests/auto/gui/text/qglyphrun/BLACKLIST4
-rw-r--r--tests/auto/gui/text/qglyphrun/CMakeLists.txt23
-rw-r--r--tests/auto/gui/text/qglyphrun/Ligatures.otfbin0 -> 24624 bytes
-rw-r--r--tests/auto/gui/text/qglyphrun/testdata.qrc5
-rw-r--r--tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp393
-rw-r--r--tests/auto/gui/text/qinputcontrol/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp29
-rw-r--r--tests/auto/gui/text/qrawfont/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qrawfont/CMakeLists.txt26
-rw-r--r--tests/auto/gui/text/qrawfont/testdata.qrc7
-rw-r--r--tests/auto/gui/text/qrawfont/tst_qrawfont.cpp31
-rw-r--r--tests/auto/gui/text/qstatictext/CMakeLists.txt7
-rw-r--r--tests/auto/gui/text/qstatictext/tst_qstatictext.cpp34
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/CMakeLists.txt7
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp37
-rw-r--r--tests/auto/gui/text/qtextblock/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextblock/tst_qtextblock.cpp29
-rw-r--r--tests/auto/gui/text/qtextcursor/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp280
-rw-r--r--tests/auto/gui/text/qtextdocument/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextdocument/common.h29
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp319
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp67
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/CMakeLists.txt7
-rw-r--r--tests/auto/gui/text/qtextdocumentlayout/tst_qtextdocumentlayout.cpp66
-rw-r--r--tests/auto/gui/text/qtextformat/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp59
-rw-r--r--tests/auto/gui/text/qtextimagehandler/CMakeLists.txt23
-rw-r--r--tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp60
-rw-r--r--tests/auto/gui/text/qtextlayout/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp187
-rw-r--r--tests/auto/gui/text/qtextlist/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextlist/tst_qtextlist.cpp87
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/BLACKLIST3
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp211
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/BLACKLIST2
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/blockquotes.md4
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/example.md2
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/links.md3
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/tst_qtextmarkdownwriter.cpp271
-rw-r--r--tests/auto/gui/text/qtextobject/CMakeLists.txt7
-rw-r--r--tests/auto/gui/text/qtextobject/tst_qtextobject.cpp29
-rw-r--r--tests/auto/gui/text/qtextodfwriter/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextodfwriter/tst_qtextodfwriter.cpp33
-rw-r--r--tests/auto/gui/text/qtextpiecetable/CMakeLists.txt8
-rw-r--r--tests/auto/gui/text/qtextpiecetable/tst_qtextpiecetable.cpp51
-rw-r--r--tests/auto/gui/text/qtextscriptengine/CMakeLists.txt5
-rw-r--r--tests/auto/gui/text/qtextscriptengine/generate/CMakeLists.txt6
-rw-r--r--tests/auto/gui/text/qtextscriptengine/generate/main.cpp29
-rw-r--r--tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp68
-rw-r--r--tests/auto/gui/text/qtexttable/CMakeLists.txt7
-rw-r--r--tests/auto/gui/text/qtexttable/tst_qtexttable.cpp146
-rw-r--r--tests/auto/gui/text/qzip/CMakeLists.txt28
-rw-r--r--tests/auto/gui/text/qzip/testdata.qrc6
-rw-r--r--tests/auto/gui/text/qzip/tst_qzip.cpp37
-rw-r--r--tests/auto/gui/util/CMakeLists.txt3
-rw-r--r--tests/auto/gui/util/qdesktopservices/CMakeLists.txt7
-rw-r--r--tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp50
-rw-r--r--tests/auto/gui/util/qdoublevalidator/CMakeLists.txt5
-rw-r--r--tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp92
-rw-r--r--tests/auto/gui/util/qintvalidator/CMakeLists.txt5
-rw-r--r--tests/auto/gui/util/qintvalidator/tst_qintvalidator.cpp66
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/CMakeLists.txt5
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp37
-rw-r--r--tests/auto/gui/util/qtexturefilereader/CMakeLists.txt24
-rw-r--r--tests/auto/gui/util/qtexturefilereader/qtexturefilereader.qrc11
-rw-r--r--tests/auto/gui/util/qtexturefilereader/tst_qtexturefilereader.cpp29
-rw-r--r--tests/auto/gui/util/qundogroup/CMakeLists.txt5
-rw-r--r--tests/auto/gui/util/qundogroup/tst_qundogroup.cpp49
-rw-r--r--tests/auto/gui/util/qundostack/CMakeLists.txt5
-rw-r--r--tests/auto/gui/util/qundostack/tst_qundostack.cpp73
319 files changed, 8770 insertions, 5787 deletions
diff --git a/tests/auto/gui/CMakeLists.txt b/tests/auto/gui/CMakeLists.txt
index 7ba124952d..b0fb8891f5 100644
--- a/tests/auto/gui/CMakeLists.txt
+++ b/tests/auto/gui/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from gui.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(kernel)
if(NOT UIKIT)
diff --git a/tests/auto/gui/image/CMakeLists.txt b/tests/auto/gui/image/CMakeLists.txt
index 14930536c9..9cc6d4d2bf 100644
--- a/tests/auto/gui/image/CMakeLists.txt
+++ b/tests/auto/gui/image/CMakeLists.txt
@@ -1,10 +1,13 @@
-# Generated from image.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-# QTBUG-87669 # special case
+# QTBUG-87669
if(TARGET Qt::Network AND NOT ANDROID)
add_subdirectory(qimagereader)
endif()
-add_subdirectory(qicoimageformat)
+if(QT_FEATURE_ico)
+ add_subdirectory(qicoimageformat)
+endif()
add_subdirectory(qpixmap)
add_subdirectory(qimage)
add_subdirectory(qimageiohandler)
@@ -15,7 +18,8 @@ add_subdirectory(qiconhighdpi)
if(QT_FEATURE_private_tests)
add_subdirectory(qpixmapcache)
endif()
-# QTBUG-87669 # special case
+
+# QTBUG-87669
if(NOT ANDROID)
add_subdirectory(qicon)
endif()
diff --git a/tests/auto/gui/image/qicoimageformat/CMakeLists.txt b/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
index 704c51a6be..78f0ef98ea 100644
--- a/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
+++ b/tests/auto/gui/image/qicoimageformat/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qicoimageformat.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qicoimageformat Test:
@@ -13,37 +14,8 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qicoimageformat
SOURCES
tst_qicoimageformat.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
TESTDATA ${test_data}
)
-## Scopes:
-#####################################################################
-
-if(ANDROID)
- # Resources:
- set(qicoimageformat_resource_files
- "icons/invalid/35floppy.ico"
- "icons/valid/35FLOPPY.ICO"
- "icons/valid/AddPerfMon.ico"
- "icons/valid/App.ico"
- "icons/valid/Obj_N2_Internal_Mem.ico"
- "icons/valid/Qt.ico"
- "icons/valid/Status_Play.ico"
- "icons/valid/TIMER01.ICO"
- "icons/valid/WORLD.ico"
- "icons/valid/WORLDH.ico"
- "icons/valid/abcardWindow.ico"
- "icons/valid/semitransparent.ico"
- "icons/valid/trolltechlogo_tiny.ico"
- "icons/valid/yellow.cur"
- )
-
- qt_internal_add_resource(tst_qicoimageformat "qicoimageformat"
- PREFIX
- "/"
- FILES
- ${qicoimageformat_resource_files}
- )
-endif()
diff --git a/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc b/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc
deleted file mode 100644
index 1e0ee8aa8c..0000000000
--- a/tests/auto/gui/image/qicoimageformat/qicoimageformat.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>icons/invalid/35floppy.ico</file>
- <file>icons/valid/35FLOPPY.ICO</file>
- <file>icons/valid/abcardWindow.ico</file>
- <file>icons/valid/AddPerfMon.ico</file>
- <file>icons/valid/App.ico</file>
- <file>icons/valid/Obj_N2_Internal_Mem.ico</file>
- <file>icons/valid/Qt.ico</file>
- <file>icons/valid/semitransparent.ico</file>
- <file>icons/valid/Status_Play.ico</file>
- <file>icons/valid/TIMER01.ICO</file>
- <file>icons/valid/trolltechlogo_tiny.ico</file>
- <file>icons/valid/WORLD.ico</file>
- <file>icons/valid/WORLDH.ico</file>
- <file>icons/valid/yellow.cur</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
index 37d5f4998c..47bfb5bca5 100644
--- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
+++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui>
#include <QtCore>
diff --git a/tests/auto/gui/image/qicon/CMakeLists.txt b/tests/auto/gui/image/qicon/CMakeLists.txt
index 5f6b139205..c900c60d5b 100644
--- a/tests/auto/gui/image/qicon/CMakeLists.txt
+++ b/tests/auto/gui/image/qicon/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qicon.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qicon Test:
@@ -33,7 +34,7 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qicon
SOURCES
tst_qicon.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
TESTDATA ${test_data}
)
@@ -91,6 +92,6 @@ qt_internal_add_resource(tst_qicon "qmake_immediate"
#####################################################################
qt_internal_extend_target(tst_qicon CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Widgets
)
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index 3363f86809..ebb0f1e9d2 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QImageReader>
@@ -810,7 +785,7 @@ void tst_QIcon::fromThemeCache()
QTest::qWait(1000); // wait enough to have a different modification time in seconds
QVERIFY(QFile(QStringLiteral(":/styles/commonstyle/images/standardbutton-save-16.png"))
.copy(dir.path() + QLatin1String("/testcache/16x16/actions/button-save.png")));
- QVERIFY(QFileInfo(cacheName).lastModified() < QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified());
+ QVERIFY(QFileInfo(cacheName).lastModified(QTimeZone::UTC) < QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified(QTimeZone::UTC));
QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes
QVERIFY(!QIcon::fromTheme("button-open").isNull());
@@ -831,7 +806,7 @@ void tst_QIcon::fromThemeCache()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
#endif // QT_CONFIG(process)
- QVERIFY(QFileInfo(cacheName).lastModified() >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified());
+ QVERIFY(QFileInfo(cacheName).lastModified(QTimeZone::UTC) >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified(QTimeZone::UTC));
QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes
QVERIFY(!QIcon::fromTheme("button-open").isNull());
QVERIFY(!QIcon::fromTheme("button-open-fallback").isNull());
diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc
deleted file mode 100644
index 23a6801e38..0000000000
--- a/tests/auto/gui/image/qicon/tst_qicon.qrc
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
-<file>tst_qicon.cpp</file>
-<file>image.png</file>
-<file>rect.png</file>
-<file>./icons/testtheme/16x16/actions/appointment-new.png</file>
-<file>./icons/testtheme/22x22/actions/appointment-new.png</file>
-<file>./second_icons/testtheme/32x32/actions/appointment-new.png</file>
-<file>./fallback_icons/red.png</file>
-<file>./icons/testtheme/index.theme</file>
-<file>./icons/testtheme/scalable/actions/svg-only.svg</file>
-<file>./icons/themeparent/16x16/actions/address-book-new.png</file>
-<file>./icons/themeparent/16x16/actions/appointment-new.png</file>
-<file>./icons/themeparent/22x22/actions/address-book-new.png</file>
-<file>./icons/themeparent/22x22/actions/appointment-new.png</file>
-<file>./icons/themeparent/32x32/actions/address-book-new.png</file>
-<file>./icons/themeparent/32x32/actions/appointment-new.png</file>
-<file>./icons/themeparent/index.theme</file>
-<file>./icons/themeparent/icon-theme.cache</file>
-<file>./icons/themeparent/scalable/actions/address-book-new.svg</file>
-<file>./icons/themeparent/scalable/actions/appointment-new.svg</file>
-<file>./styles/commonstyle/images/standardbutton-open-16.png</file>
-<file>./styles/commonstyle/images/standardbutton-open-32.png</file>
-<file>./styles/commonstyle/images/standardbutton-open-64.png</file>
-<file>./styles/commonstyle/images/standardbutton-open-128.png</file>
-<file>./styles/commonstyle/images/standardbutton-save-16.png</file>
-<file>./styles/commonstyle/images/standardbutton-save-32.png</file>
-<file>./styles/commonstyle/images/standardbutton-save-64.png</file>
-<file>./styles/commonstyle/images/standardbutton-save-128.png</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt b/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
index 989cf1f44d..6a6717df09 100644
--- a/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
+++ b/tests/auto/gui/image/qiconhighdpi/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qiconhighdpi.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qiconhighdpi Test:
@@ -13,7 +14,7 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qiconhighdpi
SOURCES
tst_qiconhighdpi.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
TESTDATA ${test_data}
)
diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
index 3282776ee6..829c463c6b 100644
--- a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
+++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <qicon.h>
diff --git a/tests/auto/gui/image/qimage/CMakeLists.txt b/tests/auto/gui/image/qimage/CMakeLists.txt
index 4c95b32e48..ecd68ac82c 100644
--- a/tests/auto/gui/image/qimage/CMakeLists.txt
+++ b/tests/auto/gui/image/qimage/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qimage.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qimage Test:
@@ -13,54 +14,20 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qimage
SOURCES
tst_qimage.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
TESTDATA ${test_data}
)
-## Scopes:
-#####################################################################
-
-if(ANDROID)
- # Resources:
- set(qimage_resource_files
- "images/image.bmp"
- "images/image.gif"
- "images/image.ico"
- "images/image.jpg"
- "images/image.pbm"
- "images/image.pgm"
- "images/image.png"
- "images/image.ppm"
- "images/image.xbm"
- "images/image.xpm"
- "images/jpeg_exif_orientation_value_1.jpg"
- "images/jpeg_exif_orientation_value_2.jpg"
- "images/jpeg_exif_orientation_value_3.jpg"
- "images/jpeg_exif_orientation_value_4.jpg"
- "images/jpeg_exif_orientation_value_5.jpg"
- "images/jpeg_exif_orientation_value_6.jpg"
- "images/jpeg_exif_orientation_value_7.jpg"
- "images/jpeg_exif_orientation_value_8.jpg"
- )
-
- qt_internal_add_resource(tst_qimage "qimage"
- PREFIX
- "/"
- FILES
- ${qimage_resource_files}
- )
-endif()
-
qt_internal_extend_target(tst_qimage CONDITION WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
gdi32
user32
)
qt_internal_extend_target(tst_qimage CONDITION APPLE
- PUBLIC_LIBRARIES
+ LIBRARIES
${FWCoreGraphics}
)
diff --git a/tests/auto/gui/image/qimage/qimage.qrc b/tests/auto/gui/image/qimage/qimage.qrc
deleted file mode 100644
index e5de27faf8..0000000000
--- a/tests/auto/gui/image/qimage/qimage.qrc
+++ /dev/null
@@ -1,22 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>images/image.bmp</file>
- <file>images/image.gif</file>
- <file>images/image.ico</file>
- <file>images/image.jpg</file>
- <file>images/image.pbm</file>
- <file>images/image.pgm</file>
- <file>images/image.png</file>
- <file>images/image.ppm</file>
- <file>images/image.xbm</file>
- <file>images/image.xpm</file>
- <file>images/jpeg_exif_orientation_value_1.jpg</file>
- <file>images/jpeg_exif_orientation_value_2.jpg</file>
- <file>images/jpeg_exif_orientation_value_3.jpg</file>
- <file>images/jpeg_exif_orientation_value_4.jpg</file>
- <file>images/jpeg_exif_orientation_value_5.jpg</file>
- <file>images/jpeg_exif_orientation_value_6.jpg</file>
- <file>images/jpeg_exif_orientation_value_7.jpg</file>
- <file>images/jpeg_exif_orientation_value_8.jpg</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 6f9e0641ac..415f016519 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -1,38 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QBuffer>
+#include <QMatrix4x4>
#include <qimage.h>
#include <qimagereader.h>
#include <qlist.h>
+#include <qset.h>
#include <qtransform.h>
#include <qrandom.h>
#include <stdio.h>
@@ -91,6 +68,7 @@ private slots:
void rotate_data();
void rotate();
+ void rotateBigImage();
void copy();
@@ -250,6 +228,8 @@ private slots:
void largeFillScale();
void largeRasterScale();
+ void metadataChangeWithReadOnlyPixels();
+
#if defined(Q_OS_WIN)
void toWinHBITMAP_data();
void toWinHBITMAP();
@@ -1234,6 +1214,23 @@ void tst_QImage::rotate()
QCOMPARE(original, dest);
}
+void tst_QImage::rotateBigImage()
+{
+ // QTBUG-105088
+ QImage big_image(3840, 2160, QImage::Format_ARGB32_Premultiplied);
+ QTransform t;
+ t.translate(big_image.width() / 2.0, big_image.height() / 2.0);
+ t.rotate(-89, Qt::YAxis, big_image.width());
+ t.translate(-big_image.width() / 2.0, -big_image.height() / 2.0);
+ QVERIFY(!big_image.transformed(t).isNull());
+
+ QMatrix4x4 m;
+ m.translate(big_image.width() / 2.0, big_image.height() / 2.0);
+ m.projectedRotate(89, 0, 1, 0, big_image.width());
+ m.translate(-big_image.width() / 2.0, -big_image.height() / 2.0);
+ QVERIFY(!big_image.transformed(m.toTransform()).isNull());
+}
+
void tst_QImage::copy()
{
// Task 99250
@@ -2642,20 +2639,20 @@ void tst_QImage::mirrored_data()
QTest::newRow("Format_Mono, horizontal+vertical") << QImage::Format_Mono << true << true << 16 << 16;
QTest::newRow("Format_MonoLSB, horizontal+vertical") << QImage::Format_MonoLSB << true << true << 16 << 16;
- QTest::newRow("Format_RGB32, vertical") << QImage::Format_RGB32 << true << false << 8 << 16;
- QTest::newRow("Format_ARGB32, vertical") << QImage::Format_ARGB32 << true << false << 16 << 8;
+ QTest::newRow("Format_RGB32, vertical, narrow") << QImage::Format_RGB32 << true << false << 8 << 16;
+ QTest::newRow("Format_ARGB32, vertical, short") << QImage::Format_ARGB32 << true << false << 16 << 8;
QTest::newRow("Format_Mono, vertical, non-aligned") << QImage::Format_Mono << true << false << 19 << 25;
QTest::newRow("Format_MonoLSB, vertical, non-aligned") << QImage::Format_MonoLSB << true << false << 19 << 25;
// Non-aligned horizontal 1-bit needs special handling so test this.
QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 13 << 17;
- QTest::newRow("Format_Mono, horizontal, non-aligned") << QImage::Format_Mono << false << true << 19 << 25;
- QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 25 << 47;
+ QTest::newRow("Format_Mono, horizontal, non-aligned, big") << QImage::Format_Mono << false << true << 19 << 25;
+ QTest::newRow("Format_Mono, horizontal+vertical, non-aligned, big") << QImage::Format_Mono << true << true << 25 << 47;
QTest::newRow("Format_Mono, horizontal+vertical, non-aligned") << QImage::Format_Mono << true << true << 21 << 16;
QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 13 << 17;
- QTest::newRow("Format_MonoLSB, horizontal, non-aligned") << QImage::Format_MonoLSB << false << true << 19 << 25;
- QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 25 << 47;
+ QTest::newRow("Format_MonoLSB, horizontal, non-aligned, big") << QImage::Format_MonoLSB << false << true << 19 << 25;
+ QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned, big") << QImage::Format_MonoLSB << true << true << 25 << 47;
QTest::newRow("Format_MonoLSB, horizontal+vertical, non-aligned") << QImage::Format_MonoLSB << true << true << 21 << 16;
}
@@ -3457,6 +3454,9 @@ void tst_QImage::exifInvalidData()
void tst_QImage::exifReadComments()
{
+#ifdef QT_NO_IMAGEIO_TEXT_LOADING
+ QSKIP("Reading text from image file is configured off");
+#endif
QImage image;
QVERIFY(image.load(m_prefix + "jpeg_exif_utf8_comment.jpg"));
QVERIFY(!image.isNull());
@@ -3850,7 +3850,7 @@ void tst_QImage::reinterpretAsFormat_data()
QTest::newRow("rgb32 -> argb32") << QImage::Format_RGB32 << QImage::Format_ARGB32 << QColor(Qt::cyan) << QColor(Qt::cyan);
QTest::newRow("argb32pm -> rgb32") << QImage::Format_ARGB32_Premultiplied << QImage::Format_RGB32 << QColor(Qt::transparent) << QColor(Qt::black);
QTest::newRow("argb32 -> rgb32") << QImage::Format_ARGB32 << QImage::Format_RGB32 << QColor(255, 0, 0, 127) << QColor(255, 0, 0);
- QTest::newRow("argb32pm -> rgb32") << QImage::Format_ARGB32_Premultiplied << QImage::Format_RGB32 << QColor(255, 0, 0, 127) << QColor(127, 0, 0);
+ QTest::newRow("argb32pm (red) -> rgb32") << QImage::Format_ARGB32_Premultiplied << QImage::Format_RGB32 << QColor(255, 0, 0, 127) << QColor(127, 0, 0);
}
void tst_QImage::reinterpretAsFormat()
@@ -3945,7 +3945,10 @@ void tst_QImage::hugeQImage()
#if Q_PROCESSOR_WORDSIZE < 8
QSKIP("Test only makes sense on 64-bit machines");
#else
- QImage image(25000, 25000, QImage::Format_RGB32);
+ std::unique_ptr<char[]> enough(new (std::nothrow) char[qsizetype(25000)*25000*4]);
+ if (!enough)
+ QSKIP("Could not allocate enough memory");
+ QImage image((uchar*)enough.get(), 25000, 25000, QImage::Format_RGB32);
QVERIFY(!image.isNull());
QCOMPARE(image.height(), 25000);
@@ -4059,6 +4062,24 @@ void tst_QImage::largeRasterScale()
// image.save("largeRasterScale.png", "PNG");
}
+void tst_QImage::metadataChangeWithReadOnlyPixels()
+{
+ const QRgb data[3] = { qRgb(255, 0, 0), qRgb(0, 255, 0), qRgb(0, 0, 255) };
+ QImage image((const uchar *)data, 3, 1, QImage::Format_RGB32);
+
+ QCOMPARE(image.constBits(), (const uchar *)data);
+ image.setDotsPerMeterX(100);
+ QCOMPARE(image.constBits(), (const uchar *)data);
+
+ QImage image2 = image;
+ QCOMPARE(image2.constBits(), (const uchar *)data);
+ image2.setDotsPerMeterX(200);
+ // Pixels and metadata has the same sharing mechanism, so a change of a shared
+ // image metadata forces pixel detach (remove this sub-test if that ever changes).
+ QVERIFY(image2.constBits() != (const uchar *)data);
+ QCOMPARE(image.constBits(), (const uchar *)data);
+}
+
#if defined(Q_OS_WIN)
static inline QColor COLORREFToQColor(COLORREF cr)
diff --git a/tests/auto/gui/image/qimageiohandler/CMakeLists.txt b/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
index 4bbf2f5b01..ccf6c617a9 100644
--- a/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
+++ b/tests/auto/gui/image/qimageiohandler/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qimageiohandler.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qimageiohandler Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qimageiohandler
SOURCES
tst_qimageiohandler.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
index 9fa0e37cad..fd0e61b1ba 100644
--- a/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
+++ b/tests/auto/gui/image/qimageiohandler/tst_qimageiohandler.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/image/qimagereader/BLACKLIST b/tests/auto/gui/image/qimagereader/BLACKLIST
new file mode 100644
index 0000000000..6422ff1dac
--- /dev/null
+++ b/tests/auto/gui/image/qimagereader/BLACKLIST
@@ -0,0 +1,8 @@
+[setClipRect:SVG: rect]
+wayland
+[setClipRect:SVGZ: rect]
+wayland
+[setScaledClipRect:SVG: rect]
+wayland
+[setScaledClipRect:SVGZ: rect]
+wayland
diff --git a/tests/auto/gui/image/qimagereader/CMakeLists.txt b/tests/auto/gui/image/qimagereader/CMakeLists.txt
index a0cda3bb73..0c19b33797 100644
--- a/tests/auto/gui/image/qimagereader/CMakeLists.txt
+++ b/tests/auto/gui/image/qimagereader/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qimagereader.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qimagereader Test:
@@ -17,7 +18,7 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qimagereader
SOURCES
tst_qimagereader.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -42,24 +43,3 @@ qt_internal_add_resource(tst_qimagereader "qmake_immediate"
${qmake_immediate_resource_files}
)
-
-#### Keys ignored in scope 1:.:.:qimagereader.pro:<TRUE>:
-# MOC_DIR = "tmp"
-
-## Scopes:
-#####################################################################
-
-if(ANDROID)
- # Resources:
- set(android_testdata_resource_files
- "images/kollada-noext"
- "images/trans.gif"
- )
-
- qt_internal_add_resource(tst_qimagereader "android_testdata"
- PREFIX
- "/"
- FILES
- ${android_testdata_resource_files}
- )
-endif()
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 1019def466..cfd48ec1e4 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -94,6 +69,8 @@ private slots:
void setScaledClipRect_data();
void setScaledClipRect();
+ void setFormat();
+
void imageFormat_data();
void imageFormat();
@@ -510,9 +487,38 @@ void tst_QImageReader::setScaledClipRect()
QImageReader originalReader(prefix + fileName);
originalReader.setScaledSize(QSize(300, 300));
QImage originalImage = originalReader.read();
+ if (format.contains("svg")) {
+ // rendering of subrect may yield slight rounding differences, truncate them away
+ image.convertTo(QImage::Format_RGB444);
+ originalImage.convertTo(QImage::Format_RGB444);
+ }
QCOMPARE(originalImage.copy(newRect), image);
}
+void tst_QImageReader::setFormat()
+{
+ QByteArray ppmImage = "P1 2 2\n1 0\n0 1";
+ QBuffer buf(&ppmImage);
+ QImageReader reader(&buf);
+
+ // read image in autodetected format
+ QCOMPARE(reader.size(), QSize(2,2));
+ buf.close();
+
+ // try reading with non-matching format, must not succeed
+ reader.setDecideFormatFromContent(false);
+ reader.setFormat("bmp");
+ reader.setDevice(&buf);
+ QCOMPARE(reader.size(), QSize());
+ buf.close();
+
+ // read with manually set matching format
+ reader.setFormat("ppm");
+ reader.setDevice(&buf);
+ QCOMPARE(reader.size(), QSize(2,2));
+ buf.close();
+}
+
void tst_QImageReader::imageFormat_data()
{
QTest::addColumn<QString>("fileName");
@@ -1953,6 +1959,10 @@ void tst_QImageReader::readText_data()
void tst_QImageReader::readText()
{
+#ifdef QT_NO_IMAGEIO_TEXT_LOADING
+ QSKIP("Reading text from image is configured away");
+#endif
+
QFETCH(QString, fileName);
QFETCH(QString, key);
QFETCH(QString, text);
@@ -1974,19 +1984,31 @@ void tst_QImageReader::preserveTexts_data()
for (int c = 0xa0; c <= 0xff; c++)
latin1set.append(QLatin1Char(c));
- QStringList fileNames;
- fileNames << QLatin1String(":/images/kollada.png")
- << QLatin1String(":/images/txts.jpg");
- foreach (const QString &fileName, fileNames) {
- QTest::newRow("Simple") << fileName << "simpletext";
- QTest::newRow("Whitespace") << fileName << " A text with whitespace ";
- QTest::newRow("Newline") << fileName << "A text\nwith newlines\n";
- QTest::newRow("Double newlines") << fileName << "A text\n\nwith double newlines\n\n";
- QTest::newRow("Long") << fileName << QString("A rather long text, at least after many repetitions. ").repeated(100);
- QTest::newRow("All Latin1 chars") << fileName << latin1set;
+ const QList<QLatin1StringView> fileNames{
+ QLatin1StringView(":/images/kollada.png"),
+ QLatin1StringView(":/images/txts.jpg")
+ // Common prefix of length 9 before file names: ":/images/", skipped below by + 9.
+ };
+ for (const auto &fileName : fileNames) {
+ QTest::addRow("Simple %s", fileName.data() + 9)
+ << QString(fileName) << "simpletext";
+ QTest::addRow("Whitespace %s", fileName.data() + 9)
+ << QString(fileName) << " A text with whitespace ";
+ QTest::addRow("Newline %s", fileName.data() + 9)
+ << QString(fileName) << "A text\nwith newlines\n";
+ QTest::addRow("Double newlines %s", fileName.data() + 9)
+ << QString(fileName) << "A text\n\nwith double newlines\n\n";
+ QTest::addRow("Long %s", fileName.data() + 9)
+ << QString(fileName)
+ << QString("A rather long text, at least after many repetitions. ").repeated(100);
+ QTest::addRow("All Latin1 chars %s", fileName.data() + 9)
+ << QString(fileName) << latin1set;
#if 0
// Depends on iTXt support in libpng
- QTest::newRow("Multibyte string") << fileName << QString::fromUtf8("\341\233\222\341\233\226\341\232\251\341\232\271\341\232\242\341\233\232\341\232\240");
+ QTest::addRow("Multibyte string %s", fileName.data() + 9)
+ << QString(fileName)
+ << QString::fromUtf8("\341\233\222\341\233\226\341\232\251\341\232"
+ "\271\341\232\242\341\233\232\341\232\240");
#endif
}
}
@@ -1994,6 +2016,10 @@ void tst_QImageReader::preserveTexts_data()
void tst_QImageReader::preserveTexts()
{
+#ifdef QT_NO_IMAGEIO_TEXT_LOADING
+ QSKIP("Reading text from image is configured away");
+#endif
+
QFETCH(QString, fileName);
QByteArray format = fileName.right(3).toLatin1();
QFETCH(QString, text);
diff --git a/tests/auto/gui/image/qimagewriter/CMakeLists.txt b/tests/auto/gui/image/qimagewriter/CMakeLists.txt
index e74321731f..31f1a1057a 100644
--- a/tests/auto/gui/image/qimagewriter/CMakeLists.txt
+++ b/tests/auto/gui/image/qimagewriter/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qimagewriter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qimagewriter Test:
@@ -13,38 +14,8 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qimagewriter
SOURCES
tst_qimagewriter.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
TESTDATA ${test_data}
)
-#### Keys ignored in scope 1:.:.:qimagewriter.pro:<TRUE>:
-# MOC_DIR = "tmp"
-
-## Scopes:
-#####################################################################
-
-if(ANDROID)
- # Resources:
- set(qimagewriter_resource_files
- "images/YCbCr_cmyk.jpg"
- "images/YCbCr_rgb.jpg"
- "images/beavis.jpg"
- "images/colorful.bmp"
- "images/earth.gif"
- "images/font.bmp"
- "images/gnus.xbm"
- "images/kollada.png"
- "images/marble.xpm"
- "images/ship63.pbm"
- "images/teapot.ppm"
- "images/trolltech.gif"
- )
-
- qt_internal_add_resource(tst_qimagewriter "qimagewriter"
- PREFIX
- "/"
- FILES
- ${qimagewriter_resource_files}
- )
-endif()
diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.qrc b/tests/auto/gui/image/qimagewriter/qimagewriter.qrc
deleted file mode 100644
index 29b036e303..0000000000
--- a/tests/auto/gui/image/qimagewriter/qimagewriter.qrc
+++ /dev/null
@@ -1,16 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>images/beavis.jpg</file>
- <file>images/colorful.bmp</file>
- <file>images/earth.gif</file>
- <file>images/font.bmp</file>
- <file>images/gnus.xbm</file>
- <file>images/kollada.png</file>
- <file>images/marble.xpm</file>
- <file>images/ship63.pbm</file>
- <file>images/teapot.ppm</file>
- <file>images/trolltech.gif</file>
- <file>images/YCbCr_cmyk.jpg</file>
- <file>images/YCbCr_rgb.jpg</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index 6ce8060306..f64c94bb90 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -127,7 +102,7 @@ void tst_QImageWriter::getSetCheck()
QCOMPARE((QIODevice *) var1, obj1.device());
// The class should possibly handle a 0-pointer as a device, since
- // there is a default contructor, so it's "handling" a 0 device by default.
+ // there is a default constructor, so it's "handling" a 0 device by default.
// For example: QMovie::setDevice(0) works just fine
obj1.setDevice((QIODevice *)0);
QCOMPARE((QIODevice *) 0, obj1.device());
@@ -281,6 +256,8 @@ void tst_QImageWriter::writeImage2()
QFETCH(QByteArray, format);
QFETCH(QImage, image);
+ SKIP_IF_UNSUPPORTED(format);
+
//we reduce the scope of writer so that it closes the associated file
// and QFile::remove can actually work
{
diff --git a/tests/auto/gui/image/qmovie/CMakeLists.txt b/tests/auto/gui/image/qmovie/CMakeLists.txt
index 545ee481d1..00fd2f22c5 100644
--- a/tests/auto/gui/image/qmovie/CMakeLists.txt
+++ b/tests/auto/gui/image/qmovie/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmovie.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qmovie Test:
@@ -13,7 +14,7 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qmovie
SOURCES
tst_qmovie.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
TESTDATA ${test_data}
)
@@ -32,16 +33,11 @@ qt_internal_add_resource(tst_qmovie "resources"
${resources_resource_files}
)
-
-#### Keys ignored in scope 1:.:.:qmovie.pro:<TRUE>:
-# MOC_DIR = "tmp"
-# QT_FOR_CONFIG = "gui-private"
-
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qmovie CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Widgets
)
diff --git a/tests/auto/gui/image/qmovie/tst_qmovie.cpp b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
index c1abeccba5..1cf13f6f9c 100644
--- a/tests/auto/gui/image/qmovie/tst_qmovie.cpp
+++ b/tests/auto/gui/image/qmovie/tst_qmovie.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -36,6 +11,7 @@
#include <QLabel>
#endif
#include <QMovie>
+#include <QProperty>
class tst_QMovie : public QObject
{
@@ -180,7 +156,7 @@ void tst_QMovie::playMovie()
movie.start();
QCOMPARE(movie.state(), QMovie::Running);
QTestEventLoop::instance().enterLoop(2);
- QCOMPARE(finishedSpy.count(), 0);
+ QCOMPARE(finishedSpy.size(), 0);
QCOMPARE(movie.state(), QMovie::Running);
QCOMPARE(movie.currentFrameNumber(), 0);
}
diff --git a/tests/auto/gui/image/qpicture/CMakeLists.txt b/tests/auto/gui/image/qpicture/CMakeLists.txt
index 29bf68fa06..af77725652 100644
--- a/tests/auto/gui/image/qpicture/CMakeLists.txt
+++ b/tests/auto/gui/image/qpicture/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpicture.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpicture Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpicture
SOURCES
tst_qpicture.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
index 25e284a6ec..de2b841927 100644
--- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp
+++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/image/qpixmap/CMakeLists.txt b/tests/auto/gui/image/qpixmap/CMakeLists.txt
index 1946715047..61267d396f 100644
--- a/tests/auto/gui/image/qpixmap/CMakeLists.txt
+++ b/tests/auto/gui/image/qpixmap/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpixmap.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpixmap Test:
@@ -25,7 +26,7 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qpixmap
SOURCES
tst_qpixmap.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -95,13 +96,13 @@ qt_internal_add_resource(tst_qpixmap "qpixmap"
#####################################################################
qt_internal_extend_target(tst_qpixmap CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Widgets
Qt::WidgetsPrivate
)
qt_internal_extend_target(tst_qpixmap CONDITION WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
gdi32
user32
)
diff --git a/tests/auto/gui/image/qpixmap/qpixmap.qrc b/tests/auto/gui/image/qpixmap/qpixmap.qrc
deleted file mode 100644
index 3965622dba..0000000000
--- a/tests/auto/gui/image/qpixmap/qpixmap.qrc
+++ /dev/null
@@ -1,51 +0,0 @@
-<RCC>
- <qresource>
- <file>loadFromData/designer_argb32.png</file>
- <file>loadFromData/designer_indexed8_no_alpha_animated.gif</file>
- <file>loadFromData/designer_indexed8_no_alpha.gif</file>
- <file>loadFromData/designer_indexed8_no_alpha.png</file>
- <file>loadFromData/designer_indexed8_with_alpha_animated.gif</file>
- <file>loadFromData/designer_indexed8_with_alpha.gif</file>
- <file>loadFromData/designer_indexed8_with_alpha.png</file>
- <file>loadFromData/designer_rgb32.jpg</file>
- <file>loadFromData/designer_rgb32.png</file>
- <file>convertFromImage/task31722_1/img1.png</file>
- <file>convertFromImage/task31722_1/img2.png</file>
- <file>convertFromToHICON/icon_8bpp_16x16.png</file>
- <file>convertFromToHICON/icon_8bpp_32x32.png</file>
- <file>convertFromToHICON/icon_8bpp_48x48.png</file>
- <file>convertFromToHICON/icon_8bpp.ico</file>
- <file>convertFromToHICON/icon_32bpp_16x16.png</file>
- <file>convertFromToHICON/icon_32bpp_32x32.png</file>
- <file>convertFromToHICON/icon_32bpp_48x48.png</file>
- <file>convertFromToHICON/icon_32bpp_256x256.png</file>
- <file>convertFromToHICON/icon_32bpp.ico</file>
- <file>convertFromImage/task31722_0/img1.png</file>
- <file>convertFromImage/task31722_0/img2.png</file>
- <file>images/designer.png</file>
- <file>images/dx_0_dy_0_50_50_100_100.png</file>
- <file>images/dx_0_dy_0_null.png</file>
- <file>images/dx_0_dy_0_x_y_w_h.png</file>
- <file>images/dx_0_dy_-10_50_50_100_100.png</file>
- <file>images/dx_0_dy_10_50_50_100_100.png</file>
- <file>images/dx_0_dy_-10_x_y_w_h.png</file>
- <file>images/dx_0_dy_10_x_y_w_h.png</file>
- <file>images/dx_0_dy_-128_x_y_w_h.png</file>
- <file>images/dx_0_dy_128_x_y_w_h.png</file>
- <file>images/dx_0_dy_1_null.png</file>
- <file>images/dx_-10_dy_0_50_50_100_100.png</file>
- <file>images/dx_10_dy_0_50_50_100_100.png</file>
- <file>images/dx_-10_dy_0_x_y_w_h.png</file>
- <file>images/dx_10_dy_0_x_y_w_h.png</file>
- <file>images/dx_-10_dy_-10_50_50_100_100.png</file>
- <file>images/dx_10_dy_10_50_50_100_100.png</file>
- <file>images/dx_-10_dy_-10_x_y_w_h.png</file>
- <file>images/dx_10_dy_10_x_y_w_h.png</file>
- <file>images/dx_-128_dy_0_x_y_w_h.png</file>
- <file>images/dx_128_dy_0_x_y_w_h.png</file>
- <file>images/dx_128_dy_128_64_64_128_128.png</file>
- <file>images/dx_-128_dy_-128_x_y_w_h.png</file>
- <file>images/dx_128_dy_128_x_y_w_h.png</file>
- <file>images/dx_1_dy_0_null.png</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 6c6c282af4..4e9be4e033 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QSet>
#include <QTemporaryFile>
@@ -46,7 +21,7 @@
#include <private/qdrawhelper_p.h>
#ifdef Q_OS_WIN
-#include <windows.h>
+#include <qt_windows.h>
#endif
diff --git a/tests/auto/gui/image/qpixmapcache/CMakeLists.txt b/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
index 9e99842e6e..8855d07823 100644
--- a/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
+++ b/tests/auto/gui/image/qpixmapcache/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpixmapcache.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpixmapcache Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qpixmapcache
SOURCES
tst_qpixmapcache.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
index a87ec5d025..d4c39a2130 100644
--- a/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/gui/image/qpixmapcache/tst_qpixmapcache.cpp
@@ -1,32 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#define Q_TEST_QPIXMAPCACHE
+// 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>
@@ -34,6 +7,12 @@
#include <qpixmapcache.h>
#include "private/qpixmapcache_p.h"
+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
+
class tst_QPixmapCache : public QObject
{
Q_OBJECT
@@ -185,7 +164,7 @@ void tst_QPixmapCache::setCacheLimit()
p1->detach();
QPixmapCache::Key key3 = QPixmapCache::insert(*p1);
p1->detach();
- QPixmapCache::flushDetachedPixmaps();
+ qt_qpixmapcache_flush_detached_pixmaps();
key2 = QPixmapCache::insert(*p1);
QCOMPARE(getPrivate(key2)->key, 1);
//This old key is not valid anymore after the flush
@@ -483,10 +462,6 @@ void tst_QPixmapCache::pixmapKey()
QVERIFY(!getPrivate(key8));
}
-QT_BEGIN_NAMESPACE
-extern int q_QPixmapCache_keyHashSize();
-QT_END_NAMESPACE
-
void tst_QPixmapCache::noLeak()
{
QPixmapCache::Key key;
@@ -524,7 +499,7 @@ void tst_QPixmapCache::strictCacheLimit()
QPixmapCache::insert(id + "-b", pixmap);
}
- QVERIFY(QPixmapCache::totalUsed() <= limit);
+ QVERIFY(qt_qpixmapcache_qpixmapcache_total_used() <= limit);
}
void tst_QPixmapCache::noCrashOnLargeInsert()
diff --git a/tests/auto/gui/itemmodels/CMakeLists.txt b/tests/auto/gui/itemmodels/CMakeLists.txt
index 69b6cb0e22..4c25418ef1 100644
--- a/tests/auto/gui/itemmodels/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from itemmodels.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qstandarditem)
if(TARGET Qt::Widgets)
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST b/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST
index ae8a64dc1f..4119afce84 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/BLACKLIST
@@ -3,6 +3,3 @@ ubuntu
b2qt
[specialFiles]
b2qt
-# QTBUG-87427
-[specialFiles]
-android
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
index 31fd8ca32d..1132e02c09 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qfilesystemmodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qfilesystemmodel Test:
@@ -7,19 +8,10 @@
qt_internal_add_test(tst_qfilesystemmodel
SOURCES
tst_qfilesystemmodel.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::Widgets
Qt::WidgetsPrivate
Qt::TestPrivate
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:qfilesystemmodel.pro:WIN32:
-# testcase.timeout = "900"
-
-#### Keys ignored in scope 3:.:.:qfilesystemmodel.pro:MACOS:
-# testcase.timeout = "900"
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index b6f6328acd..3802f8afc6 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -45,6 +20,7 @@
#include <QStyle>
#include <QtGlobal>
#include <QTemporaryDir>
+#include <QAbstractItemModelTester>
#if defined(Q_OS_WIN)
# include <qt_windows.h> // for SetFileAttributes
#endif
@@ -52,6 +28,8 @@
#include <algorithm>
+using namespace Qt::StringLiterals;
+
#define WAITTIME 1000
// Will try to wait for the condition while allowing event processing
@@ -172,6 +150,8 @@ void tst_QFileSystemModel::indexPath()
{
#if !defined(Q_OS_WIN)
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
int depth = QDir::currentPath().count('/');
model->setRootPath(QDir::currentPath());
QString backPath;
@@ -186,12 +166,14 @@ void tst_QFileSystemModel::indexPath()
void tst_QFileSystemModel::rootPath()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QCOMPARE(model->rootPath(), QString(QDir().path()));
QSignalSpy rootChanged(model.data(), &QFileSystemModel::rootPathChanged);
QModelIndex root = model->setRootPath(model->rootPath());
root = model->setRootPath("this directory shouldn't exist");
- QCOMPARE(rootChanged.count(), 0);
+ QCOMPARE(rootChanged.size(), 0);
QString oldRootPath = model->rootPath();
const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
@@ -208,48 +190,50 @@ void tst_QFileSystemModel::rootPath()
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), QString(documentPath));
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? 0 : 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
model->setRootPath(QDir::rootPath());
- int oldCount = rootChanged.count();
+ int oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), documentPath);
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
QDir newdir = documentPath;
if (newdir.cdUp()) {
- oldCount = rootChanged.count();
+ oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/.."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), newdir.path());
- QCOMPARE(rootChanged.count(), oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
#ifdef Q_OS_WIN
// check case insensitive root node on windows, tests QTBUG-71701
- QModelIndex index = model->setRootPath(uR"(\\localhost\c$)"_qs);
+ QModelIndex index = model->setRootPath(uR"(\\localhost\c$)"_s);
QVERIFY(index.isValid());
- QCOMPARE(model->rootPath(), u"//localhost/c$"_qs);
+ QCOMPARE(model->rootPath(), u"//localhost/c$"_s);
- index = model->setRootPath(uR"(\\localhost\C$)"_qs);
+ index = model->setRootPath(uR"(\\localhost\C$)"_s);
QVERIFY(index.isValid());
- QCOMPARE(model->rootPath(), u"//localhost/C$"_qs);
+ QCOMPARE(model->rootPath(), u"//localhost/C$"_s);
- index = model->setRootPath(uR"(\\LOCALHOST\C$)"_qs);
+ index = model->setRootPath(uR"(\\LOCALHOST\C$)"_s);
QVERIFY(index.isValid());
- QCOMPARE(model->rootPath(), u"//LOCALHOST/C$"_qs);
+ QCOMPARE(model->rootPath(), u"//LOCALHOST/C$"_s);
#endif
}
void tst_QFileSystemModel::readOnly()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QCOMPARE(model->isReadOnly(), true);
QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat"));
QVERIFY2(file.open(), qPrintable(file.errorString()));
@@ -261,10 +245,14 @@ void tst_QFileSystemModel::readOnly()
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
+
+ // ItemIsEditable should change, ItemNeverHasChildren should not change
QVERIFY(!(model->flags(model->index(fileName)) & Qt::ItemIsEditable));
+ QVERIFY(model->flags(model->index(fileName)) & Qt::ItemNeverHasChildren);
model->setReadOnly(false);
QCOMPARE(model->isReadOnly(), false);
QVERIFY(model->flags(model->index(fileName)) & Qt::ItemIsEditable);
+ QVERIFY(model->flags(model->index(fileName)) & Qt::ItemNeverHasChildren);
}
class CustomFileIconProvider : public QFileIconProvider
@@ -299,6 +287,8 @@ private:
void tst_QFileSystemModel::iconProvider()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(model->iconProvider());
QScopedPointer<QFileIconProvider> provider(new QFileIconProvider);
model->setIconProvider(provider.data());
@@ -408,11 +398,13 @@ void tst_QFileSystemModel::rowCount()
QSignalSpy *spy2 = nullptr;
QSignalSpy *spy3 = nullptr;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
QVERIFY(root.isValid());
- QVERIFY(spy2 && spy2->count() > 0);
- QVERIFY(spy3 && spy3->count() > 0);
+ QVERIFY(spy2 && spy2->size() > 0);
+ QVERIFY(spy3 && spy3->size() > 0);
}
void tst_QFileSystemModel::rowsInserted_data()
@@ -436,6 +428,8 @@ void tst_QFileSystemModel::rowsInserted()
{
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -452,7 +446,7 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(model.data(), tmp, files, 5));
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
- for (int i = 0; i < spy0.count(); ++i) {
+ for (int i = 0; i < spy0.size(); ++i) {
int start = spy0[i].value(1).toInt();
int end = spy0[i].value(2).toInt();
totalRowsInserted += end - start + 1;
@@ -461,24 +455,24 @@ void tst_QFileSystemModel::rowsInserted()
const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
QTRY_COMPARE(lastEntry(root), expected);
- if (spy0.count() > 0) {
+ if (spy0.size() > 0) {
if (count == 0)
- QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy0.size(), 0);
else
- QVERIFY(spy0.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
}
- if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
+ if (count == 0) QCOMPARE(spy1.size(), 0); else QVERIFY(spy1.size() >= 1);
QVERIFY(createFiles(model.data(), tmp, QStringList(".hidden_file"), 5 + count));
if (count != 0)
- QTRY_VERIFY(spy0.count() >= 1);
+ QTRY_VERIFY(spy0.size() >= 1);
else
- QTRY_COMPARE(spy0.count(), 0);
+ QTRY_COMPARE(spy0.size(), 0);
if (count != 0)
- QTRY_VERIFY(spy1.count() >= 1);
+ QTRY_VERIFY(spy1.size() >= 1);
else
- QTRY_COMPARE(spy1.count(), 0);
+ QTRY_COMPARE(spy1.size(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -490,6 +484,8 @@ void tst_QFileSystemModel::rowsRemoved()
{
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -507,14 +503,14 @@ void tst_QFileSystemModel::rowsRemoved()
}
for (int i = 0 ; i < 10; ++i) {
if (count != 0) {
- if (i == 10 || spy0.count() != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ if (i == 10 || spy0.size() != 0) {
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
}
} else {
- if (i == 10 || spy0.count() == 0) {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ if (i == 10 || spy0.size() == 0) {
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
QStringList lst;
@@ -533,11 +529,11 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + QLatin1String("/.c")));
if (count != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
} else {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
@@ -552,6 +548,8 @@ void tst_QFileSystemModel::dataChanged()
const QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = prepareTestModelRoot(model.data(), tmp);
QVERIFY(root.isValid());
@@ -567,7 +565,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
+ if (count != 0) QVERIFY(spy.size() >= 1); else QCOMPARE(spy.size(), 0);
}
void tst_QFileSystemModel::filters_data()
@@ -612,6 +610,8 @@ void tst_QFileSystemModel::filters()
{
QString tmp = flatDirTestPath;
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, QStringList()));
QModelIndex root = model->setRootPath(tmp);
QFETCH(QStringList, files);
@@ -620,7 +620,7 @@ void tst_QFileSystemModel::filters()
QFETCH(QStringList, nameFilters);
QFETCH(int, rowCount);
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
model->setNameFilters(nameFilters);
model->setNameFilterDisables(false);
model->setFilter(dirFilters);
@@ -632,12 +632,12 @@ void tst_QFileSystemModel::filters()
QDir xFactor(tmp);
QStringList dirEntries;
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
dirEntries = xFactor.entryList(nameFilters, dirFilters);
else
dirEntries = xFactor.entryList(dirFilters);
- QCOMPARE(dirEntries.count(), rowCount);
+ QCOMPARE(dirEntries.size(), rowCount);
QStringList modelEntries;
@@ -649,7 +649,7 @@ void tst_QFileSystemModel::filters()
QCOMPARE(dirEntries, modelEntries);
#ifdef Q_OS_LINUX
- if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
+ if (files.size() >= 3 && rowCount >= 3 && rowCount != 5) {
QString fileName1 = (tmp + '/' + files.at(0));
QString fileName2 = (tmp + '/' + files.at(1));
QString fileName3 = (tmp + '/' + files.at(2));
@@ -680,6 +680,8 @@ void tst_QFileSystemModel::nameFilters()
QStringList list;
list << "a" << "b" << "c";
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
model->setNameFilters(list);
model->setNameFilterDisables(false);
QCOMPARE(model->nameFilters(), list);
@@ -725,6 +727,8 @@ void tst_QFileSystemModel::setData_data()
void tst_QFileSystemModel::setData()
{
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QSignalSpy spy(model.data(), &QFileSystemModel::fileRenamed);
QFETCH(QString, subdirName);
QFETCH(QStringList, files);
@@ -744,7 +748,7 @@ void tst_QFileSystemModel::setData()
tmpIdx = model->index(tmp);
model->fetchMore(tmpIdx);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
QModelIndex idx = model->index(tmp + '/' + oldFileName);
QCOMPARE(idx.isValid(), true);
@@ -754,7 +758,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(model->setData(idx, newFileName), success);
model->setReadOnly(true);
if (success) {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
@@ -763,7 +767,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(arguments.at(2).toString(), newFileName);
QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
// cleanup
if (!subdirName.isEmpty())
QVERIFY(QDir(tmp).removeRecursively());
@@ -777,6 +781,8 @@ void tst_QFileSystemModel::sortPersistentIndex()
file.close();
QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo));
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = model->setRootPath(flatDirTestPath);
QTRY_VERIFY(model->rowCount(root) > 0);
@@ -856,7 +862,7 @@ void tst_QFileSystemModel::sort()
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) {
- QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
+ QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.size());
// File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list
@@ -883,6 +889,8 @@ void tst_QFileSystemModel::mkdir()
QString tmp = flatDirTestPath;
QString newFolderPath = QDir::toNativeSeparators(tmp + '/' + "NewFoldermkdirtest4");
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex tmpDir = model->index(tmp);
QVERIFY(tmpDir.isValid());
QDir bestatic(newFolderPath);
@@ -918,6 +926,8 @@ void tst_QFileSystemModel::deleteFile()
}
newFile.close();
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex idx = model->index(newFilePath);
QVERIFY(idx.isValid());
QVERIFY(model->remove(idx));
@@ -980,12 +990,14 @@ void tst_QFileSystemModel::caseSensitivity()
QStringList files;
files << "a" << "c" << "C";
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, files));
QModelIndex root = model->index(tmp);
QStringList paths;
QModelIndexList indexes;
QCOMPARE(model->rowCount(root), 0);
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
const QString path = tmp + '/' + files.at(i);
const QModelIndex index = model->index(path);
QVERIFY(index.isValid());
@@ -995,7 +1007,7 @@ void tst_QFileSystemModel::caseSensitivity()
if (!QFileSystemEngine::isCaseSensitive()) {
// QTBUG-31103, QTBUG-64147: Verify that files can be accessed by paths with fLipPeD case.
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < paths.size(); ++i) {
const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i)));
QCOMPARE(indexes.at(i), flippedCaseIndex);
}
@@ -1045,6 +1057,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
}
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QModelIndex root = model->setRootPath(dir.absolutePath());
// Wait for model to be notified by the file system watcher
QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
@@ -1119,6 +1133,8 @@ void tst_QFileSystemModel::permissions() // checks QTBUG-20503
const QString tmp = flatDirTestPath;
const QString file = tmp + QLatin1String("/f");
QScopedPointer<QFileSystemModel> model(new QFileSystemModel);
+ QAbstractItemModelTester tester(model.get());
+ tester.setUseFetchMore(false);
QVERIFY(createFiles(model.data(), tmp, QStringList{QLatin1String("f")}));
QVERIFY(QFile::setPermissions(file, permissions));
@@ -1183,6 +1199,9 @@ void tst_QFileSystemModel::specialFiles()
#ifndef Q_OS_UNIX
QSKIP("Not implemented");
#endif
+#ifdef Q_OS_ANDROID
+ QSKIP("Android does not allow access to root filesystem");
+#endif
QFileSystemModel model;
diff --git a/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt b/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
index e5446d596a..33b7698a7a 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qstandarditem/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qstandarditem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qstandarditem Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qstandarditem
SOURCES
tst_qstandarditem.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
index 61683b20a6..6f42c45821 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -782,10 +757,10 @@ void tst_QStandardItem::takeColumn()
QList<QStandardItem *> taken = item.takeColumn(column);
if (expectSuccess) {
- QCOMPARE(taken.count(), item.rowCount());
+ QCOMPARE(taken.size(), item.rowCount());
QCOMPARE(item.columnCount(), columns - 1);
int index = column;
- for (int i = 0; i < taken.count(); ++i) {
+ for (int i = 0; i < taken.size(); ++i) {
QCOMPARE(taken.at(i), originalChildren.takeAt(index));
index += item.columnCount();
}
@@ -843,10 +818,10 @@ void tst_QStandardItem::takeRow()
QList<QStandardItem *> taken = item.takeRow(row);
if (expectSuccess) {
- QCOMPARE(taken.count(), item.columnCount());
+ QCOMPARE(taken.size(), item.columnCount());
QCOMPARE(item.rowCount(), rows - 1);
int index = row * columns;
- for (int i = 0; i < taken.count(); ++i) {
+ for (int i = 0; i < taken.size(); ++i) {
QCOMPARE(taken.at(i), originalChildren.takeAt(index));
}
index = 0;
@@ -1009,8 +984,8 @@ void tst_QStandardItem::sortChildren()
QCOMPARE(two->child(1)->text(), QLatin1String("e"));
QCOMPARE(two->child(2)->text(), QLatin1String("f"));
- QCOMPARE(layoutAboutToBeChangedSpy.count(), (x == 0) ? 0 : 3);
- QCOMPARE(layoutChangedSpy.count(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutChangedSpy.size(), (x == 0) ? 0 : 3);
if (x == 0)
delete item;
@@ -1026,7 +1001,7 @@ public:
int type() const override { return QStandardItem::UserType + 1; }
bool operator<(const QStandardItem &other) const override {
- return text().length() < other.text().length();
+ return text().size() < other.text().size();
}
using QStandardItem::clone;
@@ -1052,8 +1027,8 @@ void tst_QStandardItem::subclassing()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
item->emitDataChanged();
- QCOMPARE(itemChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.at(0).count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)), item);
CustomItem *child0 = new CustomItem("cc");
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt b/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
index 49cbcbfa88..c241d97294 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qstandarditemmodel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qstandarditemmodel Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qstandarditemmodel
SOURCES
tst_qstandarditemmodel.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index 7758a5d5cc..07fc074577 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -473,16 +448,16 @@ void tst_QStandardItemModel::setHeaderData()
for (int i = 0; i < count; ++i) {
QString customString = QString("custom") + QString::number(i);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 1);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
+ QCOMPARE(dataChangedSpy.size(), 0);
QVariantList args = headerDataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<Qt::Orientation>(args.at(0)), orient);
QCOMPARE(args.at(1).toInt(), i);
QCOMPARE(args.at(2).toInt(), i);
QCOMPARE(m_model->headerData(i, orient).toString(), customString);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 0);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
}
//check read from invalid sections
@@ -786,9 +761,9 @@ void tst_QStandardItemModel::clear()
model.clear();
- QCOMPARE(modelResetSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 0);
- QCOMPARE(rowsRemovedSpy.count(), 0);
+ QCOMPARE(modelResetSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 0);
+ QCOMPARE(rowsRemovedSpy.size(), 0);
QCOMPARE(model.index(0, 0), QModelIndex());
QCOMPARE(model.columnCount(), 0);
QCOMPARE(model.rowCount(), 0);
@@ -830,8 +805,8 @@ void tst_QStandardItemModel::sort()
QFETCH(QStringList, expected);
// prepare model
QStandardItemModel model;
- QVERIFY(model.insertRows(0, initial.count(), QModelIndex()));
- QCOMPARE(model.rowCount(QModelIndex()), initial.count());
+ QVERIFY(model.insertRows(0, initial.size(), QModelIndex()));
+ QCOMPARE(model.rowCount(QModelIndex()), initial.size());
model.insertColumns(0, 1, QModelIndex());
QCOMPARE(model.columnCount(QModelIndex()), 1);
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -847,8 +822,8 @@ void tst_QStandardItemModel::sort()
// sort
model.sort(0, sortOrder);
- QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 1);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 1);
// make sure the model is sorted
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -892,7 +867,7 @@ void tst_QStandardItemModel::sortRole()
QFETCH(QVariantList, expectedData);
QStandardItemModel model;
- for (int i = 0; i < initialText.count(); ++i) {
+ for (int i = 0; i < initialText.size(); ++i) {
QStandardItem *item = new QStandardItem;
item->setText(initialText.at(i));
item->setData(initialData.at(i), Qt::UserRole);
@@ -900,7 +875,7 @@ void tst_QStandardItemModel::sortRole()
}
model.setSortRole(sortRole);
model.sort(0, sortOrder);
- for (int i = 0; i < expectedText.count(); ++i) {
+ for (int i = 0; i < expectedText.size(); ++i) {
QStandardItem *item = model.item(i);
QCOMPARE(item->text(), expectedText.at(i));
QCOMPARE(item->data(Qt::UserRole), expectedData.at(i));
@@ -931,15 +906,15 @@ void tst_QStandardItemModel::findItems()
model.item(1)->appendRow(new QStandardItem(QLatin1String("foo")));
QList<QStandardItem*> matches;
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 0);
- QCOMPARE(matches.count(), 2);
+ QCOMPARE(matches.size(), 2);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly, 0);
- QCOMPARE(matches.count(), 1);
+ QCOMPARE(matches.size(), 1);
matches = model.findItems(QLatin1String("food"), Qt::MatchExactly|Qt::MatchRecursive, 0);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, -1);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
matches = model.findItems(QLatin1String("foo"), Qt::MatchExactly|Qt::MatchRecursive, 1);
- QCOMPARE(matches.count(), 0);
+ QCOMPARE(matches.size(), 0);
}
void tst_QStandardItemModel::getSetHeaderItem()
@@ -1086,9 +1061,9 @@ void tst_QStandardItemModel::getSetItemData()
QSignalSpy modelDataChangedSpy(
&model, &QStandardItemModel::dataChanged);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1);
+ QCOMPARE(modelDataChangedSpy.size(), 1);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1); //it was already changed once
+ QCOMPARE(modelDataChangedSpy.size(), 1); //it was already changed once
QCOMPARE(model.itemData(idx), roles);
}
@@ -1152,12 +1127,12 @@ void tst_QStandardItemModel::setHeaderLabels()
model.setHorizontalHeaderLabels(labels);
else
model.setVerticalHeaderLabels(labels);
- for (int i = 0; i < expectedLabels.count(); ++i)
+ for (int i = 0; i < expectedLabels.size(); ++i)
QCOMPARE(model.headerData(i, orientation).toString(), expectedLabels.at(i));
- QCOMPARE(columnsInsertedSpy.count(),
- (orientation == Qt::Vertical) ? 0 : labels.count() > columns);
- QCOMPARE(rowsInsertedSpy.count(),
- (orientation == Qt::Horizontal) ? 0 : labels.count() > rows);
+ QCOMPARE(columnsInsertedSpy.size(),
+ (orientation == Qt::Vertical) ? 0 : labels.size() > columns);
+ QCOMPARE(rowsInsertedSpy.size(),
+ (orientation == Qt::Horizontal) ? 0 : labels.size() > rows);
}
void tst_QStandardItemModel::itemDataChanged()
@@ -1168,8 +1143,8 @@ void tst_QStandardItemModel::itemDataChanged()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
model.setItem(0, &item);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
QModelIndex index = model.indexFromItem(&item);
QList<QVariant> args;
args = dataChangedSpy.takeFirst();
@@ -1179,8 +1154,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(QLatin1String("foo"), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1188,12 +1163,12 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(item.data(Qt::DisplayRole), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
item.setFlags(Qt::ItemIsEnabled);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1201,8 +1176,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setFlags(item.flags());
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
}
void tst_QStandardItemModel::takeHeaderItem()
@@ -1330,7 +1305,7 @@ void tst_QStandardItemModel::setNullChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
item->setChild(0, nullptr);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::deleteChild()
@@ -1342,7 +1317,7 @@ void tst_QStandardItemModel::deleteChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
delete item->child(0);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::rootItemFlags()
@@ -1583,8 +1558,8 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1605,15 +1580,15 @@ void tst_QStandardItemModel::removeRowsAndColumns()
VERIFY_MODEL
QList<QStandardItem *> row_taken = model.takeRow(6);
- QCOMPARE(row_taken.count(), col_list.count());
- for (int c = 0; c < col_list.count(); c++)
+ 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]);
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
- QCOMPARE(col_taken.count(), row_list.count());
- for (int r = 0; r < row_list.count(); r++)
+ 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]);
col_list.remove(10);
VERIFY_MODEL
@@ -1630,8 +1605,8 @@ void tst_QStandardItemModel::itemRoleNames()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1671,7 +1646,7 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
QModelIndex index = item->index();
QCOMPARE(model.itemData(index).size(), 3);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QMap<int, QVariant> roles;
@@ -1679,21 +1654,21 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 2, 2);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.insert(Qt::UserRole + 1, 1);
roles.insert(Qt::UserRole + 2, 2);
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.clear();
roles.insert(Qt::UserRole + 1, 10);
roles.insert(Qt::UserRole + 3, 12);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QMap<int, QVariant> itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 4);
@@ -1705,13 +1680,13 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 3, 1);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
roles.clear();
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 3);
@@ -1764,13 +1739,13 @@ void tst_QStandardItemModel::signalsOnTakeItem() // QTBUG-89145
QSignalSpy dataChangedSpy(&m, &QAbstractItemModel::dataChanged);
QStandardItem *const takenItem = m.takeItem(1, 0);
for (auto &&spy : removeSpies) {
- QCOMPARE(spy->count(), 1);
+ QCOMPARE(spy->size(), 1);
const auto spyArgs = spy->takeFirst();
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), parentIndex);
QCOMPARE(spyArgs.at(1).toInt(), 0);
QCOMPARE(spyArgs.at(2).toInt(), 1);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
const auto dataChangedSpyArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedSpyArgs.at(0).value<QModelIndex>(), m.index(1, 0));
QCOMPARE(dataChangedSpyArgs.at(1).value<QModelIndex>(), m.index(1, 0));
diff --git a/tests/auto/gui/kernel/CMakeLists.txt b/tests/auto/gui/kernel/CMakeLists.txt
index 7ff4e40280..a178942d5a 100644
--- a/tests/auto/gui/kernel/CMakeLists.txt
+++ b/tests/auto/gui/kernel/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from kernel.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(QT_FEATURE_action)
add_subdirectory(qaction)
@@ -22,7 +23,9 @@ add_subdirectory(qpalette)
add_subdirectory(qscreen)
add_subdirectory(qsurfaceformat)
add_subdirectory(qwindow)
-add_subdirectory(qguiapplication)
+if(QT_FEATURE_private_tests)
+ add_subdirectory(qguiapplication)
+endif()
add_subdirectory(qpixelformat)
add_subdirectory(qrasterwindow)
add_subdirectory(qaddpostroutine)
@@ -43,12 +46,7 @@ if(TARGET Qt::Widgets)
add_subdirectory(qtouchevent)
endif()
if(QT_FEATURE_opengl)
- # special case begin
- # QTBUG-85364
- if(NOT LINUX)
- add_subdirectory(qopenglwindow)
- endif()
- # special case end
+ add_subdirectory(qopenglwindow)
endif()
if(TARGET Qt::Network AND WIN32)
add_subdirectory(noqteventloop)
diff --git a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
index 9e47156add..d54e72eda1 100644
--- a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from noqteventloop.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_noqteventloop Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_noqteventloop
SOURCES
tst_noqteventloop.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -18,6 +19,6 @@ qt_internal_add_test(tst_noqteventloop
#####################################################################
qt_internal_extend_target(tst_noqteventloop CONDITION QT_FEATURE_dynamicgl AND WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
user32
)
diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
index 65f2329e3d..8aec8ddcc6 100644
--- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
+++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -156,7 +131,8 @@ public:
}
- void run() {
+ void run() override
+ {
struct ScopedCleanup
{
/* This is in order to ensure that the window is hidden when returning from run(),
diff --git a/tests/auto/gui/kernel/qaction/CMakeLists.txt b/tests/auto/gui/kernel/qaction/CMakeLists.txt
index ed0a0a8a5b..42a3726eaf 100644
--- a/tests/auto/gui/kernel/qaction/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaction/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qaction.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qaction_kernel Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qaction_kernel
SOURCES
tst_qaction.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qaction/tst_qaction.cpp b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
index 7f817a5c98..930cee26b8 100644
--- a/tests/auto/gui/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QSignalSpy>
@@ -234,11 +209,11 @@ void tst_QAction::setToolTip()
QFETCH(QStringList, values);
QFETCH(QStringList, expectedToolTips);
- QCOMPARE(properties.count(), values.count());
- QCOMPARE(properties.count(), expectedToolTips.count());
+ QCOMPARE(properties.size(), values.size());
+ QCOMPARE(properties.size(), expectedToolTips.size());
QAction action(nullptr);
- for (int i = 0; i < properties.count(); ++i) {
+ for (int i = 0; i < properties.size(); ++i) {
const auto property = properties.at(i);
const auto value = values.at(i);
const auto expectedToolTip = expectedToolTips.at(i);
@@ -297,19 +272,19 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
// test without a group
const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr));
QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered));
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
// it is now a checkable checked action
actionWithoutGroup->setCheckable(true);
actionWithoutGroup->setChecked(true);
spyWithoutGroup.clear();
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
}
void tst_QAction::setData() // QTBUG-62006
@@ -317,14 +292,14 @@ void tst_QAction::setData() // QTBUG-62006
QAction act(nullptr);
QSignalSpy spy(&act, &QAction::changed);
QCOMPARE(act.data(), QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QAction::setEnabledSetVisible()
@@ -333,22 +308,22 @@ void tst_QAction::setEnabledSetVisible()
QSignalSpy spy(&action, &QAction::enabledChanged);
QVERIFY(action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
action.setVisible(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setEnabled(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setVisible(true);
QVERIFY(!action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.resetEnabled();
QVERIFY(action.isEnabled());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QAction::setCheckabledSetChecked()
@@ -359,37 +334,37 @@ void tst_QAction::setCheckabledSetChecked()
QSignalSpy checkableSpy(&action, &QAction::checkableChanged);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 0);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 0);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 1);
action.setChecked(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 2);
- QCOMPARE(checkedSpy.count(), 1);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 2);
+ QCOMPARE(checkedSpy.size(), 1);
+ QCOMPARE(checkableSpy.size(), 1);
action.setCheckable(false);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 3);
- QCOMPARE(checkedSpy.count(), 2);
- QCOMPARE(checkableSpy.count(), 2);
+ QCOMPARE(changedSpy.size(), 3);
+ QCOMPARE(checkedSpy.size(), 2);
+ QCOMPARE(checkableSpy.size(), 2);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 4);
- QCOMPARE(checkedSpy.count(), 3);
- QCOMPARE(checkableSpy.count(), 3);
+ QCOMPARE(changedSpy.size(), 4);
+ QCOMPARE(checkedSpy.size(), 3);
+ QCOMPARE(checkableSpy.size(), 3);
}
QTEST_MAIN(tst_QAction)
diff --git a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
index 10354f865c..fe57719264 100644
--- a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qactiongroup.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qactiongroup_kernel Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qactiongroup_kernel
SOURCES
tst_qactiongroup.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
index 8ac3a0b4c7..2e04e13b7e 100644
--- a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
diff --git a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
index 454196ce1b..66559bc333 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qaddpostroutine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qaddpostroutine Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qaddpostroutine
SOURCES
tst_qaddpostroutine.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
index 731547f681..c56eb3ff4c 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
+++ b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
diff --git a/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
index 64ef31a0b5..3c34fa3813 100644
--- a/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qbackingstore.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qbackingstore Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qbackingstore
SOURCES
tst_qbackingstore.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
index 5349119b6d..d9528fc8e4 100644
--- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
+++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
@@ -1,33 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <qwindow.h>
#include <qbackingstore.h>
+#include <qpa/qplatformbackingstore.h>
#include <qpainter.h>
#include <QTest>
@@ -42,9 +18,214 @@ class tst_QBackingStore : public QObject
Q_OBJECT
private slots:
+
+ void initTestCase_data();
+ void init();
+
+ void resize();
+ void paint();
+
+ void scrollRectInImage_data();
+ void scrollRectInImage();
+
+ void scroll();
void flush();
};
+void tst_QBackingStore::initTestCase_data()
+{
+ QTest::addColumn<QSurfaceFormat::SwapBehavior>("swapBehavior");
+
+ QTest::newRow("single-buffer") << QSurfaceFormat::SingleBuffer;
+ QTest::newRow("double-buffer") << QSurfaceFormat::DoubleBuffer;
+}
+
+void tst_QBackingStore::init()
+{
+ QFETCH_GLOBAL(QSurfaceFormat::SwapBehavior, swapBehavior);
+
+ QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
+ defaultFormat.setSwapBehavior(swapBehavior);
+ QSurfaceFormat::setDefaultFormat(defaultFormat);
+}
+
+void tst_QBackingStore::resize()
+{
+ QWindow window;
+ window.create();
+
+ QBackingStore backingStore(&window);
+
+ QRect rect(0, 0, 100, 100);
+ backingStore.resize(rect.size());
+ QCOMPARE(backingStore.size(), rect.size());
+
+ // The paint device should reflect the requested
+ // size, taking the window's DPR into account.
+ backingStore.beginPaint(rect);
+ auto paintDevice = backingStore.paintDevice();
+ QCOMPARE(paintDevice->devicePixelRatio(), window.devicePixelRatio());
+ QCOMPARE(QSize(paintDevice->width(), paintDevice->height()),
+ rect.size() * window.devicePixelRatio());
+ backingStore.endPaint();
+
+ // So should the platform backingstore when accessed as an QImage
+ QImage image = backingStore.handle()->toImage();
+ if (!image.isNull()) // toImage might not be implemented
+ QCOMPARE(image.size(), rect.size() * window.devicePixelRatio());
+}
+
+void tst_QBackingStore::paint()
+{
+ QWindow window;
+ window.create();
+
+ // The resize() test verifies that the backingstore image
+ // has a size that takes the window's DPR into account.
+ auto dpr = window.devicePixelRatio();
+
+ QBackingStore backingStore(&window);
+
+ QRect rect(0, 0, 100, 100);
+ backingStore.resize(rect.size());
+
+ // Two rounds, with flush in between
+ for (int i = 0; i < 2; ++i) {
+ backingStore.beginPaint(rect);
+ QPainter p(backingStore.paintDevice());
+ QColor bgColor = i ? Qt::red : Qt::blue;
+ QColor fgColor = i ? Qt::green : Qt::yellow;
+ p.fillRect(rect, bgColor);
+ p.fillRect(QRect(50, 50, 10, 10), fgColor);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(50 * dpr, 50 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(49 * dpr, 50 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(50 * dpr, 49 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(59 * dpr, 59 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(60 * dpr, 59 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(59 * dpr, 60 * dpr), bgColor);
+
+ backingStore.flush(rect);
+ }
+}
+
+void tst_QBackingStore::scrollRectInImage_data()
+{
+ QTest::addColumn<QRect>("rect");
+ QTest::addColumn<QPoint>("offset");
+
+ QTest::newRow("empty rect") << QRect() << QPoint();
+ QTest::newRow("rect outside image") << QRect(-100, -100, 1000, 1000) << QPoint(10, 10);
+ QTest::newRow("scroll outside positive") << QRect(10, 10, 10, 10) << QPoint(1000, 1000);
+ QTest::newRow("scroll outside negative") << QRect(10, 10, 10, 10) << QPoint(-1000, -1000);
+
+ QTest::newRow("sub-rect positive scroll") << QRect(100, 100, 50, 50) << QPoint(10, 10);
+ QTest::newRow("sub-rect negative scroll") << QRect(100, 100, 50, 50) << QPoint(-10, -10);
+
+ QTest::newRow("positive vertical only") << QRect(100, 100, 50, 50) << QPoint(0, 10);
+ QTest::newRow("negative vertical only") << QRect(100, 100, 50, 50) << QPoint(0, -10);
+ QTest::newRow("positive horizontal only") << QRect(100, 100, 50, 50) << QPoint(10, 0);
+ QTest::newRow("negative horizontal only") << QRect(100, 100, 50, 50) << QPoint(-10, 0);
+
+ QTest::newRow("whole rect positive") << QRect(0, 0, 250, 250) << QPoint(10, 10);
+ QTest::newRow("whole rect negative") << QRect(0, 0, 250, 250) << QPoint(-10, -10);
+}
+
+QT_BEGIN_NAMESPACE
+Q_GUI_EXPORT void qt_scrollRectInImage(QImage &, const QRect &, const QPoint &);
+QT_END_NAMESPACE
+
+void tst_QBackingStore::scrollRectInImage()
+{
+ QImage test(250, 250, QImage::Format_ARGB32_Premultiplied);
+
+ QFETCH(QRect, rect);
+ QFETCH(QPoint, offset);
+
+ qt_scrollRectInImage(test, rect, offset);
+}
+
+void tst_QBackingStore::scroll()
+{
+ QWindow window;
+ window.create();
+
+ // The resize() test verifies that the backingstore image
+ // has a size that takes the window's DPR into account.
+ auto dpr = window.devicePixelRatio();
+
+ QBackingStore backingStore(&window);
+ QRect rect(0, 0, 100, 100);
+
+ // Scrolling a backingstore without a size shouldn't crash
+ backingStore.scroll(rect, 10, 10);
+ backingStore.scroll(rect, -10, -10);
+
+ backingStore.resize(rect.size());
+
+ // Scrolling a backingstore without painting to it shouldn't crash
+ backingStore.scroll(rect, 10, 10);
+ backingStore.scroll(rect, -10, -10);
+
+ // Two rounds, with flush in between
+ for (int i = 0; i < 2; ++i) {
+
+ backingStore.beginPaint(rect);
+ QPainter p(backingStore.paintDevice());
+ QColor bgColor = i ? Qt::red : Qt::blue;
+ QColor fgColor = i ? Qt::green : Qt::yellow;
+ p.fillRect(rect, bgColor);
+ p.fillRect(QRect(50, 50, 10, 10), fgColor);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(50 * dpr, 50 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(49 * dpr, 50 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(50 * dpr, 49 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(59 * dpr, 59 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(60 * dpr, 59 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(59 * dpr, 60 * dpr), bgColor);
+ image = {};
+
+ bool supportsScroll = backingStore.scroll(QRect(52, 52, 6, 6), -12, -12);
+ if (!supportsScroll)
+ QSKIP("Platform backingstore does not support scrolling");
+
+ image = backingStore.handle()->toImage();
+ QCOMPARE(image.pixelColor(40 * dpr, 40 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(39 * dpr, 40 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(40 * dpr, 39 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(45 * dpr, 45 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(46 * dpr, 45 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(45 * dpr, 46 * dpr), bgColor);
+ image = {};
+
+ backingStore.flush(rect);
+
+ // Scroll again after flush, but before new round of painting
+ backingStore.scroll(QRect(52, 52, 6, 6), 12, 12);
+
+ image = backingStore.handle()->toImage();
+ QCOMPARE(image.pixelColor(64 * dpr, 64 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(63 * dpr, 64 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(64 * dpr, 63 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(69 * dpr, 69 * dpr), fgColor);
+ QCOMPARE(image.pixelColor(70 * dpr, 69 * dpr), bgColor);
+ QCOMPARE(image.pixelColor(69 * dpr, 70 * dpr), bgColor);
+ image = {};
+ }
+}
+
class Window : public QWindow
{
public:
@@ -58,7 +239,7 @@ public:
backingStore.resize(size());
}
- void exposeEvent(QExposeEvent *event) override
+ void paintEvent(QPaintEvent *event) override
{
QRect rect(QPoint(), size());
@@ -70,10 +251,7 @@ public:
backingStore.endPaint();
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
backingStore.flush(event->region().boundingRect());
-QT_WARNING_POP
}
private:
diff --git a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
index 05eba972d6..ac71b91d11 100644
--- a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qclipboard.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(copier)
add_subdirectory(paster)
diff --git a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
index ef599b121e..ea7def8c0d 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
@@ -1,23 +1,16 @@
-# Generated from copier.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## copier Binary:
#####################################################################
-# special case begin
set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-# special case end
qt_internal_add_executable(copier
- ${args} # special case
+ ${args}
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:copier.pro:WIN32:
-# DESTDIR = "../copier"
diff --git a/tests/auto/gui/kernel/qclipboard/copier/main.cpp b/tests/auto/gui/kernel/qclipboard/copier/main.cpp
index 32e91a9939..411ac1e00e 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/copier/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtCore/QStringList>
diff --git a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
index 571ae4944e..9bc1985ee4 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
@@ -1,23 +1,16 @@
-# Generated from paster.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## paster Binary:
#####################################################################
-# special case begin
set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-# special case end
qt_internal_add_executable(paster
- ${args} # special case
+ ${args}
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:paster.pro:WIN32:
-# DESTDIR = "../paster"
diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
index 7fca8af1cb..06db447569 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtGui/QImage>
diff --git a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
index 0e9fa8f40d..fad30c16fd 100644
--- a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from test.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qclipboard Test:
@@ -8,7 +9,7 @@ qt_internal_add_test(tst_qclipboard
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
SOURCES
../tst_qclipboard.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
@@ -17,9 +18,8 @@ qt_internal_add_test(tst_qclipboard
#####################################################################
qt_internal_extend_target(tst_qclipboard CONDITION MACOS
- PUBLIC_LIBRARIES
+ LIBRARIES
${FWAppKit}
)
-#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID:
# TEST_HELPER_INSTALLS = "../copier/copier" "../paster/paster"
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index 42af0dea2c..0b694bff73 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -46,7 +21,7 @@
#ifdef Q_OS_WIN
# include <QtGui/private/qguiapplication_p.h>
-# include <QtGui/private/qwindowsmime_p.h>
+# include <QtGui/qwindowsmimeconverter.h>
# include <QtGui/qpa/qplatformintegration.h>
#endif
@@ -149,7 +124,7 @@ public:
operator bool() const
{
- if (m_timer.elapsed() && !m_spy.count())
+ if (m_timer.elapsed() && !m_spy.size())
return true;
m_spy.clear();
return false;
@@ -191,11 +166,11 @@ void tst_QClipboard::testSignals()
// Test the default mode signal.
clipboard->setText(text);
- QTRY_COMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
- QCOMPARE(selectionChangedSpy.count(), 0);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_COMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard);
changedSpy.clear();
@@ -203,29 +178,29 @@ void tst_QClipboard::testSignals()
// Test the selection mode signal.
if (clipboard->supportsSelection()) {
clipboard->setText(text, QClipboard::Selection);
- QCOMPARE(selectionChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(selectionChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection);
} else {
- QCOMPARE(selectionChangedSpy.count(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
changedSpy.clear();
// Test the search mode signal.
if (clipboard->supportsFindBuffer()) {
clipboard->setText(text, QClipboard::FindBuffer);
- QCOMPARE(searchChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(searchChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer);
} else {
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(searchChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
}
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX)
@@ -365,16 +340,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->clear(QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
// an other crash test
data = new QMimeData;
@@ -401,16 +376,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
}
void tst_QClipboard::clearBeforeSetText()
@@ -451,10 +426,10 @@ void tst_QClipboard::clearBeforeSetText()
# ifdef Q_OS_WIN
-using QWindowsMime = QNativeInterface::Private::QWindowsMime;
+using QWindowsMimeConverter = QWindowsMimeConverter;
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
-class TestMime : public QWindowsMime
+class TestMime : public QWindowsMimeConverter
{
public:
bool canConvertFromMime(const FORMATETC &, const QMimeData *) const override
diff --git a/tests/auto/gui/kernel/qcursor/CMakeLists.txt b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
index 1304dd2ba2..7e29971566 100644
--- a/tests/auto/gui/kernel/qcursor/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qcursor.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcursor Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qcursor
SOURCES
tst_qcursor.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
index eb33cce95b..42ef690efa 100644
--- a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
+++ b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#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 b03f82da39..de1141b304 100644
--- a/tests/auto/gui/kernel/qdrag/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qdrag/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qdrag.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qdrag Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qdrag
SOURCES
tst_qdrag.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp b/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
index 5c243df6d0..8891ddc4ea 100644
--- a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
+++ b/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/kernel/qevent/CMakeLists.txt b/tests/auto/gui/kernel/qevent/CMakeLists.txt
index 2bb22eb469..3603ff6ff4 100644
--- a/tests/auto/gui/kernel/qevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qevent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qevent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qevent Test:
@@ -7,4 +8,7 @@
qt_internal_add_test(tst_qevent
SOURCES
tst_qevent.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::CorePrivate
)
diff --git a/tests/auto/gui/kernel/qevent/tst_qevent.cpp b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
index 6542ed5ad3..f1ffb8c35e 100644
--- a/tests/auto/gui/kernel/qevent/tst_qevent.cpp
+++ b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
@@ -1,36 +1,73 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtCore/qcoreapplication.h>
-#include <QtCore/qcoreevent.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/qevent.h>
+#include <QtCore/private/qfutureinterface_p.h>
+
+#define FOR_EACH_CORE_EVENT(X) \
+ /* qcoreevent.h */ \
+ X(QEvent, (QEvent::None)) \
+ X(QTimerEvent, (42)) \
+ X(QChildEvent, (QEvent::ChildAdded, nullptr)) \
+ X(QDynamicPropertyChangeEvent, ("size")) \
+ X(QDeferredDeleteEvent, ()) \
+ /* qfutureinterface_p.h */ \
+ X(QFutureCallOutEvent, ()) \
+ /* end */
+
+#define FOR_EACH_GUI_EVENT(X) \
+ /* qevent.h */ \
+ X(QInputEvent, (QEvent::None, nullptr)) \
+ X(QPointerEvent, (QEvent::None, nullptr)) \
+ /* doesn't work with nullptr: */ \
+ X(QSinglePointEvent, (QEvent::None, QPointingDevice::primaryPointingDevice(), {}, {}, {}, {}, {}, {})) \
+ 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(QKeyEvent, (QEvent::None, 0, {})) \
+ X(QFocusEvent, (QEvent::None)) \
+ X(QPaintEvent, (QRect{0, 0, 100, 100})) \
+ X(QMoveEvent, ({}, {})) \
+ X(QExposeEvent, ({})) \
+ X(QPlatformSurfaceEvent, ({})) \
+ X(QResizeEvent, ({}, {})) \
+ X(QCloseEvent, ()) \
+ X(QIconDragEvent, ()) \
+ X(QShowEvent, ()) \
+ X(QHideEvent, ()) \
+ X(QContextMenuEvent, (QContextMenuEvent::Reason::Keyboard, {}, {})) \
+ X(QInputMethodEvent, ()) \
+ X(QInputMethodQueryEvent, ({})) \
+ X(QDropEvent, ({}, {}, {}, {}, {})) \
+ X(QDragMoveEvent, ({}, {}, {}, {}, {})) \
+ X(QDragEnterEvent, ({}, {}, {}, {}, {})) \
+ X(QDragLeaveEvent, ()) \
+ X(QHelpEvent, ({}, {}, {})) \
+ X(QStatusTipEvent, ({})) \
+ X(QWhatsThisClickedEvent, ({})) \
+ X(QActionEvent, (0, nullptr)) \
+ X(QFileOpenEvent, (QString{})) \
+ X(QToolBarChangeEvent, (false)) \
+ X(QShortcutEvent, ({}, 0)) \
+ X(QWindowStateChangeEvent, ({})) \
+ X(QTouchEvent, (QEvent::None)) \
+ X(QScrollPrepareEvent, ({})) \
+ X(QScrollEvent, ({}, {}, {})) \
+ X(QScreenOrientationChangeEvent, (nullptr, {})) \
+ X(QApplicationStateChangeEvent, ({})) \
+ /* end */
+
+#define FOR_EACH_EVENT(X) \
+ FOR_EACH_CORE_EVENT(X) \
+ FOR_EACH_GUI_EVENT(X) \
+ /* end */
class tst_QEvent : public QObject
{
@@ -40,6 +77,7 @@ public:
~tst_QEvent();
private slots:
+ void clone() const;
void registerEventType_data();
void registerEventType();
void exhaustEventTypeRegistration(); // keep behind registerEventType() test
@@ -55,6 +93,18 @@ tst_QEvent::tst_QEvent()
tst_QEvent::~tst_QEvent()
{ }
+void tst_QEvent::clone() const
+{
+#define ACTION(Type, Init) do { \
+ const std::unique_ptr<const Type> e(new Type Init); \
+ auto c = e->clone(); \
+ static_assert(std::is_same_v<decltype(c), Type *>); \
+ delete c; \
+ } while (0);
+
+ FOR_EACH_EVENT(ACTION)
+}
+
void tst_QEvent::registerEventType_data()
{
QTest::addColumn<int>("hint");
diff --git a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
index 2404833737..837c807469 100644
--- a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qfileopenevent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(test)
add_subdirectory(qfileopeneventexternal)
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
index 658a70619f..7a39bc111c 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qfileopeneventexternal.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## qfileopeneventexternal Binary:
@@ -8,9 +9,6 @@ qt_internal_add_executable(qfileopeneventexternal
GUI
SOURCES
qfileopeneventexternal.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
-
-#### Keys ignored in scope 1:.:.:qfileopeneventexternal.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
index f21b0680bc..0af605ccb6 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui>
#include <QEvent>
@@ -39,8 +14,8 @@ struct MyApplication : public QGuiApplication
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* ev = static_cast<QFileOpenEvent *>(event);
- QFile file;
- bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered);
+ QFile file(ev->file());
+ bool ok = file.open(QFile::Append | QFile::Unbuffered);
if (ok)
file.write(QByteArray("+external"));
return true;
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
index faa5e5acfc..d7f4e32f70 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from test.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qfileopenevent Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qfileopenevent
SOURCES
tst_qfileopenevent.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
index 31cb036515..50671e17f2 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtCore/QTemporaryDir>
#include <QTest>
@@ -103,8 +78,8 @@ void tst_qfileopenevent::constructor()
QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
{
- QFile file;
- event.openFile(file, QFile::ReadOnly);
+ QFile file(event.file());
+ file.open(QFile::ReadOnly);
file.seek(0);
QByteArray data = file.readAll();
return data;
@@ -112,8 +87,8 @@ QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent)
{
- QFile file;
- bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered);
+ QFile file(event.file());
+ bool ok = file.open(QFile::Append | QFile::Unbuffered);
if (ok)
ok = file.write(writeContent) == writeContent.size();
return ok;
@@ -152,8 +127,8 @@ void tst_qfileopenevent::handleLifetime()
QScopedPointer<QFileOpenEvent> event(createFileAndEvent(QLatin1String("testHandleLifetime"), QByteArray("test content")));
// open a QFile after the original RFile is closed
- QFile qFile;
- QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true);
+ QFile qFile(event->file());
+ QVERIFY(qFile.open(QFile::Append | QFile::Unbuffered));
event.reset(0);
// write to the QFile after the event is closed
@@ -177,7 +152,8 @@ void tst_qfileopenevent::multiOpen()
QFile files[5];
for (int i=0; i<5; i++) {
- QCOMPARE(event->openFile(files[i], QFile::ReadOnly), true);
+ files[i].setFileName(event->file());
+ QVERIFY(files[i].open(QFile::ReadOnly));
}
for (int i=0; i<5; i++)
files[i].seek(i);
diff --git a/tests/auto/gui/kernel/qguiapplication/BLACKLIST b/tests/auto/gui/kernel/qguiapplication/BLACKLIST
index e6ffe78ae3..3fa6c4880b 100644
--- a/tests/auto/gui/kernel/qguiapplication/BLACKLIST
+++ b/tests/auto/gui/kernel/qguiapplication/BLACKLIST
@@ -1,3 +1,2 @@
-[focusObject]
-ubuntu-16.04
-opensuse-42.3
+[quitOnLastWindowClosedWithEventLoopLocker]
+b2qt
diff --git a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
index ffd07cad26..343866655a 100644
--- a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
@@ -1,60 +1,42 @@
-# Generated from qguiapplication.pro.
-
-if(NOT QT_FEATURE_private_tests)
- return()
-endif()
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguiapplication Test:
#####################################################################
-# special case begin
if (WIN32)
set(target_version "1.2.3.4")
else()
set(target_version "1.2.3")
endif()
-# special case end
+
+# Resources:
+set(tst_qguiapplication_resource_files
+ "icons/appicon.png"
+ "icons/usericon.png"
+)
qt_internal_add_test(tst_qguiapplication
- VERSION ${target_version} # special case
+ VERSION ${target_version}
SOURCES
- ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case
+ ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h
tst_qguiapplication.cpp
DEFINES
- QT_DISABLE_DEPRECATED_BEFORE=0x050E00
+ QT_QGUIAPPLICATIONTEST=1
INCLUDE_DIRECTORIES
../../../corelib/kernel/qcoreapplication
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
+ TESTDATA ${tst_qguiapplication_resource_files}
+ BUILTIN_TESTDATA
)
-# Resources:
-set(tst_qguiapplication_resource_files
- "icons/appicon.png"
- "icons/usericon.png"
-)
-
-qt_internal_add_resource(tst_qguiapplication "tst_qguiapplication"
- PREFIX
- "/"
- FILES
- ${tst_qguiapplication_resource_files}
-)
-
-# special case begin
+if (ANDROID)
+ set_property(TARGET tst_qguiapplication PROPERTY QT_ANDROID_VERSION_NAME ${target_version})
+endif()
if (APPLE)
set_property(TARGET tst_qguiapplication PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
set_property(TARGET tst_qguiapplication PROPERTY PROPERTY MACOSX_BUNDLE TRUE)
endif()
-# special case end
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 3:.:../../../corelib/kernel/qcoreapplication:../../../corelib/kernel/qcoreapplication/qcoreapplication.pro:WIN32:
-# VERSION = "1.2.3.4"
-
-#### Keys ignored in scope 4:.:../../../corelib/kernel/qcoreapplication:../../../corelib/kernel/qcoreapplication/qcoreapplication.pro:else:
-# VERSION = "1.2.3"
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 836419659b..5a206d8177 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -123,20 +98,20 @@ void tst_QGuiApplication::displayName()
QGuiApplication::setApplicationName("The Core Application");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The Core Application"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QGuiApplication::setApplicationDisplayName("The GUI Application");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationName("The Core Application 2");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application 2"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationDisplayName("The GUI Application 2");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application 2"));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QGuiApplication::desktopFileName()
@@ -247,12 +222,12 @@ void tst_QGuiApplication::focusObject()
window1.setFocusObject(&obj1);
QCOMPARE(app.focusObject(), &obj1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window1.setFocusObject(&obj2);
QCOMPARE(app.focusObject(), &obj2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window2.setFocusObject(&obj3);
@@ -261,12 +236,12 @@ void tst_QGuiApplication::focusObject()
QVERIFY(QTest::qWaitForWindowExposed(&window2));
QTRY_COMPARE(app.focusWindow(), &window2);
QCOMPARE(app.focusObject(), &obj3);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// focus change on unfocused window does not show
spy.clear();
window1.setFocusObject(&obj1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(app.focusObject(), &obj3);
}
@@ -278,13 +253,13 @@ void tst_QGuiApplication::allWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.allWindows().contains(window1));
QVERIFY(app.allWindows().contains(window2));
- QCOMPARE(app.allWindows().count(), 2);
+ QCOMPARE(app.allWindows().size(), 2);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.allWindows().contains(window2));
QVERIFY(!app.allWindows().contains(window1));
- QCOMPARE(app.allWindows().count(), 0);
+ QCOMPARE(app.allWindows().size(), 0);
}
void tst_QGuiApplication::topLevelWindows()
@@ -295,13 +270,13 @@ void tst_QGuiApplication::topLevelWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.topLevelWindows().contains(window1));
QVERIFY(!app.topLevelWindows().contains(window2));
- QCOMPARE(app.topLevelWindows().count(), 1);
+ QCOMPARE(app.topLevelWindows().size(), 1);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.topLevelWindows().contains(window2));
QVERIFY(!app.topLevelWindows().contains(window1));
- QCOMPARE(app.topLevelWindows().count(), 0);
+ QCOMPARE(app.topLevelWindows().size(), 0);
}
class ShowCloseShowWindow : public QWindow
@@ -545,26 +520,35 @@ void tst_QGuiApplication::palette()
// The default application palette is not resolved
QVERIFY(!QGuiApplication::palette().resolveMask());
+ // TODO: add event processing instead of the signal
+#if QT_DEPRECATED_SINCE(6, 0)
QSignalSpy signalSpy(&app, SIGNAL(paletteChanged(QPalette)));
+#endif
QPalette oldPalette = QGuiApplication::palette();
QPalette newPalette = QPalette(Qt::red);
QGuiApplication::setPalette(newPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), newPalette));
- QCOMPARE(signalSpy.count(), 1);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 1);
QVERIFY(palettesMatch(signalSpy.at(0).at(0).value<QPalette>(), newPalette));
+#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
- QCOMPARE(signalSpy.count(), 2);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 2);
QVERIFY(palettesMatch(signalSpy.at(1).at(0).value<QPalette>(), oldPalette));
+#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
- QCOMPARE(signalSpy.count(), 2);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 2);
+#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
}
@@ -573,24 +557,32 @@ void tst_QGuiApplication::font()
int argc = 1;
char *argv[] = { const_cast<char*>("tst_qguiapplication") };
QGuiApplication app(argc, argv);
+#if QT_DEPRECATED_SINCE(6, 0)
QSignalSpy signalSpy(&app, SIGNAL(fontChanged(QFont)));
+#endif
QFont oldFont = QGuiApplication::font();
QFont newFont = QFont("BogusFont", 33);
QGuiApplication::setFont(newFont);
QCOMPARE(QGuiApplication::font(), newFont);
- QCOMPARE(signalSpy.count(), 1);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0), QVariant(newFont));
+#endif
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
- QCOMPARE(signalSpy.count(), 2);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 2);
QCOMPARE(signalSpy.at(1).at(0), QVariant(oldFont));
+#endif
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
- QCOMPARE(signalSpy.count(), 2);
+#if QT_DEPRECATED_SINCE(6, 0)
+ QCOMPARE(signalSpy.size(), 2);
+#endif
}
class BlockableWindow : public QWindow
@@ -895,9 +887,9 @@ void tst_QGuiApplication::quitOnLastWindowClosed()
app.exec();
- QCOMPARE(spyAboutToQuit.count(), 1);
+ QCOMPARE(spyAboutToQuit.size(), 1);
// Should be around 10 if closing caused the quit
- QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData());
+ QVERIFY2(spyTimeout.size() < 15, QByteArray::number(spyTimeout.size()).constData());
}
void tst_QGuiApplication::quitOnLastWindowClosedMulti()
@@ -938,7 +930,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti()
app.exec();
QVERIFY(!prematureQuit);
- QCOMPARE(spyAboutToQuit.count(), 1); // fired only once
+ QCOMPARE(spyAboutToQuit.size(), 1); // fired only once
}
void tst_QGuiApplication::dontQuitOnLastWindowClosed()
@@ -966,8 +958,8 @@ void tst_QGuiApplication::dontQuitOnLastWindowClosed()
app.setQuitOnLastWindowClosed(true); // restore underlying static to default value
- QCOMPARE(spyTimeout.count(), 1); // quit timer fired
- QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted
+ QCOMPARE(spyTimeout.size(), 1); // quit timer fired
+ QCOMPARE(spyLastWindowClosed.size(), 1); // lastWindowClosed emitted
}
class QuitSpy : public QObject
@@ -1156,8 +1148,8 @@ void tst_QGuiApplication::layoutDirection()
{
qRegisterMetaType<Qt::LayoutDirection>();
- Qt::LayoutDirection oldDirection = QGuiApplication::layoutDirection();
- Qt::LayoutDirection newDirection = oldDirection == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight;
+ const Qt::LayoutDirection oldDirection = QGuiApplication::layoutDirection();
+ const Qt::LayoutDirection newDirection = oldDirection == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight;
QGuiApplication::setLayoutDirection(newDirection);
QCOMPARE(QGuiApplication::layoutDirection(), newDirection);
@@ -1169,14 +1161,70 @@ void tst_QGuiApplication::layoutDirection()
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection));
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
+
+ // with QGuiApplication instantiated, install a translator that gives us control
+ class LayoutDirectionTranslator : public QTranslator
+ {
+ public:
+ LayoutDirectionTranslator(Qt::LayoutDirection direction)
+ : direction(direction)
+ {}
+
+ bool isEmpty() const override { return false; }
+ QString translate(const char *context, const char *sourceText, const char *disambiguation, int n) const override
+ {
+ if (QByteArrayView(sourceText) == "QT_LAYOUT_DIRECTION")
+ return direction == Qt::LeftToRight ? QLatin1String("LTR") : QLatin1String("RTL");
+ return QTranslator::translate(context, sourceText, disambiguation, n);
+ }
+
+ const Qt::LayoutDirection direction;
+ };
+
+ int layoutDirectionChangedCount = 0;
+ // reset to auto-detection, should be back to oldDirection now
+ QGuiApplication::setLayoutDirection(Qt::LayoutDirectionAuto);
+ QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
+ signalSpy.clear();
+ {
+ // this translator doesn't change the direction
+ LayoutDirectionTranslator translator(oldDirection);
+ QGuiApplication::installTranslator(&translator);
+ QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
+ }
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); // ltrTranslator removed, no change
+
+ // install a new translator that changes the direction
+ {
+ LayoutDirectionTranslator translator(newDirection);
+ QGuiApplication::installTranslator(&translator);
+ QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
+ }
+ // rtlTranslator removed
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
+
+ // override translation
+ QGuiApplication::setLayoutDirection(newDirection);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
+ {
+ // this translator will be ignored
+ LayoutDirectionTranslator translator(oldDirection);
+ QGuiApplication::installTranslator(&translator);
+ QCOMPARE(QGuiApplication::layoutDirection(), newDirection);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
+ }
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
+
void tst_QGuiApplication::globalShareContext()
{
#ifndef QT_NO_OPENGL
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc
deleted file mode 100644
index b26fba37b9..0000000000
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/">
- <file>icons/usericon.png</file>
- <file>icons/appicon.png</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
index b1c0508198..f080722817 100644
--- a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qguieventdispatcher.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguieventdispatcher Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qguieventdispatcher
SOURCES
../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
index ec9441a1dc..16f15fc18e 100644
--- a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qguieventloop.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguieventloop Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qguieventloop
SOURCES
../../../corelib/kernel/qeventloop/tst_qeventloop.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::Network
@@ -17,7 +18,7 @@ qt_internal_add_test(tst_qguieventloop
#####################################################################
qt_internal_extend_target(tst_qguieventloop CONDITION WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
user32
)
diff --git a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
index 0887f05fc6..17537ce5a3 100644
--- a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qguimetatype.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguimetatype Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qguimetatype
SOURCES
tst_qguimetatype.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index aac914bc68..686e2a0e8b 100644
--- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtCore>
@@ -45,6 +20,8 @@ private slots:
void sizeOf();
void flags_data();
void flags();
+ void flags2_data();
+ void flags2();
void construct_data();
void construct();
void constructCopy_data();
@@ -318,14 +295,27 @@ struct TypeAlignment
enum { Value = alignof(T) };
};
+template <typename T> void addFlagsRow(const char *name, int id = qMetaTypeId<T>())
+{
+ QTest::newRow(name)
+ << id
+ << bool(QTypeInfo<T>::isRelocatable)
+ << bool(!std::is_trivially_default_constructible_v<T>)
+ << bool(!std::is_trivially_copy_constructible_v<T>)
+ << bool(!std::is_trivially_destructible_v<T>);
+}
+
+// tst_QGuiMetaType::flags is nearly identical to tst_QMetaType::flags
void tst_QGuiMetaType::flags_data()
{
QTest::addColumn<int>("type");
QTest::addColumn<bool>("isRelocatable");
- QTest::addColumn<bool>("isComplex");
+ QTest::addColumn<bool>("needsConstruction");
+ QTest::addColumn<bool>("needsCopyConstruction");
+ QTest::addColumn<bool>("needsDestruction");
#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
- QTest::newRow(#RealType) << MetaTypeId << bool(QTypeInfo<RealType>::isRelocatable) << bool(QTypeInfo<RealType>::isComplex);
+ addFlagsRow<RealType>(#RealType, MetaTypeId);
QT_FOR_EACH_STATIC_GUI_CLASS(ADD_METATYPE_TEST_ROW)
#undef ADD_METATYPE_TEST_ROW
}
@@ -334,13 +324,62 @@ void tst_QGuiMetaType::flags()
{
QFETCH(int, type);
QFETCH(bool, isRelocatable);
- QFETCH(bool, isComplex);
+ QFETCH(bool, needsConstruction);
+ QFETCH(bool, needsCopyConstruction);
+ QFETCH(bool, needsDestruction);
- QCOMPARE(bool(QMetaType(type).flags() & QMetaType::NeedsConstruction), isComplex);
- QCOMPARE(bool(QMetaType(type).flags() & QMetaType::NeedsDestruction), isComplex);
+ QCOMPARE(bool(QMetaType(type).flags() & QMetaType::NeedsConstruction), needsConstruction);
+ QCOMPARE(bool(QMetaType(type).flags() & QMetaType::NeedsCopyConstruction), needsCopyConstruction);
+ QCOMPARE(bool(QMetaType(type).flags() & QMetaType::NeedsDestruction), needsDestruction);
QCOMPARE(bool(QMetaType(type).flags() & QMetaType::RelocatableType), isRelocatable);
}
+template <typename T> static void addFlags2Row(QMetaType metaType = QMetaType::fromType<T>())
+{
+ QTest::newRow(metaType.name() ? metaType.name() : "UnknownType")
+ << metaType
+ << std::is_default_constructible_v<T>
+ << std::is_copy_constructible_v<T>
+ << std::is_move_constructible_v<T>
+ << std::is_destructible_v<T>
+ << (QTypeTraits::has_operator_equal<T>::value || QTypeTraits::has_operator_less_than<T>::value)
+ << QTypeTraits::has_operator_less_than<T>::value;
+};
+
+// tst_QGuiMetaType::flags2 is nearly identical to tst_QMetaType::flags2
+void tst_QGuiMetaType::flags2_data()
+{
+ QTest::addColumn<QMetaType>("type");
+ QTest::addColumn<bool>("isDefaultConstructible");
+ QTest::addColumn<bool>("isCopyConstructible");
+ QTest::addColumn<bool>("isMoveConstructible");
+ QTest::addColumn<bool>("isDestructible");
+ QTest::addColumn<bool>("isEqualityComparable");
+ QTest::addColumn<bool>("isOrdered");
+
+#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \
+ addFlags2Row<RealType>();
+QT_FOR_EACH_STATIC_GUI_CLASS(ADD_METATYPE_TEST_ROW)
+#undef ADD_METATYPE_TEST_ROW
+}
+
+void tst_QGuiMetaType::flags2()
+{
+ QFETCH(QMetaType, type);
+ QFETCH(bool, isDefaultConstructible);
+ QFETCH(bool, isCopyConstructible);
+ QFETCH(bool, isMoveConstructible);
+ QFETCH(bool, isDestructible);
+ QFETCH(bool, isEqualityComparable);
+ QFETCH(bool, isOrdered);
+
+ QCOMPARE(type.isDefaultConstructible(), isDefaultConstructible);
+ QCOMPARE(type.isCopyConstructible(), isCopyConstructible);
+ QCOMPARE(type.isMoveConstructible(), isMoveConstructible);
+ QCOMPARE(type.isDestructible(), isDestructible);
+ QCOMPARE(type.isEqualityComparable(), isEqualityComparable);
+ QCOMPARE(type.isOrdered(), isOrdered);
+}
void tst_QGuiMetaType::construct_data()
{
diff --git a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
index 5375155a82..cf63294fae 100644
--- a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qguitimer.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguitimer Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qguitimer
SOURCES
../../../corelib/kernel/qtimer/tst_qtimer.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qguivariant/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
index 3a0adab6e3..eda22152ec 100644
--- a/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qguivariant.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(test)
add_subdirectory(no_application)
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
index 2e6f548f11..b7c2998bf0 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
@@ -1,12 +1,13 @@
-# Generated from no_application.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## no_application Test:
#####################################################################
-qt_internal_add_test(no_application
+qt_internal_add_test(tst_gui_variant_no_application
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
index 1ab0f63240..bf6e2080b2 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
+++ b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
index a3292511bd..844412c937 100644
--- a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
@@ -1,27 +1,23 @@
-# Generated from test.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qguivariant Test:
#####################################################################
+# Resources:
+file(GLOB_RECURSE qguivariant_resource_files
+ RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
+ "data/*"
+)
+
qt_internal_add_test(tst_qguivariant
SOURCES
tst_qguivariant.cpp
INCLUDE_DIRECTORIES
../../../../other/qvariant_common
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
+ TESTDATA ${qguivariant_resource_files}
+ BUILTIN_TESTDATA
)
-
-# Resources:
-set(qguivariant_resource_files
- "data"
-)
-
-qt_internal_add_resource(tst_qguivariant "qguivariant"
- PREFIX
- "/"
- FILES
- ${qguivariant_resource_files}
-)
-
diff --git a/tests/auto/gui/kernel/qguivariant/test/qguivariant.qrc b/tests/auto/gui/kernel/qguivariant/test/qguivariant.qrc
deleted file mode 100644
index 576d9cda1c..0000000000
--- a/tests/auto/gui/kernel/qguivariant/test/qguivariant.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>data</file>
-</qresource>
-</RCC>
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index aea5cb3ac3..27ba5e9386 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -245,7 +220,7 @@ void tst_QGuiVariant::toColor_data()
QTest::newRow("qstring(#ff0000)") << QVariant(QString::fromUtf8("#ff0000")) << c;
QTest::newRow("qbytearray(#ff0000)") << QVariant(QByteArray("#ff0000")) << c;
- c.setNamedColor("#88112233");
+ c = QColor::fromString("#88112233");
QTest::newRow("qstring(#88112233)") << QVariant(QString::fromUtf8("#88112233")) << c;
QTest::newRow("qbytearray(#88112233)") << QVariant(QByteArray("#88112233")) << c;
}
diff --git a/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
index bdd9a5e17f..3588c35f6c 100644
--- a/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qhighdpi.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qhighdpi Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qhighdpi
SOURCES
tst_qhighdpi.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index b732954230..fad3df4daa 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <private/qhighdpiscaling_p.h>
#include <qpa/qplatformscreen.h>
@@ -64,6 +39,8 @@ private slots:
void environment_QT_SCREEN_SCALE_FACTORS_data();
void environment_QT_SCREEN_SCALE_FACTORS();
void environment_QT_USE_PHYSICAL_DPI();
+ void environment_QT_SCALE_FACTOR_ROUNDING_POLICY();
+ void application_setScaleFactorRoundingPolicy();
void screenAt_data();
void screenAt();
void screenGeometry_data();
@@ -76,6 +53,8 @@ private slots:
void mouseEvents();
void mouseVelocity();
void mouseVelocity_data();
+ void setCursor();
+ void setCursor_data();
};
/// Offscreen platform plugin test setup
@@ -86,7 +65,7 @@ const int standardScreenCount = 3;
QJsonArray tst_QHighDpi::createStandardScreens(const QList<qreal> &dpiValues)
{
- Q_ASSERT(dpiValues.count() == standardScreenCount);
+ Q_ASSERT(dpiValues.size() == standardScreenCount);
// Create row of three screens: screen#0 screen#1 screen#2
return QJsonArray {
@@ -203,65 +182,6 @@ QJsonObject tst_QHighDpi::offscreenConfiguration()
return getConfiguration(platformNativeInterface);
}
-// JsonValueRef implements support for mutating nested JSON structures, e.g.
-//
-// JsonValueRef::get(&config)["screens"][0]["logicalDpi"] = 192
-//
-class JsonValueRef {
-public:
- static JsonValueRef get(QJsonValue *value) {
- return JsonValueRef(value);
- }
-
- JsonValueRef(QJsonValue *value)
- : m_value(value) { }
-
- JsonValueRef(QJsonValue *value, JsonValueRef *parent, QString key)
- : m_value(value), m_parent(parent), m_key(key) { }
-
- JsonValueRef(QJsonValue *value, JsonValueRef *parent, int index)
- : m_value(value), m_parent(parent), m_index(index) { }
-
- ~JsonValueRef() {
- if (m_parent) {
- if (!m_key.isNull()) {
- QJsonObject parentObject = m_parent->m_value->toObject();
- parentObject[m_key] = *m_value;
- *m_parent->m_value = parentObject;
- } else if (m_index > -1) {
- QJsonArray parentArray = m_parent->m_value->toArray();
- parentArray[m_index] = *m_value;
- *m_parent->m_value = parentArray;
- }
- delete m_value; // owned if we have a parent, see operator[]
- }
- }
-
- JsonValueRef operator[](const char *str) {
- QString key = QString::fromUtf8(str);
- return JsonValueRef(new QJsonValue((*m_value)[key]), this, key);
- }
-
- JsonValueRef operator[](int index) {
- return JsonValueRef(new QJsonValue((*m_value)[index]), this, index);
- }
-
- void operator=(int value) {
- *m_value = QJsonValue(value);
- }
-
- void operator=(const char *str) {
- *m_value = QJsonValue(QString(str));
- }
-
-private:
- Q_DISABLE_COPY(JsonValueRef);
- QJsonValue *m_value = nullptr;
- JsonValueRef *m_parent = nullptr;
- QString m_key;
- int m_index = -1;
-};
-
void tst_QHighDpi::cleanup()
{
// Some test functions set environment variables. Unset them here,
@@ -269,6 +189,7 @@ void tst_QHighDpi::cleanup()
qunsetenv("QT_SCALE_FACTOR");
qunsetenv("QT_SCREEN_SCALE_FACTORS");
qunsetenv("QT_USE_PHYSICAL_DPI");
+ qunsetenv("QT_SCALE_FACTOR_ROUNDING_POLICY");
}
void tst_QHighDpi::qhighdpiscaling_data()
@@ -327,10 +248,12 @@ void tst_QHighDpi::screenDpiChange()
// Set new DPI
int newDpi = 192;
QJsonValue config = offscreenConfiguration();
- JsonValueRef::get(&config)["screens"][0]["logicalDpi"] = newDpi;
- JsonValueRef::get(&config)["screens"][1]["logicalDpi"] = newDpi;
- JsonValueRef::get(&config)["screens"][2]["logicalDpi"] = newDpi;
- setOffscreenConfiguration(config.toObject());
+ // API defect until Qt 7, so go indirectly via CBOR
+ QCborMap map = QCborMap::fromJsonObject(config.toObject());
+ map[QLatin1String("screens")][0][QLatin1String("logicalDpi")] = newDpi;
+ map[QLatin1String("screens")][1][QLatin1String("logicalDpi")] = newDpi;
+ map[QLatin1String("screens")][2][QLatin1String("logicalDpi")] = newDpi;
+ setOffscreenConfiguration(map.toJsonObject());
// TODO check events
@@ -347,7 +270,7 @@ void tst_QHighDpi::screenDpiChange()
void tst_QHighDpi::environment_QT_SCALE_FACTOR()
{
qreal factor = 3.1415;
- qputenv("QT_SCALE_FACTOR", QByteArray::number(factor));
+ qputenv("QT_SCALE_FACTOR", std::to_string(factor));
QList<qreal> dpiValues { 96, 144, 192 };
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
@@ -431,6 +354,59 @@ void tst_QHighDpi::environment_QT_USE_PHYSICAL_DPI()
}
}
+void tst_QHighDpi::environment_QT_SCALE_FACTOR_ROUNDING_POLICY()
+{
+ QList<qreal> dpiValues { 96, 144, 192 };
+
+ qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough");
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
+ }
+
+ qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "Round");
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), qRound(dpiValues[i] / qreal(96)));
+ }
+
+ qunsetenv("QT_SCALE_FACTOR_ROUNDING_POLICY");
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
+ }
+}
+
+void tst_QHighDpi::application_setScaleFactorRoundingPolicy()
+{
+ QList<qreal> dpiValues { 96, 144, 192 };
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), qRound(dpiValues[i] / qreal(96)));
+ }
+
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
+ }
+
+ // Verify that environment overrides app setting
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
+ qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough");
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+ for (int i = 0; i < dpiValues.size(); ++i)
+ QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
+ }
+}
+
void tst_QHighDpi::minimumDpr()
{
QList<qreal> dpiValues { 40, 60, 95 };
@@ -474,7 +450,7 @@ void tst_QHighDpi::screenAt()
QFETCH(QList<qreal>, dpiValues);
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- QCOMPARE(app->screens().count(), standardScreenCount); // standard setup
+ QCOMPARE(app->screens().size(), standardScreenCount); // standard setup
// Verify that screenAt() returns the correct or no screen for various points,
// for all screens.
@@ -483,7 +459,7 @@ void tst_QHighDpi::screenAt()
qreal dpi = dpiValues[i++];
// veryfy virtualSiblings and that AA_EnableHighDpiScaling is active
- QCOMPARE(screen->virtualSiblings().count(), standardScreenCount);
+ QCOMPARE(screen->virtualSiblings().size(), standardScreenCount);
QCOMPARE(screen->geometry().size(), QSize(standardScreenWidth, standardScreenHeight) * (96.0 / dpi));
// test points on screen
@@ -805,5 +781,22 @@ void tst_QHighDpi::mouseVelocity()
}
}
+void tst_QHighDpi::setCursor_data()
+{
+ standardScreenDpiTestData();
+}
+
+void tst_QHighDpi::setCursor()
+{
+ QFETCH(QList<qreal>, dpiValues);
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ for (QScreen *screen : app->screens()) {
+ QPoint center = screen->geometry().center();
+ QCursor::setPos(center.x(), center.y());
+ QCOMPARE(QCursor::pos(), center);
+ }
+}
+
#include "tst_qhighdpi.moc"
QTEST_APPLESS_MAIN(tst_QHighDpi);
diff --git a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
index aea72357dd..390c5e39ab 100644
--- a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qinputdevice.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qinputdevice Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qinputdevice
SOURCES
tst_qinputdevice.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
index 077a44b229..ac42f0da30 100644
--- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
+++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <qpa/qwindowsysteminterface.h>
@@ -43,12 +18,56 @@ private slots:
void multiSeatDevices();
private:
+ const QInputDevice *getPrimaryKeyboard(const QString& seatName = QString());
+ const QPointingDevice *getPrimaryPointingDevice(const QString& seatName = QString());
};
void tst_QInputDevice::initTestCase()
{
}
+const QInputDevice *tst_QInputDevice::getPrimaryKeyboard(const QString& seatName)
+{
+ QList<const QInputDevice *> devices = QInputDevice::devices();
+ const QInputDevice *ret = nullptr;
+ for (const QInputDevice *d : devices) {
+ if (d->type() != QInputDevice::DeviceType::Keyboard)
+ continue;
+ if (seatName.isNull() || d->seatName() == seatName) {
+ // the master keyboard's parent is not another input device
+ if (!d->parent() || !qobject_cast<const QInputDevice *>(d->parent()))
+ return d;
+ if (!ret)
+ ret = d;
+ }
+ }
+ return ret;
+}
+
+const QPointingDevice *tst_QInputDevice::getPrimaryPointingDevice(const QString& seatName)
+{
+ QList<const QInputDevice *> devices = QInputDevice::devices();
+ const QPointingDevice *mouse = nullptr;
+ const QPointingDevice *touchpad = nullptr;
+ for (const QInputDevice *dev : devices) {
+ if (!seatName.isNull() && dev->seatName() != seatName)
+ continue;
+ if (dev->type() == QInputDevice::DeviceType::Mouse) {
+ if (!mouse)
+ mouse = static_cast<const QPointingDevice *>(dev);
+ // the core pointer is likely a mouse, and its parent is not another input device
+ if (!mouse->parent() || !qobject_cast<const QInputDevice *>(mouse->parent()))
+ return mouse;
+ } else if (dev->type() == QInputDevice::DeviceType::TouchPad) {
+ if (!touchpad || !dev->parent() || dev->parent()->metaObject() != dev->metaObject())
+ touchpad = static_cast<const QPointingDevice *>(dev);
+ }
+ }
+ if (mouse)
+ return mouse;
+ return touchpad;
+}
+
void tst_QInputDevice::multiSeatDevices()
{
QWindowSystemInterface::registerInputDevice(new QInputDevice("seat 1 kbd", 1000, QInputDevice::DeviceType::Keyboard, "seat 1", this));
@@ -59,15 +78,17 @@ void tst_QInputDevice::multiSeatDevices()
QWindowSystemInterface::registerInputDevice(new QPointingDevice("seat 2 mouse", 2010, QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
QInputDevice::Capability::Position | QInputDevice::Capability::Hover,
1, 2, "seat 2", QPointingDeviceUniqueId(), this));
- QVERIFY(QInputDevice::devices().count() >= 4);
+ QVERIFY(QInputDevice::devices().size() >= 4);
QVERIFY(QInputDevicePrivate::fromId(1010));
QVERIFY(QInputDevicePrivate::fromId(1010)->hasCapability(QInputDevice::Capability::Scroll));
QVERIFY(QInputDevicePrivate::fromId(2010));
QVERIFY(!QInputDevicePrivate::fromId(2010)->hasCapability(QInputDevice::Capability::Scroll));
QVERIFY(QInputDevice::primaryKeyboard());
- QCOMPARE(QInputDevice::primaryKeyboard()->systemId(), qint64(1) << 33);
+ if (!getPrimaryKeyboard())
+ QCOMPARE(QInputDevice::primaryKeyboard()->systemId(), qint64(1) << 33);
QVERIFY(QPointingDevice::primaryPointingDevice());
- QCOMPARE(QPointingDevice::primaryPointingDevice()->systemId(), 1);
+ if (!getPrimaryPointingDevice())
+ QCOMPARE(QPointingDevice::primaryPointingDevice()->systemId(), 1);
QVERIFY(QInputDevice::primaryKeyboard("seat 1"));
QCOMPARE(QInputDevice::primaryKeyboard("seat 1")->systemId(), 1000);
QVERIFY(QPointingDevice::primaryPointingDevice("seat 1"));
diff --git a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
index bbe8652e99..a5d684e017 100644
--- a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qinputmethod.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qinputmethod Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qinputmethod
SOURCES
tst_qinputmethod.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index 318309d959..c562a5c362 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QSignalSpy>
@@ -150,7 +125,7 @@ void tst_qinputmethod::animating()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(animatingChanged()));
m_platformInputContext.emitAnimatingChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::keyboarRectangle()
@@ -162,7 +137,7 @@ void tst_qinputmethod::keyboarRectangle()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged()));
m_platformInputContext.emitKeyboardRectChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::inputItemTransform()
@@ -177,7 +152,7 @@ void tst_qinputmethod::inputItemTransform()
qApp->inputMethod()->setInputItemTransform(transform);
QCOMPARE(qApp->inputMethod()->inputItemTransform(), transform);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// reset
qApp->inputMethod()->setInputItemTransform(QTransform());
diff --git a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
index bd9f602e56..8741cfc2aa 100644
--- a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qkeyevent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qkeyevent Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qkeyevent
SOURCES
tst_qkeyevent.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
index 1873c190d5..4f2379fbb4 100644
--- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
+++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
diff --git a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
index 9d0e25d356..ded845fbfb 100644
--- a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
@@ -1,28 +1,23 @@
-# Generated from qkeysequence.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qkeysequence Test:
#####################################################################
-qt_internal_add_test(tst_qkeysequence
- SOURCES
- tst_qkeysequence.cpp
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
-)
-
# Resources:
set(qkeysequence_resource_files
"keys_de.qm"
"qt_de.qm"
)
-qt_internal_add_resource(tst_qkeysequence "qkeysequence"
- PREFIX
- "/"
- FILES
- ${qkeysequence_resource_files}
+qt_internal_add_test(tst_qkeysequence
+ SOURCES
+ tst_qkeysequence.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ TESTDATA ${qkeysequence_resource_files}
+ BUILTIN_TESTDATA
)
-
diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.qrc b/tests/auto/gui/kernel/qkeysequence/qkeysequence.qrc
deleted file mode 100644
index e224faaddd..0000000000
--- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource>
- <file>keys_de.qm</file>
- <file>qt_de.qm</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index fb7296f834..976e4f76bb 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -502,6 +477,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
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";
QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+ QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
+ QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
+ QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
+ QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
}
void tst_QKeySequence::toStringFromKeycode()
@@ -579,10 +558,6 @@ void tst_QKeySequence::parseString_data()
//QTest::newRow("Ctrl") << "Ctrl" << QKeySequence(Qt::CTRL);
//QTest::newRow("Shift") << "Shift" << QKeySequence(Qt::SHIFT);
- // Only Keys
- QTest::newRow("a") << "a" << QKeySequence(Qt::Key_A);
- QTest::newRow("A") << "A" << QKeySequence(Qt::Key_A);
-
// Incomplete
QTest::newRow("Meta+Shift+") << "Meta+Shift+" << QKeySequence(Qt::Key_unknown);
}
diff --git a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
index baf9b83b55..70fb5cc834 100644
--- a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmouseevent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qmouseevent Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qmouseevent
SOURCES
tst_qmouseevent.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index d5174e0942..dda91225e5 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
@@ -122,6 +97,7 @@ private slots:
void grabbers_data();
void grabbers();
void velocity();
+ void clone();
private:
MouseEventWidget* testMouseWidget;
@@ -288,14 +264,14 @@ void tst_QMouseEvent::grabbers()
auto firstEPD = devPriv->pointById(0);
QCOMPARE(firstEPD->eventPoint.pressTimestamp(), testMouseWidget->pressTimestamp);
QCOMPARE(firstEPD->exclusiveGrabber, grabExclusive ? testMouseWidget : nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(firstEPD->passiveGrabbers.first(), testMouseWidget);
// Ensure that grabbers are forgotten after release delivery
QTest::mouseRelease(testMouseWidget, Qt::LeftButton, Qt::KeyboardModifiers(), {10, 10});
QTRY_COMPARE(firstEPD->exclusiveGrabber, nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), 0);
}
void tst_QMouseEvent::velocity()
@@ -334,5 +310,24 @@ void tst_QMouseEvent::velocity()
QVERIFY(testMouseWidget->velocity.y() > 0);
}
+void tst_QMouseEvent::clone()
+{
+ const QPointF pos(10.0f, 10.0f);
+
+ QMouseEvent originalMe(QEvent::MouseButtonPress, pos, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ QVERIFY(!originalMe.allPointsAccepted());
+ QVERIFY(!originalMe.points().first().isAccepted());
+
+ // create a clone of the original
+ std::unique_ptr<QMouseEvent> clonedMe(originalMe.clone());
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+
+ // now we alter originalMe, which should *not* change clonedMe
+ originalMe.setAccepted(true);
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+}
+
QTEST_MAIN(tst_QMouseEvent)
#include "tst_qmouseevent.moc"
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
index 698327736e..4539a80654 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmouseevent_modal.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qmouseevent_modal Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qmouseevent_modal
SOURCES
tst_qmouseevent_modal.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::Widgets
)
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 ec2a9729bb..e589e54195 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
+++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
index d171716776..34333ac10a 100644
--- a/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qopenglwindow.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qopenglwindow Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qopenglwindow
SOURCES
tst_qopenglwindow.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
index 379034a20e..e1c4bab677 100644
--- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
+++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtOpenGL/QOpenGLWindow>
#include <QTest>
diff --git a/tests/auto/gui/kernel/qpalette/CMakeLists.txt b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
index f69ac75a41..ce77f5866b 100644
--- a/tests/auto/gui/kernel/qpalette/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpalette.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpalette Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpalette
SOURCES
tst_qpalette.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index 6524f73143..81036bee0a 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -47,6 +22,7 @@ private Q_SLOTS:
void noBrushesSetForDefaultPalette();
void cannotCheckIfInvalidBrushSet();
void checkIfBrushForCurrentGroupSet();
+ void cacheKey();
};
void tst_QPalette::roleValues_data()
@@ -122,6 +98,21 @@ void tst_QPalette::resolve()
QVERIFY(p2ResolvedTo1 != p1);
QVERIFY(p2ResolvedTo1 != p2);
+
+ QPalette p3;
+ // ensure the resolve mask is full
+ for (int r = 0; r < QPalette::NColorRoles; ++r)
+ p3.setBrush(QPalette::All, QPalette::ColorRole(r), Qt::red);
+ const QPalette::ResolveMask fullMask = p3.resolveMask();
+
+ QPalette p3ResolvedToP1 = p3.resolve(p1);
+ QVERIFY(p3ResolvedToP1.isCopyOf(p3));
+
+ QPalette p4;
+ QCOMPARE(p4.resolveMask(), QPalette::ResolveMask{});
+ // resolve must detach even if p4 has no mask
+ p4 = p4.resolve(p3);
+ QCOMPARE(p3.resolveMask(), fullMask);
}
@@ -207,9 +198,6 @@ void tst_QPalette::setBrush()
const QPalette pp = p;
QVERIFY(pp.isCopyOf(p));
- // Setting the same brush won't detach
- p.setBrush(QPalette::Disabled, QPalette::Button, Qt::green);
- QVERIFY(pp.isCopyOf(p));
}
void tst_QPalette::isBrushSet()
@@ -227,6 +215,14 @@ void tst_QPalette::isBrushSet()
QVERIFY(p.isBrushSet(QPalette::Active, QPalette::LinkVisited));
QVERIFY(p.isBrushSet(QPalette::Inactive, QPalette::LinkVisited));
QVERIFY(p.isBrushSet(QPalette::Disabled, QPalette::LinkVisited));
+
+ // Don't set flag when brush doesn't change (and also don't detach - QTBUG-98762)
+ QPalette p2;
+ QPalette p3;
+ QVERIFY(!p2.isBrushSet(QPalette::Active, QPalette::Dark));
+ p2.setBrush(QPalette::Active, QPalette::Dark, p2.brush(QPalette::Active, QPalette::Dark));
+ QVERIFY(!p3.isBrushSet(QPalette::Active, QPalette::Dark));
+ QVERIFY(p2.isBrushSet(QPalette::Active, QPalette::Dark));
}
void tst_QPalette::setAllPossibleBrushes()
@@ -269,5 +265,81 @@ void tst_QPalette::checkIfBrushForCurrentGroupSet()
QVERIFY(p.isBrushSet(QPalette::Current, QPalette::Link));
}
+void tst_QPalette::cacheKey()
+{
+ const QPalette defaultPalette;
+ // precondition: all palettes are expected to have contrasting text on base
+ QVERIFY(defaultPalette.base() != defaultPalette.text());
+ const auto defaultCacheKey = defaultPalette.cacheKey();
+ const auto defaultSerNo = defaultCacheKey >> 32;
+ const auto defaultDetachNo = defaultCacheKey & 0xffffffff;
+
+ QPalette changeTwicePalette(defaultPalette);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::red);
+ const auto firstChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, defaultCacheKey);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::green);
+ const auto secondChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, secondChangeCacheKey);
+
+ QPalette copyDifferentData(defaultPalette);
+ QPalette copyDifferentMask(defaultPalette);
+ QPalette copyDifferentMaskAndData(defaultPalette);
+
+ QCOMPARE(defaultPalette.cacheKey(), copyDifferentData.cacheKey());
+
+ // deep detach of both private and data
+ copyDifferentData.setBrush(QPalette::Base, defaultPalette.text());
+ const auto differentDataKey = copyDifferentData.cacheKey();
+ const auto differentDataSerNo = differentDataKey >> 32;
+ const auto differentDataDetachNo = differentDataKey & 0xffffffff;
+ auto loggerDeepDetach = qScopeGuard([&](){
+ qDebug() << "Deep detach serial" << differentDataSerNo;
+ qDebug() << "Deep detach detach number" << differentDataDetachNo;
+ });
+
+ QCOMPARE_NE(copyDifferentData.cacheKey(), defaultCacheKey);
+ QCOMPARE(defaultPalette.cacheKey(), defaultCacheKey);
+
+ // shallow detach, both privates reference the same data
+ copyDifferentMask.setResolveMask(0xffffffffffffffff);
+ const auto differentMaskKey = copyDifferentMask.cacheKey();
+ const auto differentMaskSerNo = differentMaskKey >> 32;
+ const auto differentMaskDetachNo = differentMaskKey & 0xffffffff;
+ auto loggerShallowDetach = qScopeGuard([&](){
+ qDebug() << "Shallow detach serial" << differentMaskSerNo;
+ qDebug() << "Shallow detach detach number" << differentMaskDetachNo;
+ });
+
+ QCOMPARE(differentMaskSerNo, defaultSerNo);
+ QCOMPARE_NE(differentMaskSerNo, defaultDetachNo);
+ QCOMPARE_NE(differentMaskKey, defaultCacheKey);
+ QCOMPARE_NE(differentMaskKey, differentDataKey);
+
+ // shallow detach, both privates reference the same data
+ copyDifferentMaskAndData.setResolveMask(0xeeeeeeeeeeeeeeee);
+ const auto modifiedCacheKey = copyDifferentMaskAndData.cacheKey();
+ QCOMPARE_NE(modifiedCacheKey, copyDifferentMask.cacheKey());
+ QCOMPARE_NE(modifiedCacheKey, defaultCacheKey);
+ QCOMPARE_NE(modifiedCacheKey, copyDifferentData.cacheKey());
+ QCOMPARE_NE(copyDifferentMask.cacheKey(), defaultCacheKey);
+
+ // full detach - both key elements are different
+ copyDifferentMaskAndData.setBrush(QPalette::Base, defaultPalette.text());
+ const auto modifiedAllKey = copyDifferentMaskAndData.cacheKey();
+ const auto modifiedAllSerNo = modifiedAllKey >> 32;
+ const auto modifiedAllDetachNo = modifiedAllKey & 0xffffffff;
+ QCOMPARE_NE(modifiedAllSerNo, defaultSerNo);
+ QCOMPARE_NE(modifiedAllDetachNo, defaultDetachNo);
+
+ QCOMPARE_NE(modifiedAllKey, copyDifferentMask.cacheKey());
+ QCOMPARE_NE(modifiedAllKey, defaultCacheKey);
+ QCOMPARE_NE(modifiedAllKey, differentDataKey);
+ QCOMPARE_NE(modifiedAllKey, modifiedCacheKey);
+
+ loggerDeepDetach.dismiss();
+ loggerShallowDetach.dismiss();
+}
+
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 e33600dd8c..435606de04 100644
--- a/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpixelformat.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpixelformat Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpixelformat
SOURCES
tst_qpixelformat.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
index 6372303290..a0cf95c7f4 100644
--- a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
+++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui/qpixelformat.h>
diff --git a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
index 82391cf18f..fad0d3381b 100644
--- a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qrasterwindow.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qrasterwindow Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qrasterwindow
SOURCES
tst_qrasterwindow.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
index f0725bff2d..64e418a251 100644
--- a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
+++ b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui/QRasterWindow>
#include <QTest>
diff --git a/tests/auto/gui/kernel/qscreen/BLACKLIST b/tests/auto/gui/kernel/qscreen/BLACKLIST
index 0395ea7b1d..ca3136fdb2 100644
--- a/tests/auto/gui/kernel/qscreen/BLACKLIST
+++ b/tests/auto/gui/kernel/qscreen/BLACKLIST
@@ -1,3 +1,3 @@
-# QTBUG-87390
[grabWindow]
-android
+# QTBUG-100412
+windows
diff --git a/tests/auto/gui/kernel/qscreen/CMakeLists.txt b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
index 9bed97cfcb..10f3633c34 100644
--- a/tests/auto/gui/kernel/qscreen/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qscreen.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qscreen Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qscreen
SOURCES
tst_qscreen.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
index 83d476e812..f64add3117 100644
--- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
+++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
@@ -1,35 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <qpainter.h>
#include <qrasterwindow.h>
#include <qscreen.h>
#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qplatformintegration.h>
+#include <private/qguiapplication_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <QTest>
#include <QSignalSpy>
@@ -180,34 +158,34 @@ void tst_QScreen::orientationChange()
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedPortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
}
void tst_QScreen::grabWindow_data()
{
- if (QGuiApplication::platformName().startsWith(QLatin1String("offscreen"), Qt::CaseInsensitive))
- QSKIP("Offscreen: Screen grabbing not implemented.");
-
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ScreenWindowGrabbing)
+ || (QGuiApplication::platformName().toLower() == QStringLiteral("xcb") && !qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")))
+ QSKIP("This platform does not support grabbing windows on screen.");
QTest::addColumn<int>("screenIndex");
QTest::addColumn<QByteArray>("screenName");
QTest::addColumn<bool>("grabWindow");
@@ -279,20 +257,30 @@ void tst_QScreen::grabWindow()
QCOMPARE(screen->name().toUtf8(), screenName);
const double screenDpr = screen->devicePixelRatio();
+ if (QHighDpiScaling::isActive()) {
+ const float rawFactor = QHighDpiScaling::factor(screen);
+ const float roundedFactor = qRound(rawFactor);
+ if (!qFuzzyCompare(roundedFactor, rawFactor))
+ QSKIP("HighDPI enabled with non-integer factor. Skip due to possible rounding errors.");
+ }
+
Window window(screen);
window.setGeometry(windowRect);
+#ifndef Q_OS_ANDROID
window.show();
+#else
+ window.showNormal();
+#endif
if (!QTest::qWaitForWindowExposed(&window))
QSKIP("Failed to expose window - aborting");
- if (QGuiApplication::platformName().startsWith(QLatin1String("xcb"), Qt::CaseInsensitive))
- QTest::qWait(1500); // this is ridiculously necessary because of effects combined with slowness of VMs
-#ifdef Q_OS_MACOS // wait for desktop on screen to scroll into place
- QTest::qWait(1000);
-#endif
+ // this is necessary because of scrolling effects combined with potential slowness of VMs
+ QTest::qWait(1500);
- QSize expectedGrabSize = grabRect.isValid() ? grabRect.size() : (grabWindow ? windowRect.size() : screen->size());
+ QSize expectedGrabSize = grabRect.isValid()
+ ? grabRect.size()
+ : (grabWindow ? windowRect.size() : screen->size());
// we ask for pixel coordinates, but will get a pixmap with device-specific DPR
expectedGrabSize *= screen->devicePixelRatio();
@@ -300,7 +288,9 @@ void tst_QScreen::grabWindow()
QImage paintedImage = window.image;
QCOMPARE(paintedImage.devicePixelRatio(), screenDpr);
- const QPixmap pixmap = screen->grabWindow(grabWindow ? window.winId() : 0, grabRect.x(), grabRect.y(), grabRect.width(), grabRect.height());
+ const QPixmap pixmap = screen->grabWindow(grabWindow
+ ? window.winId()
+ : 0, grabRect.x(), grabRect.y(), grabRect.width(), grabRect.height());
QImage grabbedImage = pixmap.toImage();
const QSize grabbedSize = grabbedImage.size();
diff --git a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
index 469ab47769..85cc0c7ce0 100644
--- a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qshortcut.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qshortcut_kernel Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qshortcut_kernel
SOURCES
tst_qshortcut.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
index 777f486263..8a1b2888a2 100644
--- a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QtGui/qguiapplication.h>
diff --git a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
index f1fab57ebe..ae94135153 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qsurfaceformat.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qsurfaceformat Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qsurfaceformat
SOURCES
tst_qsurfaceformat.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
index f4410b2dae..0b2d301ad9 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
+++ b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <qsurfaceformat.h>
diff --git a/tests/auto/gui/kernel/qtouchevent/BLACKLIST b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
index 2876c120fc..c4e4b2291d 100644
--- a/tests/auto/gui/kernel/qtouchevent/BLACKLIST
+++ b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
@@ -1,8 +1,6 @@
-[multiPointRawEventTranslationOnTouchScreen]
-ubuntu-16.04
-[multiPointRawEventTranslationOnTouchScreen]
-android
[multiPointRawEventTranslationOnTouchPad]
+# QTBUG-101519
+windows-11
android
[touchBeginWithGraphicsWidget]
android
diff --git a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
index e9a6271f58..6d5cb582e2 100644
--- a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtouchevent.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtouchevent Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qtouchevent
SOURCES
tst_qtouchevent.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
Qt::Widgets
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index 28c33e8226..be976adc5f 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -1,31 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include <QtGui/QCursor>
#include <QtGui/QScreen>
#include <QtWidgets/QGraphicsItem>
#include <QtWidgets/QGraphicsScene>
@@ -33,11 +9,16 @@
#include <QtWidgets/QGraphicsWidget>
#include <QtWidgets/QWidget>
#include <QTest>
+#include <QSet>
+#include <QVarLengthArray>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h>
#include <private/qevent_p.h>
+#include <QtGui/private/qeventpoint_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qpointingdevice_p.h>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
@@ -67,6 +48,24 @@ public:
deleteInTouchBegin = deleteInTouchUpdate = deleteInTouchEnd = false;
}
+ void paintEvent(QPaintEvent *) override
+ {
+ QPainter painter(this);
+ painter.drawRect(rect());
+ painter.setPen(Qt::darkGray);
+ painter.drawText(rect(), Qt::AlignHCenter | Qt::AlignCenter, objectName());
+ static const QString pointFormat = QString::fromUtf8("\360\237\226\227 %1, %2");
+ painter.setPen(Qt::darkGreen);
+ for (const auto &pt : std::as_const(touchBeginPoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ painter.setPen(Qt::darkYellow);
+ for (const auto &pt : std::as_const(touchUpdatePoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ painter.setPen(Qt::darkRed);
+ for (const auto &pt : std::as_const(touchEndPoints))
+ painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
+ }
+
bool event(QEvent *event) override
{
lastNormalizedPositions.clear();
@@ -80,13 +79,15 @@ public:
auto touchEvent = static_cast<QTouchEvent *>(event);
touchBeginPoints = touchEvent->points();
Q_ASSERT(touchBeginPoints.first().device() == touchEvent->pointingDevice());
- for (const QEventPoint &pt : qAsConst(touchBeginPoints))
+ for (const QEventPoint &pt : std::as_const(touchBeginPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchBegin);
if (deleteInTouchBegin)
delete this;
+ else
+ update();
break;
}
case QEvent::TouchUpdate: {
@@ -96,13 +97,15 @@ public:
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchUpdatePoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchUpdatePoints))
+ for (const QEventPoint &pt : std::as_const(touchUpdatePoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchUpdate);
if (deleteInTouchUpdate)
delete this;
+ else
+ update();
break;
}
case QEvent::TouchEnd: {
@@ -112,13 +115,15 @@ public:
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchEndPoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchEndPoints))
+ for (const QEventPoint &pt : std::as_const(touchEndPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
event->setAccepted(acceptTouchEnd);
if (deleteInTouchEnd)
delete this;
+ else
+ update();
break;
}
default:
@@ -364,9 +369,11 @@ void tst_QTouchEvent::state()
QVERIFY(!touchEvent3.isBeginEvent());
QVERIFY(!touchEvent3.isUpdateEvent());
QVERIFY(touchEvent3.isEndEvent());
+#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED // test Qt 5 compatibility wrappers
QCOMPARE(touchEvent3.touchPoints(), touchEvent3.points());
QT_WARNING_POP
+#endif
}
void tst_QTouchEvent::touchDisabledByDefault()
@@ -402,11 +409,11 @@ void tst_QTouchEvent::touchDisabledByDefault()
QVERIFY(!item.acceptTouchEvents());
// compose an event to the scene that is over the item
- QMutableEventPoint touchPoint(0);
- touchPoint.setState(QEventPoint::State::Pressed);
- touchPoint.setPosition(view.mapFromScene(item.mapToScene(item.boundingRect().center())));
- touchPoint.setGlobalPosition(view.mapToGlobal(touchPoint.position().toPoint()));
- touchPoint.setScenePosition(view.mapToScene(touchPoint.position().toPoint()));
+ QEventPoint touchPoint(0);
+ QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
+ QMutableEventPoint::setPosition(touchPoint, view.mapFromScene(item.mapToScene(item.boundingRect().center())));
+ QMutableEventPoint::setGlobalPosition(touchPoint, view.mapToGlobal(touchPoint.position().toPoint()));
+ QMutableEventPoint::setScenePosition(touchPoint, view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
@@ -462,10 +469,10 @@ void tst_QTouchEvent::touchEventAcceptedByDefault()
// compose an event to the scene that is over the item
QPointF pos = view.mapFromScene(item.mapToScene(item.boundingRect().center()));
- QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
- view.mapToScene(pos.toPoint()),
- view.mapToGlobal(pos.toPoint()));
- touchPoint.setPosition(pos);
+ QEventPoint touchPoint(0, QEventPoint::State::Pressed,
+ view.mapToScene(pos.toPoint()),
+ view.mapToGlobal(pos.toPoint()));
+ QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@@ -574,10 +581,10 @@ void tst_QTouchEvent::touchBeginPropagatesWhenIgnored()
// compose an event to the scene that is over the grandchild
QPointF pos = view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()));
- QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
- view.mapToScene(pos.toPoint()),
- view.mapToGlobal(pos.toPoint()));
- touchPoint.setPosition(pos);
+ QEventPoint touchPoint(0, QEventPoint::State::Pressed,
+ view.mapToScene(pos.toPoint()),
+ view.mapToGlobal(pos.toPoint()));
+ QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@@ -657,10 +664,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
// compose an event to the scene that is over the child
QPointF pos = view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()));
- QMutableEventPoint touchPoint(0, QEventPoint::State::Pressed,
- view.mapToScene(pos.toPoint()),
- view.mapToGlobal(pos.toPoint()));
- touchPoint.setPosition(pos);
+ QEventPoint touchPoint(0, QEventPoint::State::Pressed,
+ view.mapToScene(pos.toPoint()),
+ view.mapToGlobal(pos.toPoint()));
+ QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchBeginEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
@@ -672,10 +679,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
QVERIFY(!root.seenTouchBegin);
// send the touch update to the child, but ignore it, it doesn't propagate
- touchPoint = QMutableEventPoint(0, QEventPoint::State::Updated,
- view.mapToScene(pos.toPoint()),
- view.mapToGlobal(pos.toPoint()));
- touchPoint.setPosition(pos);
+ touchPoint = QEventPoint(0, QEventPoint::State::Updated,
+ view.mapToScene(pos.toPoint()),
+ view.mapToGlobal(pos.toPoint()));
+ QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
touchScreenDevice,
Qt::NoModifier,
@@ -687,10 +694,10 @@ void tst_QTouchEvent::touchUpdateAndEndNeverPropagate()
QVERIFY(!root.seenTouchUpdate);
// send the touch end, same thing should happen as with touch update
- touchPoint = QMutableEventPoint(0, QEventPoint::State::Released,
- view.mapToScene(pos.toPoint()),
- view.mapToGlobal(pos.toPoint()));
- touchPoint.setPosition(pos);
+ touchPoint = QEventPoint(0, QEventPoint::State::Released,
+ view.mapToScene(pos.toPoint()),
+ view.mapToGlobal(pos.toPoint()));
+ QMutableEventPoint::setPosition(touchPoint, pos);
QTouchEvent touchEndEvent(QEvent::TouchEnd,
touchScreenDevice,
Qt::NoModifier,
@@ -727,7 +734,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 0);
@@ -757,7 +764,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 0);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state());
@@ -785,7 +792,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 0);
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state());
@@ -808,9 +815,11 @@ void tst_QTouchEvent::basicRawEventTranslation()
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
{
tst_QTouchEventWidget touchWidget;
+ touchWidget.setObjectName("parent touch widget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- touchWidget.setGeometry(100, 100, 400, 300);
+ const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(100, 100);
+ touchWidget.setGeometry({topLeft, QSize(400, 300)});
tst_QTouchEventWidget leftWidget(&touchWidget);
leftWidget.setObjectName("leftWidget");
@@ -824,24 +833,25 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
touchWidget.show();
QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+ if (touchWidget.geometry().topLeft() != topLeft) {
+ qCDebug(lcTests) << "tried to set position 100, 100 on screen; got geometry"
+ << touchWidget.geometry() << "frame" << touchWidget.frameGeometry();
+ QSKIP("failed to position the widget window on this platform");
+ }
- QPointF leftPos = leftWidget.rect().center();
- QPointF rightPos = rightWidget.rect().center();
- QPointF centerPos = touchWidget.rect().center();
- QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
- QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
- QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
+ QPoint leftPos = leftWidget.rect().center();
+ QPoint rightPos = rightWidget.rect().center();
+ QPoint centerPos = touchWidget.rect().center();
+ QPoint leftScenePos = leftWidget.mapToParent(leftPos);
+ QPoint rightScenePos = rightWidget.mapToParent(rightPos);
+ QPoint leftScreenPos = leftWidget.mapToGlobal(leftPos);
+ QPoint rightScreenPos = rightWidget.mapToGlobal(rightPos);
+ QPoint centerScreenPos = touchWidget.mapToGlobal(centerPos);
// generate TouchBegins on both leftWidget and rightWidget
- ulong timestamp = 0;
- auto rawTouchPoints = QList<QEventPoint>()
- << QEventPoint(0, QEventPoint::State::Pressed, QPointF(), leftScreenPos)
- << QEventPoint(1, QEventPoint::State::Pressed, QPointF(), rightScreenPos);
- QWindow *window = touchWidget.windowHandle();
- QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ auto touchSequence = QTest::touchEvent(touchWidget.windowHandle(), touchScreenDevice);
+ touchSequence.press(0, leftScenePos).press(1, rightScenePos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -851,14 +861,14 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 1);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 1);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 1);
const int touchPointId0 = 0;
const int touchPointId1 = touchPointId0 + 1;
{
- QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchBeginPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Pressed);
QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
@@ -868,15 +878,12 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftPos);
- QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
- QEventPoint rightTouchPoint = rightWidget.touchBeginPoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchBeginPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Pressed);
QCOMPARE(rightTouchPoint.position(), rightPos);
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
@@ -886,20 +893,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightPos);
- QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
}
- rawTouchPoints.clear();
- rawTouchPoints << QEventPoint(0, QEventPoint::State::Updated, QPointF(), centerScreenPos)
- << QEventPoint(1, QEventPoint::State::Updated, QPointF(), centerScreenPos);
- nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ // an unlikely event with the two touchpoints moving exactly on top of each other
+ touchSequence.move(0, centerPos).move(1, centerPos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -909,13 +909,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 1);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 1);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 1);
{
- QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchUpdatePoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
- QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Updated);
+ QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos)));
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
@@ -924,16 +924,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(1.));
- QEventPoint rightTouchPoint = rightWidget.touchUpdatePoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchUpdatePoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
- QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Updated);
+ QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos)));
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
@@ -942,21 +939,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(1.));
}
// generate TouchEnds on both leftWidget and rightWidget
- rawTouchPoints.clear();
- rawTouchPoints << QEventPoint(0, QEventPoint::State::Released, QPointF(), centerScreenPos)
- << QEventPoint(1, QEventPoint::State::Released, QPointF(), centerScreenPos);
- nativeTouchPoints =
- QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
- QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
- QCoreApplication::processEvents();
+ touchSequence.release(0, centerPos).release(1, centerPos);
+ QVERIFY(touchSequence.commit()); // verify acceptance
QVERIFY(!touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
@@ -966,13 +955,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 1);
- QCOMPARE(rightWidget.touchEndPoints.count(), 1);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 1);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 1);
{
- QEventPoint leftTouchPoint = leftWidget.touchEndPoints.first();
+ const QEventPoint &leftTouchPoint = leftWidget.touchEndPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
- QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state());
- QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(leftTouchPoint.state(), QEventPoint::Released);
+ QCOMPARE(leftTouchPoint.position(), QPointF(leftWidget.mapFromParent(centerPos)));
QCOMPARE(leftTouchPoint.pressPosition(), leftPos);
QCOMPARE(leftTouchPoint.lastPosition(), leftPos);
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
@@ -981,16 +970,13 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(leftTouchPoint.pressure(), qreal(0.));
- QEventPoint rightTouchPoint = rightWidget.touchEndPoints.first();
+ const QEventPoint &rightTouchPoint = rightWidget.touchEndPoints.first();
QCOMPARE(rightTouchPoint.id(), touchPointId1);
- QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state());
- QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos.toPoint())));
+ QCOMPARE(rightTouchPoint.state(), QEventPoint::Released);
+ QCOMPARE(rightTouchPoint.position(), QPointF(rightWidget.mapFromParent(centerPos)));
QCOMPARE(rightTouchPoint.pressPosition(), rightPos);
QCOMPARE(rightTouchPoint.lastPosition(), rightPos);
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
@@ -999,9 +985,6 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QCOMPARE(rightTouchPoint.position(), rightWidget.mapFromParent(centerPos.toPoint()));
- QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
- QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
QCOMPARE(rightTouchPoint.pressure(), qreal(0.));
}
@@ -1025,13 +1008,13 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// this should be translated to a TouchBegin
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 1, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
+ QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 1);
@@ -1042,11 +1025,11 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchBegin = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 10, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
+ QMutableEventPoint::withTimeStamp(1234, 10, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 10);
@@ -1057,11 +1040,11 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchBegin = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 11, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
+ QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Pressed, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 11);
@@ -1071,13 +1054,13 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// moving the first point should translate to TouchUpdate
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 1, QEventPoint::State::Updated, screenPos + delta, screenPos + delta, screenPos + delta), window);
+ QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Updated, screenPos + delta, screenPos + delta, screenPos + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 1);
QCOMPARE(touchUpdatePoint.state(), QEventPoint::State::Updated);
@@ -1086,13 +1069,13 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
// releasing the first point translates to TouchEnd
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 1, QEventPoint::State::Released, screenPos + delta + delta, screenPos + delta + delta, screenPos + delta + delta), window);
+ QMutableEventPoint::withTimeStamp(1234, 1, QEventPoint::State::Released, screenPos + delta + delta, screenPos + delta + delta, screenPos + delta + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 1);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1110,14 +1093,14 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.touchEndPoints.clear();
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 10, QEventPoint::State::Released, screenPos, screenPos, screenPos) <<
- QMutableEventPoint(1234, 11, QEventPoint::State::Stationary, screenPos, screenPos, screenPos), window);
+ QMutableEventPoint::withTimeStamp(1234, 10, QEventPoint::State::Released, screenPos, screenPos, screenPos) <<
+ QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Stationary, screenPos, screenPos, screenPos), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 10);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 11);
@@ -1125,14 +1108,14 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
touchWidget.seenTouchEnd = false;
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QEventPoint>() <<
- QMutableEventPoint(1234, 11, QEventPoint::State::Released, screenPos + delta + delta,
+ QMutableEventPoint::withTimeStamp(1234, 11, QEventPoint::State::Released, screenPos + delta + delta,
screenPos + delta + delta, screenPos + delta + delta), window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 11);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1140,6 +1123,17 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
{
+#ifdef Q_OS_MACOS
+#if QT_CONFIG(cursor)
+ QCursor::setPos(0, 0); // move mouse out of the way
+ if (!QTest::qWaitFor([]{ return QCursor::pos() == QPoint(0, 0); }))
+#endif
+ QSKIP("The macOS mouse cursor interferes with this test can cannot be moved away");
+#endif
+
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
tst_QTouchEventWidget touchWidget;
touchWidget.setObjectName("touchWidget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
@@ -1158,28 +1152,29 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
rightWidget.setGeometry(300, 100, 100, 100);
touchWidget.show();
- QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+ QVERIFY(QTest::qWaitForWindowActive(&touchWidget));
- QPointF leftPos = leftWidget.rect().center();
- QPointF rightPos = rightWidget.rect().center();
- QPointF centerPos = touchWidget.rect().center();
- QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
- QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
- QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
+ const QPointF leftPos = leftWidget.rect().center();
+ const QPointF rightPos = rightWidget.rect().center();
+ const QPointF centerPos = touchWidget.rect().center();
+ const QPointF leftScreenPos = leftWidget.mapToGlobal(leftPos.toPoint());
+ const QPointF rightScreenPos = rightWidget.mapToGlobal(rightPos.toPoint());
+ const QPointF centerScreenPos = touchWidget.mapToGlobal(centerPos.toPoint());
ulong timestamp = 0;
- QList<QMutableEventPoint> rawTouchPoints;
- rawTouchPoints.append(QMutableEventPoint(0));
- rawTouchPoints.append(QMutableEventPoint(1));
+ QList<QEventPoint> rawTouchPoints = {
+ QEventPoint(0),
+ QEventPoint(1),
+ };
// generate TouchBegin on leftWidget only
{
- QMutableEventPoint &tp0 = QMutableEventPoint::from(rawTouchPoints[0]);
- tp0.setState(QEventPoint::State::Pressed);
- tp0.setGlobalPosition(leftScreenPos);
- QMutableEventPoint & tp1 = QMutableEventPoint::from(rawTouchPoints[1]);
- tp1.setState(QEventPoint::State::Pressed);
- tp1.setGlobalPosition(rightScreenPos);
+ QEventPoint &tp0 = rawTouchPoints[0];
+ QMutableEventPoint::setState(tp0, QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(tp0, leftScreenPos);
+ QEventPoint &tp1 = rawTouchPoints[1];
+ QMutableEventPoint::setState(tp1, QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(tp1, rightScreenPos);
}
QWindow *window = touchWidget.windowHandle();
QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints =
@@ -1195,8 +1190,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 2);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 0);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 2);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after press" << leftWidget.lastNormalizedPositions;
@@ -1212,7 +1208,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.2) < 0.05); // 0.198, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.2), 0.05); // 0.198, might depend on window frame size
QCOMPARE(leftTouchPoint.position(), leftPos);
QCOMPARE(leftTouchPoint.scenePosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalPosition(), leftScreenPos);
@@ -1232,7 +1228,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.8) < 0.05); // 0.798, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.8), 0.05); // 0.798, might depend on window frame size
QCOMPARE(rightTouchPoint.scenePosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.ellipseDiameters(), QSizeF(0, 0));
@@ -1240,10 +1236,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
}
// generate TouchUpdate on leftWidget
- rawTouchPoints[0].setState(QEventPoint::State::Updated);
- rawTouchPoints[0].setGlobalPosition(centerScreenPos);
- rawTouchPoints[1].setState(QEventPoint::State::Updated);
- rawTouchPoints[1].setGlobalPosition(centerScreenPos);
+ QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Updated);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoints[0], centerScreenPos);
+ QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Updated);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoints[1], centerScreenPos);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchPadDevice, nativeTouchPoints);
@@ -1257,8 +1253,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 2);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 0);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 2);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after update" << leftWidget.lastNormalizedPositions;
@@ -1274,7 +1271,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.5) < 0.05); // 0.498, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.5), 0.05); // 0.498, might depend on window frame size
QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
@@ -1294,7 +1291,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.5) < 0.05); // 0.498, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.5), 0.05); // 0.498, might depend on window frame size
QCOMPARE(rightTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
@@ -1304,8 +1301,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
// generate TouchEnd on leftWidget
// both touchpoints are still at centerScreenPos
- rawTouchPoints[0].setState(QEventPoint::State::Released);
- rawTouchPoints[1].setState(QEventPoint::State::Released);
+ QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Released);
+ QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchPadDevice, nativeTouchPoints);
@@ -1319,8 +1316,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 2);
- QCOMPARE(rightWidget.touchEndPoints.count(), 0);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 2);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchEndPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after release" << leftWidget.lastNormalizedPositions;
@@ -1337,7 +1335,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPressPosition(), leftScreenPos);
QCOMPARE(leftTouchPoint.globalLastPosition(), leftScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.5) < 0.05); // 0.498, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(0).x() - 0.5), 0.05); // 0.498, might depend on window frame size
QCOMPARE(leftTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(leftTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(leftTouchPoint.globalPosition(), centerScreenPos);
@@ -1357,7 +1355,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPressPosition(), rightScreenPos);
QCOMPARE(rightTouchPoint.globalLastPosition(), rightScreenPos);
- QVERIFY(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.5) < 0.05); // 0.498, might depend on window frame size
+ QCOMPARE_LT(qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.5), 0.05); // 0.498, might depend on window frame size
QCOMPARE(rightTouchPoint.position(), leftWidget.mapFromParent(centerPos.toPoint()));
QCOMPARE(rightTouchPoint.scenePosition(), centerScreenPos);
QCOMPARE(rightTouchPoint.globalPosition(), centerScreenPos);
@@ -1382,17 +1380,17 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
screenPos << touchWidget.mapToGlobal(pos[i].toPoint());
}
QPointF delta(10, 10);
- QList<QMutableEventPoint> rawTouchPoints;
+ QList<QEventPoint> rawTouchPoints;
// Press both points, this should be translated to a TouchBegin
for (int i = 0; i < 2; ++i) {
- QMutableEventPoint rawTouchPoint(i);
- rawTouchPoint.setState(QEventPoint::State::Pressed);
- rawTouchPoint.setGlobalPosition(screenPos[i]);
+ QEventPoint rawTouchPoint(i);
+ QMutableEventPoint::setState(rawTouchPoint, QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoint, screenPos[i]);
rawTouchPoints << rawTouchPoint;
}
- QMutableEventPoint &p0 = rawTouchPoints[0];
- QMutableEventPoint &p1 = rawTouchPoints[1];
+ QEventPoint &p0 = rawTouchPoints[0];
+ QEventPoint &p1 = rawTouchPoints[1];
ulong timestamp = 1234;
QWindow *window = touchWidget.windowHandle();
@@ -1403,19 +1401,19 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 2);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 2);
- for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) {
+ for (int i = 0; i < touchWidget.touchBeginPoints.size(); ++i) {
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i);
QCOMPARE(touchBeginPoint.id(), i);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state());
}
// moving the point should translate to TouchUpdate
- for (int i = 0; i < rawTouchPoints.count(); ++i) {
+ for (int i = 0; i < rawTouchPoints.size(); ++i) {
auto &p = rawTouchPoints[i];
- p.setState(QEventPoint::State::Updated);
- p.setGlobalPosition(p.globalPosition() + delta);
+ QMutableEventPoint::setState(p, QEventPoint::State::Updated);
+ QMutableEventPoint::setGlobalPosition(p, p.globalPosition() + delta);
}
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@@ -1424,13 +1422,13 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1);
// release last point
- p0.setState(QEventPoint::State::Stationary);
- p1.setState(QEventPoint::State::Released);
+ QMutableEventPoint::setState(p0, QEventPoint::State::Stationary);
+ QMutableEventPoint::setState(p1, QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
@@ -1439,13 +1437,13 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QCOMPARE(touchWidget.seenTouchEnd, false);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1);
// Press last point again, id should increase
- p1.setState(QEventPoint::State::Pressed);
- p1.setId(42); // new id
+ QMutableEventPoint::setState(p1, QEventPoint::State::Pressed);
+ QMutableEventPoint::setId(p1, 42); // new id
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@@ -1453,13 +1451,13 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
// release everything
- p0.setState(QEventPoint::State::Released);
- p1.setState(QEventPoint::State::Released);
+ QMutableEventPoint::setState(p0, QEventPoint::State::Released);
+ QMutableEventPoint::setState(p1, QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@@ -1467,7 +1465,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
}
@@ -1552,23 +1550,23 @@ void tst_QTouchEvent::deleteInEventHandler()
view.resize(200, 200);
view.fitInView(scene.sceneRect());
- QMutableEventPoint touchPoint(0);
- touchPoint.setState(QEventPoint::State::Pressed);
- touchPoint.setPosition(view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
- touchPoint.setGlobalPosition(view.mapToGlobal(touchPoint.position().toPoint()));
- touchPoint.setScenePosition(view.mapToScene(touchPoint.position().toPoint()));
+ QEventPoint touchPoint(0);
+ QMutableEventPoint::setState(touchPoint, QEventPoint::State::Pressed);
+ QMutableEventPoint::setPosition(touchPoint, view.mapFromScene(child1->mapToScene(child1->boundingRect().center())));
+ QMutableEventPoint::setGlobalPosition(touchPoint, view.mapToGlobal(touchPoint.position().toPoint()));
+ QMutableEventPoint::setScenePosition(touchPoint, view.mapToScene(touchPoint.position().toPoint()));
QTouchEvent touchBeginEvent(QEvent::TouchBegin,
touchScreenDevice,
Qt::NoModifier,
{touchPoint});
- touchPoint.detach();
- touchPoint.setState(QEventPoint::State::Updated);
+ QMutableEventPoint::detach(touchPoint);
+ QMutableEventPoint::setState(touchPoint, QEventPoint::State::Updated);
QTouchEvent touchUpdateEvent(QEvent::TouchUpdate,
touchScreenDevice,
Qt::NoModifier,
{touchPoint});
- touchPoint.detach();
- touchPoint.setState(QEventPoint::State::Released);
+ QMutableEventPoint::detach(touchPoint);
+ QMutableEventPoint::setState(touchPoint, QEventPoint::State::Released);
QTouchEvent touchEndEvent(QEvent::TouchEnd,
touchScreenDevice,
Qt::NoModifier,
@@ -1648,16 +1646,17 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
QPointF rightScreenPos = rightWidget->mapToGlobal(rightPos.toPoint());
ulong timestamp = 0;
- QList<QMutableEventPoint> rawTouchPoints;
- rawTouchPoints.append(QMutableEventPoint(0));
- rawTouchPoints.append(QMutableEventPoint(1));
- rawTouchPoints.append(QMutableEventPoint(2));
- rawTouchPoints[0].setState(QEventPoint::State::Pressed);
- rawTouchPoints[0].setGlobalPosition(leftScreenPos);
- rawTouchPoints[1].setState(QEventPoint::State::Pressed);
- rawTouchPoints[1].setGlobalPosition(centerScreenPos);
- rawTouchPoints[2].setState(QEventPoint::State::Pressed);
- rawTouchPoints[2].setGlobalPosition(rightScreenPos);
+ QList<QEventPoint> rawTouchPoints = {
+ QEventPoint(0),
+ QEventPoint(1),
+ QEventPoint(2),
+ };
+ QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoints[0], leftScreenPos);
+ QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoints[1], centerScreenPos);
+ QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Pressed);
+ QMutableEventPoint::setGlobalPosition(rawTouchPoints[2], rightScreenPos);
// generate begin events on all widgets, the left widget should die
QWindow *window = touchWidget.windowHandle();
@@ -1670,18 +1669,18 @@ void tst_QTouchEvent::deleteInRawEventTranslation()
QVERIFY(!rightWidget.isNull());
// generate update events on all widget, the center widget should die
- rawTouchPoints[0].setState(QEventPoint::State::Updated);
- rawTouchPoints[1].setState(QEventPoint::State::Updated);
- rawTouchPoints[2].setState(QEventPoint::State::Updated);
+ QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Updated);
+ QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Updated);
+ QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Updated);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
// generate end events on all widget, the right widget should die
- rawTouchPoints[0].setState(QEventPoint::State::Released);
- rawTouchPoints[1].setState(QEventPoint::State::Released);
- rawTouchPoints[2].setState(QEventPoint::State::Released);
+ QMutableEventPoint::setState(rawTouchPoints[0], QEventPoint::State::Released);
+ QMutableEventPoint::setState(rawTouchPoints[1], QEventPoint::State::Released);
+ QMutableEventPoint::setState(rawTouchPoints[2], QEventPoint::State::Released);
nativeTouchPoints =
QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window);
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, touchScreenDevice, nativeTouchPoints);
@@ -1830,25 +1829,25 @@ void tst_QTouchEvent::testQGuiAppDelivery()
// Now the real thing.
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
points[0].state = QEventPoint::State::Updated;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate);
points[0].state = QEventPoint::State::Released;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 3);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd);
}
@@ -1891,8 +1890,8 @@ void tst_QTouchEvent::testMultiDevice()
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
- QCOMPARE(filter.d.value(deviceTwo).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
+ QCOMPARE(filter.d.value(deviceTwo).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).globalPosition(), area0.center());
// This fails because QGuiApplicationPrivate::processTouchEvent() sends synth-mouse events
@@ -1947,7 +1946,7 @@ void tst_QTouchEvent::grabbers()
// Ensure that grabbers are persistent between events, within the stored touchpoints
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, grabExclusive ? &w : nullptr);
- QCOMPARE(devPriv->pointById(0)->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(devPriv->pointById(0)->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(devPriv->pointById(0)->passiveGrabbers.first(), &w);
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index ee1d6563cb..328d3f51b1 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -1,9 +1,4 @@
[positioning]
-opensuse-leap
-[positioning:default]
-linux
-macos ci
-[positioning:fake]
macos ci
[modalWithChildWindow]
# QTBUG-69160
@@ -11,7 +6,7 @@ android
[modalWindowEnterEventOnHide_QTBUG35109]
osx
android
-windows-10
+windows
[spuriousMouseMove]
# QTBUG-69162
windows-10
diff --git a/tests/auto/gui/kernel/qwindow/CMakeLists.txt b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
index 23671cc385..605761622f 100644
--- a/tests/auto/gui/kernel/qwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qwindow.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qwindow Test:
@@ -7,16 +8,32 @@
qt_internal_add_test(tst_qwindow
SOURCES
tst_qwindow.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
)
+if(APPLE OR WIN32)
+ qt_internal_add_test(tst_foreignwindow
+ SOURCES
+ tst_foreignwindow.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ )
+
+ if(APPLE)
+ target_compile_options(tst_foreignwindow PRIVATE -x objective-c++)
+ set_property(TARGET tst_foreignwindow PROPERTY PROPERTY MACOSX_BUNDLE TRUE)
+ endif()
+endif()
+
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qwindow CONDITION QT_FEATURE_dynamicgl AND WIN32
- PUBLIC_LIBRARIES
+ LIBRARIES
user32
)
diff --git a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
new file mode 100644
index 0000000000..256564f6bc
--- /dev/null
+++ b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
@@ -0,0 +1,121 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include <QTest>
+
+#include <QtCore/qloggingcategory.h>
+#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); }
+
+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];
+}
+
+#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);
+}
+
+#endif
+
+class tst_ForeignWindow: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase()
+ {
+ auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ if (!platformIntegration->hasCapability(QPlatformIntegration::ForeignWindows))
+ QSKIP("This platform does not support foreign windows");
+ }
+
+ void fromWinId();
+};
+
+void tst_ForeignWindow::fromWinId()
+{
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ QVERIFY(foreignWindow);
+ QVERIFY(foreignWindow->flags().testFlag(Qt::ForeignWindow));
+ QVERIFY(foreignWindow->handle());
+
+ // fromWinId does not take (exclusive) ownership of the native window,
+ // so deleting the foreign window should not be a problem/cause crashes.
+ foreignWindow.reset();
+}
+
+#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 9e8e1eac11..1cac1820d9 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <qrasterwindow.h>
#include <qpa/qwindowsysteminterface.h>
@@ -95,6 +70,7 @@ private slots:
void modalWithChildWindow();
void modalWindowModallity();
void modalWindowPosition();
+ void modalCloseWhileBlocked();
#ifndef QT_NO_CURSOR
void modalWindowEnterEventOnHide_QTBUG35109();
void spuriousMouseMove();
@@ -110,6 +86,9 @@ private slots:
void generatedMouseMove();
void keepPendingUpdateRequests();
void activateDeactivateEvent();
+ void qobject_castOnDestruction();
+ void touchToMouseTranslationByPopup();
+ void stateChangeSignal();
private:
QPoint m_availableTopLeft;
@@ -120,6 +99,11 @@ private:
QInputDevice::Capability::Position | QInputDevice::Capability::MouseEmulation);
};
+static bool isPlatformWayland()
+{
+ return QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive);
+}
+
void tst_QWindow::initTestCase()
{
// Size of reference window, 200 for < 2000, scale up for larger screens
@@ -131,6 +115,10 @@ void tst_QWindow::initTestCase()
if (screenWidth > 2000)
width = 100 * ((screenWidth + 500) / 1000);
m_testWindowSize = QSize(width, width);
+
+ // Make sure test runs consistently on all compositors by force-disabling window decorations
+ if (isPlatformWayland())
+ qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1");
}
void tst_QWindow::cleanup()
@@ -310,13 +298,6 @@ public:
m_received[event->type()]++;
m_order << event->type();
switch (event->type()) {
- case QEvent::Expose:
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- m_exposeRegion = static_cast<QExposeEvent *>(event)->region();
-QT_WARNING_POP
- break;
-
case QEvent::PlatformSurface:
m_surfaceventType = static_cast<QPlatformSurfaceEvent *>(event)->surfaceEventType();
break;
@@ -346,11 +327,6 @@ QT_WARNING_POP
return m_order.indexOf(type);
}
- QRegion exposeRegion() const
- {
- return m_exposeRegion;
- }
-
QPlatformSurfaceEvent::SurfaceEventType surfaceEventType() const
{
return m_surfaceventType;
@@ -362,7 +338,6 @@ QT_WARNING_POP
private:
QHash<QEvent::Type, int> m_received;
QList<QEvent::Type> m_order;
- QRegion m_exposeRegion;
QPlatformSurfaceEvent::SurfaceEventType m_surfaceventType;
};
@@ -522,13 +497,11 @@ static QString msgRectMismatch(const QRect &r1, const QRect &r2)
return result;
}
-static bool isPlatformWayland()
-{
- return !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive);
-}
-
void tst_QWindow::positioning()
{
+#ifdef Q_OS_ANDROID
+ QSKIP("Fails on Android. QTBUG-105201");
+#endif
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
QPlatformIntegration::NonFullScreenWindows)) {
QSKIP("This platform does not support non-fullscreen windows");
@@ -550,9 +523,8 @@ void tst_QWindow::positioning()
QCOMPARE(window.geometry(), geometry);
// explicitly use non-fullscreen show. show() can be fullscreen on some platforms
window.showNormal();
- QCoreApplication::processEvents();
- QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(QTest::qWaitForWindowActive(&window));
QMargins originalMargins = window.frameMargins();
@@ -644,9 +616,6 @@ void tst_QWindow::childWindowPositioning_data()
void tst_QWindow::childWindowPositioning()
{
- if (isPlatformWayland())
- QSKIP("Wayland: This is flaky (protocol errors for xdg-shell v6). See QTBUG-67648.");
-
const QPoint topLeftOrigin(0, 0);
ColoredWindow topLevelWindowFirst(Qt::green);
@@ -749,7 +718,7 @@ void tst_QWindow::stateChange()
// explicitly use non-fullscreen show. show() can be fullscreen on some platforms
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- for (Qt::WindowState state : qAsConst(stateSequence)) {
+ for (Qt::WindowState state : std::as_const(stateSequence)) {
window.setWindowState(state);
QCoreApplication::processEvents();
}
@@ -823,16 +792,6 @@ void tst_QWindow::isExposed()
QTRY_VERIFY(window.received(QEvent::Expose) > 0);
QTRY_VERIFY(window.isExposed());
-#ifndef Q_OS_WIN
- // This is a top-level window so assuming it is completely exposed, the
- // expose region must be (0, 0), (width, height). If this is not the case,
- // the platform plugin is sending expose events with a region in an
- // incorrect coordinate system.
- QRect r = window.exposeRegion().boundingRect();
- r = QRect(window.mapToGlobal(r.topLeft()), r.size());
- QCOMPARE(r, window.geometry());
-#endif
-
window.hide();
QCoreApplication::processEvents();
@@ -977,6 +936,9 @@ public:
if (spinLoopWhenPressed)
QCoreApplication::processEvents();
}
+ if (closeOnTap)
+ this->close();
+
}
void mouseReleaseEvent(QMouseEvent *event) override
{
@@ -1033,7 +995,7 @@ public:
}
touchEventType = event->type();
QList<QTouchEvent::TouchPoint> points = event->points();
- for (int i = 0; i < points.count(); ++i) {
+ for (int i = 0; i < points.size(); ++i) {
const auto &point = points.at(i);
switch (point.state()) {
case QEventPoint::State::Pressed:
@@ -1044,6 +1006,8 @@ public:
touchPressLocalPos = point.position();
touchPressGlobalPos = point.globalPosition();
}
+ if (closeOnTap)
+ this->close();
break;
case QEventPoint::State::Released:
++touchReleasedCount;
@@ -1100,6 +1064,8 @@ public:
const QPointingDevice *mouseDevice = nullptr;
const QPointingDevice *touchDevice = nullptr;
+
+ bool closeOnTap = false;
};
static void simulateMouseClick(QWindow *target, const QPointF &local, const QPointF &global)
@@ -1323,6 +1289,8 @@ void tst_QWindow::mouseToTouchTranslation()
QTRY_COMPARE(window.touchPressedCount, 1);
QTRY_COMPARE(window.touchReleasedCount, 1);
QCOMPARE(window.mouseDevice, window.touchDevice);
+ if (isPlatformWayland())
+ QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-100887.", Abort);
QCOMPARE(window.touchDevice->type(), QInputDevice::DeviceType::Mouse);
QCOMPARE(window.touchPressLocalPos.toPoint(), localPos);
QCOMPARE(window.touchPressGlobalPos.toPoint(), window.mapToGlobal(localPos));
@@ -1480,9 +1448,6 @@ void tst_QWindow::touchCancelWithTouchToMouse()
void tst_QWindow::touchInterruptedByPopup()
{
- if (isPlatformWayland())
- QSKIP("Wayland: This test crashes with xdg-shell unstable v6");
-
InputTestWindow window;
window.setTitle(QLatin1String(QTest::currentTestFunction()));
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
@@ -1547,7 +1512,7 @@ void tst_QWindow::orientation()
QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)));
window.reportContentOrientationChange(Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QWindow::sizes()
@@ -1566,40 +1531,51 @@ void tst_QWindow::sizes()
QCOMPARE(window.minimumHeight(), 0);
QCOMPARE(window.minimumSize(), QSize(10, 0));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 0);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 0);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMinimumHeight(10);
QCOMPARE(window.minimumWidth(), 10);
QCOMPARE(window.minimumHeight(), 10);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumWidth(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), oldMaximum.height());
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height()));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumHeight(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), 100);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, 100));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 1);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 1);
+
+ // test if min and max limits will change the size
+ QVERIFY(window.minimumWidth() < 50 && window.maximumWidth() > 80);
+ QVERIFY(window.minimumHeight() < 50 && window.maximumHeight() > 80);
+ window.resize(50, 50);
+ QCOMPARE(window.size(), QSize(50, 50));
+ window.setMinimumSize(QSize(60, 60));
+ QCOMPARE(window.size(), QSize(60, 60));
+ window.resize(80, 80);
+ window.setMaximumSize(QSize(70, 70));
+ QCOMPARE(window.size(), QSize(70, 70));
}
class CloseOnCloseEventWindow : public QWindow
@@ -1831,25 +1807,25 @@ void tst_QWindow::windowModality()
QCOMPARE(window.modality(), Qt::NonModal);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QWindow::inputReentrancy()
@@ -2032,32 +2008,32 @@ void tst_QWindow::visibility()
QVERIFY(window.isVisible());
QVERIFY(window.visibility() != QWindow::Hidden);
QVERIFY(window.visibility() != QWindow::AutomaticVisibility);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::Hidden);
QVERIFY(!window.isVisible());
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::FullScreen);
QVERIFY(window.isVisible());
QCOMPARE(window.windowState(), Qt::WindowFullScreen);
QCOMPARE(window.visibility(), QWindow::FullScreen);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen);
spy.clear();
window.setWindowState(Qt::WindowNoState);
QCOMPARE(window.visibility(), QWindow::Windowed);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState);
spy.clear();
window.setVisible(false);
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
@@ -2090,9 +2066,6 @@ void tst_QWindow::mask()
void tst_QWindow::initialSize()
{
- if (isPlatformWayland())
- QSKIP("Wayland: This fails. See QTBUG-66818.");
-
QSize defaultSize(0,0);
{
Window w;
@@ -2282,6 +2255,9 @@ void tst_QWindow::modalWindowModallity()
void tst_QWindow::modalWindowPosition()
{
+ if (isPlatformWayland())
+ QSKIP("Window position not queryable on Wayland");
+
QWindow window;
window.setTitle(QLatin1String(QTest::currentTestFunction()));
window.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWindowSize));
@@ -2293,6 +2269,22 @@ void tst_QWindow::modalWindowPosition()
QCOMPARE(window.geometry(), origGeo);
}
+void tst_QWindow::modalCloseWhileBlocked()
+{
+ QWindow first;
+ first.setModality(Qt::ApplicationModal);
+ first.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ QWindow second;
+ second.setModality(Qt::ApplicationModal);
+ second.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ first.close();
+ QTRY_VERIFY(!first.isVisible());
+}
+
#ifndef QT_NO_CURSOR
void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
{
@@ -2701,6 +2693,9 @@ void tst_QWindow::keepPendingUpdateRequests()
void tst_QWindow::activateDeactivateEvent()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
class Window : public QWindow
{
public:
@@ -2741,6 +2736,146 @@ void tst_QWindow::activateDeactivateEvent()
QCOMPARE(w2.activateCount, 1);
}
+// Test that in a slot connected to destroyed() the emitter is
+// is no longer a QWindow.
+void tst_QWindow::qobject_castOnDestruction()
+{
+ QWindow window;
+ QObject::connect(&window, &QObject::destroyed, [](QObject *object)
+ {
+ QVERIFY(!qobject_cast<QWindow *>(object));
+ QVERIFY(!dynamic_cast<QWindow *>(object));
+ QVERIFY(!object->isWindowType());
+ });
+}
+
+void tst_QWindow::touchToMouseTranslationByPopup()
+{
+ InputTestWindow window;
+ window.setTitle(QLatin1String(QTest::currentTestFunction()));
+ window.ignoreTouch = true;
+ window.setGeometry(QRect(m_availableTopLeft, m_testWindowSize));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ InputTestWindow popupWindow;
+ popupWindow.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20),
+ QSize(m_testWindowSize.width(), m_testWindowSize.height() / 2)));
+ popupWindow.setFlag(Qt::Popup);
+ popupWindow.setTransientParent(&window);
+ popupWindow.ignoreTouch = true;
+ popupWindow.closeOnTap = true;
+ popupWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&popupWindow));
+
+ QTest::touchEvent(&popupWindow, touchDevice).press(0, {1, 1}, &window);
+ QVERIFY(!popupWindow.isVisible());
+
+ // Omit touchpoint 0: because the popup was closed, touchpoint0.release is not sent.
+ const QPoint tp1(50, 1);
+ QTest::touchEvent(&window, touchDevice).press(1, tp1, &window);
+ QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton));
+ QTest::touchEvent(&window, touchDevice).release(1, tp1, &window);
+ QTRY_COMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
+}
+
+// Test that windowStateChanged is not emitted on noop change (QTBUG-102478)
+void tst_QWindow::stateChangeSignal()
+{
+ // Test only for Windows, Linux and macOS
+#if !defined(Q_OS_LINUX) && !defined(Q_OS_WINDOWS) && !defined(Q_OS_DARWIN)
+ QSKIP("Singular windowStateChanged signal emission is guaranteed for Linux, Windows and macOS only.\n"
+ "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;}));
+ 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)
+ { effectiveStates.append(state); }));
+ // Part 1:
+ // => test signal emission on programmatic state changes
+ QCOMPARE(w.windowState(), Qt::WindowNoState);
+ // - wait for target state to be set
+ // - wait for signal spy to have reached target count
+ // - extract state from signal and compare to target
+#define CHECK_STATE(State)\
+ QTRY_VERIFY(QTest::qWaitFor([&w](){return (w.windowState() == State); }));\
+ CHECK_SIGNAL(State)
+#define CHECK_SIGNAL(State)\
+ QTRY_COMPARE(spy.count(), signalCount);\
+ if (signalCount > 0) {\
+ QVariantList list = spy.at(signalCount - 1).toList();\
+ QCOMPARE(list.count(), 1);\
+ bool ok;\
+ const int stateInt = list.at(0).toInt(&ok);\
+ QVERIFY(ok);\
+ const Qt::WindowState newState = static_cast<Qt::WindowState>(stateInt);\
+ QCOMPARE(newState, State);\
+ }
+ // Check initialization
+ CHECK_STATE(Qt::WindowNoState);
+ // showMaximized after init
+ // expected behavior: signal emitted once with state == WindowMaximized
+ ++signalCount;
+ w.showMaximized();
+ CHECK_STATE(Qt::WindowMaximized);
+ // setWindowState to normal
+ // expected behavior: signal emitted once with state == WindowNoState
+ ++signalCount;
+ w.setWindowState(Qt::WindowNoState);
+ CHECK_STATE(Qt::WindowNoState);
+ // redundant setWindowState to normal - except windows, where the no-op is counted
+ // expected behavior: No emits.
+ // On Windows, a no-op state change causes a no-op resize and repaint, leading to a
+ // no-op state change and singal emission.
+#ifdef Q_OS_WINDOWS
+ ++signalCount;
+ ++signalCount;
+#endif
+ w.setWindowState(Qt::WindowNoState);
+ CHECK_STATE(Qt::WindowNoState);
+ // setWindowState to minimized
+ // expected behavior: signal emitted once with state == WindowMinimized
+ ++signalCount;
+ w.showMinimized();
+ CHECK_STATE(Qt::WindowMinimized);
+ // setWindowState to Normal
+ // expected behavior: signal emitted once with state == WindowNoState
+ ++signalCount;
+ w.showNormal();
+ CHECK_STATE(Qt::WindowNoState);
+ /*
+ - Testcase showFullScreen is omitted: Depending on window manager,
+ WindowFullScreen can be mapped to WindowMaximized
+ - Transition from WindowMinimized to WindowMaximized is omitted:
+ WindowNoState to WindowMaximized
+ */
+ // Part 2:
+ // => test signal emission on simulated user interaction
+ // To test the code path, inject state change events into the QPA event queue.
+ // Test the signal emission only, not the window's actual visible state.
+
+ // Flush pending events and clear
+ QCoreApplication::processEvents();
+ spy.clear();
+ effectiveStates.clear();
+ signalCount = 0;
+ // Maximize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowMaximized, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowMaximized);
+ // Normalize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowNoState, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowNoState);
+ // Minimize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowMinimized, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowMinimized);
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)
diff --git a/tests/auto/gui/math3d/CMakeLists.txt b/tests/auto/gui/math3d/CMakeLists.txt
index 11c50163ad..a7f2a55aa1 100644
--- a/tests/auto/gui/math3d/CMakeLists.txt
+++ b/tests/auto/gui/math3d/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from math3d.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qquaternion)
add_subdirectory(qvectornd)
diff --git a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
index 5c54bd6b95..506d4d5e19 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qmatrixnxn.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qmatrixnxn Test:
@@ -7,8 +8,6 @@
qt_internal_add_test(tst_qmatrixnxn
SOURCES
tst_qmatrixnxn.cpp
- DEFINES
- QT_DISABLE_DEPRECATED_BEFORE=0
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index 972bbe2f1c..a984cd0ae7 100644
--- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtCore/qmath.h>
@@ -125,6 +100,7 @@ private slots:
void rotate4x4_data();
void rotate4x4();
+ void projectedRotate();
void normalMatrix_data();
void normalMatrix();
@@ -157,6 +133,11 @@ private slots:
void properties();
void metaTypes();
+ // Tests for deprecated APIs
+#if QT_DEPRECATED_SINCE(6, 1)
+ void deprecatedMultiplications();
+#endif
+
private:
static void setMatrix(QMatrix2x2& m, const float *values);
static void setMatrixDirect(QMatrix2x2& m, const float *values);
@@ -1994,12 +1975,7 @@ void tst_QMatrixNxN::scale4x4()
}
QVector3D v1(2.0f, 3.0f, -4.0f);
- QVector3D v2 = m1 * v1;
- QCOMPARE(v2.x(), (float)(2.0f * x));
- QCOMPARE(v2.y(), (float)(3.0f * y));
- QCOMPARE(v2.z(), (float)(-4.0f * z));
-
- v2 = v1 * m1;
+ QVector3D v2 = m1.map(v1);
QCOMPARE(v2.x(), (float)(2.0f * x));
QCOMPARE(v2.y(), (float)(3.0f * y));
QCOMPARE(v2.z(), (float)(-4.0f * z));
@@ -2018,7 +1994,7 @@ void tst_QMatrixNxN::scale4x4()
QCOMPARE(v4.w(), (float)34.0f);
QPoint p1(2, 3);
- QPoint p2 = m1 * p1;
+ QPoint p2 = m1.map(p1);
QCOMPARE(p2.x(), (int)(2.0f * x));
QCOMPARE(p2.y(), (int)(3.0f * y));
@@ -2027,7 +2003,7 @@ void tst_QMatrixNxN::scale4x4()
QCOMPARE(p2.y(), (int)(3.0f * y));
QPointF p3(2.0f, 3.0f);
- QPointF p4 = m1 * p3;
+ QPointF p4 = m1.map(p3);
QCOMPARE(p4.x(), (float)(2.0f * x));
QCOMPARE(p4.y(), (float)(3.0f * y));
@@ -2140,7 +2116,7 @@ void tst_QMatrixNxN::translate4x4()
}
QVector3D v1(2.0f, 3.0f, -4.0f);
- QVector3D v2 = m1 * v1;
+ QVector3D v2 = m1.map(v1);
QCOMPARE(v2.x(), (float)(2.0f + x));
QCOMPARE(v2.y(), (float)(3.0f + y));
QCOMPARE(v2.z(), (float)(-4.0f + z));
@@ -2160,12 +2136,12 @@ void tst_QMatrixNxN::translate4x4()
QCOMPARE(v6.w(), (float)34.0f);
QPoint p1(2, 3);
- QPoint p2 = m1 * p1;
+ QPoint p2 = m1.map(p1);
QCOMPARE(p2.x(), (int)(2.0f + x));
QCOMPARE(p2.y(), (int)(3.0f + y));
QPointF p3(2.0f, 3.0f);
- QPointF p4 = m1 * p3;
+ QPointF p4 = m1.map(p3);
QCOMPARE(p4.x(), (float)(2.0f + x));
QCOMPARE(p4.y(), (float)(3.0f + y));
@@ -2370,7 +2346,7 @@ void tst_QMatrixNxN::rotate4x4()
p1z /= p1w;
QVector3D v1(2.0f, 3.0f, -4.0f);
- QVector3D v2 = m1 * v1;
+ QVector3D v2 = m1.map(v1);
QVERIFY(qFuzzyCompare(v2.x(), v1x));
QVERIFY(qFuzzyCompare(v2.y(), v1y));
QVERIFY(qFuzzyCompare(v2.z(), v1z));
@@ -2390,12 +2366,12 @@ void tst_QMatrixNxN::rotate4x4()
QVERIFY(qFuzzyCompare(v6.w(), v5w));
QPoint p1(2, 3);
- QPoint p2 = m1 * p1;
+ QPoint p2 = m1.map(p1);
QCOMPARE(p2.x(), qRound(p1x));
QCOMPARE(p2.y(), qRound(p1y));
QPointF p3(2.0f, 3.0f);
- QPointF p4 = m1 * p3;
+ QPointF p4 = m1.map(p3);
QVERIFY(qFuzzyCompare(float(p4.x()), p1x));
QVERIFY(qFuzzyCompare(float(p4.y()), p1y));
@@ -2408,6 +2384,22 @@ void tst_QMatrixNxN::rotate4x4()
}
}
+void tst_QMatrixNxN::projectedRotate()
+{
+ QMatrix4x4 m1, m2;
+ const QPointF origin(1000, 1000);
+
+ m1.translate(origin.x(), origin.y());
+ m1.projectedRotate(60, 0, 1, 0, 0);
+ m1.translate(-origin.x(), -origin.y());
+
+ m2.translate(origin.x(), origin.y());
+ m2.rotate(60, 0, 1, 0);
+ m2.translate(-origin.x(), -origin.y());
+
+ QCOMPARE(m1.toTransform(), m2.toTransform());
+}
+
static bool isSame(const QMatrix3x3& m1, const Matrix3& m2)
{
for (int row = 0; row < 3; ++row) {
@@ -2629,11 +2621,11 @@ void tst_QMatrixNxN::ortho()
{
QMatrix4x4 m1;
m1.ortho(QRect(0, 0, 300, 150));
- QPointF p1 = m1 * QPointF(0, 0);
- QPointF p2 = m1 * QPointF(300, 0);
- QPointF p3 = m1 * QPointF(0, 150);
- QPointF p4 = m1 * QPointF(300, 150);
- QVector3D p5 = m1 * QVector3D(300, 150, 1);
+ QPointF p1 = m1.map(QPointF(0, 0));
+ QPointF p2 = m1.map(QPointF(300, 0));
+ QPointF p3 = m1.map(QPointF(0, 150));
+ QPointF p4 = m1.map(QPointF(300, 150));
+ QVector3D p5 = m1.map(QVector3D(300, 150, 1));
QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f));
QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f));
QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f));
@@ -2648,11 +2640,11 @@ void tst_QMatrixNxN::ortho()
QMatrix4x4 m2;
m2.ortho(QRectF(0, 0, 300, 150));
- p1 = m2 * QPointF(0, 0);
- p2 = m2 * QPointF(300, 0);
- p3 = m2 * QPointF(0, 150);
- p4 = m2 * QPointF(300, 150);
- p5 = m2 * QVector3D(300, 150, 1);
+ p1 = m2.map(QPointF(0, 0));
+ p2 = m2.map(QPointF(300, 0));
+ p3 = m2.map(QPointF(0, 150));
+ p4 = m2.map(QPointF(300, 150));
+ p5 = m2.map(QVector3D(300, 150, 1));
QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f));
QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f));
QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f));
@@ -2667,11 +2659,11 @@ void tst_QMatrixNxN::ortho()
QMatrix4x4 m3;
m3.ortho(0, 300, 150, 0, -1, 1);
- p1 = m3 * QPointF(0, 0);
- p2 = m3 * QPointF(300, 0);
- p3 = m3 * QPointF(0, 150);
- p4 = m3 * QPointF(300, 150);
- p5 = m3 * QVector3D(300, 150, 1);
+ p1 = m3.map(QPointF(0, 0));
+ p2 = m3.map(QPointF(300, 0));
+ p3 = m3.map(QPointF(0, 150));
+ p4 = m3.map(QPointF(300, 150));
+ p5 = m3.map(QVector3D(300, 150, 1));
QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f));
QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f));
QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f));
@@ -2686,11 +2678,11 @@ void tst_QMatrixNxN::ortho()
QMatrix4x4 m4;
m4.ortho(0, 300, 150, 0, -2, 3);
- p1 = m4 * QPointF(0, 0);
- p2 = m4 * QPointF(300, 0);
- p3 = m4 * QPointF(0, 150);
- p4 = m4 * QPointF(300, 150);
- p5 = m4 * QVector3D(300, 150, 1);
+ p1 = m4.map(QPointF(0, 0));
+ p2 = m4.map(QPointF(300, 0));
+ p3 = m4.map(QPointF(0, 150));
+ p4 = m4.map(QPointF(300, 150));
+ p5 = m4.map(QVector3D(300, 150, 1));
QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f));
QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f));
QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f));
@@ -2718,11 +2710,11 @@ void tst_QMatrixNxN::frustum()
{
QMatrix4x4 m1;
m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
- QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f);
- QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f);
- QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f);
- QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f);
- QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f);
+ QVector3D p1 = m1.map(QVector3D(-1.0f, -1.0f, 1.0f));
+ QVector3D p2 = m1.map(QVector3D(1.0f, -1.0f, 1.0f));
+ QVector3D p3 = m1.map(QVector3D(-1.0f, 1.0f, 1.0f));
+ QVector3D p4 = m1.map(QVector3D(1.0f, 1.0f, 1.0f));
+ QVector3D p5 = m1.map(QVector3D(0.0f, 0.0f, 2.0f));
QVERIFY(qFuzzyCompare(p1.x(), -1.0f));
QVERIFY(qFuzzyCompare(p1.y(), -1.0f));
QVERIFY(qFuzzyCompare(p1.z(), -1.0f));
@@ -2754,11 +2746,11 @@ void tst_QMatrixNxN::perspective()
{
QMatrix4x4 m1;
m1.perspective(45.0f, 1.0f, -1.0f, 1.0f);
- QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f);
- QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f);
- QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f);
- QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f);
- QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f);
+ QVector3D p1 = m1.map(QVector3D(-1.0f, -1.0f, 1.0f));
+ QVector3D p2 = m1.map(QVector3D(1.0f, -1.0f, 1.0f));
+ QVector3D p3 = m1.map(QVector3D(-1.0f, 1.0f, 1.0f));
+ QVector3D p4 = m1.map(QVector3D(1.0f, 1.0f, 1.0f));
+ QVector3D p5 = m1.map(QVector3D(0.0f, 0.0f, 2.0f));
QVERIFY(qFuzzyCompare(p1.x(), 2.41421f));
QVERIFY(qFuzzyCompare(p1.y(), 2.41421f));
QVERIFY(qFuzzyCompare(p1.z(), -1.0f));
@@ -2824,25 +2816,25 @@ void tst_QMatrixNxN::flipCoordinates()
{
QMatrix4x4 m1;
m1.flipCoordinates();
- QVector3D p1 = m1 * QVector3D(2, 3, 4);
+ QVector3D p1 = m1.map(QVector3D(2, 3, 4));
QVERIFY(p1 == QVector3D(2, -3, -4));
QMatrix4x4 m2;
m2.scale(2.0f, 3.0f, 1.0f);
m2.flipCoordinates();
- QVector3D p2 = m2 * QVector3D(2, 3, 4);
+ QVector3D p2 = m2.map(QVector3D(2, 3, 4));
QVERIFY(p2 == QVector3D(4, -9, -4));
QMatrix4x4 m3;
m3.translate(2.0f, 3.0f, 1.0f);
m3.flipCoordinates();
- QVector3D p3 = m3 * QVector3D(2, 3, 4);
+ QVector3D p3 = m3.map(QVector3D(2, 3, 4));
QVERIFY(p3 == QVector3D(4, 0, -3));
QMatrix4x4 m4;
m4.rotate(90.0f, 0.0f, 0.0f, 1.0f);
m4.flipCoordinates();
- QVector3D p4 = m4 * QVector3D(2, 3, 4);
+ QVector3D p4 = m4.map(QVector3D(2, 3, 4));
QVERIFY(p4 == QVector3D(3, 2, -4));
}
@@ -3044,7 +3036,7 @@ void tst_QMatrixNxN::convertQTransform()
QCOMPARE(p1.y(), 150.0 + 2.0);
QMatrix4x4 m2(m1);
- QPointF p2 = m2 * QPointF(100.0, 150.0);
+ QPointF p2 = m2.map(QPointF(100.0, 150.0));
QCOMPARE((double)p2.x(), 100.0 - 3.5);
QCOMPARE((double)p2.y(), 150.0 + 2.0);
QCOMPARE(m1, m2.toTransform());
@@ -3056,7 +3048,7 @@ void tst_QMatrixNxN::convertQTransform()
QCOMPARE(p3.y(), -2.0 * 150.0);
QMatrix4x4 m4(m3);
- QPointF p4 = m4 * QPointF(100.0, 150.0);
+ QPointF p4 = m4.map(QPointF(100.0, 150.0));
QCOMPARE((double)p4.x(), 1.5 * 100.0);
QCOMPARE((double)p4.y(), -2.0 * 150.0);
QCOMPARE(m3, m4.toTransform());
@@ -3066,7 +3058,7 @@ void tst_QMatrixNxN::convertQTransform()
QPointF p5 = m5.map(QPointF(100.0, 150.0));
QMatrix4x4 m6(m5);
- QPointF p6 = m6 * QPointF(100.0, 150.0);
+ QPointF p6 = m6.map(QPointF(100.0, 150.0));
QVERIFY(qFuzzyCompare(float(p5.x()), float(p6.x())));
QVERIFY(qFuzzyCompare(float(p5.y()), float(p6.y())));
@@ -3316,9 +3308,9 @@ void tst_QMatrixNxN::properties()
void tst_QMatrixNxN::metaTypes()
{
- QCOMPARE(QMetaType::type("QMatrix4x4"), int(QMetaType::QMatrix4x4));
+ QCOMPARE(QMetaType::fromName("QMatrix4x4").id(), int(QMetaType::QMatrix4x4));
- QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)),
+ QCOMPARE(QByteArray(QMetaType(QMetaType::QMatrix4x4).name()),
QByteArray("QMatrix4x4"));
QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4));
@@ -3326,6 +3318,58 @@ void tst_QMatrixNxN::metaTypes()
QCOMPARE(qMetaTypeId<QMatrix4x4>(), int(QMetaType::QMatrix4x4));
}
+#if QT_DEPRECATED_SINCE(6, 1)
+void tst_QMatrixNxN::deprecatedMultiplications()
+{
+ QMatrix4x4 m;
+ m.scale(1.0f, 2.0f, 3.0f);
+ // QMatrix4x4 and QVector3D
+ {
+ QVector3D v(4.0f, 5.0f, 6.0f);
+ {
+ // QMatrix4x4 * QVector3D
+ QT_IGNORE_DEPRECATIONS(const QVector3D v1 = m * v;)
+ const QVector3D v2 = m.map(v);
+
+ QCOMPARE(v1.x(), v2.x());
+ QCOMPARE(v1.y(), v2.y());
+ QCOMPARE(v1.z(), v2.z());
+ }
+ {
+ // QVector3D * QMatrix4x4
+ QT_IGNORE_DEPRECATIONS(const QVector3D v1 = v * m;)
+
+ QVector4D v4(v, 1.0);
+ const QVector4D v2 = v4 * m;
+
+ QCOMPARE(v1.x(), v2.x());
+ QCOMPARE(v1.y(), v2.y());
+ QCOMPARE(v1.z(), v2.z());
+ }
+ }
+ {
+ // QMatrix4x4 * QPoint
+ const QPoint p(4, 5);
+
+ QT_IGNORE_DEPRECATIONS(const QPoint p1 = m * p;)
+ const QPoint p2 = m.map(p);
+
+ QCOMPARE(p1.x(), p2.x());
+ QCOMPARE(p1.y(), p2.y());
+ }
+ {
+ // QMatrix4x4 * QPointF
+ const QPointF p(4.0f, 5.0f);
+
+ QT_IGNORE_DEPRECATIONS(const QPointF p1 = m * p;)
+ const QPointF p2 = m.map(p);
+
+ QCOMPARE(p1.x(), p2.x());
+ QCOMPARE(p1.y(), p2.y());
+ }
+}
+#endif // QT_DEPRECATED_SINCE(6, 1)
+
QTEST_APPLESS_MAIN(tst_QMatrixNxN)
#include "tst_qmatrixnxn.moc"
diff --git a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
index fbeb76abdd..f35dc1a148 100644
--- a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qquaternion.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qquaternion Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qquaternion
SOURCES
tst_qquaternion.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index 4229fa1017..6be46b9ee2 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtCore/qmath.h>
@@ -600,7 +575,7 @@ void tst_QQuaternion::multiply_data()
for (float x = -1.0f; x <= 1.0f; x += 0.5f)
for (float y = -1.0f; y <= 1.0f; y += 0.5f)
for (float z = -1.0f; z <= 1.0f; z += 0.5f) {
- QTest::newRow("exhaustive")
+ QTest::addRow("exhaustive: (%.1f, %.1f, %.1f), %.1f", x, y, z, w)
<< x << y << z << w
<< z << w << y << x;
}
@@ -987,28 +962,6 @@ void tst_QQuaternion::rotationTo()
QVERIFY(myFuzzyCompare(vec2, from));
}
-static QByteArray testnameForAxis(const QVector3D &axis)
-{
- QByteArray testname;
- if (axis == QVector3D()) {
- testname = "null";
- } else {
- if (axis.x()) {
- testname += axis.x() < 0 ? '-' : '+';
- testname += 'X';
- }
- if (axis.y()) {
- testname += axis.y() < 0 ? '-' : '+';
- testname += 'Y';
- }
- if (axis.z()) {
- testname += axis.z() < 0 ? '-' : '+';
- testname += 'Z';
- }
- }
- return testname;
-}
-
// Test quaternion convertion to and from orthonormal axes.
void tst_QQuaternion::fromDirection_data()
{
@@ -1031,7 +984,10 @@ void tst_QQuaternion::fromDirection_data()
QVector3D xAxis, yAxis, zAxis;
q.getAxes(&xAxis, &yAxis, &zAxis);
- QTest::newRow("dir: " + testnameForAxis(zAxis) + ", up: " + testnameForAxis(yAxis))
+ QTest::addRow("ortho dirs: (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f)",
+ xAxis.x(), xAxis.y(), xAxis.z(),
+ yAxis.x(), yAxis.y(), yAxis.z(),
+ zAxis.x(), zAxis.y(), zAxis.z())
<< zAxis * 10.0f << yAxis * 10.0f;
}
@@ -1050,7 +1006,10 @@ void tst_QQuaternion::fromDirection_data()
QVector3D xAxis, yAxis, zAxis;
q.getAxes(&xAxis, &yAxis, &zAxis);
- QTest::newRow("dir: " + testnameForAxis(zAxis) + ", up: null")
+ QTest::addRow("bad dirs: (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f)",
+ xAxis.x(), xAxis.y(), xAxis.z(),
+ yAxis.x(), yAxis.y(), yAxis.z(),
+ zAxis.x(), zAxis.y(), zAxis.z())
<< zAxis * 10.0f << QVector3D();
}
}
@@ -1110,6 +1069,35 @@ void tst_QQuaternion::fromEulerAngles_data()
QTest::newRow("complex")
<< 30.0f << 240.0f << -45.0f << QQuaternion(-0.531976f, -0.43968f, 0.723317f, -0.02226f);
+
+ // Three gimbal_lock cases are not unique for the conversions from quaternion
+ // to euler, Qt will use only XY rotations for these cases.
+ // For example, QQuaternion(0.5f, 0.5f, -0.5f, 0.5f) can be EulerXYZ(90.0f, 0.0f, 90.0f), too.
+ // But Qt will always convert it to EulerXYZ(90.0f, -90.0f, 0.0f) without Z-rotation.
+ QTest::newRow("gimbal_lock_1")
+ << 90.0f << -90.0f << 0.0f << QQuaternion(0.5f, 0.5f, -0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_2")
+ << 90.0f << 40.0f << 0.0f << QQuaternion(0.664463f, 0.664463f, 0.241845f, -0.241845f);
+
+ QTest::newRow("gimbal_lock_3") << 90.0f << 170.0f << 0.0f
+ << QQuaternion(0.0616285f, 0.0616285f, 0.704416f, -0.704416f);
+
+ // These four examples have a fraction of errors that would bypass normalize() threshold
+ // and could make Gimbal lock detection fail.
+ QTest::newRow("gimbal_lock_fraction_1")
+ << -90.0f << 90.001152f << 0.0f << QQuaternion(0.499989986f, -0.5f, 0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_fraction_2")
+ << -90.0f << -179.999985f << 0.0f
+ << QQuaternion(1.00000001e-07f, 1.00000001e-10f, -0.707106769f, -0.707105756f);
+
+ QTest::newRow("gimbal_lock_fraction_3")
+ << -90.0f << 90.0011597f << 0.0f << QQuaternion(0.499989986f, -0.49999994f, 0.5f, 0.5f);
+
+ QTest::newRow("gimbal_lock_fraction_4")
+ << -90.0f << -180.0f << 0.0f
+ << QQuaternion(9.99999996e-12f, 9.99999996e-12f, -0.707106769f, -0.707096756f);
}
void tst_QQuaternion::fromEulerAngles()
{
diff --git a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
index c29550463a..f7478a1899 100644
--- a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
+++ b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qvectornd.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qvectornd Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qvectornd
SOURCES
tst_qvectornd.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
index c7bcb9d262..beba252293 100644
--- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
+++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
@@ -1,30 +1,38 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#ifdef QVARIANT_H
+# error "This test requires qvector{2,3,4}d.h to not include qvariant.h"
+#endif
+
+// don't assume <type_traits>
+template <typename T, typename U>
+constexpr inline bool my_is_same_v = false;
+template <typename T>
+constexpr inline bool my_is_same_v<T, T> = true;
+
+#define CHECK(cvref) \
+ static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector2D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector2D cvref >())), float cvref >); \
+ \
+ static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector3D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector3D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector3D cvref >())), float cvref >); \
+ \
+ static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector4D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector4D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector4D cvref >())), float cvref >); \
+ static_assert(my_is_same_v<decltype(get<3>(std::declval<QVector4D cvref >())), float cvref >)
+
+CHECK(&);
+CHECK(const &);
+CHECK(&&);
+CHECK(const &&);
+
+#undef CHECK
#include <QTest>
#include <QtCore/qmath.h>
diff --git a/tests/auto/gui/painting/CMakeLists.txt b/tests/auto/gui/painting/CMakeLists.txt
index 4f933139ca..2c23cfab07 100644
--- a/tests/auto/gui/painting/CMakeLists.txt
+++ b/tests/auto/gui/painting/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from painting.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qpainterpath)
add_subdirectory(qpainterpathstroker)
@@ -14,9 +15,11 @@ add_subdirectory(qpen)
add_subdirectory(qpaintengine)
add_subdirectory(qtransform)
add_subdirectory(qpolygon)
-# QTBUG-87669 # special case
+
+# QTBUG-87669
if(NOT ANDROID)
add_subdirectory(qcolorspace)
+ add_subdirectory(qcolortransform)
endif()
if(QT_FEATURE_private_tests)
add_subdirectory(qpathclipper)
diff --git a/tests/auto/gui/painting/qbrush/CMakeLists.txt b/tests/auto/gui/painting/qbrush/CMakeLists.txt
index c8dad25d94..cbb4e07134 100644
--- a/tests/auto/gui/painting/qbrush/CMakeLists.txt
+++ b/tests/auto/gui/painting/qbrush/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qbrush.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qbrush Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qbrush
SOURCES
tst_qbrush.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
index ea380e3cc9..64513b89c6 100644
--- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
+++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/painting/qcolor/CMakeLists.txt b/tests/auto/gui/painting/qcolor/CMakeLists.txt
index 87753803fb..2ca7bbead5 100644
--- a/tests/auto/gui/painting/qcolor/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolor/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qcolor.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcolor Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qcolor
SOURCES
tst_qcolor.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index 5c93a41b71..60a63fadcb 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
@@ -38,6 +13,12 @@
#include <private/qdrawingprimitive_sse2_p.h>
#include <qrgba64.h>
+#if QT_DEPRECATED_SINCE(6, 6)
+# define DEPRECATED_IN_6_6(...) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED __VA_ARGS__ QT_WARNING_POP
+#else
+# define DEPRECATED_IN_6_6(...)
+#endif
+
class tst_QColor : public QObject
{
Q_OBJECT
@@ -54,8 +35,8 @@ private slots:
void name();
void namehex_data();
void namehex();
- void setNamedColor_data();
- void setNamedColor();
+ void fromString_data();
+ void fromString();
void constructNamedColorWithSpace();
@@ -243,13 +224,13 @@ void tst_QColor::isValid_data()
QTest::newRow("defaultConstructor") << QColor() << false;
QTest::newRow("rgbConstructor-valid") << QColor(2,5,7) << true;
QTest::newRow("rgbConstructor-invalid") << QColor(2,5,999) << false;
- QTest::newRow("nameQStringConstructor-valid") << QColor(QString("#ffffff")) << true;
- QTest::newRow("nameQStringConstructor-invalid") << QColor(QString("#ffffgg")) << false;
- QTest::newRow("nameQStringConstructor-empty") << QColor(QString("")) << false;
- QTest::newRow("nameQStringConstructor-named") << QColor(QString("red")) << true;
- QTest::newRow("nameCharConstructor-valid") << QColor("#ffffff") << true;
- QTest::newRow("nameCharConstructor-invalid") << QColor("#ffffgg") << false;
- QTest::newRow("nameCharConstructor-invalid-2") << QColor("#fffffg") << false;
+ QTest::newRow("nameQStringConstructor-valid") << QColor::fromString("#ffffff") << true;
+ QTest::newRow("nameQStringConstructor-invalid") << QColor::fromString("#ffffgg") << false;
+ QTest::newRow("nameQStringConstructor-empty") << QColor::fromString("") << false;
+ QTest::newRow("nameQStringConstructor-named") << QColor::fromString("red") << true;
+ QTest::newRow("nameCharConstructor-valid") << QColor::fromString("#ffffff") << true;
+ QTest::newRow("nameCharConstructor-invalid") << QColor::fromString("#ffffgg") << false;
+ QTest::newRow("nameCharConstructor-invalid-2") << QColor::fromString("#fffffg") << false;
}
void tst_QColor::isValid()
@@ -335,7 +316,10 @@ void tst_QColor::namehex()
{
QFETCH(QString, hexcolor);
QFETCH(QColor, color);
+ DEPRECATED_IN_6_6(
QCOMPARE(QColor(hexcolor), color);
+ )
+ QCOMPARE(QColor::fromString(hexcolor), color);
}
void tst_QColor::globalColors_data()
@@ -721,25 +705,36 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData);
#undef rgb
-void tst_QColor::setNamedColor_data()
+void tst_QColor::fromString_data()
{
+#if QT_DEPRECATED_SINCE(6, 6)
QTest::addColumn<QColor>("byCtor");
QTest::addColumn<QColor>("bySetNamedColor");
+#endif
+ QTest::addColumn<QColor>("byFromString");
QTest::addColumn<QColor>("expected");
for (const auto e : rgbTbl) {
QColor expected;
expected.setRgba(e.value);
-#define ROW(expr) \
- do { \
- QColor bySetNamedColor; \
- bySetNamedColor.setNamedColor(expr); \
- auto byCtor = QColor(expr); \
- QTest::addRow("%s: %s", e.name, #expr) \
- << byCtor << bySetNamedColor << expected; \
- } while (0) \
- /*end*/
+#define ROW(expr) row(expr, #expr)
+ auto row = [&] (auto expr, const char *exprS) {
+ QT_WARNING_PUSH
+ #if QT_DEPRECATED_SINCE(6, 6)
+ QT_WARNING_DISABLE_DEPRECATED
+ QColor bySetNamedColor;
+ bySetNamedColor.setNamedColor(expr);
+ auto byCtor = QColor(expr);
+ #endif
+ QTest::addRow("%s: %s", e.name, exprS)
+ #if QT_DEPRECATED_SINCE(6, 6)
+ << byCtor << bySetNamedColor
+ #endif
+ << QColor::fromString(expr)
+ << expected;
+ QT_WARNING_POP
+ };
const auto l1 = QLatin1String(e.name);
const auto l1UpperBA = QByteArray(e.name).toUpper();
@@ -766,29 +761,42 @@ void tst_QColor::setNamedColor_data()
}
}
-void tst_QColor::setNamedColor()
+void tst_QColor::fromString()
{
+#if QT_DEPRECATED_SINCE(6, 6)
QFETCH(QColor, byCtor);
QFETCH(QColor, bySetNamedColor);
+#endif
+ QFETCH(QColor, byFromString);
QFETCH(QColor, expected);
+#if QT_DEPRECATED_SINCE(6, 6)
QCOMPARE(byCtor, expected);
QCOMPARE(bySetNamedColor, expected);
+#endif
+ QCOMPARE(byFromString, expected);
}
void tst_QColor::constructNamedColorWithSpace()
{
+ DEPRECATED_IN_6_6(
QColor whiteSmoke("white smoke");
QCOMPARE(whiteSmoke, QColor(245, 245, 245));
+ )
+ QCOMPARE(QColor::fromString("white smoke"), QColorConstants::Svg::whitesmoke);
}
void tst_QColor::colorNames()
{
- QStringList all = QColor::colorNames();
+ const QStringList all = QColor::colorNames();
QCOMPARE(all.size(), rgbTblSize);
for (int i = 0; i < all.size(); ++i)
QCOMPARE(all.at(i), QLatin1String(rgbTbl[i].name));
+ for (const QString &name : all)
+ QVERIFY(QColor::isValidColorName(name));
+ for (const auto &e : rgbTbl)
+ QVERIFY(QColor::isValidColorName(e.name));
}
void tst_QColor::spec()
diff --git a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
index 9e3460d363..a6565b57e7 100644
--- a/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
+++ b/tests/auto/gui/painting/qcolorspace/CMakeLists.txt
@@ -1,39 +1,27 @@
-# Generated from qcolorspace.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcolorspace Test:
#####################################################################
# Collect test data
-file(GLOB_RECURSE test_data_glob
+file(GLOB_RECURSE test_data
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- resources/*)
-list(APPEND test_data ${test_data_glob})
+ resources/*
+)
+
+foreach(file IN LISTS test_data)
+ set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
+endforeach()
qt_internal_add_test(tst_qcolorspace
SOURCES
tst_qcolorspace.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
TESTDATA ${test_data}
+ BUILTIN_TESTDATA
)
-
-file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "resources/*")
-foreach(file IN LISTS resource_glob_0)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-# Resources:
-set(qmake_immediate_resource_files
- ${resource_glob_0}
-)
-
-qt_internal_add_resource(tst_qcolorspace "qmake_immediate"
- PREFIX
- "/"
- FILES
- ${qmake_immediate_resource_files}
-)
-
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 576885de34..08f45a2552 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
@@ -65,6 +40,8 @@ private slots:
void imageConversion64PM();
void imageConversionOverLargerGamut_data();
void imageConversionOverLargerGamut();
+ void imageConversionOverLargerGamut2_data();
+ void imageConversionOverLargerGamut2();
void loadImage();
@@ -489,6 +466,55 @@ void tst_QColorSpace::imageConversionOverLargerGamut()
}
}
+void tst_QColorSpace::imageConversionOverLargerGamut2_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("rgbx16x4") << QImage::Format_RGBX16FPx4;
+ QTest::newRow("rgba16x4") << QImage::Format_RGBA16FPx4;
+ QTest::newRow("rgba16x4PM") << QImage::Format_RGBA16FPx4_Premultiplied;
+ QTest::newRow("rgbx32x4") << QImage::Format_RGBX32FPx4;
+ QTest::newRow("rgba32x4") << QImage::Format_RGBA32FPx4;
+ QTest::newRow("rgba32x4PM") << QImage::Format_RGBA32FPx4_Premultiplied;
+}
+
+void tst_QColorSpace::imageConversionOverLargerGamut2()
+{
+ QFETCH(QImage::Format, format);
+
+ QColorSpace csfrom = QColorSpace::DisplayP3;
+ QColorSpace csto = QColorSpace::SRgb;
+
+ QImage testImage(256, 256, format);
+ testImage.setColorSpace(csfrom);
+ for (int y = 0; y < 256; ++y)
+ for (int x = 0; x < 256; ++x)
+ testImage.setPixel(x, y, qRgba(x, y, 16, 255));
+
+ QImage resultImage = testImage.convertedToColorSpace(csto);
+ for (int y = 0; y < 256; ++y) {
+ float lastRed = -256.0f;
+ for (int x = 0; x < 256; ++x) {
+ float pr = resultImage.pixelColor(x, y).redF();
+ QVERIFY(pr >= lastRed);
+ lastRed = pr;
+ }
+ }
+ for (int x = 0; x < 256; ++x) {
+ float lastGreen = -256.0f;
+ for (int y = 0; y < 256; ++y) {
+ float pg = resultImage.pixelColor(x, y).greenF();
+ QVERIFY(pg >= lastGreen);
+ lastGreen = pg;
+ }
+ }
+ // Test colors outside of sRGB are converted to values outside of 0-1 range.
+ QVERIFY(resultImage.pixelColor(255, 0).redF() > 1.0f);
+ QVERIFY(resultImage.pixelColor(255, 0).greenF() < 0.0f);
+ QVERIFY(resultImage.pixelColor(0, 255).redF() < 0.0f);
+ QVERIFY(resultImage.pixelColor(0, 255).greenF() > 1.0f);
+}
+
void tst_QColorSpace::loadImage()
{
QString prefix = QFINDTESTDATA("resources/");
diff --git a/tests/auto/gui/painting/qcolortransform/CMakeLists.txt b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
new file mode 100644
index 0000000000..061902f175
--- /dev/null
+++ b/tests/auto/gui/painting/qcolortransform/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qcolortransform Test:
+#####################################################################
+
+qt_internal_add_test(tst_qcolortransform
+ SOURCES
+ tst_qcolortransform.cpp
+ LIBRARIES
+ Qt::Gui
+ Qt::GuiPrivate
+)
diff --git a/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
new file mode 100644
index 0000000000..06e8db3e71
--- /dev/null
+++ b/tests/auto/gui/painting/qcolortransform/tst_qcolortransform.cpp
@@ -0,0 +1,380 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+
+#include <QTest>
+
+#include <qcolorspace.h>
+#include <qcolortransform.h>
+#include <qrgbafloat.h>
+#include <QtGui/private/qcolortransform_p.h>
+
+class tst_QColorTransform : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QColorTransform();
+
+private slots:
+ void mapRGB32_data();
+ void mapRGB32();
+ void mapRGB64_data();
+ void mapRGB64();
+ void mapRGBAFP16x4_data();
+ void mapRGBAFP16x4();
+ void mapRGBAFP32x4_data();
+ void mapRGBAFP32x4();
+ void mapQColor_data();
+ void mapQColor();
+ void mapRGB32Prepared_data();
+ void mapRGB32Prepared();
+
+ void transformIsIdentity();
+};
+
+tst_QColorTransform::tst_QColorTransform()
+{ }
+
+
+void tst_QColorTransform::mapRGB32_data()
+{
+ QTest::addColumn<QColorTransform>("transform");
+ QTest::addColumn<bool>("sharesRed");
+
+ QColorSpace srgb(QColorSpace::SRgb);
+ QColorSpace srgbLinear(QColorSpace::SRgbLinear);
+ QColorSpace adobeRgb(QColorSpace::AdobeRgb);
+ QColorSpace adobeRgbLinear = adobeRgb.withTransferFunction(QColorSpace::TransferFunction::Linear);
+ QColorSpace dp3(QColorSpace::DisplayP3);
+ QColorSpace dp3Linear = dp3.withTransferFunction(QColorSpace::TransferFunction::Linear);
+
+ QTest::newRow("default") << QColorTransform() << true;
+ QTest::newRow("sRGB to Linear sRGB") << srgb.transformationToColorSpace(srgbLinear) << true;
+ QTest::newRow("AdobeRGB to sRGB") << adobeRgb.transformationToColorSpace(srgb) << true;
+ QTest::newRow("Linear AdobeRGB to AdobeRGB") << adobeRgbLinear.transformationToColorSpace(adobeRgb) << true;
+ QTest::newRow("Linear AdobeRGB to Linear sRGB") << adobeRgbLinear.transformationToColorSpace(srgbLinear) << true;
+ QTest::newRow("sRgb to AdobeRGB") << srgb.transformationToColorSpace(adobeRgb) << true;
+ QTest::newRow("DP3 to sRGB") << dp3.transformationToColorSpace(srgb) << false;
+ QTest::newRow("DP3 to Linear DP3") << dp3.transformationToColorSpace(dp3Linear) << false;
+ QTest::newRow("Linear DP3 to Linear sRGB") << dp3Linear.transformationToColorSpace(srgbLinear) << false;
+}
+
+void tst_QColorTransform::mapRGB32()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+ // Do basic sanity tests of conversions between similar sane color spaces
+
+ QRgb testColor = qRgb(32, 64, 128);
+ QRgb result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(128, 64, 32);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) > qGreen(result));
+ QVERIFY(qGreen(result) > qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgba(15, 31, 63, 128);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 128);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(0, 0, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 0);
+ QCOMPARE(qGreen(result), 0);
+ QCOMPARE(qBlue(result), 0);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 255);
+ QCOMPARE(qGreen(result), 255);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qAlpha(result), 255);
+ if (sharesRed)
+ QCOMPARE(qRed(result), 255);
+
+ testColor = qRgb(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+}
+
+void tst_QColorTransform::mapRGB64_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGB64()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgba64 testColor = QRgba64::fromRgba(128, 64, 32, 255);
+ QRgba64 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 0xffff);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgba64::fromRgba64(0, 0, 0, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgba64::fromRgba64(0xffff, 0xffff, 0xffff, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgba64::fromRgba64(0xffff, 0xffff, 0, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result.alpha(), 0xffff);
+ if (sharesRed)
+ QCOMPARE(result.red(), 0xffff);
+
+ testColor = QRgba64::fromRgba64(0, 0xffff, 0xffff, 0xffff);
+ result = transform.map(testColor);
+ QCOMPARE(result.blue(), 0xffff);
+ QCOMPARE(result.alpha(), 0xffff);
+}
+
+void tst_QColorTransform::mapRGBAFP16x4_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGBAFP16x4()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgbaFloat16 testColor = QRgbaFloat16::fromRgba(128, 64, 32, 255);
+ QRgbaFloat16 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgbaFloat16{0.0f, 0.0f, 0.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgbaFloat16{1.0f, 1.0f, 1.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QRgbaFloat16{1.0f, 1.0f, 0.0f, 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};
+ result = transform.map(testColor);
+ // QRgbaFloat16 might overflow blue if we convert to a smaller gamut:
+ QCOMPARE(result.blue16(), 65535);
+ QCOMPARE(result.alpha(), 1.0f);
+}
+
+void tst_QColorTransform::mapRGBAFP32x4_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGBAFP32x4()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QRgbaFloat32 testColor = QRgbaFloat32::fromRgba(128, 64, 32, 255);
+ QRgbaFloat32 result = transform.map(testColor);
+ QVERIFY(result.red() > result.green());
+ QVERIFY(result.green() > result.blue());
+ QCOMPARE(result.alpha(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = QRgbaFloat32{0.0f, 0.0f, 0.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.red(), 0.0f);
+ QCOMPARE(result.green(), 0.0f);
+ QCOMPARE(result.blue(), 0.0f);
+ QCOMPARE(result.alpha(), 1.0f);
+
+ testColor = QRgbaFloat32{1.0f, 1.0f, 1.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.red(), 1.0f);
+ QCOMPARE(result.green(), 1.0f);
+ QCOMPARE(result.blue(), 1.0f);
+ QCOMPARE(result.alpha(), 1.0f);
+
+ testColor = QRgbaFloat32{1.0f, 1.0f, 0.0f, 1.0f};
+ result = transform.map(testColor);
+ QCOMPARE(result.alpha(), 1.0f);
+ if (sharesRed)
+ QCOMPARE(result.red(), 1.0f);
+
+ testColor = QRgbaFloat32{0.0f, 1.0f, 1.0f, 1.0f};
+ result = transform.map(testColor);
+ // QRgbaFloat16 might overflow blue if we convert to a smaller gamut:
+ QCOMPARE(result.blue16(), 65535);
+ QCOMPARE(result.alpha(), 1.0f);
+}
+
+void tst_QColorTransform::mapQColor_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapQColor()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ QColor testColor(32, 64, 128);
+ QColor result = transform.map(testColor);
+ QVERIFY(result.redF() < result.greenF());
+ QVERIFY(result.greenF() < result.blueF());
+ QCOMPARE(result.alphaF(), 1.0f);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = Qt::black;
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = Qt::white;
+ result = transform.map(testColor);
+ QCOMPARE(result, testColor);
+
+ testColor = QColor(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(result.alphaF(), 1);
+ if (sharesRed)
+ QVERIFY(result.redF() >= 1.0f);
+
+ testColor = QColor(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(result.alphaF(), 1.0f);
+ QVERIFY(result.blueF() >= 1.0f);
+}
+
+void tst_QColorTransform::mapRGB32Prepared_data()
+{
+ mapRGB32_data();
+}
+
+void tst_QColorTransform::mapRGB32Prepared()
+{
+ QFETCH(QColorTransform, transform);
+ QFETCH(bool, sharesRed);
+
+ // The same tests as mapRGB32 but prepared, to use the LUT code-paths
+ if (!transform.isIdentity())
+ QColorTransformPrivate::get(transform)->prepare();
+
+ QRgb testColor = qRgb(32, 64, 128);
+ QRgb result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(128, 64, 32);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) > qGreen(result));
+ QVERIFY(qGreen(result) > qBlue(result));
+ QCOMPARE(qAlpha(result), 255);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgba(15, 31, 63, 128);
+ result = transform.map(testColor);
+ QVERIFY(qRed(result) < qGreen(result));
+ QVERIFY(qGreen(result) < qBlue(result));
+ QCOMPARE(qAlpha(result), 128);
+ if (transform.isIdentity())
+ QVERIFY(result == testColor);
+ else
+ QVERIFY(result != testColor);
+
+ testColor = qRgb(0, 0, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 0);
+ QCOMPARE(qGreen(result), 0);
+ QCOMPARE(qBlue(result), 0);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qRed(result), 255);
+ QCOMPARE(qGreen(result), 255);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+
+ testColor = qRgb(255, 255, 0);
+ result = transform.map(testColor);
+ QCOMPARE(qAlpha(result), 255);
+ if (sharesRed)
+ QCOMPARE(qRed(result), 255);
+
+ testColor = qRgb(0, 255, 255);
+ result = transform.map(testColor);
+ QCOMPARE(qBlue(result), 255);
+ QCOMPARE(qAlpha(result), 255);
+}
+
+void tst_QColorTransform::transformIsIdentity()
+{
+ QColorTransform ct;
+ QVERIFY(ct.isIdentity());
+
+ QColorSpace cs = QColorSpace::SRgb;
+ ct = cs.transformationToColorSpace(QColorSpace::SRgb);
+ QVERIFY(ct.isIdentity());
+
+ ct = cs.transformationToColorSpace(QColorSpace::SRgbLinear);
+ QVERIFY(!ct.isIdentity());
+
+ ct = cs.withTransferFunction(QColorSpace::TransferFunction::Linear).transformationToColorSpace(QColorSpace::SRgbLinear);
+ QVERIFY(ct.isIdentity());
+}
+
+QTEST_MAIN(tst_QColorTransform)
+#include "tst_qcolortransform.moc"
diff --git a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
index 913619461e..129b9a67b8 100644
--- a/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagelayout/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpagelayout.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpagelayout Test:
@@ -9,7 +10,7 @@ qt_internal_add_test(tst_qpagelayout
tst_qpagelayout.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
index 830e0cd16c..123663a0e3 100644
--- a/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
+++ b/tests/auto/gui/painting/qpagelayout/tst_qpagelayout.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include <QTest>
#include <QtGui/qpagelayout.h>
diff --git a/tests/auto/gui/painting/qpageranges/CMakeLists.txt b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
index 660d4b4336..b779b51618 100644
--- a/tests/auto/gui/painting/qpageranges/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpageranges/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpageranges.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpageranges Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qpageranges
SOURCES
tst_qpageranges.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
index 4912aa43c1..4677399b3f 100644
--- a/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
+++ b/tests/auto/gui/painting/qpageranges/tst_qpageranges.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <qpageranges.h>
@@ -95,7 +70,7 @@ void tst_QPageRanges::addPage()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (int pageNumber : qAsConst(pageNumbers)) {
+ for (int pageNumber : std::as_const(pageNumbers)) {
if (QByteArrayView(QTest::currentDataTag()) == "invalid")
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addPage: 'pageNumber' must be greater than 0");
result.addPage(pageNumber);
@@ -137,7 +112,7 @@ void tst_QPageRanges::addRange()
QFETCH(PageRangeList, expected);
QPageRanges result;
- for (const auto &range : qAsConst(ranges)) {
+ for (const auto &range : std::as_const(ranges)) {
const QByteArrayView testdata(QTest::currentDataTag());
if (testdata.startsWith("invalid"))
QTest::ignoreMessage(QtWarningMsg, "QPageRanges::addRange: 'from' and 'to' must be greater than 0");
diff --git a/tests/auto/gui/painting/qpagesize/CMakeLists.txt b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
index fc6fd931c2..009272aeff 100644
--- a/tests/auto/gui/painting/qpagesize/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpagesize/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpagesize.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpagesize Test:
@@ -9,6 +10,6 @@ qt_internal_add_test(tst_qpagesize
tst_qpagesize.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
index 838f7e59cd..bac7e9cdf8 100644
--- a/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
+++ b/tests/auto/gui/painting/qpagesize/tst_qpagesize.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGlobal>
diff --git a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
index b843135645..bb34f49bee 100644
--- a/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpaintengine/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpaintengine.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpaintengine Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpaintengine
SOURCES
tst_qpaintengine.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
index 4363799702..24e13c2821 100644
--- a/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
+++ b/tests/auto/gui/painting/qpaintengine/tst_qpaintengine.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/painting/qpainter/CMakeLists.txt b/tests/auto/gui/painting/qpainter/CMakeLists.txt
index 9466dddadd..31a59dedcd 100644
--- a/tests/auto/gui/painting/qpainter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainter/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpainter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainter Test:
@@ -26,7 +27,7 @@ list(APPEND test_data "task217400.png")
qt_internal_add_test(tst_qpainter
SOURCES
tst_qpainter.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
@@ -37,202 +38,7 @@ qt_internal_add_test(tst_qpainter
#####################################################################
qt_internal_extend_target(tst_qpainter CONDITION TARGET Qt::Widgets
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Widgets
Qt::WidgetsPrivate
)
-
-if(ANDROID)
- # Resources:
- set(testdata_resource_files
- "drawEllipse/10x10SizeAt0x0.png"
- "drawEllipse/10x10SizeAt100x100.png"
- "drawEllipse/10x10SizeAt200x200.png"
- "drawEllipse/13x100SizeAt0x0.png"
- "drawEllipse/13x100SizeAt100x100.png"
- "drawEllipse/13x100SizeAt200x200.png"
- "drawEllipse/200x200SizeAt0x0.png"
- "drawEllipse/200x200SizeAt100x100.png"
- "drawEllipse/200x200SizeAt200x200.png"
- "drawLine_rop_bitmap/dst.xbm"
- "drawLine_rop_bitmap/res/res_AndNotROP.xbm"
- "drawLine_rop_bitmap/res/res_AndROP.xbm"
- "drawLine_rop_bitmap/res/res_ClearROP.xbm"
- "drawLine_rop_bitmap/res/res_CopyROP.xbm"
- "drawLine_rop_bitmap/res/res_NandROP.xbm"
- "drawLine_rop_bitmap/res/res_NopROP.xbm"
- "drawLine_rop_bitmap/res/res_NorROP.xbm"
- "drawLine_rop_bitmap/res/res_NotAndROP.xbm"
- "drawLine_rop_bitmap/res/res_NotCopyROP.xbm"
- "drawLine_rop_bitmap/res/res_NotOrROP.xbm"
- "drawLine_rop_bitmap/res/res_NotROP.xbm"
- "drawLine_rop_bitmap/res/res_NotXorROP.xbm"
- "drawLine_rop_bitmap/res/res_OrNotROP.xbm"
- "drawLine_rop_bitmap/res/res_OrROP.xbm"
- "drawLine_rop_bitmap/res/res_SetROP.xbm"
- "drawLine_rop_bitmap/res/res_XorROP.xbm"
- "drawPixmap_rop/dst1.png"
- "drawPixmap_rop/dst2.png"
- "drawPixmap_rop/dst3.png"
- "drawPixmap_rop/res/res_AndNotROP0.png"
- "drawPixmap_rop/res/res_AndNotROP1.png"
- "drawPixmap_rop/res/res_AndNotROP2.png"
- "drawPixmap_rop/res/res_AndNotROP3.png"
- "drawPixmap_rop/res/res_AndNotROP4.png"
- "drawPixmap_rop/res/res_AndNotROP5.png"
- "drawPixmap_rop/res/res_AndNotROP6.png"
- "drawPixmap_rop/res/res_AndNotROP7.png"
- "drawPixmap_rop/res/res_AndROP0.png"
- "drawPixmap_rop/res/res_AndROP1.png"
- "drawPixmap_rop/res/res_AndROP2.png"
- "drawPixmap_rop/res/res_AndROP3.png"
- "drawPixmap_rop/res/res_AndROP4.png"
- "drawPixmap_rop/res/res_AndROP5.png"
- "drawPixmap_rop/res/res_AndROP6.png"
- "drawPixmap_rop/res/res_AndROP7.png"
- "drawPixmap_rop/res/res_ClearROP0.png"
- "drawPixmap_rop/res/res_ClearROP1.png"
- "drawPixmap_rop/res/res_ClearROP2.png"
- "drawPixmap_rop/res/res_ClearROP3.png"
- "drawPixmap_rop/res/res_ClearROP4.png"
- "drawPixmap_rop/res/res_ClearROP5.png"
- "drawPixmap_rop/res/res_ClearROP6.png"
- "drawPixmap_rop/res/res_ClearROP7.png"
- "drawPixmap_rop/res/res_CopyROP0.png"
- "drawPixmap_rop/res/res_CopyROP1.png"
- "drawPixmap_rop/res/res_CopyROP2.png"
- "drawPixmap_rop/res/res_CopyROP3.png"
- "drawPixmap_rop/res/res_CopyROP4.png"
- "drawPixmap_rop/res/res_CopyROP5.png"
- "drawPixmap_rop/res/res_CopyROP6.png"
- "drawPixmap_rop/res/res_CopyROP7.png"
- "drawPixmap_rop/res/res_NandROP0.png"
- "drawPixmap_rop/res/res_NandROP1.png"
- "drawPixmap_rop/res/res_NandROP2.png"
- "drawPixmap_rop/res/res_NandROP3.png"
- "drawPixmap_rop/res/res_NandROP4.png"
- "drawPixmap_rop/res/res_NandROP5.png"
- "drawPixmap_rop/res/res_NandROP6.png"
- "drawPixmap_rop/res/res_NandROP7.png"
- "drawPixmap_rop/res/res_NopROP0.png"
- "drawPixmap_rop/res/res_NopROP1.png"
- "drawPixmap_rop/res/res_NopROP2.png"
- "drawPixmap_rop/res/res_NopROP3.png"
- "drawPixmap_rop/res/res_NopROP4.png"
- "drawPixmap_rop/res/res_NopROP5.png"
- "drawPixmap_rop/res/res_NopROP6.png"
- "drawPixmap_rop/res/res_NopROP7.png"
- "drawPixmap_rop/res/res_NorROP0.png"
- "drawPixmap_rop/res/res_NorROP1.png"
- "drawPixmap_rop/res/res_NorROP2.png"
- "drawPixmap_rop/res/res_NorROP3.png"
- "drawPixmap_rop/res/res_NorROP4.png"
- "drawPixmap_rop/res/res_NorROP5.png"
- "drawPixmap_rop/res/res_NorROP6.png"
- "drawPixmap_rop/res/res_NorROP7.png"
- "drawPixmap_rop/res/res_NotAndROP0.png"
- "drawPixmap_rop/res/res_NotAndROP1.png"
- "drawPixmap_rop/res/res_NotAndROP2.png"
- "drawPixmap_rop/res/res_NotAndROP3.png"
- "drawPixmap_rop/res/res_NotAndROP4.png"
- "drawPixmap_rop/res/res_NotAndROP5.png"
- "drawPixmap_rop/res/res_NotAndROP6.png"
- "drawPixmap_rop/res/res_NotAndROP7.png"
- "drawPixmap_rop/res/res_NotCopyROP0.png"
- "drawPixmap_rop/res/res_NotCopyROP1.png"
- "drawPixmap_rop/res/res_NotCopyROP2.png"
- "drawPixmap_rop/res/res_NotCopyROP3.png"
- "drawPixmap_rop/res/res_NotCopyROP4.png"
- "drawPixmap_rop/res/res_NotCopyROP5.png"
- "drawPixmap_rop/res/res_NotCopyROP6.png"
- "drawPixmap_rop/res/res_NotCopyROP7.png"
- "drawPixmap_rop/res/res_NotOrROP0.png"
- "drawPixmap_rop/res/res_NotOrROP1.png"
- "drawPixmap_rop/res/res_NotOrROP2.png"
- "drawPixmap_rop/res/res_NotOrROP3.png"
- "drawPixmap_rop/res/res_NotOrROP4.png"
- "drawPixmap_rop/res/res_NotOrROP5.png"
- "drawPixmap_rop/res/res_NotOrROP6.png"
- "drawPixmap_rop/res/res_NotOrROP7.png"
- "drawPixmap_rop/res/res_NotROP0.png"
- "drawPixmap_rop/res/res_NotROP1.png"
- "drawPixmap_rop/res/res_NotROP2.png"
- "drawPixmap_rop/res/res_NotROP3.png"
- "drawPixmap_rop/res/res_NotROP4.png"
- "drawPixmap_rop/res/res_NotROP5.png"
- "drawPixmap_rop/res/res_NotROP6.png"
- "drawPixmap_rop/res/res_NotROP7.png"
- "drawPixmap_rop/res/res_NotXorROP0.png"
- "drawPixmap_rop/res/res_NotXorROP1.png"
- "drawPixmap_rop/res/res_NotXorROP2.png"
- "drawPixmap_rop/res/res_NotXorROP3.png"
- "drawPixmap_rop/res/res_NotXorROP4.png"
- "drawPixmap_rop/res/res_NotXorROP5.png"
- "drawPixmap_rop/res/res_NotXorROP6.png"
- "drawPixmap_rop/res/res_NotXorROP7.png"
- "drawPixmap_rop/res/res_OrNotROP0.png"
- "drawPixmap_rop/res/res_OrNotROP1.png"
- "drawPixmap_rop/res/res_OrNotROP2.png"
- "drawPixmap_rop/res/res_OrNotROP3.png"
- "drawPixmap_rop/res/res_OrNotROP4.png"
- "drawPixmap_rop/res/res_OrNotROP5.png"
- "drawPixmap_rop/res/res_OrNotROP6.png"
- "drawPixmap_rop/res/res_OrNotROP7.png"
- "drawPixmap_rop/res/res_OrROP0.png"
- "drawPixmap_rop/res/res_OrROP1.png"
- "drawPixmap_rop/res/res_OrROP2.png"
- "drawPixmap_rop/res/res_OrROP3.png"
- "drawPixmap_rop/res/res_OrROP4.png"
- "drawPixmap_rop/res/res_OrROP5.png"
- "drawPixmap_rop/res/res_OrROP6.png"
- "drawPixmap_rop/res/res_OrROP7.png"
- "drawPixmap_rop/res/res_SetROP0.png"
- "drawPixmap_rop/res/res_SetROP1.png"
- "drawPixmap_rop/res/res_SetROP2.png"
- "drawPixmap_rop/res/res_SetROP3.png"
- "drawPixmap_rop/res/res_SetROP4.png"
- "drawPixmap_rop/res/res_SetROP5.png"
- "drawPixmap_rop/res/res_SetROP6.png"
- "drawPixmap_rop/res/res_SetROP7.png"
- "drawPixmap_rop/res/res_XorROP0.png"
- "drawPixmap_rop/res/res_XorROP1.png"
- "drawPixmap_rop/res/res_XorROP2.png"
- "drawPixmap_rop/res/res_XorROP3.png"
- "drawPixmap_rop/res/res_XorROP4.png"
- "drawPixmap_rop/res/res_XorROP5.png"
- "drawPixmap_rop/res/res_XorROP6.png"
- "drawPixmap_rop/res/res_XorROP7.png"
- "drawPixmap_rop/src1.xbm"
- "drawPixmap_rop/src2-mask.xbm"
- "drawPixmap_rop/src2.xbm"
- "drawPixmap_rop/src3.xbm"
- "drawPixmap_rop_bitmap/dst.xbm"
- "drawPixmap_rop_bitmap/res/res_AndNotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_AndROP.xbm"
- "drawPixmap_rop_bitmap/res/res_ClearROP.xbm"
- "drawPixmap_rop_bitmap/res/res_CopyROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NandROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NopROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NorROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotAndROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotCopyROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotOrROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_NotXorROP.xbm"
- "drawPixmap_rop_bitmap/res/res_OrNotROP.xbm"
- "drawPixmap_rop_bitmap/res/res_OrROP.xbm"
- "drawPixmap_rop_bitmap/res/res_SetROP.xbm"
- "drawPixmap_rop_bitmap/res/res_XorROP.xbm"
- "drawPixmap_rop_bitmap/src1-mask.xbm"
- "drawPixmap_rop_bitmap/src1.xbm"
- "drawPixmap_rop_bitmap/src2.xbm"
- "task217400.png"
- )
-
- qt_internal_add_resource(tst_qpainter "testdata"
- PREFIX
- "/"
- FILES
- ${testdata_resource_files}
- )
-endif()
diff --git a/tests/auto/gui/painting/qpainter/testdata.qrc b/tests/auto/gui/painting/qpainter/testdata.qrc
deleted file mode 100644
index a7b8c222e5..0000000000
--- a/tests/auto/gui/painting/qpainter/testdata.qrc
+++ /dev/null
@@ -1,186 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>task217400.png</file>
- <file>drawEllipse/10x10SizeAt0x0.png</file>
- <file>drawEllipse/10x10SizeAt100x100.png</file>
- <file>drawEllipse/10x10SizeAt200x200.png</file>
- <file>drawEllipse/13x100SizeAt0x0.png</file>
- <file>drawEllipse/13x100SizeAt100x100.png</file>
- <file>drawEllipse/13x100SizeAt200x200.png</file>
- <file>drawEllipse/200x200SizeAt0x0.png</file>
- <file>drawEllipse/200x200SizeAt100x100.png</file>
- <file>drawEllipse/200x200SizeAt200x200.png</file>
- <file>drawLine_rop_bitmap/dst.xbm</file>
- <file>drawLine_rop_bitmap/res/res_AndNotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_AndROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_ClearROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_CopyROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NandROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NopROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NorROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotAndROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotCopyROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotOrROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_NotXorROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_OrNotROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_OrROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_SetROP.xbm</file>
- <file>drawLine_rop_bitmap/res/res_XorROP.xbm</file>
- <file>drawPixmap_rop/dst1.png</file>
- <file>drawPixmap_rop/dst2.png</file>
- <file>drawPixmap_rop/dst3.png</file>
- <file>drawPixmap_rop/src1.xbm</file>
- <file>drawPixmap_rop/src2-mask.xbm</file>
- <file>drawPixmap_rop/src2.xbm</file>
- <file>drawPixmap_rop/src3.xbm</file>
- <file>drawPixmap_rop/res/res_AndNotROP0.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP1.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP2.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP3.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP4.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP5.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP6.png</file>
- <file>drawPixmap_rop/res/res_AndNotROP7.png</file>
- <file>drawPixmap_rop/res/res_AndROP0.png</file>
- <file>drawPixmap_rop/res/res_AndROP1.png</file>
- <file>drawPixmap_rop/res/res_AndROP2.png</file>
- <file>drawPixmap_rop/res/res_AndROP3.png</file>
- <file>drawPixmap_rop/res/res_AndROP4.png</file>
- <file>drawPixmap_rop/res/res_AndROP5.png</file>
- <file>drawPixmap_rop/res/res_AndROP6.png</file>
- <file>drawPixmap_rop/res/res_AndROP7.png</file>
- <file>drawPixmap_rop/res/res_ClearROP0.png</file>
- <file>drawPixmap_rop/res/res_ClearROP1.png</file>
- <file>drawPixmap_rop/res/res_ClearROP2.png</file>
- <file>drawPixmap_rop/res/res_ClearROP3.png</file>
- <file>drawPixmap_rop/res/res_ClearROP4.png</file>
- <file>drawPixmap_rop/res/res_ClearROP5.png</file>
- <file>drawPixmap_rop/res/res_ClearROP6.png</file>
- <file>drawPixmap_rop/res/res_ClearROP7.png</file>
- <file>drawPixmap_rop/res/res_CopyROP0.png</file>
- <file>drawPixmap_rop/res/res_CopyROP1.png</file>
- <file>drawPixmap_rop/res/res_CopyROP2.png</file>
- <file>drawPixmap_rop/res/res_CopyROP3.png</file>
- <file>drawPixmap_rop/res/res_CopyROP4.png</file>
- <file>drawPixmap_rop/res/res_CopyROP5.png</file>
- <file>drawPixmap_rop/res/res_CopyROP6.png</file>
- <file>drawPixmap_rop/res/res_CopyROP7.png</file>
- <file>drawPixmap_rop/res/res_NandROP0.png</file>
- <file>drawPixmap_rop/res/res_NandROP1.png</file>
- <file>drawPixmap_rop/res/res_NandROP2.png</file>
- <file>drawPixmap_rop/res/res_NandROP3.png</file>
- <file>drawPixmap_rop/res/res_NandROP4.png</file>
- <file>drawPixmap_rop/res/res_NandROP5.png</file>
- <file>drawPixmap_rop/res/res_NandROP6.png</file>
- <file>drawPixmap_rop/res/res_NandROP7.png</file>
- <file>drawPixmap_rop/res/res_NopROP0.png</file>
- <file>drawPixmap_rop/res/res_NopROP1.png</file>
- <file>drawPixmap_rop/res/res_NopROP2.png</file>
- <file>drawPixmap_rop/res/res_NopROP3.png</file>
- <file>drawPixmap_rop/res/res_NopROP4.png</file>
- <file>drawPixmap_rop/res/res_NopROP5.png</file>
- <file>drawPixmap_rop/res/res_NopROP6.png</file>
- <file>drawPixmap_rop/res/res_NopROP7.png</file>
- <file>drawPixmap_rop/res/res_NorROP0.png</file>
- <file>drawPixmap_rop/res/res_NorROP1.png</file>
- <file>drawPixmap_rop/res/res_NorROP2.png</file>
- <file>drawPixmap_rop/res/res_NorROP3.png</file>
- <file>drawPixmap_rop/res/res_NorROP4.png</file>
- <file>drawPixmap_rop/res/res_NorROP5.png</file>
- <file>drawPixmap_rop/res/res_NorROP6.png</file>
- <file>drawPixmap_rop/res/res_NorROP7.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP0.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP1.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP2.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP3.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP4.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP5.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP6.png</file>
- <file>drawPixmap_rop/res/res_NotAndROP7.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP0.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP1.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP2.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP3.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP4.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP5.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP6.png</file>
- <file>drawPixmap_rop/res/res_NotCopyROP7.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP0.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP1.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP2.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP3.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP4.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP5.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP6.png</file>
- <file>drawPixmap_rop/res/res_NotOrROP7.png</file>
- <file>drawPixmap_rop/res/res_NotROP0.png</file>
- <file>drawPixmap_rop/res/res_NotROP1.png</file>
- <file>drawPixmap_rop/res/res_NotROP2.png</file>
- <file>drawPixmap_rop/res/res_NotROP3.png</file>
- <file>drawPixmap_rop/res/res_NotROP4.png</file>
- <file>drawPixmap_rop/res/res_NotROP5.png</file>
- <file>drawPixmap_rop/res/res_NotROP6.png</file>
- <file>drawPixmap_rop/res/res_NotROP7.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP0.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP1.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP2.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP3.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP4.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP5.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP6.png</file>
- <file>drawPixmap_rop/res/res_NotXorROP7.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP0.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP1.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP2.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP3.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP4.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP5.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP6.png</file>
- <file>drawPixmap_rop/res/res_OrNotROP7.png</file>
- <file>drawPixmap_rop/res/res_OrROP0.png</file>
- <file>drawPixmap_rop/res/res_OrROP1.png</file>
- <file>drawPixmap_rop/res/res_OrROP2.png</file>
- <file>drawPixmap_rop/res/res_OrROP3.png</file>
- <file>drawPixmap_rop/res/res_OrROP4.png</file>
- <file>drawPixmap_rop/res/res_OrROP5.png</file>
- <file>drawPixmap_rop/res/res_OrROP6.png</file>
- <file>drawPixmap_rop/res/res_OrROP7.png</file>
- <file>drawPixmap_rop/res/res_SetROP0.png</file>
- <file>drawPixmap_rop/res/res_SetROP1.png</file>
- <file>drawPixmap_rop/res/res_SetROP2.png</file>
- <file>drawPixmap_rop/res/res_SetROP3.png</file>
- <file>drawPixmap_rop/res/res_SetROP4.png</file>
- <file>drawPixmap_rop/res/res_SetROP5.png</file>
- <file>drawPixmap_rop/res/res_SetROP6.png</file>
- <file>drawPixmap_rop/res/res_SetROP7.png</file>
- <file>drawPixmap_rop/res/res_XorROP0.png</file>
- <file>drawPixmap_rop/res/res_XorROP1.png</file>
- <file>drawPixmap_rop/res/res_XorROP2.png</file>
- <file>drawPixmap_rop/res/res_XorROP3.png</file>
- <file>drawPixmap_rop/res/res_XorROP4.png</file>
- <file>drawPixmap_rop/res/res_XorROP5.png</file>
- <file>drawPixmap_rop/res/res_XorROP6.png</file>
- <file>drawPixmap_rop/res/res_XorROP7.png</file>
- <file>drawPixmap_rop_bitmap/dst.xbm</file>
- <file>drawPixmap_rop_bitmap/src1-mask.xbm</file>
- <file>drawPixmap_rop_bitmap/src1.xbm</file>
- <file>drawPixmap_rop_bitmap/src2.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_AndNotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_AndROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_ClearROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_CopyROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NandROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NopROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NorROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotAndROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotCopyROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotOrROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_NotXorROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_OrNotROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_OrROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_SetROP.xbm</file>
- <file>drawPixmap_rop_bitmap/res/res_XorROP.xbm</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 45490ef815..92c3ea4a5a 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -69,6 +44,9 @@ Q_OBJECT
public:
tst_QPainter();
+ enum ClipType { ClipRect, ClipRectF, ClipRegionSingle, ClipRegionMulti, ClipPathR, ClipPath };
+ Q_ENUM(ClipType);
+
private slots:
void cleanupTestCase();
void getSetCheck();
@@ -155,6 +133,8 @@ private slots:
void clipBoundingRect();
void transformedClip();
+ void scaledClipConsistency_data();
+ void scaledClipConsistency();
void setOpacity_data();
void setOpacity();
@@ -301,6 +281,9 @@ private slots:
void drawImageAtPointF();
void scaledDashes();
+#if QT_CONFIG(raster_fp)
+ void hdrColors();
+#endif
private:
void fillData();
@@ -1749,10 +1732,11 @@ void tst_QPainter::setClipRect()
/*
Verify that the clipping works correctly.
- The red outline should be covered by the blue rect on top and left,
- while it should be clipped on the right and bottom and thus the red outline be visible
+ Just like fillRect, cliprect should snap rightwards and downwards in case of .5 coordinates.
+ The red outline should be covered by the blue rect on top,
+ while it should be clipped on the other edges and thus the red outline be visible
- See: QTBUG-83229
+ See: QTBUG-83229, modified by QTBUG-100329
*/
void tst_QPainter::clipRect()
{
@@ -1778,7 +1762,7 @@ void tst_QPainter::clipRect()
p.end();
QCOMPARE(image.pixelColor(clipRect.left() + 1, clipRect.top()), QColor(Qt::blue));
- QCOMPARE(image.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::blue));
+ QCOMPARE(image.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::red));
QCOMPARE(image.pixelColor(clipRect.left() + 1, clipRect.bottom()), QColor(Qt::red));
QCOMPARE(image.pixelColor(clipRect.right(), clipRect.top() + 1), QColor(Qt::red));
}
@@ -2846,7 +2830,14 @@ void tst_QPainter::monoImages()
}
}
-#if !defined(Q_OS_AIX) && !defined(Q_CC_MSVC) && !defined(Q_OS_SOLARIS) && !defined(__UCLIBC__) && !defined(Q_OS_INTEGRITY)
+#if defined(Q_OS_DARWIN) || defined(Q_OS_FREEBSD) || defined(Q_OS_ANDROID)
+# define TEST_FPE_EXCEPTIONS
+#elif defined(Q_OS_LINUX) && defined(__GLIBC__)
+# define TEST_FPE_EXCEPTIONS
+#elif defined(Q_OS_WIN) && defined(Q_CC_GNU)
+# define TEST_FPE_EXCEPTIONS
+#endif
+#ifdef TEST_FPE_EXCEPTIONS
#include <fenv.h>
static const QString fpeExceptionString(int exception)
@@ -4580,6 +4571,96 @@ void tst_QPainter::transformedClip()
}
}
+void tst_QPainter::scaledClipConsistency_data()
+{
+ QTest::addColumn<ClipType>("clipType");
+
+ QTest::newRow("clipRect") << ClipRect;
+ QTest::newRow("clipRectF") << ClipRectF;
+ QTest::newRow("clipRegionSingle") << ClipRegionSingle;
+ QTest::newRow("clipRegionMulti") << ClipRegionMulti;
+ QTest::newRow("clipPathR") << ClipPathR;
+ QTest::newRow("clipPath") << ClipPath;
+}
+
+void tst_QPainter::scaledClipConsistency()
+{
+ QFETCH(ClipType, clipType);
+
+ const QList<QRect> clipRects = {
+ // Varying odd and even coordinates and width/height
+ QRect(1, 1, 7, 8),
+ QRect(8, 0, 8, 9),
+ QRect(0, 9, 8, 7),
+ QRect(8, 9, 8, 7),
+ };
+ // Assert that these are edge to edge:
+ QPointF center = QRectF(clipRects[0]).bottomRight();
+ Q_ASSERT(QRectF(clipRects[1]).bottomLeft() == center);
+ Q_ASSERT(QRectF(clipRects[2]).topRight() == center);
+ Q_ASSERT(QRectF(clipRects[3]).topLeft() == center);
+
+ QRegion multiRegion;
+ for (const QRect &clipRect : clipRects)
+ multiRegion += clipRect;
+
+ QColor fillColor(Qt::black);
+ fillColor.setAlphaF(0.5);
+
+ for (int i = 100; i <= 300; i++) {
+ qreal dpr = qreal(i) / 100.0;
+ QImage img(QSize(16, 16) * dpr, QImage::Format_RGB32);
+ img.fill(Qt::white);
+ img.setDevicePixelRatio(dpr);
+
+ for (const QRect &clipRect : clipRects) {
+ QPainter p(&img);
+ switch (clipType) {
+ case ClipRect:
+ p.setClipRect(clipRect);
+ break;
+ case ClipRectF:
+ p.setClipRect(QRectF(clipRect));
+ break;
+ case ClipRegionSingle:
+ p.setClipRegion(QRegion(clipRect));
+ break;
+ case ClipRegionMulti:
+ p.setClipRegion(multiRegion);
+ break;
+ case ClipPath:
+ p.rotate(0.001); // Avoid the path being optimized to a rectf
+ Q_FALLTHROUGH();
+ case ClipPathR: {
+ QPainterPath path;
+ path.addRect(clipRect); // Will be recognized and converted back to a rectf
+ p.setClipPath(path);
+ break;
+ }
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ p.fillRect(p.window(), fillColor);
+ if (clipType == ClipRegionMulti)
+ break; // once is enough, we're not using the clipRect anyway
+ }
+
+ int qtWidth = img.width() / 4;
+ int qtHeight = img.height() / 4;
+ QPoint imgCenter = img.rect().center();
+ const QRgb targetColor = img.pixel(qtWidth, qtHeight);
+
+ // Test that there are no gaps or overlaps where the cliprects meet
+ for (int offset = -2; offset <= 2; offset++) {
+ QCOMPARE(img.pixel(imgCenter.x() + offset, qtHeight), targetColor);
+ QCOMPARE(img.pixel(imgCenter.x() + offset, img.height() - qtHeight), targetColor);
+ QCOMPARE(img.pixel(qtWidth, imgCenter.y() + offset), targetColor);
+ QCOMPARE(img.pixel(img.width() - qtWidth, imgCenter.y() + offset), targetColor);
+ }
+ }
+}
+
#if defined(Q_OS_MAC)
// Only Mac supports sub pixel positions in raster engine currently
void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
@@ -4930,16 +5011,16 @@ void tst_QPainter::blendARGBonRGB_data()
QTest::newRow("ARGB_PM over RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
<< QPainter::CompositionMode_SourceOver << qRgba(85, 0, 0, 85) << 85;
#if QT_CONFIG(raster_64bit)
- QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
- << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85;
- QTest::newRow("ARGB source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
- << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85;
+ QTest::newRow("ARGB@85 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 85) << 85;
+ QTest::newRow("ARGB@120 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
+ << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 120) << 85;
#endif
- QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
- << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85;
+ QTest::newRow("ARGB_PM@85 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(85, 0, 0, 85) << 85;
#if QT_CONFIG(raster_64bit)
- QTest::newRow("ARGB_PM source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
- << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170;
+ QTest::newRow("ARGB_PM@180 source RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32_Premultiplied
+ << QPainter::CompositionMode_Source << qRgba(180, 0, 0, 180) << 170;
#endif
QTest::newRow("ARGB source-in RGB30") << QImage::Format_RGB30 << QImage::Format_ARGB32
<< QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 85) << 85;
@@ -5100,7 +5181,7 @@ void tst_QPainter::drawPolyline()
p.setPen(pen);
QVERIFY(p.pen().isCosmetic());
if (r) {
- for (int i = 0; i < points.count()-1; i++) {
+ for (int i = 0; i < points.size()-1; i++) {
p.drawLine(points.at(i), points.at(i+1));
}
} else {
@@ -5393,6 +5474,49 @@ void tst_QPainter::scaledDashes()
QVERIFY(backFound);
}
+#if QT_CONFIG(raster_fp)
+void tst_QPainter::hdrColors()
+{
+ QImage img(10, 10, QImage::Format_RGBA32FPx4_Premultiplied);
+ img.fill(Qt::transparent);
+
+ QColor color = QColor::fromRgbF(2.0f, -0.25f, 1.5f);
+ img.setPixelColor(2, 2, color);
+ QCOMPARE(img.pixelColor(2, 2), color);
+
+ {
+ QPainterPath path;
+ path.addEllipse(4, 4, 2, 2);
+ QPainter p(&img);
+ p.fillPath(path, color);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ img.fill(color);
+ QCOMPARE(img.pixelColor(8, 8), color);
+
+ QColor color2 = QColor::fromRgbF(0.0f, 1.25f, 2.5f);
+ {
+ QPainter p(&img);
+ p.fillRect(0, 0, 3, 3, color2);
+ p.end();
+ }
+ QCOMPARE(img.pixelColor(1, 1), color2);
+ QCOMPARE(img.pixelColor(4, 4), color);
+
+ QImage img2(10, 10, QImage::Format_RGBX32FPx4);
+ img2.fill(Qt::black); // fill to avoid random FP values like Inf which can break SourceOver composition
+ {
+ QPainter p(&img2);
+ p.drawImage(0, 0, img);
+ p.end();
+ }
+ QCOMPARE(img2.pixelColor(2, 2), color2);
+ QCOMPARE(img2.pixelColor(5, 5), color);
+}
+#endif
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
index 53ea3ce9fb..092986045a 100644
--- a/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
+++ b/tests/auto/gui/painting/qpainter/utils/createImages/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <qapplication.h>
diff --git a/tests/auto/gui/painting/qpainterpath/BLACKLIST b/tests/auto/gui/painting/qpainterpath/BLACKLIST
deleted file mode 100644
index b3e6d3bfe4..0000000000
--- a/tests/auto/gui/painting/qpainterpath/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[contains_QPointF]
-msvc-2019
diff --git a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
index 47450c9146..7e77c1012f 100644
--- a/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpath/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpainterpath.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainterpath Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpainterpath
SOURCES
tst_qpainterpath.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
index dcba95d33c..20ee6e07c7 100644
--- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -410,11 +385,11 @@ void tst_QPainterPath::contains_QRectF_data()
QTest::newRow("inside 2 rects (winding)") << path << QRectF(51, 51, 48, 48) << true;
path.addEllipse(0, 0, 150, 150);
- QTest::newRow("topRight 2 rects") << path << QRectF(100, 25, 24, 24) << true;
- QTest::newRow("bottomLeft 2 rects") << path << QRectF(25, 100, 24, 24) << true;
+ QTest::newRow("topRight rects+circle") << path << QRectF(100, 25, 24, 24) << true;
+ QTest::newRow("bottomLeft rects+circle") << path << QRectF(25, 100, 24, 24) << true;
path.setFillRule(Qt::OddEvenFill);
- QTest::newRow("inside 2 rects") << path << QRectF(50, 50, 49, 49) << false;
+ QTest::newRow("inside rects+circle") << path << QRectF(50, 50, 49, 49) << false;
}
void tst_QPainterPath::contains_QRectF()
@@ -918,17 +893,17 @@ void tst_QPainterPath::testArcMoveTo_data()
QRectF(100, 100, 100, -100),
QRectF(100, 100, -100, -100),
};
+ constexpr qreal tinyAngle = 1e-10;
- for (uint domain = 0; domain < sizeof rects / sizeof *rects; ++domain) {
- const QByteArray dB = QByteArray::number(domain);
- for (int i=-360; i<=360; ++i) {
- QTest::newRow(("test " + dB + ' ' + QByteArray::number(i)).constData())
- << rects[domain] << (qreal) i;
- }
+ int index = 0;
+ for (const auto &rect : rects) {
+ for (int i = -360; i <= 360; ++i)
+ QTest::addRow("test %d %d", index, i) << rect << qreal(i);
// test low angles
- QTest::newRow("low angles 1") << rects[domain] << (qreal) 1e-10;
- QTest::newRow("low angles 2") << rects[domain] << (qreal)-1e-10;
+ QTest::addRow("low +angle %d", index) << rect << tinyAngle;
+ QTest::addRow("low -angle %d", index) << rect << -tinyAngle;
+ ++index;
}
}
@@ -1245,38 +1220,65 @@ void tst_QPainterPath::testNaNandInfinites()
QPointF p3 = QPointF(qQNaN(), 1);
QPointF pInf = QPointF(qInf(), 1);
- // all these operations with NaN/Inf should be ignored
- // can't test operator>> reliably, as we can't create a path with NaN to << later
+ // All these operations with NaN/Inf should be ignored.
+ // Can't test operator>> reliably, as we can't create a path with NaN to << later.
+#ifdef QT_NO_DEBUG
+# define WARNS(name)
+#else
+# define WARNS(name) \
+ QTest::ignoreMessage(QtWarningMsg, "QPainterPath::" #name ": " \
+ "Adding point with invalid coordinates, ignoring call")
+#endif
+ WARNS(moveTo);
path1.moveTo(p1);
+ WARNS(moveTo);
path1.moveTo(qSNaN(), qQNaN());
+ WARNS(moveTo);
path1.moveTo(pInf);
+ WARNS(lineTo);
path1.lineTo(p1);
+ WARNS(lineTo);
path1.lineTo(qSNaN(), qQNaN());
+ WARNS(lineTo);
path1.lineTo(pInf);
+ WARNS(cubicTo);
path1.cubicTo(p1, p2, p3);
+ WARNS(cubicTo);
path1.cubicTo(p1, QPointF(1, 1), QPointF(2, 2));
+ WARNS(cubicTo);
path1.cubicTo(pInf, QPointF(10, 10), QPointF(5, 1));
+ WARNS(quadTo);
path1.quadTo(p1, p2);
+ WARNS(quadTo);
path1.quadTo(QPointF(1, 1), p3);
+ WARNS(quadTo);
path1.quadTo(QPointF(1, 1), pInf);
+ WARNS(arcTo);
path1.arcTo(QRectF(p1, p2), 5, 5);
+ WARNS(arcTo);
path1.arcTo(QRectF(pInf, QPointF(1, 1)), 5, 5);
+ WARNS(addRect);
path1.addRect(QRectF(p1, p2));
+ WARNS(addRect);
path1.addRect(QRectF(pInf, QPointF(1, 1)));
+ WARNS(addEllipse);
path1.addEllipse(QRectF(p1, p2));
+ WARNS(addEllipse);
path1.addEllipse(QRectF(pInf, QPointF(1, 1)));
+#undef WARNS
+
QCOMPARE(path1, path2);
path1.lineTo(QPointF(1, 1));
- QVERIFY(path1 != path2);
+ QCOMPARE_NE(path1, path2);
}
#endif // signaling_nan
diff --git a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
index f4c301c42e..7716500534 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpainterpathstroker/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpainterpathstroker.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpainterpathstroker Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpainterpathstroker
SOURCES
tst_qpainterpathstroker.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
index de3f612b10..3a3f8ff89f 100644
--- a/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
+++ b/tests/auto/gui/painting/qpainterpathstroker/tst_qpainterpathstroker.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
index 191b1b8a93..3b2d123382 100644
--- a/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpathclipper/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpathclipper.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
if(NOT QT_FEATURE_private_tests)
return()
@@ -14,18 +15,15 @@ qt_internal_add_test(tst_qpathclipper
tst_qpathclipper.cpp
INCLUDE_DIRECTORIES
.
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
-#### Keys ignored in scope 1:.:.:qpathclipper.pro:<TRUE>:
-# _REQUIREMENTS = "qtConfig(private_tests)"
-
## Scopes:
#####################################################################
qt_internal_extend_target(tst_qpathclipper CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qpathclipper/pathcompare.h b/tests/auto/gui/painting/qpathclipper/pathcompare.h
index 4f855194a4..d1207cfdc0 100644
--- a/tests/auto/gui/painting/qpathclipper/pathcompare.h
+++ b/tests/auto/gui/painting/qpathclipper/pathcompare.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#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 a814958394..e6be402df7 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.cpp
+++ b/tests/auto/gui/painting/qpathclipper/paths.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 "paths.h"
QPainterPath Paths::rect()
diff --git a/tests/auto/gui/painting/qpathclipper/paths.h b/tests/auto/gui/painting/qpathclipper/paths.h
index 61daa0c3a4..8c421dec2e 100644
--- a/tests/auto/gui/painting/qpathclipper/paths.h
+++ b/tests/auto/gui/painting/qpathclipper/paths.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#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 83a8d6bd47..4ecfa24105 100644
--- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
+++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 "private/qpathclipper_p.h"
#include "paths.h"
#include "pathcompare.h"
@@ -495,15 +470,19 @@ void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::O
break;
}
- if (expected != inResult) {
- char str[256];
- const char *opStr =
- op == QPathClipper::BoolAnd ? "and" :
- op == QPathClipper::BoolOr ? "or" : "sub";
- sprintf(str, "Expected: %d, actual: %d, subject: %d, clip: %d, op: %s\n",
- int(expected), int(inResult), subjectIndex, clipIndex, opStr);
- QFAIL(str);
- }
+ auto failLogger = qScopeGuard([&]{
+ qCritical().noquote().nospace()
+ << "\n\tExpected: " << expected
+ << "\n\tActual: " << inResult
+ << "\n\tSubject: " << subjectIndex
+ << "\n\tClip: " << clipIndex
+ << "\n\tOp: " << (op == QPathClipper::BoolAnd
+ ? "and"
+ : op == QPathClipper::BoolOr
+ ? "or" : "sub");
+ });
+ QCOMPARE(inResult, expected);
+ failLogger.dismiss();
}
}
diff --git a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
index c6eb5b1034..059c0f4fc0 100644
--- a/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpdfwriter/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpdfwriter.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpdfwriter Test:
@@ -9,7 +10,7 @@ qt_internal_add_test(tst_qpdfwriter
tst_qpdfwriter.cpp
DEFINES
QT_USE_USING_NAMESPACE
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
index c74baf0ba4..aaa0877625 100644
--- a/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
+++ b/tests/auto/gui/painting/qpdfwriter/tst_qpdfwriter.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGlobal>
diff --git a/tests/auto/gui/painting/qpen/CMakeLists.txt b/tests/auto/gui/painting/qpen/CMakeLists.txt
index 321c40fa8f..97aa8c3f80 100644
--- a/tests/auto/gui/painting/qpen/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpen/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpen.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpen Test:
@@ -7,6 +8,6 @@
qt_internal_add_test(tst_qpen
SOURCES
tst_qpen.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp
index 64c01a81b5..e13a8e3270 100644
--- a/tests/auto/gui/painting/qpen/tst_qpen.cpp
+++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/painting/qpolygon/CMakeLists.txt b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
index a61529d397..cae26e0153 100644
--- a/tests/auto/gui/painting/qpolygon/CMakeLists.txt
+++ b/tests/auto/gui/painting/qpolygon/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qpolygon.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qpolygon Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qpolygon
SOURCES
tst_qpolygon.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
@@ -15,6 +16,6 @@ qt_internal_add_test(tst_qpolygon
#####################################################################
qt_internal_extend_target(tst_qpolygon CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
index 4cde0aa549..512381ab95 100644
--- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
@@ -41,6 +16,7 @@ class tst_QPolygon : public QObject
private slots:
void constructors();
+ void toPolygonF();
void boundingRect_data();
void boundingRect();
void boundingRectF_data();
@@ -80,6 +56,17 @@ void tst_QPolygon::constructors()
constructors_helperF(QRectF(1, 2, 3, 4));
}
+void tst_QPolygon::toPolygonF()
+{
+ const QPolygon p = {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}};
+ auto pf = p.toPolygonF();
+ static_assert(std::is_same_v<decltype(pf), QPolygonF>);
+ QCOMPARE(pf.size(), p.size());
+ auto p2 = pf.toPolygon();
+ static_assert(std::is_same_v<decltype(p2), QPolygon>);
+ QCOMPARE(p, p2);
+}
+
void tst_QPolygon::boundingRect_data()
{
QTest::addColumn<QPolygon>("poly");
@@ -181,8 +168,8 @@ void tst_QPolygon::swap()
QPolygon p2(QList<QPoint>() << QPoint(0, 0) << QPoint(0, 10) << QPoint(10, 10)
<< QPoint(10, 0));
p1.swap(p2);
- QCOMPARE(p1.count(),4);
- QCOMPARE(p2.count(),3);
+ QCOMPARE(p1.size(),4);
+ QCOMPARE(p2.size(),3);
}
void tst_QPolygon::intersections_data()
diff --git a/tests/auto/gui/painting/qregion/CMakeLists.txt b/tests/auto/gui/painting/qregion/CMakeLists.txt
index 9564e0719e..39fe5d5c9f 100644
--- a/tests/auto/gui/painting/qregion/CMakeLists.txt
+++ b/tests/auto/gui/painting/qregion/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qregion.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qregion Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qregion
SOURCES
tst_qregion.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
)
diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp
index 29179c44a0..14e210a056 100644
--- a/tests/auto/gui/painting/qregion/tst_qregion.cpp
+++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/painting/qtransform/CMakeLists.txt b/tests/auto/gui/painting/qtransform/CMakeLists.txt
index 4d50e2cf33..c4549e9807 100644
--- a/tests/auto/gui/painting/qtransform/CMakeLists.txt
+++ b/tests/auto/gui/painting/qtransform/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qtransform.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qtransform Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qtransform
SOURCES
tst_qtransform.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
)
@@ -15,6 +16,6 @@ qt_internal_add_test(tst_qtransform
#####################################################################
qt_internal_extend_target(tst_qtransform CONDITION UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY
- PUBLIC_LIBRARIES
+ LIBRARIES
m
)
diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
index 1bab7200f0..ecc8f7e4cc 100644
--- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
+++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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>
diff --git a/tests/auto/gui/platform/CMakeLists.txt b/tests/auto/gui/platform/CMakeLists.txt
index fc2d330fd7..4b2cee205d 100644
--- a/tests/auto/gui/platform/CMakeLists.txt
+++ b/tests/auto/gui/platform/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
if(QT_FEATURE_xcb)
add_subdirectory(qx11info)
endif()
diff --git a/tests/auto/gui/platform/qx11info/CMakeLists.txt b/tests/auto/gui/platform/qx11info/CMakeLists.txt
index c4ce1f91c8..c14630825c 100644
--- a/tests/auto/gui/platform/qx11info/CMakeLists.txt
+++ b/tests/auto/gui/platform/qx11info/CMakeLists.txt
@@ -1,7 +1,10 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_test(tst_qx11info
SOURCES
tst_qx11info.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::GuiPrivate
XCB::XCB
)
diff --git a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
index 0cd11c87ac..315dc55069 100644
--- a/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
+++ b/tests/auto/gui/platform/qx11info/tst_qx11info.cpp
@@ -1,31 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 David Faure <david.faure@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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
#include <QtGui>
#include <QtTest/QtTest>
@@ -112,6 +87,8 @@ void tst_QX11Info::startupId()
{
int argc = 0;
QGuiApplication app(argc, 0);
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test is only for X11, not Wayland.");
// This relies on the fact that no widget was shown yet,
// so please make sure this method is always the first test.
@@ -133,6 +110,8 @@ void tst_QX11Info::isPlatformX11()
{
int argc = 0;
QGuiApplication app(argc, 0);
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test is only for X11, not Wayland.");
QVERIFY(QX11Info::isPlatformX11());
}
@@ -141,6 +120,8 @@ void tst_QX11Info::appTime()
{
int argc = 0;
QGuiApplication app(argc, 0);
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test is only for X11, not Wayland.");
// No X11 event received yet
QCOMPARE(QX11Info::appTime(), 0ul);
@@ -367,6 +348,8 @@ void tst_QX11Info::peeker()
{
int argc = 0;
QGuiApplication app(argc, 0);
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test is only for X11, not Wayland.");
PeekerTest test;
test.show();
@@ -378,6 +361,8 @@ void tst_QX11Info::isCompositingManagerRunning()
{
int argc = 0;
QGuiApplication app(argc, 0);
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("This test is only for X11, not Wayland.");
const bool b = QX11Info::isCompositingManagerRunning();
Q_UNUSED(b);
const bool b2 = QX11Info::isCompositingManagerRunning(0);
diff --git a/tests/auto/gui/qopengl/CMakeLists.txt b/tests/auto/gui/qopengl/CMakeLists.txt
index 3be29695a5..e9c39fa38d 100644
--- a/tests/auto/gui/qopengl/CMakeLists.txt
+++ b/tests/auto/gui/qopengl/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qopengl.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qopengl Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qopengl
SOURCES
tst_qopengl.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index e2e7f153a0..09554a542f 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtOpenGL/QOpenGLFramebufferObject>
#include <QtOpenGL/QOpenGLPaintDevice>
@@ -32,7 +7,9 @@
#include <QtOpenGL/qopengltextureblitter.h>
#include <QtOpenGL/QOpenGLVertexArrayObject>
#include <QtOpenGL/QOpenGLBuffer>
-#include <QtOpenGL/QOpenGLFunctions_4_2_Core>
+#if !QT_CONFIG(opengles2)
+# include <QtOpenGL/QOpenGLFunctions_4_2_Core>
+#endif
#include <QtOpenGL/QOpenGLVersionFunctionsFactory>
#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QOpenGLFunctions>
@@ -643,6 +620,10 @@ static bool supportsInternalFboFormat(QOpenGLContext *ctx, int glFormat)
void tst_QOpenGL::fboRenderingRGB30()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105738)");
+#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
QSKIP("QTBUG-22617");
#endif
@@ -1182,6 +1163,7 @@ void tst_QOpenGL::sizeLessWindow()
// child window
{
QWindow parent;
+ parent.setSurfaceType(QWindow::OpenGLSurface);
QWindow window(&parent);
window.setSurfaceType(QWindow::OpenGLSurface);
@@ -1610,6 +1592,13 @@ void tst_QOpenGL::bufferCreate()
buf.allocate(128);
QCOMPARE(buf.size(), 128);
+ {
+ QOpenGLBuffer moved = std::move(buf);
+ QCOMPARE_EQ(moved.isCreated(), true);
+ QCOMPARE_EQ(moved.size(), 128);
+ buf = std::move(moved);
+ }
+
buf.release();
buf.destroy();
@@ -1695,10 +1684,11 @@ void tst_QOpenGL::nullTextureInitializtion()
/*
Verify that the clipping works correctly.
- The red outline should be covered by the blue rect on top and left,
- while it should be clipped on the right and bottom and thus the red outline be visible
+ Just like fillRect, cliprect should snap rightwards and downwards in case of .5 coordinates.
+ The red outline should be covered by the blue rect on top,
+ while it should be clipped on the other edges and thus the red outline be visible
- See: QTBUG-83229
+ See: QTBUG-83229, modified by QTBUG-100329
*/
void tst_QOpenGL::clipRect()
{
@@ -1754,7 +1744,7 @@ void tst_QOpenGL::clipRect()
QCOMPARE(fb.size(), size);
QCOMPARE(fb.pixelColor(clipRect.left() + 1, clipRect.top()), QColor(Qt::blue));
- QCOMPARE(fb.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::blue));
+ QCOMPARE(fb.pixelColor(clipRect.left(), clipRect.top() + 1), QColor(Qt::red));
QCOMPARE(fb.pixelColor(clipRect.left() + 1, clipRect.bottom()), QColor(Qt::red));
// Enable this once QTBUG-85286 is fixed
diff --git a/tests/auto/gui/qopenglconfig/CMakeLists.txt b/tests/auto/gui/qopenglconfig/CMakeLists.txt
index d193e15c2e..9d3f6423b6 100644
--- a/tests/auto/gui/qopenglconfig/CMakeLists.txt
+++ b/tests/auto/gui/qopenglconfig/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qopenglconfig.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qopenglconfig Test:
@@ -10,7 +11,7 @@ list(APPEND test_data "buglist.json")
qt_internal_add_test(tst_qopenglconfig
SOURCES
tst_qopenglconfig.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
index d65293f8b8..2572c47096 100644
--- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
+++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// 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 <QtGui/QOpenGLFunctions>
#include <QtGui/QScreen>
diff --git a/tests/auto/gui/qvulkan/CMakeLists.txt b/tests/auto/gui/qvulkan/CMakeLists.txt
index 7cca165ed2..bce98888bd 100644
--- a/tests/auto/gui/qvulkan/CMakeLists.txt
+++ b/tests/auto/gui/qvulkan/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from qvulkan.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qvulkan Test:
@@ -7,7 +8,7 @@
qt_internal_add_test(tst_qvulkan
SOURCES
tst_qvulkan.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
diff --git a/tests/auto/gui/qvulkan/tst_qvulkan.cpp b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
index b1cc2dd052..0afebfba28 100644
--- a/tests/auto/gui/qvulkan/tst_qvulkan.cpp
+++ b/tests/auto/gui/qvulkan/tst_qvulkan.cpp
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtGui/QVulkanInstance>
#include <QtGui/QVulkanFunctions>
#include <QtGui/QVulkanWindow>
+#include <QtCore/qvarlengtharray.h>
#include <QTest>
@@ -51,6 +27,10 @@ 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");
@@ -87,6 +67,10 @@ 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;
@@ -112,6 +96,10 @@ void tst_QVulkan::vulkanCheckSupported()
void tst_QVulkan::vulkan11()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105739)");
+#endif
#if VK_VERSION_1_1
QVulkanInstance inst;
if (inst.supportedApiVersion() < QVersionNumber(1, 1))
@@ -161,15 +149,17 @@ void tst_QVulkan::vulkan11()
QByteArray deviceUuid = QByteArray::fromRawData((const char *) deviceIdProps.deviceUUID, VK_UUID_SIZE).toHex();
QByteArray driverUuid = QByteArray::fromRawData((const char *) deviceIdProps.driverUUID, VK_UUID_SIZE).toHex();
qDebug() << "deviceUUID" << deviceUuid << "driverUUID" << driverUuid;
+ const bool deviceUuidZero = std::find_if(deviceUuid.cbegin(), deviceUuid.cend(), [](char c) -> bool { return c; }) == deviceUuid.cend();
+ const bool driverUuidZero = std::find_if(driverUuid.cbegin(), driverUuid.cend(), [](char c) -> bool { return c; }) == driverUuid.cend();
// deviceUUID cannot be all zero as per spec
- bool seenNonZero = false;
- for (int i = 0; i < VK_UUID_SIZE; ++i) {
- if (deviceIdProps.deviceUUID[i]) {
- seenNonZero = true;
- break;
- }
+ if (!driverUuidZero) {
+ // ...but then there are implementations such as some
+ // versions of Mesa lavapipe, that returns all zeroes
+ // for both uuids. skip the check if the driver uuid
+ // was zero too.
+ // https://gitlab.freedesktop.org/mesa/mesa/-/issues/5875
+ QVERIFY(!deviceUuidZero);
}
- QVERIFY(seenNonZero);
} else {
qDebug("Physical device is not Vulkan 1.1 capable");
}
@@ -184,6 +174,10 @@ void tst_QVulkan::vulkan11()
void tst_QVulkan::vulkanPlainWindow()
{
+#ifdef Q_OS_ANDROID
+ QSKIP("Fails on Android 7 emulator (QTBUG-108328)");
+#endif
+
QVulkanInstance inst;
if (!inst.create())
QSKIP("Vulkan init failed; skip");
@@ -220,6 +214,10 @@ 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");
@@ -266,6 +264,10 @@ 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");
@@ -471,6 +473,10 @@ void tst_QVulkan::vulkanWindowRenderer()
void tst_QVulkan::vulkanWindowGrab()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() >= 31)
+ QSKIP("Fails on Android 12 (QTBUG-105739)");
+#endif
QVulkanInstance inst;
inst.setLayers(QByteArrayList() << "VK_LAYER_KHRONOS_validation");
if (!inst.create())
diff --git a/tests/auto/gui/rhi/CMakeLists.txt b/tests/auto/gui/rhi/CMakeLists.txt
index 786e121f00..898a67d2dc 100644
--- a/tests/auto/gui/rhi/CMakeLists.txt
+++ b/tests/auto/gui/rhi/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from rhi.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
add_subdirectory(qshader)
add_subdirectory(qrhi)
diff --git a/tests/auto/gui/rhi/qrhi/BLACKLIST b/tests/auto/gui/rhi/qrhi/BLACKLIST
index 68621ac66b..b3284f8979 100644
--- a/tests/auto/gui/rhi/qrhi/BLACKLIST
+++ b/tests/auto/gui/rhi/qrhi/BLACKLIST
@@ -7,3 +7,15 @@ android
# Skip 3D textures with Android emulator, the sw-based GL there is no good
[threeDimTexture]
android
+# Same here, GLES 3.0 features seem hopeless
+[renderToTextureTextureArray]
+android
+# Ditto
+[renderToTextureSampleWithSeparateTextureAndSampler]
+android
+[renderToFloatTexture]
+android
+[renderToRgb10Texture]
+android
+[tessellation vulkan]
+android
diff --git a/tests/auto/gui/rhi/qrhi/CMakeLists.txt b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
index 65d072c6b9..3f5e5ab7c5 100644
--- a/tests/auto/gui/rhi/qrhi/CMakeLists.txt
+++ b/tests/auto/gui/rhi/qrhi/CMakeLists.txt
@@ -1,26 +1,22 @@
-# Generated from qrhi.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qrhi Test:
#####################################################################
+# Resources:
+file(GLOB_RECURSE qrhi_resource_files
+ RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
+ data/*
+)
+
qt_internal_add_test(tst_qrhi
SOURCES
tst_qrhi.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Gui
Qt::GuiPrivate
+ TESTDATA ${qrhi_resource_files}
+ BUILTIN_TESTDATA
)
-
-# Resources:
-set(qrhi_resource_files
- "data"
-)
-
-qt_internal_add_resource(tst_qrhi "qrhi"
- PREFIX
- "/"
- FILES
- ${qrhi_resource_files}
-)
-
diff --git a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
index 0102457b8a..5b07c7bf2b 100644
--- a/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
+++ b/tests/auto/gui/rhi/qrhi/data/buildshaders.bat
@@ -1,48 +1,28 @@
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-::
:: Copyright (C) 2019 The Qt Company Ltd.
-:: Contact: https://www.qt.io/licensing/
-::
-:: This file is part of the QtQuick module of the Qt Toolkit.
-::
-:: $QT_BEGIN_LICENSE:LGPL$
-:: Commercial License Usage
-:: Licensees holding valid commercial Qt licenses may use this file in
-:: accordance with the commercial license agreement provided with the
-:: Software or, alternatively, in accordance with the terms contained in
-:: a written agreement between you and The Qt Company. For licensing terms
-:: and conditions see https://www.qt.io/terms-conditions. For further
-:: information use the contact form at https://www.qt.io/contact-us.
-::
-:: GNU Lesser General Public License Usage
-:: Alternatively, this file may be used under the terms of the GNU Lesser
-:: General Public License version 3 as published by the Free Software
-:: Foundation and appearing in the file LICENSE.LGPL3 included in the
-:: packaging of this file. Please review the following information to
-:: ensure the GNU Lesser General Public License version 3 requirements
-:: will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-::
-:: GNU General Public License Usage
-:: Alternatively, this file may be used under the terms of the GNU
-:: General Public License version 2.0 or (at your option) the GNU General
-:: Public license version 3 or any later version approved by the KDE Free
-:: Qt Foundation. The licenses are as published by the Free Software
-:: Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-:: included in the packaging of this file. Please review the following
-:: information to ensure the GNU General Public License requirements will
-:: be met: https://www.gnu.org/licenses/gpl-2.0.html and
-:: https://www.gnu.org/licenses/gpl-3.0.html.
-::
-:: $QT_END_LICENSE$
-::
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+:: SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
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
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simpletextured.vert.qsb simpletextured.vert
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simpletextured.frag.qsb simpletextured.frag
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 20 -o simpletextured_array.frag.qsb simpletextured_array.frag
+qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o simpletextured_separate.frag.qsb simpletextured_separate.frag
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured.vert.qsb textured.vert
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured.frag.qsb textured.frag
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured_multiubuf.vert.qsb textured_multiubuf.vert
qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o textured_multiubuf.frag.qsb textured_multiubuf.frag
+qsb --glsl 320es,410 --msl 12 --msltess simpletess.vert -o simpletess.vert.qsb
+qsb --glsl 320es,410 --msl 12 --tess-mode triangles simpletess.tesc -o simpletess.tesc.qsb
+qsb --glsl 320es,410 --msl 12 --tess-vertex-count 3 simpletess.tese -o simpletess.tese.qsb
+qsb --glsl 320es,410 --msl 12 simpletess.frag -o simpletess.frag.qsb
+qsb --glsl 310es,430 --msl 12 --hlsl 50 storagebuffer.comp -o storagebuffer.comp.qsb
+qsb --glsl 320es,430 --msl 12 --msltess storagebuffer_runtime.vert -o storagebuffer_runtime.vert.qsb
+qsb --glsl 320es,430 --msl 12 --tess-mode triangles storagebuffer_runtime.tesc -o storagebuffer_runtime.tesc.qsb
+qsb --glsl 320es,430 --msl 12 --tess-vertex-count 3 storagebuffer_runtime.tese -o storagebuffer_runtime.tese.qsb
+qsb --glsl 320es,430 --msl 12 storagebuffer_runtime.frag -o storagebuffer_runtime.frag.qsb
+qsb --glsl 320es,430 --hlsl 50 -c --msl 12 storagebuffer_runtime.comp -o storagebuffer_runtime.comp.qsb
+qsb --glsl "150,120,100 es" --hlsl 50 -c --msl 12 -o half.vert.qsb half.vert
+qsb --glsl 320es,430 --msl 21 --msltess tessinterfaceblocks.vert -o tessinterfaceblocks.vert.qsb
+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
diff --git a/tests/auto/gui/rhi/qrhi/data/half.vert b/tests/auto/gui/rhi/qrhi/data/half.vert
new file mode 100644
index 0000000000..b503201351
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/half.vert
@@ -0,0 +1,10 @@
+#version 440
+
+layout(location = 0) in vec3 position;
+
+out gl_PerVertex { vec4 gl_Position; };
+
+void main()
+{
+ gl_Position = vec4(position, 1.0);
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/half.vert.qsb b/tests/auto/gui/rhi/qrhi/data/half.vert.qsb
new file mode 100644
index 0000000000..fb8680024a
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/half.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.frag b/tests/auto/gui/rhi/qrhi/data/simpletess.frag
new file mode 100644
index 0000000000..375587662f
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.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/simpletess.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simpletess.frag.qsb
new file mode 100644
index 0000000000..0f42103ac5
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.tesc b/tests/auto/gui/rhi/qrhi/data/simpletess.tesc
new file mode 100644
index 0000000000..e192fc77c7
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.tesc
@@ -0,0 +1,22 @@
+#version 440
+
+layout(vertices = 3) out;
+
+layout(location = 0) in vec3 inColor[];
+layout(location = 0) out vec3 outColor[];
+layout(location = 1) patch out float a_per_patch_output_variable;
+
+void main()
+{
+ if (gl_InvocationID == 0) {
+ gl_TessLevelOuter[0] = 4.0;
+ gl_TessLevelOuter[1] = 4.0;
+ gl_TessLevelOuter[2] = 4.0;
+
+ gl_TessLevelInner[0] = 4.0;
+ }
+
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+ outColor[gl_InvocationID] = inColor[gl_InvocationID];
+ a_per_patch_output_variable = 1.0;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.tesc.qsb b/tests/auto/gui/rhi/qrhi/data/simpletess.tesc.qsb
new file mode 100644
index 0000000000..8c98d92c46
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.tesc.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.tese b/tests/auto/gui/rhi/qrhi/data/simpletess.tese
new file mode 100644
index 0000000000..17b348635a
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.tese
@@ -0,0 +1,17 @@
+#version 440
+
+layout(triangles, fractional_odd_spacing, ccw) in;
+
+layout(location = 0) in vec3 inColor[];
+layout(location = 0) out vec3 outColor;
+layout(location = 1) patch in float a_per_patch_output_variable;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+};
+
+void main()
+{
+ gl_Position = mvp * ((gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position));
+ outColor = gl_TessCoord.x * inColor[0] + gl_TessCoord.y * inColor[1] + gl_TessCoord.z * inColor[2] * a_per_patch_output_variable;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.tese.qsb b/tests/auto/gui/rhi/qrhi/data/simpletess.tese.qsb
new file mode 100644
index 0000000000..8aa7632717
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.tese.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.vert b/tests/auto/gui/rhi/qrhi/data/simpletess.vert
new file mode 100644
index 0000000000..3838d2f3bb
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.vert
@@ -0,0 +1,12 @@
+#version 440
+
+layout(location = 0) in vec3 position;
+layout(location = 1) in vec3 color;
+
+layout(location = 0) out vec3 v_color;
+
+void main()
+{
+ gl_Position = vec4(position, 1.0);
+ v_color = color;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletess.vert.qsb b/tests/auto/gui/rhi/qrhi/data/simpletess.vert.qsb
new file mode 100644
index 0000000000..ee90983e0b
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletess.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag b/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag
new file mode 100644
index 0000000000..41b0e4f1c2
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag
@@ -0,0 +1,14 @@
+#version 440
+
+layout(location = 0) in vec2 uv;
+layout(location = 0) out vec4 fragColor;
+
+layout(binding = 3) uniform texture2D tex;
+layout(binding = 5) uniform sampler samp;
+
+void main()
+{
+ vec4 c = texture(sampler2D(tex, samp), uv);
+ c.rgb *= c.a;
+ fragColor = c;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag.qsb b/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag.qsb
new file mode 100644
index 0000000000..c5afe1a8eb
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/simpletextured_separate.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp
new file mode 100644
index 0000000000..fd6cabebc5
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp
@@ -0,0 +1,28 @@
+#version 430
+layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+
+
+layout (binding = 0, std430) buffer toGpu
+{
+ float _float;
+ vec2 _vec2;
+ vec3 _vec3;
+ vec4 _vec4;
+};
+
+layout (binding = 1, std140) buffer fromGpu
+{
+ int _int;
+ ivec2 _ivec2;
+ ivec3 _ivec3;
+ ivec4 _ivec4;
+};
+
+void main()
+{
+ _int = int(_float);
+ _ivec2 = ivec2(_vec2);
+ _ivec3 = ivec3(_vec3);
+ _ivec4 = ivec4(_vec4);
+}
+
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb
new file mode 100644
index 0000000000..77887ed941
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer.comp.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp
new file mode 100644
index 0000000000..d36f5426bc
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp
@@ -0,0 +1,25 @@
+#version 430
+
+layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+
+layout (binding = 0, std430) buffer toGpu
+{
+ float _float[];
+};
+
+
+layout (binding = 1, std140) buffer fromGpu
+{
+ int _int[];
+};
+
+void main()
+{
+ int length = min(_float.length(), _int.length());
+
+ for (int i = 0; i < length; ++i)
+ _int[i] = int(_float[i]);
+
+}
+
+
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp.qsb
new file mode 100644
index 0000000000..b4c43ecc9b
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.comp.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag
new file mode 100644
index 0000000000..2e45a5f62a
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag
@@ -0,0 +1,33 @@
+#version 450
+
+layout (location = 0) out vec4 fragColor;
+
+layout (std430, binding = 1) readonly buffer ssboG
+{
+ float g[];
+};
+
+layout (std430, binding = 2) readonly buffer ssboB
+{
+ float b[];
+};
+
+layout (std430, binding = 6) readonly buffer ssboR
+{
+ float r[];
+};
+
+layout (std430, binding = 3) readonly buffer ssbo3
+{
+ vec4 _vec4;
+};
+
+void main()
+{
+
+ // some OpenGL implementations will optimize out the buffer variables if we don't use them
+ // resulting in a .length() of 0.
+ float a = (r[0]+g[0]+b[0])>0?1:1;
+
+ fragColor = a * vec4(r.length(), g.length(), b.length(), 255)/vec4(255);
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag.qsb
new file mode 100644
index 0000000000..53fc9a1906
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc
new file mode 100644
index 0000000000..56060285d2
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc
@@ -0,0 +1,42 @@
+#version 450
+
+layout(vertices = 3) out;
+
+
+layout (std430, binding = 7) readonly buffer ssbo7
+{
+ float float7[];
+};
+
+layout (std430, binding = 8) readonly buffer ssbo8
+{
+ float float8[];
+};
+
+layout (std430, binding = 9) readonly buffer ssbo9
+{
+ float float9[];
+};
+
+layout (std430, binding = 10) readonly buffer ssbo10
+{
+ float float10[];
+};
+
+void main()
+{
+
+ // some OpenGL implementations will optimize out the buffer variables if we don't use them
+ // resulting in a .length() of 0
+ float a = float7[0] == 0 && float8[0] == 0 && float9[0] == 0 && float10[0] == 0 ? 1 : 1;
+
+ if (gl_InvocationID == 0) {
+ gl_TessLevelOuter[0] = float7.length() * a;
+ gl_TessLevelOuter[1] = float8.length() * a;
+ gl_TessLevelOuter[2] = float9.length() * a;
+ gl_TessLevelInner[0] = float10.length() * a;
+ }
+
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc.qsb
new file mode 100644
index 0000000000..e48aa0269c
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tesc.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
new file mode 100644
index 0000000000..a8bec13561
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese
@@ -0,0 +1,39 @@
+#version 450
+
+layout(triangles, fractional_odd_spacing, ccw) in;
+
+layout (std140, binding = 6) uniform unused0
+{
+ int unused;
+}u0;
+
+layout (binding = 0) uniform u
+{
+ mat4 matrix;
+};
+
+layout (std430, binding = 5) readonly buffer ssbo5
+{
+ float _float[];
+};
+
+layout (std430, binding = 8) readonly buffer ssbo8
+{
+ float float8[];
+};
+
+layout (std430, binding = 1) readonly buffer unused1
+{
+ int unused[];
+}u1;
+
+
+void main()
+{
+ // some OpenGL implementations will optimize out the buffer variables if we don't use them
+ // resulting in a .length() of 0
+ float a = _float[0] == 0 && float8[0] == 1 ? 1 : 1;
+
+ if(_float.length() == 64)
+ gl_Position = a * matrix * ((gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position)) * (float8.length()==2?1:0);
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese.qsb
new file mode 100644
index 0000000000..23a433b5ae
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.tese.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert
new file mode 100644
index 0000000000..b3ac10efea
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert
@@ -0,0 +1,48 @@
+#version 450
+
+layout (location = 0) in vec3 position;
+
+layout (std140, binding = 6) uniform unused0
+{
+ int unused;
+}u0;
+
+layout (binding = 0) uniform u
+{
+ mat4 matrix;
+};
+
+layout (std430, binding = 5) readonly buffer ssbo5
+{
+ float _float[];
+};
+
+layout (std140, binding = 3) readonly buffer ssbo3
+{
+ vec4 _vec4;
+};
+
+layout (std430, binding = 4) readonly buffer ssbo1
+{
+ bool _bool[];
+};
+
+layout (std430, binding = 1) readonly buffer unused1
+{
+ int unused[];
+}u1;
+
+
+void main()
+{
+
+ // some OpenGL implementations will optimize out the buffer variables if we don't use them
+ // resulting in a .length() of 0
+ float a = _float[0] == 0 && _bool[0] ? 1 : 1;
+
+ gl_Position = vec4(0);
+
+ if(_bool.length() == 32)
+ gl_Position = a * matrix * vec4(position*_vec4.xyz, _float.length() == 64 ? 1.0 : 0.0);
+
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert.qsb b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert.qsb
new file mode 100644
index 0000000000..8b1cff52fd
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/storagebuffer_runtime.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.frag.qsb b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.frag.qsb
new file mode 100644
index 0000000000..7eda4bed2d
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.frag.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc
new file mode 100644
index 0000000000..92a2dc28fa
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc
@@ -0,0 +1,56 @@
+#version 440
+
+layout(vertices = 3) out;
+
+layout(location = 4) in VertOut
+{
+ vec3 v_color;
+ int a;
+ float b;
+}vOut[];
+
+layout(location = 5) out TescOutA {
+ vec3 color;
+ int id;
+}tcOutA[];
+
+layout(location = 10) out TescOutB {
+ vec2 some;
+ int other[3];
+ vec3 variables;
+}tcOutB[];
+
+layout(location = 2) patch out TescOutC {
+ vec3 stuff;
+ float more_stuff;
+}tcOutC;
+
+void main()
+{
+ // tesc builtin outputs
+ gl_TessLevelOuter[0] = 1.0;
+ gl_TessLevelOuter[1] = 2.0;
+ gl_TessLevelOuter[2] = 3.0;
+ gl_TessLevelOuter[3] = 4.0;
+ gl_TessLevelInner[0] = 5.0;
+ gl_TessLevelInner[1] = 6.0;
+
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+ gl_out[gl_InvocationID].gl_PointSize = 10 + gl_InvocationID;
+ gl_out[gl_InvocationID].gl_ClipDistance[0] = 20.0 + gl_InvocationID;
+ gl_out[gl_InvocationID].gl_ClipDistance[1] = 40.0 + gl_InvocationID;
+ gl_out[gl_InvocationID].gl_ClipDistance[2] = 60.0 + gl_InvocationID;
+ gl_out[gl_InvocationID].gl_ClipDistance[3] = 80.0 + gl_InvocationID;
+ gl_out[gl_InvocationID].gl_ClipDistance[4] = 100.0 + gl_InvocationID;
+
+ // outputs
+ tcOutA[gl_InvocationID].color = vOut[gl_InvocationID].v_color;
+ tcOutA[gl_InvocationID].id = gl_InvocationID + 91;
+ tcOutB[gl_InvocationID].some = vec2(gl_InvocationID, vOut[gl_InvocationID].a);
+ tcOutB[gl_InvocationID].other[0] = gl_PrimitiveID + 10;
+ tcOutB[gl_InvocationID].other[1] = gl_PrimitiveID + 20;
+ tcOutB[gl_InvocationID].other[2] = gl_PrimitiveID + 30;
+ tcOutB[gl_InvocationID].variables = vec3(3.0f, vOut[gl_InvocationID].b, 17.0f);
+ tcOutC.stuff = vec3(1.0, 2.0, 3.0);
+ tcOutC.more_stuff = 4.0;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc.qsb b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc.qsb
new file mode 100644
index 0000000000..b503d596c6
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tesc.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese
new file mode 100644
index 0000000000..05430a5f63
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese
@@ -0,0 +1,96 @@
+#version 440
+
+layout(triangles, fractional_odd_spacing, ccw) in;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 mvp;
+};
+
+layout(location = 5) in TescOutA {
+ vec3 color;
+ int id;
+}tcOutA[];
+
+layout(location = 10) in TescOutB {
+ vec2 some;
+ int other[3];
+ vec3 variables;
+}tcOutB[];
+
+layout(location = 2) patch in TescOutC {
+ vec3 stuff;
+ float more_stuff;
+}tcOutC;
+
+layout(location = 0) out vec3 outColor;
+
+struct A {
+ vec3 color;
+ int id;
+};
+
+struct B {
+ vec2 some;
+ int other[3];
+ vec3 variables;
+};
+
+struct C {
+ vec3 stuff;
+ float more_stuff;
+};
+
+struct Element {
+ A a[3];
+ B b[3];
+ C c;
+ vec4 tesslevelOuter;
+ vec2 tessLevelInner;
+ float pointSize[3];
+ float clipDistance[3][5];
+ vec3 tessCoord;
+ int patchVerticesIn;
+ int primitiveID;
+};
+
+layout(std430, binding = 1) buffer result {
+ int count;
+ Element elements[];
+};
+
+void main()
+{
+ gl_Position = mvp * ((gl_TessCoord.x * gl_in[0].gl_Position) + (gl_TessCoord.y * gl_in[1].gl_Position) + (gl_TessCoord.z * gl_in[2].gl_Position));
+ outColor = gl_TessCoord.x * tcOutA[0].color + gl_TessCoord.y * tcOutA[1].color + gl_TessCoord.z * tcOutA[2].color;
+
+ count = 1;
+
+ elements[gl_PrimitiveID].c.stuff = tcOutC.stuff;
+ elements[gl_PrimitiveID].c.more_stuff = tcOutC.more_stuff;
+ elements[gl_PrimitiveID].tesslevelOuter = vec4(gl_TessLevelOuter[0], gl_TessLevelOuter[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]);
+ elements[gl_PrimitiveID].tessLevelInner = vec2(gl_TessLevelInner[0], gl_TessLevelInner[1]);
+
+ for (int i = 0; i < 3; ++i) {
+
+ elements[gl_PrimitiveID].a[i].color = tcOutA[i].color;
+ elements[gl_PrimitiveID].a[i].id = tcOutA[i].id;
+
+ elements[gl_PrimitiveID].b[i].some = tcOutB[i].some;
+ elements[gl_PrimitiveID].b[i].other = tcOutB[i].other;
+ elements[gl_PrimitiveID].b[i].variables = tcOutB[i].variables;
+
+ elements[gl_PrimitiveID].pointSize[i] = gl_in[i].gl_PointSize;
+ elements[gl_PrimitiveID].clipDistance[i][0] = gl_in[i].gl_ClipDistance[0];
+ elements[gl_PrimitiveID].clipDistance[i][1] = gl_in[i].gl_ClipDistance[1];
+ elements[gl_PrimitiveID].clipDistance[i][2] = gl_in[i].gl_ClipDistance[2];
+ elements[gl_PrimitiveID].clipDistance[i][3] = gl_in[i].gl_ClipDistance[3];
+ elements[gl_PrimitiveID].clipDistance[i][4] = gl_in[i].gl_ClipDistance[4];
+
+ }
+
+ elements[gl_PrimitiveID].tessCoord = gl_TessCoord;
+ elements[gl_PrimitiveID].patchVerticesIn = 3;
+ elements[gl_PrimitiveID].primitiveID = gl_PrimitiveID;
+
+}
+
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese.qsb b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese.qsb
new file mode 100644
index 0000000000..898bda454a
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.tese.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert
new file mode 100644
index 0000000000..7c722bb374
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert
@@ -0,0 +1,20 @@
+#version 440
+
+layout(location = 0) in vec3 position;
+layout(location = 1) in vec3 color;
+
+
+layout(location = 4) out VertOut
+{
+ vec3 v_color;
+ int a;
+ float b;
+};
+
+void main()
+{
+ gl_Position = vec4(position, 1.0);
+ v_color = color;
+ a = gl_VertexIndex;
+ b = 13.0f + gl_VertexIndex;
+}
diff --git a/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert.qsb b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert.qsb
new file mode 100644
index 0000000000..07384d643c
--- /dev/null
+++ b/tests/auto/gui/rhi/qrhi/data/tessinterfaceblocks.vert.qsb
Binary files differ
diff --git a/tests/auto/gui/rhi/qrhi/qrhi.qrc b/tests/auto/gui/rhi/qrhi/qrhi.qrc
deleted file mode 100644
index f161d8aad6..0000000000
--- a/tests/auto/gui/rhi/qrhi/qrhi.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>data</file>
- </qresource>
-</RCC>
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index 24d6ad2d7c..844bd6a521 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -1,36 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QTest>
#include <QThread>
#include <QFile>
#include <QOffscreenSurface>
#include <QPainter>
+#include <qrgbafloat.h>
+#include <qrgba64.h>
#include <QtGui/private/qrhi_p.h>
#include <QtGui/private/qrhi_p_p.h>
@@ -40,6 +17,8 @@
# include <QOpenGLContext>
# include <QOpenGLFunctions>
# include <QtGui/private/qrhigles2_p.h>
+# include <QtGui/private/qguiapplication_p.h>
+# include <qpa/qplatformintegration.h>
# define TST_GL
#endif
@@ -52,7 +31,9 @@
#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)
@@ -72,9 +53,10 @@ private slots:
void cleanupTestCase();
void rhiTestData();
- void rhiTestDataOpenGL();
void create_data();
void create();
+ void stats_data();
+ void stats();
void nativeHandles_data();
void nativeHandles();
void nativeHandlesImportVulkan();
@@ -113,8 +95,12 @@ private slots:
void renderToTextureMip();
void renderToTextureCubemapFace_data();
void renderToTextureCubemapFace();
+ void renderToTextureTextureArray_data();
+ void renderToTextureTextureArray();
void renderToTextureTexturedQuad_data();
void renderToTextureTexturedQuad();
+ void renderToTextureSampleWithSeparateTextureAndSampler_data();
+ void renderToTextureSampleWithSeparateTextureAndSampler();
void renderToTextureArrayOfTexturedQuad_data();
void renderToTextureArrayOfTexturedQuad();
void renderToTextureTexturedQuadAndUniformBuffer_data();
@@ -123,6 +109,8 @@ private slots:
void renderToTextureTexturedQuadAllDynamicBuffers();
void renderToTextureDeferredSrb_data();
void renderToTextureDeferredSrb();
+ void renderToTextureDeferredUpdateSamplerInSrb_data();
+ void renderToTextureDeferredUpdateSamplerInSrb();
void renderToTextureMultipleUniformBuffersAndDynamicOffset_data();
void renderToTextureMultipleUniformBuffersAndDynamicOffset();
void renderToTextureSrbReuse_data();
@@ -133,18 +121,43 @@ private slots:
void renderToWindowSimple();
void finishWithinSwapchainFrame_data();
void finishWithinSwapchainFrame();
+ void resourceUpdateBatchBufferTextureWithSwapchainFrames_data();
+ void resourceUpdateBatchBufferTextureWithSwapchainFrames();
+ void textureRenderTargetAutoRebuild_data();
+ void textureRenderTargetAutoRebuild();
void pipelineCache_data();
void pipelineCache();
- void textureImportOpenGL_data();
void textureImportOpenGL();
- void renderbufferImportOpenGL_data();
void renderbufferImportOpenGL();
void threeDimTexture_data();
void threeDimTexture();
+ void oneDimTexture_data();
+ void oneDimTexture();
void leakedResourceDestroy_data();
void leakedResourceDestroy();
+ void renderToFloatTexture_data();
+ void renderToFloatTexture();
+ void renderToRgb10Texture_data();
+ void renderToRgb10Texture();
+
+ void tessellation_data();
+ void tessellation();
+
+ void tessellationInterfaceBlocks_data();
+ void tessellationInterfaceBlocks();
+
+ void storageBuffer_data();
+ void storageBuffer();
+ void storageBufferRuntimeSizeCompute_data();
+ void storageBufferRuntimeSizeCompute();
+ void storageBufferRuntimeSizeGraphics_data();
+ void storageBufferRuntimeSizeGraphics();
+
+ void halfPrecisionAttributes_data();
+ void halfPrecisionAttributes();
+
private:
void setWindowType(QWindow *window, QRhi::Implementation impl);
@@ -157,7 +170,10 @@ private:
QRhiVulkanInitParams vk;
#endif
#ifdef TST_D3D11
- QRhiD3D11InitParams d3d;
+ QRhiD3D11InitParams d3d11;
+#endif
+#ifdef TST_D3D12
+ QRhiD3D12InitParams d3d12;
#endif
#ifdef TST_MTL
QRhiMetalInitParams mtl;
@@ -173,6 +189,12 @@ private:
void tst_QRhi::initTestCase()
{
#ifdef TST_GL
+ QSurfaceFormat fmt;
+ fmt.setDepthBufferSize(24);
+ fmt.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(fmt);
+
+ initParams.gl.format = QSurfaceFormat::defaultFormat();
fallbackSurface = QRhiGles2InitParams::newFallbackSurface();
initParams.gl.fallbackSurface = fallbackSurface;
#endif
@@ -182,7 +204,7 @@ void tst_QRhi::initTestCase()
if (supportedVersion >= QVersionNumber(1, 2))
vulkanInstance.setApiVersion(QVersionNumber(1, 2));
else if (supportedVersion >= QVersionNumber(1, 1))
- vulkanInstance.setApiVersion(QVersionNumber(1, 2));
+ vulkanInstance.setApiVersion(QVersionNumber(1, 1));
vulkanInstance.setLayers({ "VK_LAYER_KHRONOS_validation" });
vulkanInstance.setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
vulkanInstance.create();
@@ -190,7 +212,10 @@ void tst_QRhi::initTestCase()
#endif
#ifdef TST_D3D11
- initParams.d3d.enableDebugLayer = true;
+ initParams.d3d11.enableDebugLayer = true;
+#endif
+#ifdef TST_D3D12
+ initParams.d3d12.enableDebugLayer = true;
#endif
}
@@ -208,32 +233,29 @@ void tst_QRhi::rhiTestData()
QTest::addColumn<QRhi::Implementation>("impl");
QTest::addColumn<QRhiInitParams *>("initParams");
+// webOS does not support raster (software) pipeline
+#ifndef Q_OS_WEBOS
QTest::newRow("Null") << QRhi::Null << static_cast<QRhiInitParams *>(&initParams.null);
+#endif
#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
+ if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
#endif
#ifdef TST_VK
if (vulkanInstance.isValid())
QTest::newRow("Vulkan") << QRhi::Vulkan << static_cast<QRhiInitParams *>(&initParams.vk);
#endif
#ifdef TST_D3D11
- QTest::newRow("Direct3D 11") << QRhi::D3D11 << static_cast<QRhiInitParams *>(&initParams.d3d);
+ QTest::newRow("Direct3D 11") << QRhi::D3D11 << static_cast<QRhiInitParams *>(&initParams.d3d11);
+#endif
+#ifdef TST_D3D12
+ QTest::newRow("Direct3D 12") << QRhi::D3D12 << static_cast<QRhiInitParams *>(&initParams.d3d12);
#endif
#ifdef TST_MTL
QTest::newRow("Metal") << QRhi::Metal << static_cast<QRhiInitParams *>(&initParams.mtl);
#endif
}
-void tst_QRhi::rhiTestDataOpenGL()
-{
- QTest::addColumn<QRhi::Implementation>("impl");
- QTest::addColumn<QRhiInitParams *>("initParams");
-
-#ifdef TST_GL
- QTest::newRow("OpenGL") << QRhi::OpenGLES2 << static_cast<QRhiInitParams *>(&initParams.gl);
-#endif
-}
-
void tst_QRhi::create_data()
{
rhiTestData();
@@ -256,10 +278,13 @@ void tst_QRhi::create()
QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
if (rhi) {
+ QVERIFY(QRhi::probe(impl, initParams));
+
qDebug() << rhi->driverInfo();
QCOMPARE(rhi->backend(), impl);
QVERIFY(strcmp(rhi->backendName(), ""));
+ QVERIFY(!strcmp(rhi->backendName(), QRhi::backendName(rhi->backend())));
QVERIFY(!rhi->driverInfo().deviceName.isEmpty());
QCOMPARE(rhi->thread(), QThread::currentThread());
@@ -336,13 +361,22 @@ void tst_QRhi::create()
const int texMax = rhi->resourceLimit(QRhi::TextureSizeMax);
const int maxAtt = rhi->resourceLimit(QRhi::MaxColorAttachments);
const int framesInFlight = rhi->resourceLimit(QRhi::FramesInFlight);
+ const int texArrayMax = rhi->resourceLimit(QRhi::TextureArraySizeMax);
+ const int uniBufRangeMax = rhi->resourceLimit(QRhi::MaxUniformBufferRange);
+ const int maxVertexInputs = rhi->resourceLimit(QRhi::MaxVertexInputs);
+ const int maxVertexOutputs = rhi->resourceLimit(QRhi::MaxVertexOutputs);
+
QVERIFY(texMin >= 1);
QVERIFY(texMax >= texMin);
QVERIFY(maxAtt >= 1);
QVERIFY(framesInFlight >= 1);
+ if (rhi->isFeatureSupported(QRhi::TextureArrays))
+ QVERIFY(texArrayMax > 1);
+ QVERIFY(uniBufRangeMax >= 224 * 4 * 4);
+ QVERIFY(maxVertexInputs >= 8);
+ QVERIFY(maxVertexOutputs >= 8);
QVERIFY(rhi->nativeHandles());
- QVERIFY(rhi->profiler());
const QRhi::Feature features[] = {
QRhi::MultisampleTexture,
@@ -373,7 +407,18 @@ void tst_QRhi::create()
QRhi::PipelineCacheDataLoadSave,
QRhi::ImageDataStride,
QRhi::RenderBufferImport,
- QRhi::ThreeDimensionalTextures
+ QRhi::ThreeDimensionalTextures,
+ QRhi::RenderTo3DTextureSlice,
+ QRhi::TextureArrays,
+ QRhi::Tessellation,
+ QRhi::GeometryShader,
+ QRhi::TextureArrayRange,
+ QRhi::NonFillPolygonMode,
+ QRhi::OneDimensionalTextures,
+ QRhi::OneDimensionalTextureMipmaps,
+ QRhi::HalfAttributes,
+ QRhi::RenderToOneDimensionalTexture,
+ QRhi::ThreeDimensionalTextureMipmaps
};
for (size_t i = 0; i <sizeof(features) / sizeof(QRhi::Feature); ++i)
rhi->isFeatureSupported(features[i]);
@@ -389,6 +434,38 @@ void tst_QRhi::create()
}
}
+void tst_QRhi::stats_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::stats()
+{
+ 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 statistics getter");
+
+ QRhiStats stats = rhi->statistics();
+ qDebug() << stats;
+ QCOMPARE(stats.totalPipelineCreationTime, 0);
+
+ if (impl == QRhi::Vulkan) {
+ QScopedPointer<QRhiBuffer> buf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 32768));
+ QVERIFY(buf->create());
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(1024, 1024)));
+ QVERIFY(tex->create());
+
+ stats = rhi->statistics();
+ qDebug() << stats;
+ QVERIFY(stats.allocCount > 0);
+ QVERIFY(stats.blockCount > 0);
+ QVERIFY(stats.usedBytes > 0);
+ }
+}
+
void tst_QRhi::nativeHandles_data()
{
rhiTestData();
@@ -417,8 +494,6 @@ void tst_QRhi::nativeHandles()
const QRhiVulkanNativeHandles *vkHandles = static_cast<const QRhiVulkanNativeHandles *>(rhiHandles);
QVERIFY(vkHandles->physDev);
QVERIFY(vkHandles->dev);
- QVERIFY(vkHandles->gfxQueueFamilyIdx >= 0);
- QVERIFY(vkHandles->gfxQueueIdx >= 0);
QVERIFY(vkHandles->gfxQueue);
QVERIFY(vkHandles->vmemAllocator);
}
@@ -448,6 +523,17 @@ void tst_QRhi::nativeHandles()
}
break;
#endif
+#ifdef TST_D3D12
+ case QRhi::D3D12:
+ {
+ const QRhiD3D12NativeHandles *d3dHandles = static_cast<const QRhiD3D12NativeHandles *>(rhiHandles);
+ QVERIFY(d3dHandles->dev);
+ QVERIFY(d3dHandles->minimumFeatureLevel > 0);
+ QVERIFY(d3dHandles->adapterLuidLow || d3dHandles->adapterLuidHigh);
+ QVERIFY(d3dHandles->commandQueue);
+ }
+ break;
+#endif
#ifdef TST_MTL
case QRhi::Metal:
{
@@ -492,6 +578,10 @@ void tst_QRhi::nativeHandles()
case QRhi::D3D11:
break;
#endif
+#ifdef TST_D3D12
+ case QRhi::D3D12:
+ break;
+#endif
#ifdef TST_MTL
case QRhi::Metal:
{
@@ -551,6 +641,10 @@ void tst_QRhi::nativeHandles()
case QRhi::D3D11:
break;
#endif
+#ifdef TST_D3D12
+ case QRhi::D3D12:
+ break;
+#endif
#ifdef TST_MTL
case QRhi::Metal:
break;
@@ -618,7 +712,7 @@ void tst_QRhi::nativeHandlesImportVulkan()
void tst_QRhi::nativeHandlesImportD3D11()
{
#ifdef TST_D3D11
- QScopedPointer<QRhi> rhi(QRhi::create(QRhi::D3D11, &initParams.d3d, QRhi::Flags(), nullptr));
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::D3D11, &initParams.d3d11, QRhi::Flags(), nullptr));
if (!rhi)
QSKIP("QRhi could not be created, skipping testing D3D11 native handle import");
@@ -630,7 +724,7 @@ void tst_QRhi::nativeHandlesImportD3D11()
h.featureLevel = 0; // see if these are queried as expected, even when not provided
h.adapterLuidLow = 0;
h.adapterLuidHigh = 0;
- QScopedPointer<QRhi> adoptingRhi(QRhi::create(QRhi::D3D11, &initParams.d3d, QRhi::Flags(), &h));
+ QScopedPointer<QRhi> adoptingRhi(QRhi::create(QRhi::D3D11, &initParams.d3d11, QRhi::Flags(), &h));
QVERIFY(adoptingRhi);
const QRhiD3D11NativeHandles *newNativeHandles = static_cast<const QRhiD3D11NativeHandles *>(adoptingRhi->nativeHandles());
QCOMPARE(newNativeHandles->dev, nativeHandles->dev);
@@ -645,7 +739,7 @@ void tst_QRhi::nativeHandlesImportD3D11()
QRhiD3D11NativeHandles h = *nativeHandles;
h.dev = nullptr;
h.context = nullptr;
- QScopedPointer<QRhi> adoptingRhi(QRhi::create(QRhi::D3D11, &initParams.d3d, QRhi::Flags(), &h));
+ QScopedPointer<QRhi> adoptingRhi(QRhi::create(QRhi::D3D11, &initParams.d3d11, QRhi::Flags(), &h));
QVERIFY(adoptingRhi);
const QRhiD3D11NativeHandles *newNativeHandles = static_cast<const QRhiD3D11NativeHandles *>(adoptingRhi->nativeHandles());
QVERIFY(newNativeHandles->dev != nativeHandles->dev);
@@ -665,7 +759,6 @@ void tst_QRhi::nativeHandlesImportOpenGL()
#ifdef TST_GL
QRhiGles2NativeHandles h;
QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
- ctx->setFormat(QRhiGles2InitParams::adjustedFormat());
if (!ctx->create())
QSKIP("No OpenGL context, skipping OpenGL-specific test");
h.context = ctx.data();
@@ -731,6 +824,14 @@ void tst_QRhi::nativeTexture()
}
break;
#endif
+#ifdef TST_D3D12
+ case QRhi::D3D12:
+ {
+ auto *texture = reinterpret_cast<void *>(nativeTex.object);
+ QVERIFY(texture);
+ }
+ break;
+#endif
#ifdef TST_MTL
case QRhi::Metal:
{
@@ -806,6 +907,18 @@ void tst_QRhi::nativeBuffer()
}
break;
#endif
+ #ifdef TST_D3D12
+ case QRhi::D3D12:
+ {
+ QVERIFY(nativeBuf.slotCount >= 1); // always backed by native buffers
+ for (int i = 0; i < nativeBuf.slotCount; ++i) {
+ auto *buffer = static_cast<void * const *>(nativeBuf.objects[i]);
+ QVERIFY(buffer);
+ QVERIFY(*buffer);
+ }
+ }
+ break;
+ #endif
#ifdef TST_MTL
case QRhi::Metal:
{
@@ -903,6 +1016,8 @@ void tst_QRhi::resourceUpdateBatchBuffer()
if (rhi->isFeatureSupported(QRhi::ReadBackNonUniformBuffer))
batch->readBackBuffer(dynamicBuffer.data(), 5, 10, &readResult);
+ else
+ qDebug("Skipping verification of buffer data as ReadBackNonUniformBuffer is not supported");
QVERIFY(submitResourceUpdates(rhi.data(), batch));
@@ -1004,7 +1119,7 @@ void tst_QRhi::resourceUpdateBatchRGBATextureUpload()
QRhiResourceUpdateBatch *batch = rhi->nextResourceUpdateBatch();
- QRhiTextureUploadEntry upload(0, 0, { image.constBits(), int(image.sizeInBytes()) });
+ QRhiTextureUploadEntry upload(0, 0, { image.constBits(), quint32(image.sizeInBytes()) });
QRhiTextureUploadDescription uploadDesc(upload);
batch->uploadTexture(texture.data(), uploadDesc);
@@ -1092,8 +1207,8 @@ void tst_QRhi::resourceUpdateBatchRGBATextureUpload()
// SourceTopLeft is not supported for non-QImage-based uploads.
const QImage im = image.copy(QRect(greenRectPos, copySize));
QRhiTextureSubresourceUploadDescription desc;
- desc.setData(QByteArray::fromRawData(reinterpret_cast<const char *>(im.constBits()),
- int(im.sizeInBytes())));
+ desc.setData(QByteArray::fromRawData(reinterpret_cast<const char *>(im.constBits()), im.sizeInBytes()));
+
desc.setSourceSize(copySize);
desc.setDestinationTopLeft(QPoint(gap, gap));
@@ -1518,6 +1633,31 @@ void tst_QRhi::renderToTextureSimple_data()
rhiTestData();
}
+static QRhiGraphicsPipeline *createSimplePipeline(QRhi *rhi, QRhiShaderResourceBindings *srb, QRhiRenderPassDescriptor *rpDesc)
+{
+ std::unique_ptr<QRhiGraphicsPipeline> pipeline(rhi->newGraphicsPipeline());
+ QShader vs = loadShader(":/data/simple.vert.qsb");
+ if (!vs.isValid())
+ return nullptr;
+ QShader fs = loadShader(":/data/simple.frag.qsb");
+ if (!fs.isValid())
+ return nullptr;
+ pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });
+ QRhiVertexInputLayout inputLayout;
+ inputLayout.setBindings({ { 2 * sizeof(float) } });
+ inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float2, 0 } });
+ pipeline->setVertexInputLayout(inputLayout);
+ pipeline->setShaderResourceBindings(srb);
+ pipeline->setRenderPassDescriptor(rpDesc);
+ return pipeline->create() ? pipeline.release() : nullptr;
+}
+
+static const float triangleVertices[] = {
+ -1.0f, -1.0f,
+ 1.0f, -1.0f,
+ 0.0f, 1.0f
+};
+
void tst_QRhi::renderToTextureSimple()
{
QFETCH(QRhi::Implementation, impl);
@@ -1543,32 +1683,15 @@ void tst_QRhi::renderToTextureSimple()
QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch();
- static const float vertices[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- 0.0f, 1.0f
- };
- QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertices)));
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(triangleVertices)));
QVERIFY(vbuf->create());
- updates->uploadStaticBuffer(vbuf.data(), vertices);
+ updates->uploadStaticBuffer(vbuf.data(), triangleVertices);
QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
QVERIFY(srb->create());
- QScopedPointer<QRhiGraphicsPipeline> pipeline(rhi->newGraphicsPipeline());
- QShader vs = loadShader(":/data/simple.vert.qsb");
- QVERIFY(vs.isValid());
- QShader fs = loadShader(":/data/simple.frag.qsb");
- QVERIFY(fs.isValid());
- pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });
- QRhiVertexInputLayout inputLayout;
- inputLayout.setBindings({ { 2 * sizeof(float) } });
- inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float2, 0 } });
- pipeline->setVertexInputLayout(inputLayout);
- pipeline->setShaderResourceBindings(srb.data());
- pipeline->setRenderPassDescriptor(rpDesc.data());
-
- QVERIFY(pipeline->create());
+ QScopedPointer<QRhiGraphicsPipeline> pipeline(createSimplePipeline(rhi.data(), srb.data(), rpDesc.data()));
+ QVERIFY(pipeline);
cb->beginPass(rt.data(), Qt::blue, { 1.0f, 0 }, updates);
cb->setGraphicsPipeline(pipeline.data());
@@ -1670,32 +1793,15 @@ void tst_QRhi::renderToTextureMip()
QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch();
- static const float vertices[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- 0.0f, 1.0f
- };
- QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertices)));
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(triangleVertices)));
QVERIFY(vbuf->create());
- updates->uploadStaticBuffer(vbuf.data(), vertices);
+ updates->uploadStaticBuffer(vbuf.data(), triangleVertices);
QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
QVERIFY(srb->create());
- QScopedPointer<QRhiGraphicsPipeline> pipeline(rhi->newGraphicsPipeline());
- QShader vs = loadShader(":/data/simple.vert.qsb");
- QVERIFY(vs.isValid());
- QShader fs = loadShader(":/data/simple.frag.qsb");
- QVERIFY(fs.isValid());
- pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });
- QRhiVertexInputLayout inputLayout;
- inputLayout.setBindings({ { 2 * sizeof(float) } });
- inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float2, 0 } });
- pipeline->setVertexInputLayout(inputLayout);
- pipeline->setShaderResourceBindings(srb.data());
- pipeline->setRenderPassDescriptor(rpDesc.data());
-
- QVERIFY(pipeline->create());
+ QScopedPointer<QRhiGraphicsPipeline> pipeline(createSimplePipeline(rhi.data(), srb.data(), rpDesc.data()));
+ QVERIFY(pipeline);
cb->beginPass(rt.data(), Qt::blue, { 1.0f, 0 }, updates);
cb->setGraphicsPipeline(pipeline.data());
@@ -1792,32 +1898,15 @@ void tst_QRhi::renderToTextureCubemapFace()
QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch();
- static const float vertices[] = {
- -1.0f, -1.0f,
- 1.0f, -1.0f,
- 0.0f, 1.0f
- };
- QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(vertices)));
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(triangleVertices)));
QVERIFY(vbuf->create());
- updates->uploadStaticBuffer(vbuf.data(), vertices);
+ updates->uploadStaticBuffer(vbuf.data(), triangleVertices);
QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
QVERIFY(srb->create());
- QScopedPointer<QRhiGraphicsPipeline> pipeline(rhi->newGraphicsPipeline());
- QShader vs = loadShader(":/data/simple.vert.qsb");
- QVERIFY(vs.isValid());
- QShader fs = loadShader(":/data/simple.frag.qsb");
- QVERIFY(fs.isValid());
- pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });
- QRhiVertexInputLayout inputLayout;
- inputLayout.setBindings({ { 2 * sizeof(float) } });
- inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float2, 0 } });
- pipeline->setVertexInputLayout(inputLayout);
- pipeline->setShaderResourceBindings(srb.data());
- pipeline->setRenderPassDescriptor(rpDesc.data());
-
- QVERIFY(pipeline->create());
+ QScopedPointer<QRhiGraphicsPipeline> pipeline(createSimplePipeline(rhi.data(), srb.data(), rpDesc.data()));
+ QVERIFY(pipeline);
cb->beginPass(rt.data(), Qt::blue, { 1.0f, 0 }, updates);
cb->setGraphicsPipeline(pipeline.data());
@@ -1880,6 +1969,116 @@ void tst_QRhi::renderToTextureCubemapFace()
QFAIL("Encountered a pixel that is neither red or blue");
}
+ QVERIFY(redCount > 0 && blueCount > 0);
+ QCOMPARE(redCount + blueCount, outputSize.width());
+
+ if (rhi->isYUpInFramebuffer() == rhi->isYUpInNDC())
+ QVERIFY(redCount < blueCount); // 100, 412
+ else
+ QVERIFY(redCount > blueCount); // 412, 100
+}
+
+void tst_QRhi::renderToTextureTextureArray_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::renderToTextureTextureArray()
+{
+ 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::TextureArrays))
+ QSKIP("TextureArrays is not supported with this backend, skipping test");
+
+ const QSize outputSize(512, 256);
+ const int ARRAY_SIZE = 8;
+ QScopedPointer<QRhiTexture> texture(rhi->newTextureArray(QRhiTexture::RGBA8,
+ ARRAY_SIZE,
+ outputSize,
+ 1,
+ QRhiTexture::RenderTarget
+ | QRhiTexture::UsedAsTransferSource));
+ QVERIFY(texture->create());
+
+ const int LAYER = 5; // render into element #5
+
+ QRhiColorAttachment colorAtt(texture.data());
+ colorAtt.setLayer(LAYER);
+ QRhiTextureRenderTargetDescription rtDesc(colorAtt);
+ QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget(rtDesc));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
+ rt->setRenderPassDescriptor(rpDesc.data());
+ QVERIFY(rt->create());
+
+ QCOMPARE(rt->pixelSize(), texture->pixelSize());
+ QCOMPARE(rt->pixelSize(), outputSize);
+
+ QRhiCommandBuffer *cb = nullptr;
+ QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess);
+ QVERIFY(cb);
+
+ QRhiResourceUpdateBatch *updates = rhi->nextResourceUpdateBatch();
+
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(triangleVertices)));
+ QVERIFY(vbuf->create());
+ updates->uploadStaticBuffer(vbuf.data(), triangleVertices);
+
+ QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
+ QVERIFY(srb->create());
+
+ QScopedPointer<QRhiGraphicsPipeline> pipeline(createSimplePipeline(rhi.data(), srb.data(), rpDesc.data()));
+ QVERIFY(pipeline);
+
+ cb->beginPass(rt.data(), Qt::blue, { 1.0f, 0 }, updates);
+ cb->setGraphicsPipeline(pipeline.data());
+ cb->setViewport({ 0, 0, float(rt->pixelSize().width()), float(rt->pixelSize().height()) });
+ QRhiCommandBuffer::VertexInput vbindings(vbuf.data(), 0);
+ cb->setVertexInput(0, 1, &vbindings);
+ cb->draw(3);
+
+ QRhiReadbackResult readResult;
+ QImage result;
+ readResult.completed = [&readResult, &result] {
+ result = QImage(reinterpret_cast<const uchar *>(readResult.data.constData()),
+ readResult.pixelSize.width(), readResult.pixelSize.height(),
+ QImage::Format_RGBA8888);
+ };
+ QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch();
+ QRhiReadbackDescription readbackDescription(texture.data());
+ readbackDescription.setLayer(LAYER);
+ readbackBatch->readBackTexture(readbackDescription, &readResult);
+
+ cb->endPass(readbackBatch);
+
+ rhi->endOffscreenFrame();
+
+ QCOMPARE(result.size(), outputSize);
+
+ if (impl == QRhi::Null)
+ return;
+
+ const int y = 100;
+ const quint32 *p = reinterpret_cast<const quint32 *>(result.constScanLine(y));
+ int x = result.width() - 1;
+ int redCount = 0;
+ int blueCount = 0;
+ const int maxFuzz = 1;
+ while (x-- >= 0) {
+ const QRgb c(*p++);
+ if (qRed(c) >= (255 - maxFuzz) && qGreen(c) == 0 && qBlue(c) == 0)
+ ++redCount;
+ else if (qRed(c) == 0 && qGreen(c) == 0 && qBlue(c) >= (255 - maxFuzz))
+ ++blueCount;
+ else
+ QFAIL("Encountered a pixel that is neither red or blue");
+ }
+
+ QVERIFY(redCount > 0 && blueCount > 0);
QCOMPARE(redCount + blueCount, outputSize.width());
if (rhi->isYUpInFramebuffer() == rhi->isYUpInNDC())
@@ -2018,6 +2217,131 @@ void tst_QRhi::renderToTextureTexturedQuad()
QVERIFY(qGreen(result.pixel(214, 191)) > 2 * qBlue(result.pixel(214, 191)));
}
+void tst_QRhi::renderToTextureSampleWithSeparateTextureAndSampler_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::renderToTextureSampleWithSeparateTextureAndSampler()
+{
+ // Same as renderToTextureTexturedQuad but the fragment shader uses a
+ // separate image and sampler. For Vulkan/Metal/D3D11 these are natively
+ // supported. For OpenGL this exercises the auto-generated combined sampler
+ // in the GLSL code and the mapping table that gets applied at run time by
+ // the backend.
+
+ 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");
+
+ QImage inputImage;
+ inputImage.load(QLatin1String(":/data/qt256.png"));
+ QVERIFY(!inputImage.isNull());
+
+ QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size(), 1,
+ QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource));
+ QVERIFY(texture->create());
+
+ QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ texture.data() }));
+ 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();
+
+ QScopedPointer<QRhiBuffer> vbuf(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, sizeof(quadVerticesUvs)));
+ QVERIFY(vbuf->create());
+ updates->uploadStaticBuffer(vbuf.data(), quadVerticesUvs);
+
+ QScopedPointer<QRhiTexture> inputTexture(rhi->newTexture(QRhiTexture::RGBA8, inputImage.size()));
+ QVERIFY(inputTexture->create());
+ updates->uploadTexture(inputTexture.data(), inputImage);
+
+ QScopedPointer<QRhiSampler> sampler(rhi->newSampler(QRhiSampler::Nearest, QRhiSampler::Nearest, QRhiSampler::None,
+ QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge));
+ QVERIFY(sampler->create());
+
+ QScopedPointer<QRhiShaderResourceBindings> srb(rhi->newShaderResourceBindings());
+ srb->setBindings({
+ QRhiShaderResourceBinding::texture(3, QRhiShaderResourceBinding::FragmentStage, inputTexture.data()),
+ QRhiShaderResourceBinding::sampler(5, QRhiShaderResourceBinding::FragmentStage, sampler.data())
+ });
+ QVERIFY(srb->create());
+
+ QScopedPointer<QRhiGraphicsPipeline> pipeline(rhi->newGraphicsPipeline());
+ pipeline->setTopology(QRhiGraphicsPipeline::TriangleStrip);
+ QShader vs = loadShader(":/data/simpletextured.vert.qsb");
+ QVERIFY(vs.isValid());
+ QShader fs = loadShader(":/data/simpletextured_separate.frag.qsb");
+ QVERIFY(fs.isValid());
+ pipeline->setShaderStages({ { QRhiShaderStage::Vertex, vs }, { QRhiShaderStage::Fragment, fs } });
+ QRhiVertexInputLayout inputLayout;
+ inputLayout.setBindings({ { 4 * sizeof(float) } });
+ inputLayout.setAttributes({
+ { 0, 0, QRhiVertexInputAttribute::Float2, 0 },
+ { 0, 1, QRhiVertexInputAttribute::Float2, 2 * sizeof(float) }
+ });
+ pipeline->setVertexInputLayout(inputLayout);
+ pipeline->setShaderResourceBindings(srb.data());
+ pipeline->setRenderPassDescriptor(rpDesc.data());
+
+ QVERIFY(pipeline->create());
+
+ cb->beginPass(rt.data(), Qt::black, { 1.0f, 0 }, updates);
+ cb->setGraphicsPipeline(pipeline.data());
+ cb->setShaderResources();
+ cb->setViewport({ 0, 0, float(texture->pixelSize().width()), float(texture->pixelSize().height()) });
+ QRhiCommandBuffer::VertexInput vbindings(vbuf.data(), 0);
+ cb->setVertexInput(0, 1, &vbindings);
+ cb->draw(4);
+
+ QRhiReadbackResult readResult;
+ QImage result;
+ readResult.completed = [&readResult, &result] {
+ result = QImage(reinterpret_cast<const uchar *>(readResult.data.constData()),
+ readResult.pixelSize.width(), readResult.pixelSize.height(),
+ QImage::Format_RGBA8888_Premultiplied);
+ };
+ QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch();
+ readbackBatch->readBackTexture({ texture.data() }, &readResult);
+ cb->endPass(readbackBatch);
+
+ rhi->endOffscreenFrame();
+
+ QVERIFY(!result.isNull());
+
+ if (impl == QRhi::Null)
+ return;